-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolar_panel.py
More file actions
51 lines (43 loc) · 1.32 KB
/
Copy pathsolar_panel.py
File metadata and controls
51 lines (43 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
solar_panel.py
Solar PV panel model based on the single-diode equivalent circuit.
Given irradiance (G) and temperature (T), and an operating voltage,
this returns the current and power the panel produces.
"""
import numpy as np
q = 1.602176634e-19
k = 1.380649e-23
class SolarPanel:
def __init__(self,
I_sc_ref=8.21,
V_oc_ref=32.9,
n=1.3,
N_s=60,
T_ref=298.15,
G_ref=1000):
self.I_sc_ref = I_sc_ref
self.V_oc_ref = V_oc_ref
self.n = n
self.N_s = N_s
self.T_ref = T_ref
self.G_ref = G_ref
def get_current(self, V, G, T_celsius):
T = T_celsius + 273.15
I_sc = self.I_sc_ref * (G / self.G_ref)
V_t = (self.n * self.N_s * k * T) / q
V_oc = self.V_oc_ref
I_0 = I_sc / (np.exp(V_oc / V_t) - 1)
I = I_sc - I_0 * (np.exp(V / V_t) - 1)
return max(I, 0)
def get_power(self, V, G, T_celsius):
I = self.get_current(V, G, T_celsius)
return V * I
if __name__ == "__main__":
panel = SolarPanel()
G = 1000
T = 25
print("Voltage(V) | Current(A) | Power(W)")
for V in range(0, 33, 4):
I = panel.get_current(V, G, T)
P = panel.get_power(V, G, T)
print(f"{V:10} | {I:10.2f} | {P:8.2f}")