pvcracks.pvspice_lite package
Submodules
pvcracks.pvspice_lite.pvspice_helper module
Created on Thu Mar 7 15:18:35 2024
Helper functions for reading in ELs and IVs.
@author: bbyford, nrjost
- pvcracks.pvspice_lite.pvspice_helper.Extract_Params(slice)[source]
Extract single-diode model parameters from a DataFrame.
- Parameters
slice (pandas.DataFrame) – DataFrame containing one or more rows with the following columns: - Rs : series resistance - Rsh : shunt resistance - I : photo-generated current - Is : saturation current - N : diode ideality factor
- Returns
Params – A list of parameter dictionaries, one per row in slice. Each dict has keys: ‘Rs’, ‘Rsh’, ‘I’, ‘Is’, and ‘N’, with values taken from the corresponding row.
- Return type
list of dict
- pvcracks.pvspice_lite.pvspice_helper.Read_EL(path)[source]
Tile individual cell EL images into a single module image.
- Parameters
slice (pandas.DataFrame) – DataFrame with an ‘ELPath’ column pointing to each cell image.
input_size (tuple of int) – Desired size (height, width) for each cell image.
rows (int, optional) – Number of rows in the module layout (default is 6).
cols (int, optional) – Number of columns in the module layout (default is 10).
- Returns
img – Combined module image formed by tiling resized cell images.
- Return type
numpy.ndarray
- pvcracks.pvspice_lite.pvspice_helper.Read_IV(IVPath, sav_window=5, sav_order=2, samples=400)[source]
Read an IV curve from a CSV file, rectify it, smooth it, and interpolate.
- Parameters
IVPath (str) – Path to the CSV file containing IV data with columns ‘Voltage’ and ‘Current’.
sav_window (int, optional) – Window length for the Savitzky-Golay filter (default is 5).
sav_order (int, optional) – Polynomial order for the Savitzky-Golay filter (default is 2).
samples (int, optional) – Number of voltage sample points to interpolate (default is 400).
- Returns
vn (numpy.ndarray) – Evenly spaced voltage values after rectification, smoothing, and interpolation.
Ic (numpy.ndarray) – Current values corresponding to vn after smoothing and interpolation.
- pvcracks.pvspice_lite.pvspice_helper.cells2Mod(slice, input_size, rows=6, cols=10)[source]
Tile individual cell EL images into a single module image.
- Parameters
slice (pandas.DataFrame) – DataFrame with an ‘ELPath’ column pointing to each cell image.
input_size (tuple of int) – Desired size (height, width) for each cell image.
rows (int, optional) – Number of rows in the module layout (default is 6).
cols (int, optional) – Number of columns in the module layout (default is 10).
- Returns
img – Combined module image formed by tiling resized cell images.
- Return type
numpy.ndarray
pvcracks.pvspice_lite.pvspice_tools module
Created on Thu Mar 7 15:18:35 2024
Build pv module netlists, run ngspice and read in output.
@author: nrjost, bbyford
- pvcracks.pvspice_lite.pvspice_tools.Create_Cell_NetCode(params, a, b, c)[source]
Build and simulate a mini-module SPICE circuit, then return its IV curve.
- Parameters
params (list of dict) – List of dictionaries, each containing single-diode parameters for one cell.
file_path (str) – Directory where the SPICE circuit and output files will be written.
V (array-like) – Voltage points for the DC sweep.
V_Step (float, optional) – Step size for the DC voltage sweep (default is 0.001).
file_name (str, optional) – Suffix for output file names (default is empty).
- Returns
vn (numpy.ndarray) – Interpolated voltage values from the simulation output.
fitted_current (numpy.ndarray) – Interpolated current values corresponding to vn.
- pvcracks.pvspice_lite.pvspice_tools.MiniMod_Spice(params, file_path, V, V_Step=0.001, file_name='', spicepath='')[source]
Build and simulate a mini-module SPICE circuit, then return its IV curve.
- Parameters
params (list of dict) – List of dictionaries, each containing single-diode parameters for one cell.
file_path (str) – Directory where the SPICE circuit and output files will be written.
V (array-like) – Voltage points for the DC sweep.
V_Step (float, optional) – Step size for the DC voltage sweep (default is 0.001).
file_name (str, optional) – Suffix for output file names (default is empty).
- Returns
vn (numpy.ndarray) – Interpolated voltage values from the simulation output.
fitted_current (numpy.ndarray) – Interpolated current values corresponding to vn.
- pvcracks.pvspice_lite.pvspice_tools.ngpsice_read_voltage_current_modules(path)[source]
Read the volatage and current from the ngspice output file
- Parameters
path (str) – path where output of spice simulation file is saved
- Returns
voltage (float, array) – voltage values
current (float, array) – current values
df_iv (float, pandas DataFrame) – IV values
Notes
If halfcut is true output IV for a halfcut module interconnection, esle for a series interconnection with full size cells This code can be further modified to show current and voltage of specific components such as the bypass diodes, the output file has all nodes of the simulation
- pvcracks.pvspice_lite.pvspice_tools.run_ngspice(ngpsice_path, circuit_file)[source]
Run ngspice using path and netlist/circuit
- Parameters
ngpsice_path (str) – path to ngspice, example: ‘C:/Spice64/bin/ngspice.exe’
circuit_file (str) – path to netlist, example: ‘C:/Spice64/test/solar_circuit.cir’
- Return type
Nothing the output is saved to the path given in module_to_netlist
Notes
- To install ngspice follow the instructions here: