class FixedSpeedFixedPitch(ControlsVT): Omega = Float(units='rpm') pitch = Float(units='deg') varSpeed = Bool(False) varPitch = Bool(False)
def __init__(self, iotype, client, rpath): ProxyMixin.__init__(self, client, rpath) default = self._valstr == 'true' desc = client.get(rpath+'.description') Bool.__init__(self, default_value=default, iotype=iotype, desc=desc)
class DrivenComponent(Component): """ Just something to be driven and compute results. """ x = Array([1., 1., 1., 1.], iotype='in') y = Array([1., 1., 1., 1.], iotype='in') raise_error = Bool(False, iotype='in') stop_exec = Bool(False, iotype='in') sleep = Float(0., iotype='in') rosen_suzuki = Float(0., iotype='out') sum_y = Float(0., iotype='out') extra = Float(1.5, iotype='out') def __init__(self, *args, **kwargs): super(DrivenComponent, self).__init__(*args, **kwargs) def execute(self): """ Compute results from input vector. """ self.extra = 2.5 if self.sleep: time.sleep(self.sleep) self.rosen_suzuki = rosen_suzuki(self.x) self.sum_y = sum(self.y) if self.raise_error: self.raise_exception('Forced error', RuntimeError) if self.stop_exec: self.parent.driver.stop() # Only valid if sequential!
class VarSpeedVarPitch(ControlsVT): minOmega = Float(units='rpm') maxOmega = Float(units='rpm') minPitch = Float(units='deg') varSpeed = Bool(True) varPitch = Bool(True)
def __init__(self, excelFile, xmlFile): super(ExcelWrapper, self).__init__() self.xmlFile = xmlFile try: tree = ET.parse(self.xmlFile) except: if not os.path.exists(self.xmlFile): print 'Cannot find the xml file at ' + self.xmlFile self.variables = tree.findall("Variable") for v in self.variables: name = v.attrib['name'] kwargs = dict([(key, v.attrib[key]) for key in ('iotype', 'desc', 'units') if key in v.attrib]) if v.attrib['iotype'] == 'in': if v.attrib['type'] == 'Float': self.add(v.attrib['name'], Float(float(v.attrib['value']), **kwargs)) elif v.attrib['type'] == 'Int': self.add(v.attrib['name'], Int(int(v.attrib['value']), **kwargs)) elif v.attrib['type'] == 'Bool': self.add( v.attrib['name'], Bool(ast.literal_eval(v.attrib['value']), **kwargs)) elif v.attrib['type'] == 'Str': self.add(v.attrib['name'], Str(v.attrib['value'], **kwargs)) else: if v.attrib['type'] == 'Float': self.add(v.attrib['name'], Float(**kwargs)) elif v.attrib['type'] == 'Int': self.add(v.attrib['name'], Int(**kwargs)) elif v.attrib['type'] == 'Bool': self.add(v.attrib['name'], Bool(**kwargs)) elif v.attrib['type'] == 'Str': self.add(v.attrib['name'], Str(**kwargs)) self.excelFile = excelFile self.xlInstance = None self.workbook = None self.ExcelConnectionIsValid = True if not os.path.exists(self.excelFile): print "Invalid file given" self.ExcelConnectionIsValid = False else: self.excelFile = os.path.abspath(self.excelFile) xl = self.openExcel() if xl is None: print "Connection to Excel failed." self.ExcelConnectionIsValid = False else: self.xlInstance = xl self.workbook = xl.Workbooks.Open(self.excelFile)
class WingParms(XMLContainer): """ XML parameters specific to a Wing. """ XMLTAG = 'Mwing_Parms' num_pnts = Int(iotype='in', xmltag='Num_Pnts', desc='') driver = Int(iotype='in', xmltag='Driver', desc='') aspect_ratio = Float(iotype='in', xmltag='Aspect_Ratio', desc='') taper_ratio = Float(iotype='in', xmltag='Taper_Ratio', desc='') area = Float(iotype='in', xmltag='Area', desc='') span = Float(iotype='in', xmltag='Span', desc='') tip_chord = Float(iotype='in', xmltag='Tip_Chord', desc='') root_chord = Float(iotype='in', xmltag='Root_Chord', desc='') sweep = Float(iotype='in', xmltag='Sweep', desc='') sweep_loc = Float(iotype='in', xmltag='Sweep_Loc', desc='') twist_loc = Float(iotype='in', xmltag='Twist_Loc', desc='') in_twist = Float(iotype='in', xmltag='In_Twist', desc='') in_dihed = Float(iotype='in', xmltag='In_Dihed', desc='') mid_twist = Float(iotype='in', xmltag='Mid_Twist', desc='') mid_dihed = Float(iotype='in', xmltag='Mid_Dihed', desc='') out_twist = Float(iotype='in', xmltag='Out_Twist', desc='') out_dihed = Float(iotype='in', xmltag='Out_Dihed', desc='') strake_sweep = Float(iotype='in', xmltag='Strake_Sweep', desc='') strake_span_per = Float(iotype='in', xmltag='Strake_Span_Per', desc='') aft_ext_sweep = Float(iotype='in', xmltag='Aft_Ext_Sweep', desc='') aft_ext_span_per = Float(iotype='in', xmltag='Aft_Ext_Span_Per', desc='') all_move_flag = Bool(iotype='in', xmltag='All_Move_Flag', desc='') in_flap_type = Int(iotype='in', xmltag='In_Flap_Type', desc='') out_flap_type = Int(iotype='in', xmltag='Out_Flap_Type', desc='') in_slat_type = Int(iotype='in', xmltag='In_Slat_Type', desc='') out_slat_type = Int(iotype='in', xmltag='Out_Slat_Type', desc='') in_flap_span_in = Float(iotype='in', xmltag='In_Flap_Span_In', desc='') in_flap_span_out = Float(iotype='in', xmltag='In_Flap_Span_Out', desc='') in_flap_chord = Float(iotype='in', xmltag='In_Flap_Chord', desc='') out_flap_span_in = Float(iotype='in', xmltag='Out_Flap_Span_In', desc='') out_flap_span_out = Float(iotype='in', xmltag='Out_Flap_Span_Out', desc='') out_flap_chord = Float(iotype='in', xmltag='Out_Flap_Chord', desc='') in_slat_span_in = Float(iotype='in', xmltag='In_Slat_Span_In', desc='') in_slat_span_out = Float(iotype='in', xmltag='In_Slat_Span_Out', desc='') in_slat_chord = Float(iotype='in', xmltag='In_Slat_Chord', desc='') out_slat_span_in = Float(iotype='in', xmltag='Out_Slat_Span_In', desc='') out_slat_span_out = Float(iotype='in', xmltag='Out_Slat_Span_Out', desc='') out_slat_chord = Float(iotype='in', xmltag='Out_Slat_Chord', desc='') deflect_on_off = Bool(iotype='in', xmltag='Deflect_On_Off', desc='') deflect_name = Str(iotype='in', xmltag='Deflect_Name', desc='') deflect_scale = Float(iotype='in', xmltag='Deflect_Scale', desc='') deflect_twist_scale = Float(iotype='in', xmltag='Deflect_Twist_Scale', desc='') strake_aft_flag = Bool(iotype='in', xmltag='Strake_Aft_Flag', desc='') # TODO: handle array. deflect_pnts = Str(iotype='in', xmltag='Deflect_Pnts', desc='') def __init__(self): super(WingParms, self).__init__(self.XMLTAG)
class MSWingParms(XMLContainer): """ XML parameters specific to a Multi-Section Wing. """ XMLTAG = 'Mswing_Parms' total_span = Float(low=0.1, high=10000., iotype='in', xmltag='Total_Span', desc='') total_proj_span = Float(low=0.1, high=10000., iotype='in', xmltag='Total_Proj_Span', desc='') avg_chord = Float(low=0.1, high=10000., iotype='in', xmltag='Avg_Chord', desc='Average chord.') total_area = Float(low=1., high=1000000., iotype='in', xmltag='Total_Area', desc='') sweep_off = Float(iotype='in', xmltag='Sweep_Off', desc='Sweep offset.') rounded_tips = Bool(False, iotype='in', xmltag='Round_End_Cap_Flag', desc='') deg_per_seg = Int(9, low=1, high=30, units='deg', iotype='in', xmltag='Deg_Per_Seg', desc='Degrees per segment in blend.') max_num_segs = Int(iotype='in', xmltag='Max_Num_Seg', desc='Max number of segments in blend.') rel_dihedral_flag = Bool(False, iotype='in', xmltag='Rel_Dihedral_Flag', desc='') rel_twist_flag = Bool(False, iotype='in', xmltag='Rel_Twist_Flag', desc='') def __init__(self): super(MSWingParms, self).__init__(self.XMLTAG)
class DrivenComponent(Component): """ Just something to be driven and compute results. """ x0 = Float(1., iotype='in') y0 = Float(1., iotype='in') # used just to get ParameterGroup x1 = Float(1., iotype='in') x2 = Float(1., iotype='in') x3 = Float(1., iotype='in') err_event = Event() stop_exec = Bool(False, iotype='in') rosen_suzuki = Float(0., iotype='out') def __init__(self): super(DrivenComponent, self).__init__() self._raise_err = False def _err_event_fired(self): self._raise_err = True def execute(self): """ Compute results from input vector. """ self.rosen_suzuki = rosen_suzuki(self.x0, self.x1, self.x2, self.x3) if self._raise_err: self.raise_exception('Forced error', RuntimeError) if self.stop_exec: self.parent.driver.stop() # Only valid if sequential!
class IterateUntil(Driver): """ A simple driver to run a workflow until some stop condition is met. """ max_iterations = Int(10, iotype="in", desc="Maximum number of iterations.") iteration = Int(0, iotype="out", desc="Current iteration counter.") run_at_least_once = Bool( True, iotype="in", desc= "If True, driver will ignore stop conditions for the first iteration and run at least one iteration." ) def start_iteration(self): """ Code executed before the iteration. """ self.iteration = 0 def continue_iteration(self): self.record_case() if self.iteration < 1 and self.run_at_least_once: self.iteration += 1 return True if self.should_stop(): return False if self.iteration < self.max_iterations: self.iteration += 1 return True return False
class showBPMtext(Component): """ Shows the estimated BPM in the image frame """ ready = Bool(False, iotype="in") bpm = Float(iotype="in") x = Int(iotype="in") y = Int(iotype="in") fps = Float(iotype="in") size = Float(iotype="in") n = Int(iotype="in") def __init__(self): super(showBPMtext, self).__init__() self.add("frame_in", Array(iotype="in")) self.add("frame_out", Array(iotype="out")) def execute(self): #if self.bpm: #print("[!]BPM: %0.1f" % self.bpm) if self.ready: col = (0, 255, 0) text = "%0.1f bpm" % self.bpm tsize = 2 else: col = (100, 255, 100) gap = (self.n - self.size) / self.fps text = "(estimate: %0.1f bpm, wait %0.0f s)" % (self.bpm, gap) tsize = 1 cv2.putText(self.frame_in, text, (self.x, self.y), cv2.FONT_HERSHEY_PLAIN, tsize, col) self.frame_out = self.frame_in return self.bpm
class DOEdriver(CaseIterDriverBase): """ Driver for Design of Experiments. """ # pylint: disable-msg=E1101 DOEgenerator = Slot(IDOEgenerator, iotype='in', required=True, desc='Iterator supplying normalized DOE values.') record_doe = Bool(True, iotype='in', desc='Record normalized DOE values to CSV file.') doe_filename = Str('', iotype='in', desc='Name of CSV file to record to' ' (default is <driver-name>.csv)') case_outputs = ListStr([], iotype='in', desc='A list of outputs to be saved with each case.') case_filter = Slot(ICaseFilter, iotype='in', desc='Selects cases to be run.') def execute(self): """Generate and evaluate cases.""" self._csv_file = None try: super(DOEdriver, self).execute() finally: if self._csv_file is not None: self._csv_file.close() def get_case_iterator(self): """Returns a new iterator over the Case set.""" return self._get_cases() def _get_cases(self): """Generate each case.""" params = self.get_parameters().values() self.DOEgenerator.num_parameters = len(params) record_doe = self.record_doe events = self.get_events() outputs = self.case_outputs case_filter = self.case_filter if record_doe: if not self.doe_filename: self.doe_filename = '%s.csv' % self.name self._csv_file = open(self.doe_filename, 'wb') csv_writer = csv.writer(self._csv_file) for i, row in enumerate(self.DOEgenerator): if record_doe: csv_writer.writerow(['%.16g' % val for val in row]) vals = [p.low+(p.high-p.low)*val for p,val in zip(params,row)] case = self.set_parameters(vals, Case(parent_uuid=self._case_id)) # now add events for varname in events: case.add_input(varname, True) case.add_outputs(outputs) if case_filter is None or case_filter.select(i, case): yield case
class Texture(XMLContainer): """ XML parameters for a texture/image applied to a surface. """ XMLTAG = 'Applied_Texture' texture_name = Str('Default_Name', iotype='in', xmltag='Name', desc='Name of texture.') texture_filename = Str('Default_Name', iotype='in', xmltag='Texture_Name', desc='Filename for texture data (.jpg or .tga)') all_surf_flag = Bool(False, iotype='in', xmltag='All_Surf_Flag', desc='If True, apply to all surfaces of component.') surf_id = Int(0, iotype='in', xmltag='Surf_ID', desc='ID of surface to apply to.') u = Float(0.5, iotype='in', xmltag='U', desc='Position along U axis.') w = Float(0.5, iotype='in', xmltag='W', desc='Position along W axis.') scale_u = Float(1.0, iotype='in', xmltag='Scale_U', desc='Scaling in U direction.') scale_w = Float(1.0, iotype='in', xmltag='Scale_W', desc='Scaling in W direction.') wrap_u = Bool(False, iotype='in', xmltag='Wrap_U_Flag', desc='') wrap_w = Bool(False, iotype='in', xmltag='Wrap_W_Flag', desc='') repeat = Bool(False, iotype='in', xmltag='Repeat_Flag', desc='Repeat texture over surface.') bright = Float(1.0, low=0., high=1., iotype='in', xmltag='Bright', desc='Brightness.') alpha = Float(1.0, low=0., high=1., iotype='in', xmltag='Alpha', desc='Transparency.') flip_u = Bool(False, iotype='in', xmltag='Flip_U_Flag', desc='') flip_w = Bool(False, iotype='in', xmltag='Flip_W_Flag', desc='') refl_flip_u = Bool(False, iotype='in', xmltag='Refl_Flip_U_Flag', desc='') refl_flip_w = Bool(False, iotype='in', xmltag='Refl_Flip_W_Flag', desc='') def __init__(self): super(Texture, self).__init__(self.XMLTAG)
class HAWC2SCommandsOpt(VariableTree): include_torsiondeform = Int(1) bladedeform = Str('bladedeform') tipcorrect = Str('tipcorrect') induction = Str('induction') gradients = Str('gradients') blade_only = Bool(False) matrixwriteout = Str('nomatrixwriteout') eigenvaluewriteout = Str('noeigenvaluewriteout') frequencysorting = Str('modalsorting') number_of_modes = Int(10) maximum_damping = Float(0.5) minimum_frequency = Float(0.5) zero_pole_threshold = Float(0.1) aero_deflect_ratio = Float(0.01) vloc_out = Bool(False) regions = Array()
class PostprocessCasesBase(Component): """ Postprocess list of cases returned by a case recorder """ cases = Instance(ICaseIterator, iotype='in') keep_dirs = Bool( False, desc='Flag to keep ObjServer directories for debugging purposes')
class PropParms(XMLContainer): """ XML parameters specific to a propeller. """ XMLTAG = 'Prop_Parms' num_blades = Int(4, low=1, iotype='in', xmltag='NumBlades', desc='') smooth_flag = Bool(True, iotype='in', xmltag='SmoothFlag', desc='') num_u = Int(3, low=1, iotype='in', xmltag='NumU', desc='') num_w = Int(1, low=1, iotype='in', xmltag='NumW', desc='') diameter = Float(4., low=0.01, high=1000., iotype='in', xmltag='Diameter', desc='') cone_angle = Float(0., low=-45., high=45., units='deg', iotype='in', xmltag='ConeAngle', desc='') pitch = Float(0., low=-180., high=180., units='deg', iotype='in', xmltag='Pitch', desc='') def __init__(self): super(PropParms, self).__init__(self.XMLTAG) self._stations = [] def read(self, this): """ Read parameters from XML tree element `this`. """ super(PropParms, self).read(this) stations = this.findall(SectParms.XMLTAG) for i, element in enumerate(stations): name = 'station_%d' % i section = self.add(name, SectParms()) section.read(element) self._stations.append(section) def write(self, parent, nesting=0): """ Write parameters to XML tree under `parent`. Returns tree element. """ this = super(PropParms, self).write(parent, nesting) for station in self._stations: station.write(this, nesting + 2) return this
class BlankParms(XMLContainer): """ XML parameters specific to a 'blank'. """ XMLTAG = 'Blank_Parms' point_mass_flag = Bool(False, iotype='in', xmltag='PointMassFlag', desc='') point_mass = Float(1.0, iotype='in', xmltag='PointMass', desc='') def __init__(self): super(BlankParms, self).__init__(self.XMLTAG)
class FstTowerStrucGeometry(VariableTree): description = Str(desc='description of tower') # General Tower Paramters NTwInptSt = Int(desc='Number of input stations to specify tower geometry') CalcTMode = Bool( desc= 'alculate tower mode shapes internally {T: ignore mode shapes from below, F: use mode shapes from below} [CURRENTLY IGNORED] (flag)' ) TwrFADmp1 = Float( desc='Tower 1st fore-aft mode structural damping ratio (%)') TwrFADmp2 = Float( desc='Tower 2nd fore-aft mode structural damping ratio (%)') TwrSSDmp1 = Float( desc='Tower 1st side-to-side mode structural damping ratio (%)') TwrSSDmp2 = Float( desc='Tower 2nd side-to-side mode structural damping ratio (%)') # Tower Adjustment Factors FAStTunr1 = Float( desc='Tower fore-aft modal stiffness tuner, 1st mode (-)') FAStTunr2 = Float( desc='Tower fore-aft modal stiffness tuner, 2nd mode (-)') SSStTunr1 = Float(desc='Tower side-to-side stiffness tuner, 1st mode (-)') SSStTunr2 = Float(desc='Tower side-to-side stiffness tuner, 2nd mode (-)') AdjTwMa = Float(desc='Factor to adjust tower mass density (-)') AdjFASt = Float(desc='Factor to adjust tower fore-aft stiffness (-)') AdjSSSt = Float(desc='Factor to adjust tower side-to-side stiffness (-)') # Distributed Tower Properties HtFract = Array() TMassDen = Array() TwFAStif = Array() TwSSStif = Array() TwGJStif = Array() TwEAStif = Array() TwFAIner = Array() TwSSIner = Array() TwFAcgOf = Array() TwSScgOf = Array() # Tower Mode Shapes TwFAM1Sh = Array( desc='Tower Fore-Aft Mode 1 Shape Coefficients x^2, x^3, x^4, x^5, x^6' ) TwFAM2Sh = Array( desc='Tower Fore-Aft Mode 2 Shape Coefficients x^2, x^3, x^4, x^5, x^6' ) TwSSM1Sh = Array( desc= 'Tower Side-to-Side Mode 1 Shape Coefficients x^2, x^3, x^4, x^5, x^6') TwSSM2Sh = Array( desc= 'Tower Side-to-Side Mode 2 Shape Coefficients x^2, x^3, x^4, x^5, x^6')
class HAWC2Simulation(VariableTree): time_stop = Float(300, desc='Simulation stop time') solvertype = Int(1, desc='Solver type. Default Newmark') convergence_limits = List([1.0e3, 1.0, 0.7], desc='Sovler convergence limits') on_no_convergence = Str() max_iterations = Int(100, desc='Maximum iterations') newmark_deltat = Float(0.02, desc='Newmark time step') eig_out = Bool(False) logfile = Str('hawc2_case.log')
class Connectable(Component): b_in = Bool(iotype='in') e_in = Enum(values=(1, 2, 3), iotype='in') f_in = Float(iotype='in') i_in = Int(iotype='in') s_in = Str(iotype='in') b_out = Bool(iotype='out') e_out = Enum(values=(1, 2, 3), iotype='out') f_out = Float(iotype='out') i_out = Int(iotype='out') s_out = Str(iotype='out') def execute(self): self.b_out = self.b_in self.e_out = self.e_in self.f_out = self.f_in self.i_out = self.i_in self.s_out = self.s_in
class PostprocessIECCasesBase(Component): """ Postprocess list of cases returned by a case recorder """ cases = Instance(ICaseIterator, iotype='in') keep_dirs = Bool(False, desc='Flag to keep ObjServer directories for debugging purposes') def execute(self): for case in self.cases: inputs = case.get_input('runner.inputs') print 'processing case %s' % inputs.case_name
class TestComponent(Component): """ Component which tracks it's total executions and can request that the run be stopped. """ dummy_input = Int(0, iotype='in') set_stop = Bool(False, iotype='in') total_executions = Int(0, iotype='out') def execute(self): self.total_executions += 1 if self.set_stop: self.parent.driver.stop()
class ExternalParms(XMLContainer): """ XML parameters specific to an 'external'. """ XMLTAG = 'External_Parms' external_type = Enum(_MISSLE_TYPE, iotype='in', xmltag='External_Type', values=(_BOMB_TYPE, _MISSLE_TYPE, _TANK_TYPE, _FIXED_TANK_TYPE), aliases=('Bomb', 'Missile', 'Tank', 'Fixed Tank'), desc='Type of external store.') length = Float(6.5, low=0.1, high=100., iotype='in', xmltag='Length', desc='Store length.') fine_ratio = Float(15.0, low=2., high=50., iotype='in', xmltag='Finess_Ratio', desc='') drag = Float(0.01, low=0., high=100., iotype='in', xmltag='Drag', desc='Equivalent flat plate drag of store.') pylon = Bool(True, iotype='in', xmltag='Pylon_Flag', desc='If True, include pylon.') pylon_height = Float(0.35, low=0.001, high=20., iotype='in', xmltag='Pylon_Height', desc='Height of pylon.') pylon_drag = Float(0.01, low=0., high=100., iotype='in', xmltag='Pylon_Drag', desc='Equivalent flat plat drag of pylon.') def __init__(self): super(ExternalParms, self).__init__(self.XMLTAG)
class Oneinp(Component): """ A simple input component """ ratio1 = Float(2., iotype='in', desc='Float Variable') ratio2 = Int(2, iotype='in', desc='Int Variable') ratio3 = Bool(False, iotype='in', desc='Float Variable') ratio4 = Float(1.03, iotype='in', desc='Float variable ', units='ft') ratio5 = Str('01234', iotype='in', desc='string variable') ratio6 = Enum(0, (0, 3, 11, 27), iotype='in', desc='some enum') unit = Float(0.0, units='ft', iotype='in') no_unit = Float(0.0, iotype='in') def execute(self): """
class Oneout(Component): """ A simple output component """ ratio1 = Float(3.54, iotype='out', desc='Float Variable') ratio2 = Int(9, iotype='out', desc='Integer variable') ratio3 = Bool(True, iotype='out', desc='Boolean Variable') ratio4 = Float(1.03, iotype='out', desc='Float variable ', units='cm') ratio5 = Str('05678', iotype='out', desc='string variable') ratio6 = Enum(27, (0, 3, 9, 27), iotype='out', desc='some enum') unit = Float(12.0, units='inch', iotype='out') no_unit = Float(12.0, iotype='out') def execute(self): """
class PhaseController(Component): """ Outputs either a convex combination of two floats generated from an inputted phase angle, or a set of two default values The inputted phase should be an angle ranging from 0 to 2*pi The behavior is toggled by the boolean "state" input, which may be connected by another component or set directly by the user during a run (In short, this component can help make parts of an image frame flash in sync to a detected heartbeat signal, in real time) """ phase = Float(iotype="in") state = Bool(iotype="in") alpha = Float(iotype="out") beta = Float(iotype="out") def __init__(self, default_a, default_b, state=False): super(PhaseController, self).__init__() self.state = state self.default_a = default_a self.default_b = default_b def toggle(self): if self.state: self.state = False else: self.state = True return self.state def on(self): if not self.state: self.toggle() def off(self): if self.state: self.toggle() def execute(self): if self.state: t = (np.sin(self.phase) + 1.) / 2. t = 0.9 * t + 0.1 self.alpha = t self.beta = 1 - t else: self.alpha = self.default_a self.beta = self.default_b
class FstBladeStrucGeometry(VariableTree): description = Str(desc='Blade file description') # General Model Inputs NBlInpSt = Int(desc='Number of blade input stations (-)') CalcBMode = Bool( desc= 'Calculate blade mode shapes internally {T: ignore mode shapes from below, F: use mode shapes from below} [CURRENTLY IGNORED] (flag)' ) BldFlDmp1 = Float( desc='Blade flap mode #1 structural damping in percent of critical (%)' ) BldFlDmp2 = Float( desc='Blade flap mode #2 structural damping in percent of critical (%)' ) BldEdDmp1 = Float( desc='Blade edge mode #1 structural damping in percent of critical (%)' ) FlStTunr1 = Float( desc='Blade flapwise modal stiffness tuner, 1st mode (-)') FlStTunr2 = Float( desc='Blade flapwise modal stiffness tuner, 2nd mode (-)') AdjBlMs = Float(desc='Factor to adjust blade mass density (-)') AdjFlSt = Float(desc='Factor to adjust blade flap stiffness (-)') AdjEdSt = Float(desc='Factor to adjust blade edge stiffness (-)') # Distributed Blade Properties BlFract = Array() AeroCent = Array() StrcTwst = Array() BMassDen = Array() FlpStff = Array() EdgStff = Array() GJStff = Array() EAStff = Array() Alpha = Array() FlpIner = Array() EdgIner = Array() PrecrvRef = Array() FlpcgOf = Array() Edgcgof = Array() FlpEAOf = Array() EdgEAOf = Array() # Blade Mode Shapes BldFl1Sh = Array() BldFl2Sh = Array() BldEdgSh = Array()
class HAWC2Mann(VariableTree): create_turb = Bool(True) L = Float(29.4) alfaeps = Float(1.0) gamma = Float(3.7) seed = Float() highfrq_compensation = Float(1.) turb_base_name = Str('mann_turb') turb_directory = Str('turb') box_nu = Int(8192) box_nv = Int(32) box_nw = Int(32) box_du = Float(0.8056640625) box_dv = Float(5.6) box_dw = Float(5.6) std_scaling = Array([1.0, 0.7, 0.5])
class FLORISParameters(VariableTree): """Container of FLORIS wake parameters""" # original tuning parameters pP = Float(1.88, iotype='in') # yaw power correction parameter ke = Float(0.05, iotype='in') # wake expansion paramters keCorrArray = Float(0.0, iotype='in') # array-correction factor keCorrCT = Float(0.0, iotype='in') # CT-correction factor baselineCT = Float(4.0 * (1.0 / 3.0) * (1.0 - (1.0 / 3.0)), iotype='in') # Baseline CT for ke-correction me = Array(np.array([-0.5, 0.22, 1.0]), iotype='in') # relative expansion of wake zones kd = Float(0.17, iotype='in') # wake deflection recovery factor # define initial wake displacement and angle (not determined by yaw angle) useWakeAngle = Bool(True, iotype='in') initialWakeDisplacement = Float(-4.5, iotype='in') initialWakeAngle = Float(1.5, iotype='in') bd = Float(-0.01, iotype='in') # correction recovery coefficients with yaw useaUbU = Bool(True, iotype='in') aU = Float(12.0, iotype='in', units='deg') bU = Float(1.3, iotype='in') MU = Array(np.array([0.5, 1.0, 5.5]), iotype='in') CTcorrected = Bool( True, iotype='in', desc= 'CT factor already corrected by CCBlade calculation (approximately factor cos(yaw)^2)' ) CPcorrected = Bool( True, iotype='in', desc= 'CP factor already corrected by CCBlade calculation (assumed with approximately factor cos(yaw)^3)' ) axialIndProvided = Bool( False, iotype='in', desc= 'CT factor already corrected by CCBlade calculation (approximately factor cos(yaw)^2)' ) # adjust initial wake diameter to yaw adjustInitialWakeDiamToYaw = Bool(False, iotype='in') # shear layer (only influences visualization) shearCoefficientAlpha = Float(0.10805, iotype='in') shearZh = Float(90., iotype='in')
class CabinLayoutParms(XMLContainer): """ XML parameters specific to cabin layout. """ XMLTAG = 'Cabin_Layout_Parms' geom_filename = Str(iotype='in', xmltag='Geom_Data_File_Name', desc='') mirror_active = Bool(False, iotype='in', xmltag='Mirror_Active', desc='') def __init__(self): super(CabinLayoutParms, self).__init__(self.XMLTAG) self._cross_sections = [] def read(self, this): """ Read parameters from XML tree element `this`. """ super(CabinLayoutParms, self).read(this) section_list = this.find('Cabin_Cross_Sections_List') if section_list is None: self.raise_exception('No Cabin_Cross_Sections_List!?', RuntimeError) sections = section_list.findall(CrossSection.XMLTAG) for i, element in enumerate(sections): name = '%s_%d' % (CrossSection.XMLTAG, i) section = self.add(name, CrossSection()) section.read(element) self._cross_sections.append(section) def write(self, parent, nesting=0): """ Write parameters to XML tree under `parent`. Returns tree element. """ this = super(CabinLayoutParms, self).write(parent, nesting) section_list = ElementTree.Element('Cabin_Cross_Sections_List') section_list.text = self.tail(nesting + 2) section_list.tail = self.tail(nesting + 1) for section in self._cross_sections: section.write(section_list, nesting + 2) this.append(section_list) return this
class HAWC2Wind(VariableTree): density = Float(1.225, desc='Density') wsp = Float(desc='Hub height wind speed') tint = Float(desc='Turbulence intensity') horizontal_input = Enum(1, (0, 1), desc='0=meteorological default, 1=horizontal') center_pos0 = Array( np.zeros(3), desc='Turbulence box center start point in global coordinates.') windfield_rotations = Array( np.zeros(3), desc='Orientation of the wind field, yaw, tilt, rotation.') shear_type = Enum(1, (0, 1, 2, 3, 4), desc='Definition of the mean wind shear:' '0=None,1=constant,2=logarithmic,3=power law,4=linear') shear_factor = Float(0., desc='Shear parameter - depends on the shear type') turb_format = Enum(0, (0, 1, 2), desc='Turbulence format (0=none, 1=mann, 2=flex)') tower_shadow_method = Enum( 0, (0, 1, 2, 3), desc='Tower shadow model' '(0=none, 1=potential flow - default, 2=jet model, 3=potential_2') scale_time_start = Float(desc='Starting time for turbulence scaling') wind_ramp_t0 = Float(0., desc='Start time for wind ramp') wind_ramp_t1 = Float(desc='End time for wind ramp') wind_ramp_factor0 = Float(0., desc='Start factor for wind ramp') wind_ramp_factor1 = Float(1., desc='End factor for wind ramp') wind_ramp_abs = List() iec_gust = Bool(False, desc='Flag for specifying an IEC gust') iec_gust_type = Enum('eog', ('eog', 'edc', 'ecd', 'ews'), desc='IEC gust types') G_A = Float() G_phi0 = Float() G_t0 = Float() G_T = Float() mann = VarTree(HAWC2Mann())
def setUp(self): self.top = top = set_as_top(Assembly()) driver = top.add('driver', SimpleCaseIterDriver()) top.add('comp1', ExecComp(exprs=['z=x+y'])) top.add('comp2', ExecComp(exprs=['z=x+1'])) top.connect('comp1.z', 'comp2.x') top.comp1.add('a_string', Str("Hello',;','", iotype='out')) top.comp1.add('a_array', Array(array([1.0, 3.0, 5.5]), iotype='out')) top.comp1.add('x_array', Array(array([1.0, 1.0, 1.0]), iotype='in')) top.comp1.add('b_bool', Bool(False, iotype='in')) top.comp1.add('vt', VarTree(DumbVT(), iotype='out')) driver.workflow.add(['comp1', 'comp2']) # now create some Cases outputs = ['comp1.z', 'comp2.z', 'comp1.a_string', 'comp1.a_array[2]'] cases = [] for i in range(10): inputs = [('comp1.x', i + 0.1), ('comp1.y', i * 2 + .1), ('comp1.x_array[1]', 99.88), ('comp1.b_bool', True)] cases.append( Case(inputs=inputs, outputs=outputs, label='case%s' % i)) driver.iterator = ListCaseIterator(cases) self.filename = "openmdao_test_csv_case_iterator.csv"