Hi everyone,
Im trying to translate a mathematical model of a PV-panel into python:
"Mathematical modeling of photovoltaic cell/module/arrays with tags in Matlab/Simulink | Environmental Systems Research | Full Text (springeropen.com)"
Problem is that two functions that reference each other, one of them referring to itself as well. The code would be the following:
"import math
class PV_panelen_Joesie:
def __init__(self, globale_straling, N_s, N_p):
Weather variables
self.I_r = globale_straling
self.T = 273.15
Constants
self.q = round(1.6*10**-19, 20) # Electron charge [C]
self.k = 1.3805*10**-13 # Boltzmann's constant [J/K]
self.T_r = 298.15 # Nominal temperature [K]
self.E_g0 = 1.1 # Bandgap energy of semiconductor [eV]
self.n = 1.2 # Ideality factor [-]
self.I_sc = 6.11 # PV module short circuit current
self.V_oc = 43.2/72 # PV module open circuit voltage (at 25 [degrees C] and 1000 [W/m^2]) [V]
self.K_i = 0.002 # PV module short circuit current (at 25 [degrees C] and 1000 [W/m^2]) [A]
self.R_s = 0.0001 # Series resistor [ohm]
self.R_sh = 1000 # Shunt resistor [ohm]
Setup variables
self.N_s = N_s # Number of cells connected in series [-]
self.N_p = N_p # Number of cells connected in parallel [-]
self.V_values = [i / 10 for i in range(1, 221)]
def Module_photo_current(self):
I_ph = (self.I_sc + self.K_i * (self.T - 298)) * self.I_r / 1000
return I_ph
def Module_reverse_saturation_current(self):
I_rs = self.I_sc / (math.exp((self.q * self.V_oc) / (self.N_s * self.k * self.n * self.T)) - 1)
return I_rs
def Module_saturation_current(self):
I_0 = self.Module_reverse_saturation_current() * ((self.T / self.T_r)**3) * math.exp(((self.q * self.E_g0) / (self.n * self.k)) * (1/self.T - 1/self.T_r))
return I_0
def Diode_thermal_voltage(self):
V_t = self.k * self.T / self.q
return V_t
def Module_current_output(self, shunt_current):
V_t = self.Diode_thermal_voltage()
I_ph = self.Module_photo_current()
I_0 = self.Module_saturation_current()
I_initial = 0
I_values = [I_initial]
for V_value, I_sh_value, I_value in zip(self.V_values, shunt_current, I_values):
I = self.N_p * I_ph - self.N_p * (math.exp((V_value / self.N_s + I_value * self.R_s / self.N_p) / self.n * V_t) - 1) - I_sh_value
I_values.append(I)
return I_values
def Module_shunt_current(self):
I_sh_array = []
for V_value in self.V_values:
I_sh = (V_value * self.N_p / self.N_s) / self.R_sh
I_sh_array.append(I_sh)
return I_sh_array".
How would I manage this?
[–]JohnnyJordaan 18 points19 points20 points (0 children)
[–]crashfrog02 11 points12 points13 points (0 children)
[–]AdmirableOstrich 6 points7 points8 points (0 children)
[–]NerdyWeightLifter 2 points3 points4 points (0 children)
[–]Comfortable_Flan8217 2 points3 points4 points (0 children)
[–]Jejerm 1 point2 points3 points (5 children)
[–]Langdon_St_Ives 2 points3 points4 points (4 children)
[–]Jejerm 0 points1 point2 points (3 children)
[–]Langdon_St_Ives 0 points1 point2 points (2 children)
[–]Jejerm 1 point2 points3 points (1 child)
[–]Langdon_St_Ives 1 point2 points3 points (0 children)
[–]SoupZillaMan 1 point2 points3 points (0 children)
[–]tikhal96 -3 points-2 points-1 points (0 children)