Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
desc = props.get('description')
if desc:
args['desc'] = desc.decode('string_escape')
values = props.get('enumValues')
if values:
if typ == 'string':
values = values.decode('string_escape')
args['values'] = [cvt(val.strip(' "')) for val in values.split(',')]
aliases = props.get('enumAliases')
if aliases:
aliases = aliases.decode('string_escape')
args['aliases'] = [val.strip(' "') for val in aliases.split(',')]
units = props.get('units')
if units:
args['units'] = get_translation(units)
vartree.add(name, Enum(**args))
voltage
distInter
terrain
layout
soil
"""
assembly.replace('bos_a', LandBOS())
assembly.add('voltage', Float(iotype='in', units='kV', desc='interconnect voltage'))
assembly.add('distInter', Float(iotype='in', units='mi', desc='distance to interconnect'))
assembly.add('terrain', Enum('FLAT_TO_ROLLING', ('FLAT_TO_ROLLING', 'RIDGE_TOP', 'MOUNTAINOUS'),
iotype='in', desc='terrain options'))
assembly.add('layout', Enum('SIMPLE', ('SIMPLE', 'COMPLEX'), iotype='in',
desc='layout options'))
assembly.add('soil', Enum('STANDARD', ('STANDARD', 'BOUYANT'), iotype='in',
desc='soil options'))
# connections to bos
assembly.connect('machine_rating', 'bos_a.machine_rating')
assembly.connect('rotor.diameter', 'bos_a.rotor_diameter')
assembly.connect('rotor.hubHt', 'bos_a.hub_height')
assembly.connect('turbine_number', 'bos_a.turbine_number')
assembly.connect('rotor.mass_all_blades + hub.hub_system_mass + nacelle.nacelle_mass', 'bos_a.RNA_mass')
assembly.connect('voltage', 'bos_a.voltage')
assembly.connect('distInter', 'bos_a.distInter')
assembly.connect('terrain', 'bos_a.terrain')
assembly.connect('layout', 'bos_a.layout')
assembly.connect('soil', 'bos_a.soil')
from plant_costsse.ecn_offshore_opex.ecn_offshore_opex import opex_ecn_assembly
from plant_financese.nrel_csm_fin.nrel_csm_fin import fin_csm_assembly
from plant_energyse.nrel_csm_aep.nrel_csm_aep import aep_csm_assembly
@implement_base(ExtendedFinancialAnalysis)
class lcoe_csm_ecn_assembly(Assembly):
# Variables
machine_rating = Float(units = 'kW', iotype='in', desc= 'rated machine power in kW')
rotor_diameter = Float(units = 'm', iotype='in', desc= 'rotor diameter of the machine')
max_tip_speed = Float(units = 'm/s', iotype='in', desc= 'maximum allowable tip speed for the rotor')
hub_height = Float(units = 'm', iotype='in', desc='hub height of wind turbine above ground / sea level')
sea_depth = Float(units = 'm', iotype='in', desc = 'sea depth for offshore wind project')
# Parameters
drivetrain_design = Enum('geared', ('geared', 'single_stage', 'multi_drive', 'pm_direct_drive'), iotype='in')
altitude = Float(0.0, units = 'm', iotype='in', desc= 'altitude of wind plant')
turbine_number = Int(100, iotype='in', desc = 'total number of wind turbines at the plant')
year = Int(2009, iotype='in', desc = 'year of project start')
month = Int(12, iotype='in', desc = 'month of project start')
# Extra AEP parameters
max_power_coefficient = Float(0.488, iotype='in', desc= 'maximum power coefficient of rotor for operation in region 2')
opt_tsr = Float(7.525, iotype='in', desc= 'optimum tip speed ratio for operation in region 2')
cut_in_wind_speed = Float(3.0, units = 'm/s', iotype='in', desc= 'cut in wind speed for the wind turbine')
cut_out_wind_speed = Float(25.0, units = 'm/s', iotype='in', desc= 'cut out wind speed for the wind turbine')
altitude = Float(0.0, units = 'm', iotype='in', desc= 'altitude of wind plant')
shear_exponent = Float(0.1, iotype='in', desc= 'shear exponent for wind plant')
wind_speed_50m = Float(8.35, units = 'm/s', iotype='in', desc='mean annual wind speed at 50 m height')
weibull_k= Float(2.1, iotype='in', desc = 'weibull shape factor for annual wind speed distribution')
soiling_losses = Float(0.0, iotype='in', desc = 'energy losses due to blade soiling for the wind plant - average across turbines')
array_losses = Float(0.06, iotype='in', desc = 'energy losses due to turbine interactions - across entire plant')
thrust_coefficient = Float(0.50, iotype='in', desc='thrust coefficient at rated power')
dsw = Float(iotype='in', units='lb/inch**3', desc=' Density of the wing material')
kdew = Float(iotype='in', desc="Knock-down factor for Young's Modulus")
kdfw = Float(iotype='in', desc='Knock-down factor for Ultimate strength')
# Geometric parameters
# --------------------
istama = Enum([1, 2], iotype='in', desc=' 1 - Position of wing is unknown; 2 - position is known')
cs1 = Float(iotype='in', desc='Position of structural wing box from leading edge as percent of root chord')
cs2 = Float(iotype='in', desc=' Position of structural wing box from trailing edge as percent of root chord')
uwwg = Float(iotype='in', units='lb/ft**2', desc=' Wing Weight / Wing Area of baseline aircraft ')
xwloc1 = Float(iotype='in', desc=' Location of wing as a percentage of body length')
# Structural Concept
# --------------------
claqr = Float(iotype='in', desc='Ratio of body lift to wing lift')
ifuel = Enum([1, 2], iotype='in', desc=' 1 - No fuel is stored in the wing; 2 - Fuel is stored in the wing')
cwman = Float(iotype='in', desc='Design maneuver load factor')
cf = Float(iotype='in', desc="Shanley's const. for frame bending")
# Tails
# --------------------
itail = Enum([1, 2], iotype='in', desc=' 1 - Control surfaces mounted on tail; 2 - Control surfaces mounted on wing')
uwt = Float(iotype='in', units='lb/ft**2', desc='(Htail Weight + Vtail Weight) / Htail Area of baseline aircraft')
clrt = Float(iotype='in', desc=' Location of tail as a percentage of body length')
harea = Float(iotype='in', units='ft**2', desc=' Location of tail as a percentage of body length')
# Fuselage geometry
# --------------------
frn = Float(iotype='in', desc='Fineness ratio of the nose section (length/diameter)')
frab = Float(iotype='in', desc='Fineness ratio of the after-body section (length/diameter)')
bodl = Float(iotype='in', units='ft', desc='Length of the fuselage ')
bdmax = Float(iotype='in', units='ft', desc='Maximum diameter of fuselage')
with_new_nacelle : bool
False uses the default implementation, True uses an experimental implementation designed
to smooth out discontinities making in amenable for gradient-based optimization
flexible_blade : bool
if True, internally solves the coupled aero/structural deflection using fixed point iteration.
Note that the coupling is currently only in the flapwise deflection, and is primarily
only important for highly flexible blades. If False, the aero loads are passed
to the structure but there is no further iteration.
"""
# --- general turbine configuration inputs---
assembly.add('rho', Float(1.225, iotype='in', units='kg/m**3', desc='density of air', deriv_ignore=True))
assembly.add('mu', Float(1.81206e-5, iotype='in', units='kg/m/s', desc='dynamic viscosity of air', deriv_ignore=True))
assembly.add('shear_exponent', Float(0.2, iotype='in', desc='shear exponent', deriv_ignore=True))
assembly.add('hub_height', Float(90.0, iotype='in', units='m', desc='hub height'))
assembly.add('turbine_class', Enum('I', ('I', 'II', 'III'), iotype='in', desc='IEC turbine class'))
assembly.add('turbulence_class', Enum('B', ('A', 'B', 'C'), iotype='in', desc='IEC turbulence class class'))
assembly.add('g', Float(9.81, iotype='in', units='m/s**2', desc='acceleration of gravity', deriv_ignore=True))
assembly.add('cdf_reference_height_wind_speed', Float(90.0, iotype='in', desc='reference hub height for IEC wind speed (used in CDF calculation)'))
assembly.add('downwind', Bool(False, iotype='in', desc='flag if rotor is downwind'))
assembly.add('tower_dt', Float(iotype='in', units='m', desc='tower top diameter')) # update for jacket
assembly.add('generator_speed', Float(iotype='in', units='rpm', desc='generator speed'))
assembly.add('machine_rating', Float(5000.0, units='kW', iotype='in', desc='machine rated power'))
assembly.add('rna_weightM', Bool(True, iotype='in', desc='flag to consider or not the RNA weight effect on Moment'))
assembly.add('rotor', RotorSE())
if with_new_nacelle:
assembly.add('hub',HubSE())
if with_3pt_drive:
assembly.add('nacelle', Drive3pt())
else:
assembly.add('nacelle', Drive4pt())
False uses the default implementation, True uses an experimental implementation designed
to smooth out discontinities making in amenable for gradient-based optimization
flexible_blade : bool
if True, internally solves the coupled aero/structural deflection using fixed point iteration.
Note that the coupling is currently only in the flapwise deflection, and is primarily
only important for highly flexible blades. If False, the aero loads are passed
to the structure but there is no further iteration.
"""
# --- general turbine configuration inputs---
assembly.add('rho', Float(1.225, iotype='in', units='kg/m**3', desc='density of air', deriv_ignore=True))
assembly.add('mu', Float(1.81206e-5, iotype='in', units='kg/m/s', desc='dynamic viscosity of air', deriv_ignore=True))
assembly.add('shear_exponent', Float(0.2, iotype='in', desc='shear exponent', deriv_ignore=True))
assembly.add('hub_height', Float(90.0, iotype='in', units='m', desc='hub height'))
assembly.add('turbine_class', Enum('I', ('I', 'II', 'III', 'IV'), iotype='in', desc='IEC turbine class'))
assembly.add('turbulence_class', Enum('B', ('A', 'B', 'C'), iotype='in', desc='IEC turbulence class class'))
assembly.add('g', Float(9.81, iotype='in', units='m/s**2', desc='acceleration of gravity', deriv_ignore=True))
assembly.add('cdf_reference_height_wind_speed', Float(90.0, iotype='in', desc='reference hub height for IEC wind speed (used in CDF calculation)'))
assembly.add('downwind', Bool(False, iotype='in', desc='flag if rotor is downwind'))
assembly.add('tower_d', Array([0.0], iotype='in', units='m', desc='diameters along tower'))
assembly.add('generator_speed', Float(iotype='in', units='rpm', desc='generator speed'))
assembly.add('machine_rating', Float(5000.0, units='kW', iotype='in', desc='machine rated power'))
assembly.add('rna_weightM', Bool(True, iotype='in', desc='flag to consider or not the RNA weight effect on Moment'))
assembly.add('rotor', RotorSE())
if with_new_nacelle:
assembly.add('hub',HubSE())
assembly.add('hubSystem',Hub_System_Adder_drive())
assembly.add('moments',blade_moment_transform())
assembly.add('forces',blade_force_transform())
if with_3pt_drive:
assembly.add('nacelle', Drive3pt())
class OptLatinHypercube(Container):
"""IDOEgenerator which provides a Latin hypercube DOE sample set.
The Morris-Mitchell sampling criterion of the DOE is optimzied
using an evolutionary algorithm.
"""
implements(IDOEgenerator)
num_samples = Int(20, desc="Number of sample points in the DOE sample set.")
num_parameters = Int(2, desc="Number of parameters, or dimensions, for the DOE.")
population = Int(20,
desc="Size of the population used in the evolutionary optimization.")
generations = Int(2,
desc="Number of generations the optimization will evolve over.")
norm_method = Enum(["1-norm","2-norm"],
desc="Vector norm calculation method. '1-norm' is faster but less accurate.")
def __init__(self, num_samples=None, population=None,generations=None):
super(OptLatinHypercube,self).__init__()
self.qs = [1,2,5,10,20,50,100] #list of qs to try for Phi_q optimization
if num_samples is not None:
self.num_samples = num_samples
if population is not None:
self.population = population
if generations is not None:
self.generations = generations
def __iter__(self):
"""Return an iterator over our sets of input values."""
return self._get_input_values()
from openmdao.main.workflow import Workflow
from openmdao.util.decorators import add_delegate
class GradientOptions(VariableTree):
''' Options for calculation of the gradient by the driver's workflow. '''
# Finite Difference
fd_form = Enum('forward', ['forward', 'backward', 'central', 'complex_step'],
desc="Finite difference mode. (forward, backward, central) "
"You can also set to 'complex_step' to peform the complex "
"step method if your components support it.",
framework_var=True)
fd_step = Float(1.0e-6, desc='Default finite difference stepsize',
framework_var=True)
fd_step_type = Enum('absolute',
['absolute', 'relative', 'bounds_scaled'],
desc='Set to absolute, relative, '
'or scaled to the bounds (high-low) step sizes',
framework_var=True)
force_fd = Bool(False, desc="Set to True to force finite difference "
"of this driver's entire workflow in a"
"single block.",
framework_var=True)
directional_fd = Bool(False, desc="Set to True to do a directional "
"finite difference for each GMRES "
"iteration instead of pre-computing "
"the full fd space.",
framework_var=True)
inequality constraints.
Note: Constraints should be added using the OpenMDAO convention
(positive = violated).
"""
implements(IHasParameters, IHasConstraints, IHasObjective, IOptimizer)
# pylint: disable-msg=E1101
accuracy = Float(1.0e-6, iotype='in',
desc='Convergence accuracy')
maxiter = Int(50, iotype='in',
desc='Maximum number of iterations.')
iprint = Enum(0, [0, 1, 2, 3], iotype='in',
desc='Controls the frequency of output: 0 (no output),1,2,3.')
iout = Int(6, iotype='in',
desc='Fortran output unit. Leave this at 6 for STDOUT.')
output_filename = Str('slsqp.out', iotype='in',
desc='Name of output file (if iout not 6).')
error_code = Int(0, iotype='out',
desc='Error code returned from SLSQP.')
def __init__(self):
super(SLSQPdriver, self).__init__()
self.error_messages = {
class FixedPointIterator(Driver):
""" A simple fixed point iteration driver, which runs a workflow and passes
the value from the output to the input for the next iteration. Relative
change and number of iterations are used as termination criteria. This type
of iteration is also known as Gauss-Seidel."""
implements(IHasParameters, IHasEqConstraints, ISolver)
# pylint: disable=E1101
max_iteration = Int(25, iotype='in', desc='Maximum number of '
'iterations before termination.')
tolerance = Float(1.0e-6, iotype='in', desc='Absolute convergence '
'tolerance between iterations.')
norm_order = Enum('Infinity', ['Infinity', 'Euclidean'],
desc='For multivariable iteration, type of norm '
'to use to test convergence.')
iprint = Enum(0, [0, 1], iotype='in', desc='set to 1 to print '
'residual during convergence.')
def __init__(self):
super(FixedPointIterator, self).__init__()
self.current_iteration = 0
self.normval = 1.e99
self.norm0 = 1.e99
def execute(self):
""" Executes an iterative solver """
# print 'Executes an iterative solver',