-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsolar_cell_sparse.py
52 lines (26 loc) · 1.04 KB
/
solar_cell_sparse.py
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
52
import numpy as np
import openmdao.api as om
class SolarCell(om.ExplicitComponent):
def setup(self):
n = 2
m = 3
self.add_input('T', val=np.ones((n,m))*28., units='degC')
self.add_output('eta', val=np.ones((n,m))*0.32, desc='solar cell efficiency with respect to absorbed power')
rows_cols = np.arange(6)
self.declare_partials('eta', 'T', rows=rows_cols, cols=rows_cols)
def compute(self, inputs, outputs):
self.alp_sc = 0.91
T0 = 28. #reference temperature
eff0 = .285 #efficiency at ref temp
T1 = -150.
eff1 = 0.335
delta_T = inputs['T'] - T0
self.slope = (eff1 - eff0) / (T1 - T0)
outputs['eta'] = (eff0 + self.slope * delta_T)/self.alp_sc
def compute_partials(self, inputs, J):
J['eta', 'T'] = np.ones(6) * self.slope/self.alp_sc
if __name__ == "__main__":
p = om.Problem()
p.model.add_subsystem('sc', SolarCell())
p.setup()
p.check_partials()