/
fan.py
31 lines (19 loc) · 888 Bytes
/
fan.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
from math import pi
from openmdao.main.api import Component
from openmdao.lib.datatypes.api import Float
class Fan(Component):
hub_to_tip = Float(.4, iotype="in", desc="hub to tip ratio for the fan")
flow_area = Float(.4, iotype="in", units="cm**2", desc="required flow area for the fan")
tip_radius = Float(.4, iotype="out", units="cm", desc="tip radius for the fan")
hub_radius = Float(.4, iotype="out", units="cm", desc="hub radius for the fan")
def execute(self):
self.tip_radius = (self.flow_area/(pi)*1/(1-self.hub_to_tip**2))**.5
self.hub_radius = self.hub_to_tip*self.tip_radius
if __name__ == "__main__":
from openmdao.main.api import set_as_top
f = set_as_top(Fan())
f.hub_to_tip = .4
f.flow_area = 14400
f.execute()
print "tip_radius (cm): %f"%f.tip_radius
print "hub_radius (cm): %f"%f.hub_radius