How to use the openmdao.lib.datatypes.api.Float function in openmdao

To help you get started, we’ve selected a few openmdao examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JustinSGray / Hyperloop / src / hyperloop / tube_limit_flow.py View on Github external
import pylab as p

from openmdao.main.api import Component
from openmdao.lib.datatypes.api import Float

from pycycle.flowstation import FlowStation, secant

class TubeLimitFlow(Component): 
    """Finds the limit velocity for a body traveling through a tube"""
    #Inputs
    radius_tube = Float(111.5 , iotype="in", units="cm", desc="required radius for the tube")    
    radius_inlet = Float(73.7, iotype="in", units="cm", desc="radius of the inlet at it's largest point")
    Ps_tube = Float(99, iotype="in", desc="static pressure in the tube", units="Pa") 
    Ts_tube = Float(292.1, iotype="in", desc="static temperature in the tube", units="degK")
    Mach_pod = Float(1.0, iotype="in", desc="travel Mach of the pod")
    Mach_bypass = Float(.95, iotype="in", desc="Mach in the air passing around the pod")
    #Outputs
    limit_speed = Float(iotype="out", desc="pod travel speed where flow choking occurs", units="m/s")
    limit_Mach = Float(iotype="out", desc="pod travel Mach number where flow choking occurs")
    W_excess = Float(iotype="out", desc="excess tube mass flow above the Kantrowitz limit", units="kg/s")
    W_tube = Float(iotype="out", desc="Tube demand flow", units="kg/s")
    W_kant = Float(iotype="out", desc="Kantrowitz limit flow", units="kg/s")
    #mu_air = Float(iotype="out", desc="dynamic viscosity of air", units="Pa*s")

    def execute(self):

    	fs_tube = self.fs_tube = FlowStation()

        tube_rad = self.radius_tube*0.0328084 #convert to ft
        inlet_rad = self.radius_inlet*0.0328084
github OpenMDAO / OpenMDAO-Framework / openmdao.lib / src / openmdao / lib / optproblems / heart_dipole.py View on Github external
class Dipole1(Component): 
    
    x1 = Float(0.0,iotype="in")
    x4 = Float(0.0,iotype="in")
    x6 = Float(0.0,iotype="in")
    x7 = Float(0.0,iotype="in")

    x3 = Float(0.0,iotype="in")
    x5 = Float(0.0,iotype="in")

    x2 = Float(0.0,iotype="out")
    x8 = Float(0.0,iotype="out")
    
    f5 = Float(0.0,iotype="out")
    f7 = Float(0.0,iotype="out")
    
    def execute(self): 
        x1 = self.x1
        x4 = self.x4        
        x6 = self.x6
        x7 = self.x7
        
        x3 = self.x3
        x5 = self.x5
                
        #f1 = 0 = x1 + x2 - d_mx
        self.x2 = x2 = d_mx - x1
        
        #f3 = 0 = x1*x8 + x6*x2 - x7*x3 - x8*x4 - d_a
        self.x8 = x8 = (x5*x1 + x6*x2 - x7*x3 - d_a)/x4
github JustinSGray / Hyperloop / src / hyperloop / cycle / heat_exchanger.py View on Github external
from openmdao.main.api import convert_units as cu

from pycycle.api import FlowStationVar, FlowStation, CycleComponent


class HeatExchanger(CycleComponent): 
    """Calculates required Q to reach perscribed temperatures for a water-to-air heat exchanger"""

    #inputs
    W_cold = Float(0.45, iotype="in", units = 'kg/s', desc='Mass flow rate of cold fluid (water)') 
    #Wh = Float(iotype="in", units = 'kg/s', desc='Mass flow rate of the hot fluid (air)') 
    Cp_cold = Float(4186, iotype="in", units = 'J/(kg*K)', desc='Specific Heat of the cold fluid (water)') 
    #Cp_hot = Float(iotype="in", units = 'J/(kg*K)', desc='Specific Heat of the hot fluid (air)') 
    #T_hot_in = Float(iotype="in", units = 'K', desc='Temp of air into heat exchanger')     
    T_cold_in = Float(288.1, iotype="in", units = 'K', desc='Temp of water into heat exchanger') 
    effectiveness = Float(.9765, iotype="in", desc='Heat Exchange Effectiveness') 
    MNexit_des = Float(.6, iotype="in", desc="mach number at the exit of heat exchanger")
    #State Vars
    T_hot_out = Float(338.4, iotype="in", units = 'K', desc='Temp of air out of the heat exchanger')    
    T_cold_out = Float(iotype="in", units = 'K', desc='Temp of water out of the heat exchanger') 
    

    Fl_I = FlowStationVar(iotype="in", desc="incoming air stream to heat exchanger", copy=None)

    #outputs
    Qreleased = Float(iotype="out", units = 'W', desc='Energy Released') 
    Qabsorbed= Float(iotype="out", units = 'W', desc='Energy Absorbed') 
    LMTD = Float(iotype="out", desc='Logarathmic Mean Temperature Difference')
    Qmax= Float(iotype="out", units = 'W', desc='Theoretical maximum possible heat transfer') 
 
    residual_qmax = Float(iotype="out", desc='Residual of max*effectiveness') 
    residual_e_balance = Float(iotype="out", desc='Residual of the energy balance')
github JustinSGray / Hyperloop / src / hyperloop / cycle / heat_exchanger.py View on Github external
from openmdao.lib.drivers.api import BroydenSolver 
from openmdao.main.api import convert_units as cu

from pycycle.api import FlowStationVar, FlowStation, CycleComponent


class HeatExchanger(CycleComponent): 
    """Calculates required Q to reach perscribed temperatures for a water-to-air heat exchanger"""

    #inputs
    W_cold = Float(0.45, iotype="in", units = 'kg/s', desc='Mass flow rate of cold fluid (water)') 
    #Wh = Float(iotype="in", units = 'kg/s', desc='Mass flow rate of the hot fluid (air)') 
    Cp_cold = Float(4186, iotype="in", units = 'J/(kg*K)', desc='Specific Heat of the cold fluid (water)') 
    #Cp_hot = Float(iotype="in", units = 'J/(kg*K)', desc='Specific Heat of the hot fluid (air)') 
    #T_hot_in = Float(iotype="in", units = 'K', desc='Temp of air into heat exchanger')     
    T_cold_in = Float(288.1, iotype="in", units = 'K', desc='Temp of water into heat exchanger') 
    effectiveness = Float(.9765, iotype="in", desc='Heat Exchange Effectiveness') 
    MNexit_des = Float(.6, iotype="in", desc="mach number at the exit of heat exchanger")
    #State Vars
    T_hot_out = Float(338.4, iotype="in", units = 'K', desc='Temp of air out of the heat exchanger')    
    T_cold_out = Float(iotype="in", units = 'K', desc='Temp of water out of the heat exchanger') 
    

    Fl_I = FlowStationVar(iotype="in", desc="incoming air stream to heat exchanger", copy=None)

    #outputs
    Qreleased = Float(iotype="out", units = 'W', desc='Energy Released') 
    Qabsorbed= Float(iotype="out", units = 'W', desc='Energy Absorbed') 
    LMTD = Float(iotype="out", desc='Logarathmic Mean Temperature Difference')
    Qmax= Float(iotype="out", units = 'W', desc='Theoretical maximum possible heat transfer') 
 
    residual_qmax = Float(iotype="out", desc='Residual of max*effectiveness')
github JustinSGray / Hyperloop / src / hyperloop / cycle / heat_exchanger_sizing.py View on Github external
k_p = 400.0#, units = 'W/(m*K)', iotype='in', desc='thermal conductivity of the pipe')

class HeatExchangerSizing(Component):
    """ Main Component """

    #--Inputs--
    T_win = Float(units = 'K', iotype='in', desc='Temp of water into heat exchanger') #368 , 110
    T_wout = Float(units = 'K', iotype='in', desc='Temp of water out of heat exchanger') #358 , 190
    T_ain = Float(units = 'K', iotype='in', desc='Temp of air into heat exchanger') #297, 400
    T_aout = Float(units = 'K', iotype='in', desc='Temp of air out of heat exchanger') #308, 170
    Mdot_a = Float(units = 'kg/s', iotype='in', desc='Mass flow rate of air')

    #Heat Exchanger Physical Design Variables
    Di_shell = Float(0.05102, units = 'm', iotype='in', desc='Shell pipe (inner) Diameter')
    Do_tube = Float(0.03493, units = 'm', iotype='in', desc='Tube pipe (outer) Diameter')
    Di_tube = Float(0.03279, units = 'm', iotype='in', desc='Tube pipe (inner) Diameter') #0.03279, 0.0371851871796067
    N = Float(1, units = 'm', iotype='in', desc='Number of Tube Passes')
    
    cooled = Bool(True, desc= 'Boolean true if fluid is cooled, false if heated')
    coFlow = Bool(False, desc= 'Boolean true if co-flow, false if coutner-flow')

    #Assumed Constant Properties of air (should come in from flow station)
    rho_a = Float(0.616, units = 'kg/m**3', iotype='in', desc='density of air ')
    cp_a = Float(1006., units = 'J/(kg*K)', iotype='in', desc='specific heat of air')
    dvisc_a = Float(0.00002, units = 'kg/(m*s)', iotype='in', desc='dynamic viscosity for air')
    kvisc_a = Float(0.00001568, units = 'm**2/s', iotype='in', desc='kinematic viscosity for air')
    

    #--Outputs--
    #Calculated Variables
    Asurf_pipe = Float(units = 'm**2', iotype='out', desc='Surface Area of the Pipe')
    Da_h = Float(units= 'm', iotype='out', desc='Hyrdraulic Diameter of the shell (annulus) for fluid flow')
github OpenMDAO / OpenMDAO-Framework / misc / disciplines.py View on Github external
z2 = self.z2
        
        self.y2 = self.temp2 + z2
        
        
class Coupler(Component):
    """Component that holds some design variables.
    This is only needed because we can't hook an optimizer up to multiple
    locations of the same design variable"""
    
    # pylint: disable-msg=E1101
    z1_in = Float(0.0, iotype='in', desc='Global Design Variable')
    z2_in = Float(0.0, iotype='in', desc='Global Design Variable')
    x1_in = Float(0.0, iotype='in', desc='Local Design Variable for CO')
    y1_in = Float(0.0, iotype='in', desc='Coupling Variable')
    y2_in = Float(0.0, iotype='in', desc='Coupling Variable')
    z1 = Float(0.0, iotype='out', desc='Global Design Variable')
    z2 = Float(0.0, iotype='out', desc='Global Design Variable')
    x1 = Float(0.0, iotype='out', desc='Local Design Variable for CO')
    y1 = Float(0.0, iotype='out', desc='Coupling Variable')
    y2 = Float(0.0, iotype='out', desc='Coupling Variable')
    
    def execute(self):
        """ Pass everything through"""
        self.z1 = self.z1_in
        self.z2 = self.z2_in
        self.x1 = self.x1_in
        self.y1 = self.y1_in
        self.y2 = self.y2_in
github OpenMDAO / OpenMDAO-Framework / examples / openmdao.examples.bar3simulation / openmdao / examples / bar3simulation / bar3_wrap_f.py View on Github external
bar2_length = Float(100.0, iotype='in', units='inch',
                        desc='Length of bar 2 and horizontal distance between \
                        nodes')

    weight_density = Float(0.284, iotype='in', units='lb/(inch**3)',
                        desc='weight density of all bars')

    lumped_mass = Float(0.68005, iotype='in', units='lb*s*s/inch',
                        desc='Lumped Mass at the free node')

    bar1_force = Float(0., iotype='out', units='lb',
                        desc='Force in bar 1')
    bar2_force = Float(0., iotype='out', units='lb',
                        desc='Force in bar 2')
    bar3_force = Float(0., iotype='out', units='lb',
                        desc='Force in bar 3')
    bar1_stress = Float(0., iotype='out', units='lb/(inch*inch)',
                        desc='Stress in bar 1')
    bar2_stress = Float(0., iotype='out', units='lb/(inch*inch)',
                        desc='Stress in bar 2')
    bar3_stress = Float(0., iotype='out', units='lb/(inch*inch)',
                        desc='Stress in bar 3')
    displacement_x_dir = Float(0., iotype='out', units='inch',
                        desc='Displacement in x-direction')
    displacement_y_dir = Float(0., iotype='out', units='inch',
                        desc='Displacement in y-direction')
    frequency = Float(0., iotype='out', units='Hz',
                        desc='Frequency in Hertz')
    weight = Float(0., iotype='out', units='lb',
                        desc='Weight of the structure')
github JustinSGray / Hyperloop / src / hyperloop / tube_wall_temp.py View on Github external
from openmdao.lib.drivers.api import BroydenSolver 
from openmdao.lib.datatypes.api import Float, Bool
from openmdao.main.api import convert_units as cu

from pycycle.api import FlowStationVar


class TubeWallTemp(Component):
    """ Calculates Q released/absorbed by the hyperloop tube """
    #--Inputs--
    #Hyperloop Parameters/Design Variables
    diameter_outer_tube = Float(2.23, units = 'm', iotype='in', desc='tube outer diameter') #7.3ft
    length_tube = Float(482803, units = 'm', iotype='in', desc='Length of entire Hyperloop') #300 miles, 1584000ft
    num_pods = Float(34, units = 'K', iotype='in', desc='Number of Pods in the Tube at a given time') #
    temp_boundary = Float(322.0, units = 'K', iotype='in', desc='Average Temperature of the tube wall') #
    temp_outside_ambient = Float(305.6, units = 'K', iotype='in', desc='Average Temperature of the outside air') #
    nozzle_air = FlowStationVar(iotype="in", desc="air exiting the pod nozzle", copy=None)
    bearing_air = FlowStationVar(iotype="in", desc="air exiting the air bearings", copy=None)
    #constants
    solar_insolation = Float(1000., iotype="in", units = 'W/m**2', desc='solar irradiation at sea level on a clear day') #
    nn_incidence_factor = Float(0.7, iotype="in", desc='Non-normal incidence factor') #
    surface_reflectance = Float(0.5, desc='Solar Reflectance Index') #
    q_per_area_solar = Float(350., units = 'W/m**2', desc='Solar Heat Rate Absorbed per Area') #
    q_total_solar = Float(375989751., iotype="in", units = 'W', desc='Solar Heat Absorbed by Tube') #
    emissivity_tube = Float(0.5, iotype="in", units = 'W', desc='Emmissivity of the Tube') #
    sb_constant = Float(0.00000005670373, iotype="in", units = 'W/((m**2)*(K**4))', desc='Stefan-Boltzmann Constant') #

    #--Outputs--
    area_rad = Float(337486.1, units = 'm**2', iotype='out', desc='Tube Radiating Area') #    
    #Required for Natural Convection Calcs
    GrDelTL3 = Float(1946216.7, units = '1/((ft**3)*F)', iotype='out', desc='Heat Radiated to the outside') #
    Pr = Float(0.707, iotype='out', desc='Prandtl') #
github JustinSGray / Hyperloop / src / hyperloop / geometry / fan.py View on Github external
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()
github OpenMDAO / OpenMDAO-Framework / openmdao.lib / src / openmdao / lib / optproblems / hulme.py View on Github external
g_y = Float(0.0,iotype="out")
    
    def execute(self): 
        x = self.x_y
        w1 = self.w1
        w3 = self.w3
        
        self.y1 = 0.08*x**3-0.05*w1+0.11*w3-0.09*(x*w1)**3
        self.y2 = 0.59*w3+0.41*w1**2+0.99*(x*w3)**3
        self.g_y = -226.7 + 0.26*x**3 + 0.51*w1**2 + 0.53*(x*w3)

class Z(Component): 
    
    x_z = Float(0.0,iotype="in")
    y2  = Float(0.0,iotupe="in")
    w2 = Float(0.0,iotype="in")
    
    z1 = Float(0.0,iotype="out")
    g_z = Float(0.0,iotype="out")
    
    def execute(self): 
        x = self.x_z
        y = self.y2
        w2 = self.w2
        
        self.z1 = -0.43*x**2-0.88*w2**2+0.25*(w2*x)**2
        self.g_z = -1095.1 + 0.33*y**2 + 0.47*(x*w2)
        
        
class HulmeProblem(OptProblem): 
    
    def __init__(self):