class CrossSectionStructureVT(VariableTree):
    """
    Container for a cross-sectional definition of the
    internal structure of a blade.
    """
    s = Float()
    regions = List(desc='List of names of regions in the cross section')
    webs = List(desc='List of names of regions in the cross section')
    materials = Dict(desc='Dictionary of MaterialProps vartrees')
    airfoil = VarTree(AirfoilShape(), desc='Cross sectional shape')
    DPs = List(desc='Region division points (nregion + 1)')

    def add_region(self, name):

        self.add(name, VarTree(Region()))
        self.regions.append(name)
        return getattr(self, name)

    def add_web(self, name):

        self.add(name, VarTree(Region()))
        self.webs.append(name)
        return getattr(self, name)

    def add_material(self, name, material):

        if name in self.materials.keys():
            return
        else:
            self.materials[name] = material

        return self.materials[name]
class HAWC2ConstraintFix4(VariableTree):

    con_type = Str()
    mbdy1 = List(desc='Main_body name to which the next main_body is fixed')
    mbdy2 = List(
        desc='Main_body name of the main_body that is fixed to main_body1')
    time = Float(2., desc='Time for the pre-stress process. Default=2 sec')
class HAWC2ConstraintFix1(VariableTree):

    con_type = Str()
    mbdy1 = List(desc='Main_body name to which the next main_body is fixed')
    mbdy2 = List(
        desc='Main_body name of the main_body that is fixed to main_body1')
    disable_at = Float(desc='Time at which constraint can be disabled')
Beispiel #4
0
class GenericPostProcessWindRose(Component):
    """Using the same wind rose for all the wind turbines"""
    # Inputs
    wind_speeds = List([],
                       iotype='in',
                       units='m/s',
                       desc='The different wind speeds to run [nWS]')
    wind_directions = List([],
                           iotype='in',
                           units='deg',
                           desc='The different wind directions to run [nWD]')
    frequencies = List([],
                       iotype='in',
                       desc='The different wind directions to run [nWD*nWS]')
    powers = List([],
                  iotype='in',
                  units='kW*h',
                  desc='The different wind directions to run [nWD*nWS]')

    # Outputs
    net_aep = Float(0.0,
                    iotype='out',
                    units='kW*h',
                    desc='Annual Energy Production')
    gross_aep = Float(0.0,
                      iotype='out',
                      units='kW*h',
                      desc='Gross Annual Energy Production')
    capacity_factor = Float(0.0, iotype='out', desc='Capacity factor')
    array_aep = Array([],
                      iotype='out',
                      units='kW*h',
                      desc='The energy production per sector [nWD, nWS]')
Beispiel #5
0
class AEPMultipleWindRoses(FUSEDAssembly):
    """Base class to calculate Annual Energy Production (AEP) of a wind farm.
    Implement the same interface as `BaseAEPModel` and `AEPWindRose`
    """
    wf = InterfaceSlot(GenericWindFarm,
                       desc='A wind farm assembly or component')
    postprocess_wind_rose = InterfaceSlot(
        GenericPostProcessWindRose,
        desc='The component taking care of postprocessing the wind rose')
    case_gen = InterfaceSlot(GenericWindRoseCaseGenerator,
                             desc='Generate the cases from the inputs')

    # Inputs
    wind_speeds = List([],
                       iotype='in',
                       units='m/s',
                       desc='The different wind speeds to run [nWS]')
    wind_directions = List([],
                           iotype='in',
                           units='deg',
                           desc='The different wind directions to run [nWD]')
    wt_layout = VarTree(GenericWindFarmTurbineLayout(),
                        iotype='in',
                        desc='wind turbine properties and layout')

    # Outputs
    array_aep = Array([],
                      iotype='out',
                      units='kW*h',
                      desc='The energy production per sector [nWD, nWS]')
    gross_aep = Float(
        iotype='out',
        units='kW*h',
        desc=
        'Gross Annual Energy Production before availability and loss impacts')
    net_aep = Float(
        iotype='out',
        units='kW*h',
        desc='Net Annual Energy Production after availability and loss impacts'
    )
    capacity_factor = Float(0.0,
                            iotype='out',
                            desc='Capacity factor for wind plant')
    wt_aep = Array([],
                   iotype='out',
                   units='kW*h',
                   desc='The energy production per turbine [nWT]')

    def configure(self):
        self.add('case_gen', MultipleWindRosesCaseGenerator())
        self.add('postprocess_wind_rose', PostProcessMultipleWindRoses())
        configure_AEPWindRose(self)
        self.connect('wt_layout', 'case_gen.wt_layout')
        self.disconnect('wind_rose_driver.case_outputs.wf.power',
                        'postprocess_wind_rose.powers')
        self.connect('wind_rose_driver.case_outputs.wf.wt_power',
                     'postprocess_wind_rose.powers')
        self.connect('postprocess_wind_rose.wt_aep', 'wt_aep')
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|)')
Beispiel #7
0
class PostProcessMultipleWindRoses(Component):
    """Use a different wind rose for each wind turbine"""
    # Inputs
    wind_speeds = List([],
                       iotype='in',
                       units='m/s',
                       desc='The different wind speeds to run [nWS]')
    wind_directions = List([],
                           iotype='in',
                           units='deg',
                           desc='The different wind directions to run [nWD]')
    frequencies = List(
        [],
        iotype='in',
        desc='The different wind directions to run [nWD*nWS][nWT]')
    powers = List([],
                  iotype='in',
                  units='kW*h',
                  desc='The different wind directions to run [nWD*nWS][nWT]')

    # Outputs
    net_aep = Float(0.0,
                    iotype='out',
                    units='kW*h',
                    desc='Net Annual Energy Production')
    gross_aep = Float(0.0,
                      iotype='out',
                      units='kW*h',
                      desc='Gross Annual Energy Production')
    capacity_factor = Float(0.0, iotype='out', desc='Capacity factor')
    array_aep = Array([],
                      iotype='out',
                      units='kW*h',
                      desc='The energy production per sector [nWD, nWS]')
    wt_aep = Array([],
                   iotype='out',
                   units='kW*h',
                   desc='The energy production per turbine [nWT]')

    def execute(self):
        nwd, nws = len(self.wind_directions), len(self.wind_speeds)
        assert len(self.frequencies) == nws * nwd
        assert len(self.powers) == nws * nwd

        array_aep = array([
            array(freq) * array(power) * 24 * 365
            for freq, power in zip(self.frequencies, self.powers)
        ])
        self.net_aep = array_aep.sum()
        # TODO: FIX gross_aep and capacity factor
        #self.gross_aep = array([array(freq) * array(power).max() * 24 * 365 for freq, power in zip(self.frequencies, self.powers)]).sum()
        #self.capacity_factor = self.net_aep / self.gross_aep

        self.array_aep = array_aep.sum(1).reshape(
            [len(self.wind_directions),
             len(self.wind_speeds)])
        self.wt_aep = array_aep.sum(0)
Beispiel #8
0
class AEPSingleWindRose(FUSEDAssembly):
    """Base class to calculate Annual Energy Production (AEP) of a wind farm.
    Implement the same interface as `BaseAEPModel`
    """
    wf = InterfaceSlot(GenericWindFarm,
                       desc='A wind farm assembly or component')
    postprocess_wind_rose = InterfaceSlot(
        GenericPostProcessWindRose,
        desc='The component taking care of postprocessing the wind rose')
    case_gen = InterfaceSlot(GenericWindRoseCaseGenerator,
                             desc='Generate the cases from the inputs')

    # Inputs
    wind_speeds = List([],
                       iotype='in',
                       units='m/s',
                       desc='The different wind speeds to run [nWS]')
    wind_directions = List([],
                           iotype='in',
                           units='deg',
                           desc='The different wind directions to run [nWD]')
    wind_rose = Array(
        [],
        iotype='in',
        desc='Probability distribution of wind speed, wind direction [nWD, nWS]'
    )

    # Outputs
    array_aep = Array([],
                      iotype='out',
                      units='kW*h',
                      desc='The energy production per sector [nWD, nWS]')
    gross_aep = Float(
        iotype='out',
        units='kW*h',
        desc=
        'Gross Annual Energy Production before availability and loss impacts')
    net_aep = Float(
        iotype='out',
        units='kW*h',
        desc='Net Annual Energy Production after availability and loss impacts'
    )
    capacity_factor = Float(0.0,
                            iotype='out',
                            desc='Capacity factor for wind plant')

    def configure(self):
        self.add('case_gen', SingleWindRoseCaseGenerator())
        self.add('postprocess_wind_rose', PostProcessSingleWindRose())
        configure_AEPWindRose(self)
        self.connect('wind_rose', 'case_gen.wind_rose')
Beispiel #9
0
class DTU10MWLoadCaseReader(Component):
    """
    reads the published DTU 10MW extreme load tables into a LoadVectorCaseArray

    The DTU 10MW RWT extreme load cases are written as one file per
    radial section with rows of cases with the following header

    ## ##############################################
    ## Section 001 at r=2.8 m
    ## ##############################################
    """

    case_files = List(iotype='in', desc='List of load case files')
    case_filter = List(iotype='in', desc='List of cases indices to include, if empty all are used')
    blade_length = Float(86.366, iotype='in')

    load_cases = VarTree(LoadVectorArrayCaseList(), iotype='out', desc='Load case arrays')

    def execute(self):

        rdata = []

        r = []
        for name in self.case_files:
            fid = open(name, 'r')
            fid.readline()
            radius = fid.readline().split()[4]
            radius = float(radius.strip('r='))
            r.append(radius)
            fid.readline()
            rdata.append(np.loadtxt(fid))

        isort = np.argsort(r)
        r = np.asarray(r)[isort]
        r = (r - r[0]) / self.blade_length
        rdata = np.asarray(rdata)[isort]

        if len(self.case_filter) == 0:
            self.case_filter = range(rdata.shape[1])

        for i in self.case_filter:
            c = np.zeros((rdata.shape[0], 9))
            c[:, 0] = r
            c[:, 1:] = rdata[:, i, :] * 1.e6
            v = LoadVectorArray()
            try:
                v.case_id = cases[i]
            except:
                v.case_id = 'case%03d' % i
            v._fromarray(c)
            self.load_cases.cases.append(v)
class HAWC2ConstraintBearing45(VariableTree):

    con_type = Str()
    mbdy1 = List(desc='Main_body name to which the next main_body is fixed')
    mbdy2 = List(
        desc='Main_body name of the main_body that is fixed to main_body1')
    bearing_vector = Array(
        np.zeros(4),
        desc='Vector to which the free rotation is possible.'
        'The direction of this vector also defines the coo to which the output angle is defined.'
        '1. Coo. system used for vector definition (0=global,1=mbdy1,2=mbdy2)'
        '2. x-axis'
        '3. y-axis'
        '4. z-axis')
Beispiel #11
0
class PostProcessSingleWindRose(Component):
    """Using the same wind rose for all the wind turbines"""
    # Inputs
    wind_speeds = List([],
                       iotype='in',
                       units='m/s',
                       desc='The different wind speeds to run [nWS]')
    wind_directions = List([],
                           iotype='in',
                           units='deg',
                           desc='The different wind directions to run [nWD]')
    frequencies = List([],
                       iotype='in',
                       desc='The different wind directions to run [nWD*nWS]')
    powers = List([],
                  iotype='in',
                  units='kW*h',
                  desc='The different wind directions to run [nWD*nWS]')

    # Outputs
    net_aep = Float(0.0,
                    iotype='out',
                    units='kW*h',
                    desc='Annual Energy Production')
    gross_aep = Float(0.0,
                      iotype='out',
                      units='kW*h',
                      desc='Gross Annual Energy Production')
    capacity_factor = Float(0.0, iotype='out', desc='Capacity factor')
    array_aep = Array([],
                      iotype='out',
                      units='kW*h',
                      desc='The energy production per sector [nWD, nWS]')

    def execute(self):
        list_aep = [
            freq * power * 24 * 365
            for freq, power in zip(self.frequencies, self.powers)
        ]
        self.net_aep = sum(list_aep)
        # TODO: FIX gross_aep and capacity factor
        #self.gross_aep = self.net_aep
        #self.capacity_factor = self.net_aep / self.gross_aep

        if len(self.wind_speeds) > 0 and len(self.wind_directions) > 0:
            self.array_aep = array(list_aep).reshape(
                [len(self.wind_speeds),
                 len(self.wind_directions)])
        else:
            print self.__class__.__name__, 'inputs, wind_speed or wind_directions are empty'
Beispiel #12
0
class TurbineEnvironmentCaseListVT(VariableTree):

    vhub = List(desc='Hub-height velocity')
    direction = List(desc='Incident wind direction')
    density = List([1.225], desc='air density')
    viscosity = List([1.78405e-5], desc='air viscosity')
    ti = List([0.], desc='Turbulence intensity in percent')
    inflow_type = List(Enum('constant', ('constant','log','powerlaw','linear','user')), desc='shear type')
    shear_exp = List([0.], iotype='in', desc='Shear exponent (when applicaple)') 
    kappa = List([0.4], iotype='in', desc='Von Karman constant')
    z0 = List([0.111], iotype='in', desc='Roughness length')
Beispiel #13
0
class WeibullWindRoseVT(VariableTree):
    wind_directions = List(desc='Direction sectors angles [n_wd]', units='deg')
    k = List(desc='Weibull exponent k [n_wd]', units='deg')
    A = List(desc='Weibull parameter A [n_wd]', units='m/s')
    frequency = List(desc='Frequency of wind direction [n_wd]', units='deg')

    def df(self):
        """Returns a pandas.DataFrame object"""
        return pd.DataFrame(self.to_weibull_array(),
                            columns=['wind_direction', 'frequency', 'A', 'k'])

    def to_weibull_array(self):
        """Returns a weibull array [wind_direction, frequency, A, k]"""
        return np.vstack(
            [self.wind_directions, self.frequency, self.A, self.k]).T
Beispiel #14
0
class DeMux(Component):
    """ Takes one List input and splits it into *n* indvidual outputs. This is a 
    logical demultiplexer. """

    n = Int(2,
            low=2,
            iotype="in",
            desc="number of items in the array to be \
    demultiplexed")
    inputs = List(iotype="in")

    def __init__(self, n=2):
        super(DeMux, self).__init__()
        self.n = n
        self._outputs = []
        self._n_changed(n, n)

    def _n_changed(self, old, new):

        for name in self._outputs:
            if self.parent:
                self.parent.disconnect('.'.join([self.name, name]))
            self.remove_trait(name)
        self._outputs = []
        for i in xrange(new):
            name = "output_%d" % (i + 1)
            self.add(name, Any(iotype="out"))
            self._outputs.append(name)

    def execute(self):
        for data, out in zip(self.inputs, self._outputs):
            setattr(self, out, data)
Beispiel #15
0
class DistributedLoadsArrayVT(VariableTree):
    """
    Container for a list of blade loads
    """

    loads_array = List(desc='List of arrays of spanwise loads')

    def add_case(self, obj, wsp=None, case_name=None):
        """
        Add a BeamDisplacementsVT

        Specify either wsp or a user specified case name

        Parameters
        ----------
        obj: BeamDisplacementsVT object 
            case to be added
        wsp: float
            optional wind speed
        case_name: str
            custom case name
        """

        if wsp == None and case_name == None:
            raise RuntimeError('Expected either wsp or case_name, got ' %
                               (wsp, case_name))
        if wsp is not None:
            name = 'loads%2.2f' % wsp
        elif case_name is not None:
            name = case_name

        self.add(name, VarTree(obj))
        self.loads_array.append(name)

        return getattr(self, name)
Beispiel #16
0
class LoadVectorArrayCaseList(VariableTree):
    """
    List of load vector cases as function of span
    """
    cases = List(LoadVectorArray, desc='List of load cases')

    def _interp_s(self, s):
        """
        interpolate the case list at a specific location ``s``

        Parameters
        ----------
        s: float
            curve fraction at which to interpolate the data

        Returns
        -------
        lc2d: LoadVectorCaseList
            Variable tree containing list of cases at ``s``
        """

        lc2d = LoadVectorCaseList()
        lc2d.s = s
        for case in self.cases:
            lc2d.cases.append(case._interp_s(s))

        return lc2d
Beispiel #17
0
class Mux(Component):
    """ Takes in *n* inputs and exports a length *n* List 
    with the data. It is a logical multiplexer.
    """

    n = Int(2, low=2, iotype="in", desc="number of inputs to be multiplexed")
    output = List(iotype="out")

    def __init__(self, n=2):
        super(Mux, self).__init__()
        self._inputs = []
        self.n = n
        self._n_changed(n, n)  #just to initialize it

    def _n_changed(self, old, new):
        for name in self._inputs:
            if self.parent:
                self.parent.disconnect('.'.join([self.name, name]))
            self.remove_trait(name)
        self._inputs = []
        #build the inputs
        for i in xrange(new):
            name = "input_%d" % (i + 1)
            self.add(name, Any(iotype="in"))
            self._inputs.append(name)

    def execute(self):
        self.output = [getattr(self, inp) for inp in self._inputs]
Beispiel #18
0
class LoadCaseReader(Component):

    case_files = List(iotype='in', desc='List of load case files')
    case_filter = List(iotype='in', desc='List of cases indices to include, if empty all are used')
    blade_length = Float(86.366, iotype='in')

    load_cases = VarTree(LoadVectorArrayCaseList(), iotype='out', desc='Load case arrays')

    def execute(self):
        for name in self.case_files:
            fid = open(name, 'r')
            case_id = fid.readline().split()[1]
            data = np.loadtxt(fid)
            lc = LoadVectorArray()
            lc._fromarray(data)
            self.load_cases.cases.append(lc.copy())
Beispiel #19
0
class Vis3DCollection(Container):
    """ A named collection of objects. """

    objects = List(Container)  # Prefer (Vis3DCollection, Vis3DObject)

    def add(self, *args, **kwargs):
        """
        Remember :class:`Vis3DCollection` and :class:`Vis3DObject` instances
        added (and in what order).
        """
        obj = super(Vis3DCollection, self).add(*args, **kwargs)
        if isinstance(obj, (Vis3DCollection, Vis3DObject)):
            self.objects.append(obj)
        return obj

    def add_vis3d(self, name, other, offset):
        """
        Copy :class:`Vis3DCollection` `other` to this one as `name`.
        `offset` is used to determine updated zone numbers.
        """
        collection = self.add(name, Vis3DCollection())
        for obj in other.objects:
            collection.add(obj.name, obj.clone(offset))

    def write_ensight(self, stream):
        """ Writes Ensight commands to `stream`. """
        for obj in self.objects:
            obj.write_ensight(stream)
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')
class DistributionCaseDriver(CaseIterDriverBase):
    """ Driver for evaluating models at point distributions. """

    implements(IHasParameters)

    distribution_generator = Slot(
        IDistributionGenerator,
        iotype='in',
        required=True,
        desc='Iterator supplying values of point distribitions.')

    case_outputs = List(Str,
                        iotype='in',
                        desc='A list of outputs to be saved with each case.')

    def get_case_iterator(self):
        """Returns a new iterator over the Case set."""
        return self._get_cases()

    def _get_cases(self):
        """Iterator over the cases"""

        params = self.get_parameters().values()
        self.distribution_generator.num_parameters = len(params)

        for row in self.distribution_generator:
            case = self.set_parameters(row, Case(parent_uuid=self._case_id))
            case.add_outputs(self.case_outputs)

            yield case
class BECASStressRecovery(Assembly):
    """
    Assembly that implements the FUSED-Wind I/O interface 
    defined in StressRecoveryCSCode.
    The assembly sets up a series of BECAS computations that iterate
    over a list of CSLoadVectorCaseArray's and computes stresses and
    strains. The assembly assumes that BECAS has already been executed
    to compute the stiffness matrix of the cross sections and that
    a series of .mat restart files are present in the base_dir.
    """

    load_cases = List(LoadVectorCaseList,
                      iotype='in',
                      desc='List of section load vectors used to perform'
                      'failure analysis')

    failure = Array(iotype='out', desc='Failure parameter')

    def _pre_execute(self):
        super(BECASStressRecovery, self)._pre_execute()

        self.tt = time.time()

    def _post_execute(self):
        super(BECASStressRecovery, self)._post_execute()

        t = time.time() - self.tt
        self._logger.info('BECASStressRecovery time: %f' % t)
class Broadcaster(Component):
    """Takes inputs and passes them directly to outputs
    to be broadcast out to other components."""

    names = List(
        Str,
        iotype="in",
        desc="Names of the variables you want to broadcast from this component."
    )
    types = Dict(
        {'default': Float},
        iotype="in",
        desc=
        "Name/type pairs describing the variable types of each broadcast variable; "
        "'default' name is used if no other type is set explicitly.")

    def __init__(self, names, types=None):
        """names: ListSrt, list of the variable names you would like the broadcaster to create for you. All inputs will be named with an '_in' added. Outputs will follow the name given.
        types: Dict, dictionary of the name/type pairs describing which types you would like to broadcast. If given, the name 'default' indicates the default variable type to use."""

        super(Broadcaster, self).__init__()
        self._vars = []
        if types is not None:
            self.types = types
        self.names = names

    def _types_changed(self, old, new):
        if self.names:
            self._names_changed(self.names, self.names)

    #code to create inputs and outputs when names is changed
    def _names_changed(self, old, new):
        for in_var, out_var in self._vars:
            if self.parent:
                self.parent.disconnect('.'.join([self.name, in_var]))
                self.parent.disconnect('.'.join([self.name, out_var]))
            self.remove_trait(in_var)
            self.remove_trait(out_var)
        self._vars = []
        for name in new:
            if name in self.types:
                traits = self.types[name]
            elif 'default' in self.types:
                traits = self.types['default']
            else:
                self.raise_exception(
                    'No type was provided for "%s" and no "default" type was provided. '
                    'Specify at least one of these.' % name, ValueError)

            in_var = "%s_in" % name
            out_var = name
            self.add_trait(in_var, Float(iotype="in", low=-9e99, high=9e99))
            self.add_trait(out_var, Float(iotype="out"))

            self._vars.append((in_var, out_var))

    def execute(self, *args, **kwargs):
        for in_var, out_var in self._vars:
            setattr(self, out_var, getattr(self, in_var))
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')
Beispiel #25
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
class Dummy(Component):
    x = Float(0.0, low=-10, high=10, iotype='in')
    y = Float(0.0, low=0, high=10, iotype='in')
    lst = List([1, 2, 3, 4, 5], iotype='in')
    i = Int(0, low=-10, high=10, iotype='in')
    j = Int(0, low=0, high=10, iotype='in')
    enum_i = Enum(values=(1, 5, 8), iotype='in')
    enum_f = Enum(values=(1.1, 5.5, 8.8), iotype='in')
    def __init__(self, channels=[0, 1, 2]):
        super(frameSlices, self).__init__()
        self.add("frame_in", Array(iotype="in"))
        self.add("rects_in", Array(iotype="in"))
        self.add("slices", List([np.array([0, 0])], iotype="out"))
        self.add("combined", Array(iotype="out"))

        self.channels = channels
class SectionVT(VariableTree):
    s0 = Float()
    s1 = Float()
    regions = List()

    def add_region(self, name):
        self.add(name, VarTree(RegionVT()))
        self.regions.append(name)
class HAWC2Aero(VariableTree):

    nblades = Int(3, desc='Number of blades')
    hub_vec_mbdy_name = Str('shaft')
    hub_vec_coo = Int(-3)
    links = List()
    induction_method = Enum(1, (0, 1),
                            desc='BEM induction method, 0=none, 1=normal')
    aerocalc_method = Enum(1, (0, 1), desc='BEM aero method, 0=none, 1=normal')
    aerosections = Int(30, desc='Number of BEM aerodynamic sections')
    tiploss_method = Enum(1, (0, 1),
                          desc='BEM induction method, 0=none, 1=prandtl')
    dynstall_method = Enum(
        2, (0, 1, 2),
        desc='BEM induction method, 0=none, 1=stig oeye method,2=mhh method')
    ae_sets = List([1, 1, 1])
    ae_filename = Str()
    pc_filename = Str()
Beispiel #30
0
class AeroelasticHAWTVT(BasicTurbineVT):

    tilt_angle = Float(units='deg', desc='Rotor tilt angle')
    cone_angle = Float(units='deg', desc='Rotor cone angle')
    hub_radius = Float(units='m', desc='Hub radius')
    blade_length = Float(units='m', desc='blade length')
    tower_height = Float(units='m', desc='Tower height')
    towertop_length = Float(units='m', desc='Nacelle Diameter')
    shaft_length = Float(units='m', desc='Shaft length')

    airfoildata = VarTree(AirfoilDatasetVT(), desc='Airfoil Aerodynamic characteristics')

    drivetrain_performance = VarTree(DrivetrainPerformanceVT(), desc='drivetrain performance VT')

    bodies = List()

    def add_main_body(self, name, body=None):

        if body is None:

            body = MainBody()
            
            if 'blade' in name:
                body.remove('geom')
                body.add('geom', VarTree(BladePlanformVT()))
            if 'tower' in name:
                body.remove('geom')
                body.add('geom', VarTree(TubularTowerGeometryVT()))

        self.add(name, VarTree(body))
        self.bodies.append(name)

        return getattr(self, name)

    def get_main_body(self, name):

        return getattr(self, name)

    def remove_main_body(self, name):

        self.delete(name)

    def set_machine_type(self, machine_type):

        self.remove('controls')

        if machine_type == 'FixedSpeedFixedPitch':
            self.add('controls', VarTree(FixedSpeedFixedPitch()))
        if machine_type == 'FixedSpeedVarPitch':
            self.add('controls', VarTree(FixedSpeedVarPitch()))
        if machine_type == 'VarSpeedFixedPitch':
            self.add('controls', VarTree(VarSpeedFixedPitch()))
        if machine_type == 'VarSpeedVarPitch':
            self.add('controls', VarTree(VarSpeedVarPitch()))

        return self.controls
Beispiel #31
0
    def __init__(self, iotype, client, rpath, typ):
        ProxyMixin.__init__(self, client, rpath)
        self._type = typ

        default = [typ(val.strip(' "')) for val in self._valstr.split(',')]
        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:
            List.__init__(self, trait=Float, iotype=iotype, desc=desc,
                           value=default, low=low, high=high,
                           units=om_units)
        elif typ == int:
            List.__init__(self, trait=Int, iotype=iotype, desc=desc,
                           value=default, low=low, high=high)
        else:
            List.__init__(self, trait=Str, iotype=iotype, desc=desc,
                          value=default)