Skip to content

Commit

Permalink
added weights model hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
FernCarrera committed May 28, 2019
1 parent 0034a4b commit 3b301ef
Show file tree
Hide file tree
Showing 5 changed files with 4,270 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Model/Propulsion/cruise_comp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from openmdao.api import ExplicitComponent

rho = 1.225 #density, [kg/m**3]


class WeightComp(ExplicitComponent):


def setup(self):
self.add_input('W',desc='Weight of aircraft')
self.add_input('Cd',desc='coefficient of drag')
self.add_input('Cl',desc='coefficient of lift')
self.add_input('AR',desc='Aspect Ratio')
self.add_input('S',desc='Refernce Area')
self.add_input('V',desc='Airspeed')

self.add_output('P_C',desc='Power required for cruise')

self.declare_partials(of='*', wrt='*', method='fd')



def compute(self,inputs,outputs):
outputs['P_C'] = (( (2*(inputs['W']**3)*(inputs['Cd']**2))/(inputs['S']*rho*(inputs['Cl']**3)) )**.5)/1000
27 changes: 27 additions & 0 deletions Model/Propulsion/range_comp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from openmdao.api import ExplicitComponent

B_density = 400 # [Wh/kg]
FAA = 0.5 # [hr], flight time required by FAA for emergency
LO_time = 90/3600 # [hr], time to reach cruise alt
res = 0.80 # 20% battery reserve for healthy and happy battery :)
class RangeComp(ExplicitComponent):


def setup(self):
self.add_input('B_W',desc='Battery Weight')
self.add_input('P_L',desc='Power Required @ Liftoff')
self.add_input('P_C',desc='Power Required @ Cruise')
self.add_input('V',desc='Speed flying @ cruise')

self.add_output('R',desc='Max Range W/Reserve & Emergency 30min')
self.add_output('t',desc='Time flying @ max range')

self.declare_partials(of='*', wrt='*', method='fd')

def compute(self,inputs,outputs):
LO_Wh = inputs['P_L']*LO_time*1000 # Energy spent on liftoff
time = ( (B_density*inputs['B_W']*res)-LO_Wh-(LO_Wh/2) ) / (1000*inputs['P_C'])
dist = (time-FAA)*inputs['V']

outputs['R'] = dist
outputs['t'] = time
Binary file not shown.
25 changes: 25 additions & 0 deletions Model/Weight/gross_weight_comp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from openmdao.api import ExplicitComponent


class GrossWeightComp(ExplicitComponent):

def setup(self):
self.add_input('Wp') # weight of payload (passangers)
self.add_input('Wb') # weight of battery
self.add_input('We/W0') # empty over gross
self.add_output('W0') # gross weight
self.declare_partials('*', '*')

def compute(self, inputs, outputs):
Wp = inputs['Wp']
Wb = inputs['Wb']
We_W0 = inputs['We/W0']
outputs['W0'] = (Wp + Wb) / (1 - We_W0)

def compute_partials(self, inputs, partials):
Wp = inputs['Wp']
Wb = inputs['Wb']
We_W0 = inputs['We/W0']
partials['W0', 'Wp'] = 1. / (1 - We_W0)
partials['W0', 'Wb'] = 1. / (1 - We_W0)
partials['W0', 'We/W0'] = (Wp + Wb) / (1 - We_W0) ** 2
Loading

0 comments on commit 3b301ef

Please sign in to comment.