Example #1
0
class ShaftVT(VariableTree):

    mass = Float(desc='blade mass')
    I_x = Float(desc='first area moment of inertia')
    I_y = Float(desc='Second area moment of inertia')
    CM = Array(np.zeros(3), desc='')
    length = Float()
Example #2
0
class NacelleVT(VariableTree):

    mass = Float(desc='blade mass')
    I_x = Float(desc='first area moment of inertia')
    I_y = Float(desc='Second area moment of inertia')
    CM = Array(np.zeros(3), desc='')
    diameter = Float()
Example #3
0
class HubVT(VariableTree):

    diameter = Float(desc='blade length')
    mass = Float(desc='blade mass')
    I_x = Float(desc='first area moment of inertia')
    I_y = Float(desc='Second area moment of inertia')
    CM = Array(np.zeros(3), desc='')
Example #4
0
class HAWC2ConstraintFix23(VariableTree):

    con_type = Str()
    mbdy = Str(desc='Main_body name to which the next main_body is fixed')
    dof = Array(np.zeros(3),
                desc='Direction in global coo that is fixed in rotation'
                '0: free, 1: fixed')
Example #5
0
class HAWC2AirfoilDataset(VariableTree):
    """A set of airfoil polars for a range of relative thicknesses"""

    np = Int(desc='number of airfoil polars in set')
    rthick = Array(
        desc='Array of relative thicknesses linked to the airfoil polars')
    polars = List(desc='List of polars')
Example #6
0
class ConfigGravity(AtlasConfiguration):
    """ Atlas configuration for gravity case """

    Omega_opt = Float(iotype='in', desc='rotor angular velocity')
    OmegaRatio = Float(iotype='in')

    Cl_opt = Array(iotype='in')

    H_opt = Float(iotype='in', desc='height of aircraft')

    TWire_opt = Float(iotype='in', desc='')

    def execute(self):
        super(ConfigGravity, self).execute()

        # use optimizer provided values
        self.Omega = (self.Omega_opt**3 * self.OmegaRatio)**(1. / 3.)

        self.Cl = self.Cl_opt

        self.h = self.H_opt + self.zWire

        self.TWire = [self.TWire_opt]

        self.flags.Load = 1  # gravity and wire forces only

        # FIXME: the following two flags are ignored
        self.flags.FreeWake = 0  # momentum theory
        self.flags.AeroStr = 0  # assume flat wing (no deformation)
Example #7
0
    def __init__(self, n, rawG=None):
        super(Comm_GainPattern, self).__init__()
        self.n = n

        if rawG is None:
            fpath = os.path.dirname(os.path.realpath(__file__))
            rawGdata = np.genfromtxt(fpath + '/data/Comm/Gain.txt')
            rawG = (10**(rawGdata / 10.0)).reshape((361, 361), order='F')

        # Inputs
        self.add(
            'azimuthGS',
            Array(
                np.zeros(n),
                iotype='in',
                shape=(n, ),
                units="rad",
                desc=
                "Azimuth angle from satellite to ground station in Earth-fixed frame over time"
            ))

        self.add(
            'elevationGS',
            Array(
                np.zeros(n),
                iotype='in',
                shape=(self.n, ),
                units="rad",
                desc=
                "Elevation angle from satellite to ground station in Earth-fixed frame over time"
            ))

        # Outputs
        self.add(
            'gain',
            Array(np.zeros(n),
                  iotype='out',
                  shape=(n, ),
                  units="unitless",
                  desc="Transmitter gain over time"))

        pi = np.pi
        az = np.linspace(0, 2 * pi, 361)
        el = np.linspace(0, 2 * pi, 361)

        self.MBI = MBI.MBI(rawG, [az, el], [15, 15], [4, 4])
        self.x = np.zeros((self.n, 2), order='F')
Example #8
0
class RotorLoadsArrayVT(VariableTree):

    wsp = Array(units='m/s', desc='Wind speeds')
    rpm = Array(units='rpm', desc='Rotor speed')
    pitch = Array(units='deg', desc='Pitch angle')

    T = Array([0.], units='N', desc='thrust')
    Q = Array([0.], units='N*m', desc='torque')
    P = Array([0.], units='W', desc='power')

    CT = Array([0.], units=None, desc='thrust coefficient')
    CQ = Array([0.], units=None, desc='torque coefficient')
    CP = Array([0.], units=None, desc='power coefficient')
Example #9
0
 def __init__(self, pitch_array):
     super(FASTInitialConditions, self).__init__()
     self.add(
         'Pitch',
         Array(pitch_array,
               dtype=float,
               desc="Pitch points used for blade pitch interp [degrees]",
               iotype='in'))
Example #10
0
class HAWC2Constraint(VariableTree):

    con_name = Str()
    con_type = Enum('free',
                    ('fixed', 'fixed_to_body', 'free', 'prescribed_angle'),
                    desc='Constraint type')
    body1 = Str(desc='Main body name to which the body is attached')
    DOF = Array(np.zeros(6), desc='Degrees of freedom')
Example #11
0
    def set_outputs(self, entries):

        for i, c in enumerate(entries):
            self.add(
                'out_%i' % (i + 1),
                Array(desc='Output %i of type2_dll %s: %s' %
                      ((i + 1), self.parent.name, c.name + ' ' +
                       ' '.join([str(val) for val in _makelist(c.val)]))))
Example #12
0
class HAWC2SVar(VariableTree):

    ground_fixed = VarTree(HAWC2SBody())
    rotating_axissym = VarTree(HAWC2SBody())
    rotating_threebladed = VarTree(HAWC2SBody())
    second_order_actuator = VarTree(SecondOrderActuator())
    commands = List()
    options = VarTree(HAWC2SCommandsOpt())
    operational_data_filename = Str()
    ch_list_in = VarTree(HAWC2OutputListVT())
    ch_list_out = VarTree(HAWC2OutputListVT())

    wsp_curve = Array(desc='Pitch curve from operational data file')
    pitch_curve = Array(desc='Pitch curve from operational data file')
    rpm_curve = Array(desc='RPM curve from operational data file')
    wsp_cases = List()
    cases = List(desc='List of input dictionaries with wsp, rpm and pitch')
Example #13
0
class GenericInflowGenerator(Component):
    """
    Framework for an inflow model
    """
    wind_speed = Float(0.0,
                       iotype='in',
                       units='m/s',
                       desc='the reference wind speed')
    ws_positions = Array(
        [],
        iotype='in',
        desc=
        'the positions of the wind speeds in the global frame of reference [n,3] (x,y,z)'
    )
    ws_array = Array([],
                     iotype='out',
                     desc='an array of wind speed to find wind speed')
Example #14
0
 class Dummy(Component): 
 
     x = Array([[-1, 1],[-2, 2]], iotype='in', shape=(2,2))
     xlist = List([1,2], iotype='in')
     xdict = Dict({'a' : 'b'}, iotype='in')
     
     def execute(self): 
         self.y = self.x
Example #15
0
    def __init__(self, datasize=0):

        super(windSpeedToCPCT, self).__init__()

        self.add(
            'wind_speed',
            Array(np.zeros(datasize),
                  iotype='in',
                  units='m/s',
                  desc='range of wind speeds'))
        self.add(
            'CP',
            Array(np.zeros(datasize), iotype='out', desc='power coefficients'))
        self.add(
            'CT',
            Array(np.zeros(datasize), iotype='out',
                  desc='thrust coefficients'))
Example #16
0
class Strain(VariableTree):
    top = Array(desc='')
    bottom = Array(desc='')
    back = Array(desc='')
    front = Array(desc='')

    bending_x = Array(desc='')
    bending_z = Array(desc='')
    axial_y = Array(desc='')
    torsion_y = Array(desc='')
Example #17
0
    def __init__(self, n_times):

        super(BatterySOC, self).__init__()

        # Inputs
        self.add(
            'iSOC',
            Array([0.0],
                  shape=(1, ),
                  dtype=np.float,
                  iotype="in",
                  units="unitless",
                  desc="Initial state of charge"))

        self.add(
            'P_bat',
            Array(np.zeros((n_times, )),
                  shape=(n_times, ),
                  dtype=np.float,
                  units="W",
                  iotype="in",
                  desc="Battery power over time"))

        self.add(
            'temperature',
            Array(np.zeros((5, n_times)),
                  shape=(5, n_times),
                  dtype=np.float,
                  units="degK",
                  iotype="in",
                  desc="Battery temperature over time"))

        # Outputs
        self.add(
            'SOC',
            Array(np.zeros((1, n_times)),
                  shape=(1, n_times),
                  dtype=np.float,
                  iotype="out",
                  units="unitless",
                  desc="Battery state of charge over time"))

        self.state_var = "SOC"
        self.init_state_var = "iSOC"
        self.external_vars = ["P_bat", "temperature"]
Example #18
0
    def __init__(self, n=2):
        super(Attitude_Torque, self).__init__()

        self.n = n

        # Inputs
        self.add(
            'w_B',
            Array(np.zeros((3, n)),
                  iotype='in',
                  shape=(3, n),
                  units="1/s",
                  desc="Angular velocity in body-fixed frame over time"))

        self.add(
            'wdot_B',
            Array(np.zeros((3, n)),
                  iotype='in',
                  shape=(3, n),
                  units="1/s**2",
                  desc="Time derivative of w_B over time"))

        # Outputs
        self.add(
            'T_tot',
            Array(np.zeros((3, n)),
                  iotype='out',
                  shape=(3, n),
                  units="N*m",
                  desc="Total reaction wheel torque over time"))

        self.dT_dwdot = np.zeros((n, 3, 3))
        self.dwx_dw = np.zeros((3, 3, 3))

        self.dwx_dw[0, :, 0] = (0., 0., 0.)
        self.dwx_dw[1, :, 0] = (0., 0., -1.)
        self.dwx_dw[2, :, 0] = (0., 1., 0.)

        self.dwx_dw[0, :, 1] = (0., 0., 1.)
        self.dwx_dw[1, :, 1] = (0., 0., 0.)
        self.dwx_dw[2, :, 1] = (-1., 0, 0.)

        self.dwx_dw[0, :, 2] = (0., -1., 0)
        self.dwx_dw[1, :, 2] = (1., 0., 0.)
        self.dwx_dw[2, :, 2] = (0., 0., 0.)
Example #19
0
    def __init__(self, n):
        super(Comm_BitRate, self).__init__()
        self.n = n

        # Inputs
        self.add(
            'P_comm',
            Array(np.zeros(self.n),
                  iotype='in',
                  shape=(self.n, ),
                  units="W",
                  desc="Communication power over time"))

        self.add(
            'gain',
            Array(np.zeros(self.n),
                  iotype='in',
                  shape=(self.n, ),
                  units="unitless",
                  desc="Transmitter gain over time"))

        self.add(
            'GSdist',
            Array(np.zeros(self.n),
                  iotype='in',
                  shape=(self.n, ),
                  units="km",
                  desc="Distance from ground station to satellite over time"))

        self.add(
            'CommLOS',
            Array(np.zeros(self.n),
                  iotype='in',
                  shape=(self.n, ),
                  units="unitless",
                  desc="Satellite to ground station line of sight over time"))

        # Outputs
        self.add(
            'Dr',
            Array(np.zeros(self.n),
                  iotype='out',
                  shape=(self.n, ),
                  units="Gibyte/s",
                  desc="Download rate over time"))
Example #20
0
    def __init__(self,prob_size=1): 
        super(Discipline,self).__init__()        

        self.add_trait("z",Array(zeros((prob_size,1)),iotype="in",
                                 desc="global varaibles",
                                 shape=(prob_size,1)))
        
        self.add_trait("C_z",Array(ones((prob_size,prob_size)), iotype="in", 
                                   desc="global variable constants",
                                   shape=(prob_size,prob_size)))

        self.add_trait("x",Array(zeros((prob_size,1)), iotype="in",
                                 desc="local variables",
                                 shape=(prob_size,1)))
        
        self.add_trait("C_x",Array(ones((prob_size,prob_size)), iotype="in", 
                                   desc="local variable constants",
                                   shape=(prob_size,prob_size)))
        
        #have to have the same number of coupling inputs as discipline outputs    
        self.add_trait("y_out",Array(zeros((prob_size,1)),iotype="out",
                                 desc="discipline output varaibles",
                                 shape=(prob_size,1)))
        
        self.add_trait("y_in",Array(zeros((prob_size,1)), iotype="in",
                                 desc="input coupling variables",
                                 shape=(prob_size,1)))
        
        self.add_trait("C_y",Array(identity(prob_size), iotype="in", 
                                   desc="local variable constants",
                                   shape=(prob_size,prob_size)))
Example #21
0
    def __init__(self, n=2):
        super(Power_Total, self).__init__()

        self.n = n

        self.add(
            'P_sol',
            Array(np.zeros((n, ), order='F'),
                  size=(n, ),
                  dtype=np.float,
                  units='W',
                  desc='Solar panels power over time',
                  iotype="in"))
        self.add(
            'P_comm',
            Array(np.zeros((n, ), order='F'),
                  size=(n, ),
                  dtype=np.float,
                  units='W',
                  desc='Communication power over time',
                  iotype="in"))
        self.add(
            'P_RW',
            Array(
                np.zeros((
                    3,
                    n,
                ), order='F'),
                size=(
                    3,
                    n,
                ),
                dtype=np.float,
                units='W',
                desc='Power used by reaction wheel over time',  # qqq ?
                iotype="in"))

        self.add(
            'P_bat',
            Array(np.zeros((n, ), order='F'),
                  size=(n, ),
                  dtype=np.float,
                  units='W',
                  desc='Battery power over time',
                  iotype="out"))
Example #22
0
class AxodComp(Component):
    """ OpenMDAO component wrapper for AXOD. """

    input_filename = Str(iotype='in')
    results = []

    hpower = Float(iotype='out')

    # 'float32' here could be just 'float', but AXOD is single-precision
    # so it just takes more space.  Not an issue with such small arrays,
    # but for larger data it may be important.
    tott  = Array(_ZEROS48,dtype=float32, shape=(48,), iotype='out')
    totp  = Array(_ZEROS48,dtype=float32, shape=(48,), iotype='out')
    mflow = Array(_ZEROS48,dtype=float32, shape=(48,), iotype='out')
    effs  = Array(_ZEROS48,dtype=float32, shape=(48,), iotype='out')
    effr  = Array(_ZEROS48,dtype=float32, shape=(48,), iotype='out')
    # tott  = Array(dtype=numpy_float32, shape=(48,), iotype='out')
    # otp  = Array(dtype=numpy_float32, shape=(48,), iotype='out')
    # mflow = Array(dtype=numpy_float32, shape=(48,), iotype='out')
    # effs  = Array(dtype=numpy_float32, shape=(48,), iotype='out')
    # effr  = Array(dtype=numpy_float32, shape=(48,), iotype='out')

    def __init__(self, input_filename=''):
        super(AxodComp, self).__init__()
        self.input_filename = input_filename

    def execute(self):
        """ Run AXOD. """
        if os.path.exists('axod.out'):
            os.remove('axod.out')
        self.results = []

        self._logger.debug('running')
        try:
            shutil.copyfile(self.input_filename, 'axod.inp')
            (self.hpower, self.tott, self.totp,
             self.mflow, self.effs, self.effr) = axod.axod()
        except Exception, exc:
            self.raise_exception(str(exc), type(exc))
        self._logger.debug('done')

        if os.path.exists('axod.out'):
            inp = open('axod.out', 'rU')
            self.results = inp.readlines()
            inp.close()
Example #23
0
class HAWC2OrientationRelative(VariableTree):

    body1 = List(desc='Main body name to which the body is attached')
    body2 = List(desc='Main body name to which the body is attached')
    body2_eulerang = List(desc='sequence of euler angle rotations, x->y->z')
    mbdy2_ini_rotvec_d1 = Array(
        np.zeros(4),
        desc='Initial rotation velocity of main body and all'
        'subsequent attached bodies (vx, vy, vz, |v|)')
Example #24
0
class ArrayParaboloid(Component):
    inArray = Array([0.0, 0.0], iotype="in")
    f_xy = Float(iotype='out', desc='F(x,y)')

    def execute(self):
        x = self.inArray[0]
        y = self.inArray[1]

        self.f_xy = (x - 3.0)**2 + x * y + (y + 4.0)**2 - 3.0
Example #25
0
    def __init__(self, n=2):
        super(Sun_LOS, self).__init__()

        self.n = n

        self.r1 = 6378.137 * 0.85  # Earth's radius is 6378 km. 0.85 is the alpha in John Hwang's paper
        self.r2 = 6378.137

        self.add(
            'r_e2b_I',
            Array(np.zeros((6, n), order='F'),
                  size=(
                      6,
                      n,
                  ),
                  dtype=np.float,
                  units="unitless",
                  desc="Position and velocity vectors from " +
                  "Earth to satellite in Earth-centered " +
                  "inertial frame over time.",
                  iotype="in"))

        self.add(
            'r_e2s_I',
            Array(np.zeros((3, n), order='F'),
                  size=(
                      3,
                      n,
                  ),
                  dtype=np.float,
                  units="km",
                  desc="Position vector from " +
                  "Earth to sun in Earth-centered inertial " +
                  "frame over time.",
                  iotype="in"))

        self.add(
            'LOS',
            Array(np.zeros((n, ), order='F'),
                  size=(n, ),
                  dtype=np.float,
                  units="unitless",
                  desc="Satellite to sun " + "line of sight over time",
                  iotype="out"))
Example #26
0
class Fblade(VariableTree):
    Fx = Array(units='N/m', desc='drag axis')
    Fz = Array(units='N/m', desc='lift axis')
    My = Array(desc='')
    Q = Array(desc='Torque')
    P = Array(desc='Power')
    Pi = Array(desc='')
    Pp = Array(desc='')
Example #27
0
class Fblade(VariableTree):
    Fx = Array(desc='')
    Fz = Array(desc='')
    My = Array(desc='')
    Q = Array(desc='')
    P = Array(desc='')
    Pi = Array(desc='')
    Pp = Array(desc='')
Example #28
0
    def __init__(self, Ns):
        super(Strain, self).__init__()

        self.add('top', Array(np.zeros((3, Ns + 1)), desc=''))
        self.add('bottom', Array(np.zeros((3, Ns + 1)), desc=''))
        self.add('back', Array(np.zeros((3, Ns + 1)), desc=''))
        self.add('front', Array(np.zeros((3, Ns + 1)), desc=''))

        self.add('bending_x', Array(np.zeros((1, Ns + 1)), desc=''))
        self.add('bending_z', Array(np.zeros((1, Ns + 1)), desc=''))
        self.add('axial_y', Array(np.zeros((1, Ns + 1)), desc=''))
        self.add('torsion_y', Array(np.zeros((1, Ns + 1)), desc=''))
 def __init__(self, minSize=(50, 50), smooth=10., return_one=True):
     #fn = "cascades/haarcascade_frontalface_default.xml"
     fn = "cascades/haarcascade_frontalface_alt.xml"
     #fn="cascades/haarcascade_frontalface_alt2.xml"
     #fn = "cascades/haarcascade_frontalface_alt_tree"
     super(faceDetector, self).__init__(fn,
                                        minSize=minSize,
                                        smooth=smooth,
                                        return_one=return_one)
     self.add("foreheads", Array([[0, 0, 2, 2]], iotype="out"))
Example #30
0
class SimpleWind(VariableTree):

    TimeSteps = Int(desc='number of time steps')

    Time = Array(desc='time step')
    HorSpd = Array(desc='horizontal wind speed')
    WindDir = Array(desc='wind direction')
    VerSpd = Array(desc='vertical wind speed')
    HorShr = Array(desc='horizontal shear')
    VerShr = Array(desc='vertical power-law shear')
    LnVShr = Array(desc='vertical linear shear')
    GstSpd = Array(desc='gust speed not sheared by Aerodyn')
Example #31
0
    def __init__(self, iotype, client, rpath, typ):
        ProxyMixin.__init__(self, client, rpath)
        self._type = typ

        default = self._parse(self._valstr)
        desc = client.get(rpath+'.description')

        if typ == float:
            as_units = client.get(rpath+'.units')
            if as_units:
                om_units = get_translation(as_units)
            else:
                om_units = None

        if typ != str:
            if client.get(rpath+'.hasUpperBound') == 'true':
                high = typ(client.get(rpath+'.upperBound'))
            else:
                high = None
            if client.get(rpath+'.hasLowerBound') == 'true':
                low = typ(client.get(rpath+'.lowerBound'))
            else:
                low = None

        if typ == float:
            Array.__init__(self, dtype=typ, iotype=iotype, desc=desc,
                           default_value=default, low=low, high=high,
                           units=om_units)
        elif typ == int:
            Array.__init__(self, dtype=typ, iotype=iotype, desc=desc,
                           default_value=default, low=low, high=high)
        else:
# FIXME: This will pickle, but not unpickle.
#        Probabably don't want fixed max-length string storage anyway.
            Array.__init__(self, dtype=typ, iotype=iotype, desc=desc,
                           default_value=default)