Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
- ``excitingmixing``: The excitingmixing algorithm. ``J=-1/alpha``
The ``broyden2`` is the best. For large systems, use ``broyden3``;
excitingmixing is also very effective. The remaining nonlinear solvers from
SciPy are, in their own words, of "mediocre quality," so they were not
implemented.
"""
implements(IHasParameters, IHasEqConstraints, ISolver)
# pylint: disable-msg=E1101
algorithm = Enum('broyden2', ['broyden2', 'broyden3', 'excitingmixing'],
iotype = 'in', desc='Algorithm to use. Choose from '
'broyden2, broyden3, and excitingmixing.')
itmax = Int(10, iotype='in', desc='Maximum number of iterations before '
'termination.')
alpha = Float(0.4, iotype='in', desc='Mixing Coefficient.')
alphamax = Float(1.0, iotype='in', desc='Maximum Mixing Coefficient (only '
'used with excitingmixing.)')
tol = Float(0.00001, iotype='in',
desc='Convergence tolerance. If the norm of the independent '
'vector is lower than this, then terminate successfully.')
def __init__(self):
super(BroydenSolver, self).__init__()
self.workflow = CyclicWorkflow()
lofi_model = Slot(Component, desc='Low fidelity model', required=True)
hifi_model = Slot(Component, desc='High fidelity model', required=True)
# Inputs.
# No 'Option' variables yet.
doe_type = Str('lhs', iotype='in',
desc='Type of DOE used to generate response surface.')
rs_type = Str('quadratic', iotype='in', desc='Type of response surface.')
n_samples = Int(value=1, low=1, iotype='in', desc='Number of samples.')
tolerance = Float(1.0e10, iotype='in', desc='?')
correction_function = Int(1, iotype='in',
desc='Type of correction function.')
w_h = Float(0.5, iotype='in', desc='?')
accuracy_test_type = Int(2, iotype='in',
desc='Method for testing accuracy of response.')
n_samples_test = Int(value=10, low=1, iotype='in',
desc='Number of additional samples for additional-points test.')
ntheta = Int(3, iotype='in',
desc='For Kriging method, ntheta=1(SA),2(Cobyla),3(BFGS)')
# TODO: change these to delegates or passthroughs
sample_points = Array(iotype='out', desc='Points used to make response',
ref_name='sample_points', ref_parent='midfi_model')
lofi_results = Array(iotype='out', desc='Points used to make response',
ref_name='lofi_results', ref_parent='midfi_model')
hifi_results = Array(iotype='out', desc='Points used to make response',
ref_name='hifi_results', ref_parent='midfi_model')
#name='M4_MidFi',
"""
implements(IComponent)
directory = Str('', desc='If non-blank, the directory to execute in.',
framework_var=True, iotype='in', deriv_ignore=True)
external_files = List(FileMetadata,
desc='FileMetadata objects for external files used'
' by this component.', deriv_ignore=True)
force_fd = Bool(False, iotype='in', framework_var=True, deriv_ignore=True,
desc="If True, always finite difference this component.")
# this will automagically call _get_log_level and _set_log_level when needed
log_level = Property(desc='Logging message level')
exec_count = Int(0, iotype='out', framework_var=True, deriv_ignore=True,
desc='Number of times this Component has been executed.')
derivative_exec_count = Int(0, iotype='out', framework_var=True, deriv_ignore=True,
desc="Number of times this Component's derivative "
"function has been executed.")
itername = Str('', iotype='out', desc='Iteration coordinates.', deriv_ignore=True,
framework_var=True)
# TODO: add 'fd' option to missing_deriv_policy
missing_deriv_policy = Enum(['error', 'assume_zero'], iotype='in',
framework_var=True, deriv_ignore=True,
desc='Determines behavior when some '
'analytical derivatives are provided '
'but some are missing')
nTurbines = Int(iotype='in', desc='number of turbines')
cost = Float(iotype='out', units='USD', desc='foundations cost')
def execute(self):
self.cost = _landbos.foundationCost(self.rating, self.diameter,
self.topMass/1000.0, self.hubHeight, Enum2Int(self, 'soil'), self.nTurbines)
class Erection(Component):
rating = Float(iotype='in', units='kW', desc='machine rating')
hubHeight = Float(iotype='in', units='m', desc='hub height')
nTurbines = Int(iotype='in', desc='number of turbines')
weatherDelayDays = Int(iotype='in', units='d', desc='weather delay days')
craneBreakdowns = Int(iotype='in', desc='crane breakdowns')
deliveryAssistRequired = Bool(iotype='in', desc='delivery assist required')
cost = Float(iotype='out', units='USD', desc='erection cost')
def execute(self):
self.cost = _landbos.erectionCost(self.rating, self.hubHeight,
self.nTurbines, self.weatherDelayDays,
self.craneBreakdowns, self.deliveryAssistRequired)
class ElecMaterials(Component):
terrain = Enum('FLAT_TO_ROLLING', ('FLAT_TO_ROLLING', 'RIDGE_TOP', 'MOUNTAINOUS'),
iotype='in', desc='terrain options')
layout = Enum('SIMPLE', ('SIMPLE', 'COMPLEX'), iotype='in',
desc='layout options')
if eqcon.rhs.text == '0' or eqcon.lhs.text == '0':
msg = "Please specify constraints in the form 'A=B'"
msg += ': %s = %s' % (eqcon.lhs.text, eqcon.rhs.text)
self.raise_exception(msg, RuntimeError)
if len(eqcon.get_referenced_varpaths()) > 2:
msg = "Please specify constraints in the form 'A=B'"
msg += ': %s = %s' % (eqcon.lhs.text, eqcon.rhs.text)
self.raise_exception(msg, RuntimeError)
@add_delegate(HasStopConditions)
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):
""" Convergence check."""
if self.iteration < 1 and self.run_at_least_once:
self.iteration += 1
return True
if self.should_stop():
# Plant configuration
# climate
shear_exponent = Float(0.1, iotype='in', desc= 'shear exponent for wind plant') #TODO - could use wind model here
shear_exponent = Float(9.52, units = 'm/s', iotype='in', desc='mean annual wind speed at 50 m height')
weibull_k= Float(2.10, iotype='in', desc = 'weibull shape factor for annual wind speed distribution')
altitude = Float(0.0, units = 'm', iotype='in', desc= 'altitude of wind plant')
air_density = Float(0.0, units = 'kg / (m * m * m)', iotype='in', desc= 'air density at wind plant site') # default air density value is 0.0 - forces aero csm to calculate air density in model
sea_depth = Float(20.0, units = 'm', iotype='in', desc = 'sea depth for offshore wind project')
distance_from_shore = Float(30.0, units = 'km', iotype='in', desc = 'distance of plant from shore')
soil_type = Str("Sand", iotype='in', desc = 'soil type at plant site')
# plant operation
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.10, iotype='in', desc = 'energy losses due to turbine interactions - across entire plant')
turbine_number = Int(100, iotype='in', desc = 'total number of wind turbines at the plant')
# financial
year = Int(2009, units = 'yr', iotype='in', desc = 'year of project start')
month = Int(12, units = 'mon', iotype='in', desc = 'month of project start')
fixedChargeRate = Float(0.12, iotype = 'in', desc = 'fixed charge rate for coe calculation')
constructionFinancingRate = Float(0.03, iotype = 'in', desc = 'financing construction rate')
taxRate = Float(0.4, iotype = 'in', desc = 'tax rate applied to operations')
discountRate = Float(0.07, iotype = 'in', desc = 'applicable project discount rate')
constructionTime = Float(1.0, iotype = 'in', desc = 'number of years to complete project construction')
project_lifetime = Float(20.0, iotype = 'in', desc = 'project lifetime for LCOE calculation')
# ------------- Outputs --------------
# See passthrough variables below
def __init__(self,inputs=None):
""" Creates a new LCOE Assembly object """
super(lcoe_cst_bos_ecn_ow_assembly, self).__init__()
assembly.add('blade_edge_dynload_factor_ext', Float(iotype='in', desc='Extreme dynamic edgewise loads factor', group='Loads'))
assembly.add('blade_edge_dynload_factor_fat', Float(iotype='in', desc='Fatigue dynamic edgewise loads factor', group='Loads'))
assembly.add('PMtarget_blades', Float(1., iotype='in', desc='', group='Rotor'))
assembly.add('max_tipspeed', Float(iotype='in', desc='Maximum tip speed', group='Aero'))
assembly.add('n_wsp', Int(iotype='in', desc='Number of wind speed bins', group='Aero'))
assembly.add('min_wsp', Float(0.0, iotype = 'in', units = 'm/s', desc = 'min wind speed', group='Aero'))
assembly.add('max_wsp', Float(iotype = 'in', units = 'm/s', desc = 'max wind speed', group='Aero'))
assembly.add('turbulence_int', Float(iotype='in', desc='Reference turbulence intensity', group='Plant_AEP'))
# assembly.add('WeibullInput', Bool(True, iotype='in', desc='Flag for Weibull input', group='AEP'))
assembly.add('weibull_C', Float(iotype = 'in', units='m/s', desc = 'Weibull scale factor', group='AEP'))
assembly.add('weibull_k', Float(iotype = 'in', desc='Weibull shape or form factor', group='AEP'))
assembly.add('blade_sections', Int(iotype='in', desc='number of sections along blade', group='Rotor'))
assembly.add('wohler_exponent_blade_flap', Float(iotype='in', desc='Blade flap fatigue Wohler exponent', group='Rotor'))
assembly.add('MaxChordrR', Float(iotype='in', units='m', desc='Spanwise position of maximum chord', group='Rotor'))
assembly.add('tif_blade_root_flap_ext', Float(1., iotype='in', desc='Technology improvement factor flap extreme', group='Rotor'))
assembly.add('tif_blade_root_edge_ext', Float(1., iotype='in', desc='Technology improvement factor edge extreme', group='Rotor'))
assembly.add('tif_blade_root_flap_fat', Float(1., iotype='in', desc='Technology improvement factor flap LEQ', group='Rotor'))
assembly.add('sc_frac_flap', Float(iotype='in', desc='spar cap fraction of chord', group='Rotor'))
assembly.add('sc_frac_edge', Float(iotype='in', desc='spar cap fraction of thickness', group='Rotor'))
assembly.add('safety_factor_blade', Float(iotype='in', desc='Blade loads safety factor', group='Rotor'))
assembly.add('stress_limit_extreme_blade', Float(iotype='in', units='MPa', desc='Blade ultimate strength', group='Rotor'))
assembly.add('stress_limit_fatigue_blade', Float(iotype='in', units='MPa', desc='Blade fatigue strength', group='Rotor'))
assembly.add('AddWeightFactorBlade', Float(iotype='in', desc='Additional weight factor for blade shell', group='Rotor'))
assembly.add('blade_material_density', Float(iotype='in', units='kg/m**3', desc='Average density of blade materials', group='Rotor'))
assembly.add('blade_mass', Float(iotype = 'out', units = 'kg', desc = 'Blade mass'))
# assembly.add('mean_wsp', Float(iotype = 'in', units = 'm/s', desc = 'mean wind speed', group='Aero')) # [m/s]
from fusedwind.plant_cost.fused_fin_asym import ExtendedFinancialAnalysis
# NREL cost and scaling model sub-assemblies
from turbinese.turbine import TurbineSE
from Turbine_CostsSE.Turbine_CostsSE.turbine_costsSE import Turbine_CostsSE
from Plant_CostsSE.Plant_BOS.NREL_CSM_BOS.nrel_csm_bos import bos_csm_assembly
from Plant_CostsSE.Plant_OM.NREL_CSM_OM.nrel_csm_om import om_csm_assembly
from Plant_FinanceSE.NREL_CSM_FIN.nrel_csm_fin import fin_csm_assembly
from Plant_AEPSE.Basic_AEP.basic_aep import BasicAEP
class lcoe_se_csm_assembly(ExtendedFinancialAnalysis):
# parameters
sea_depth = Float(0.0, units='m', iotype='in', desc='sea depth for offshore wind project')
drivetrain_design = Int(1, iotype='in', desc='drivetrain design type 1 = 3-stage geared, 2 = single-stage geared, 3 = multi-generator, 4 = direct drive')
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')
array_losses = Float(0.059, iotype='in', desc='energy losses due to turbine interactions - across entire plant')
other_losses = Float(0.0, iotype='in', desc='energy losses due to blade soiling, electrical, etc')
availability = Float(0.94, iotype='in', desc='average annual availbility of wind turbines at plant')
def configure(self):
super(lcoe_se_csm_assembly, self).configure()
self.replace('tcc_a', Turbine_CostsSE())
self.replace('bos_a', bos_csm_assembly())
self.replace('opex_a', om_csm_assembly())
self.replace('aep_a', BasicAEP())
self.replace('fin_a', fin_csm_assembly())
@add_delegate(HasParameters, HasObjective, HasEvents)
class Genetic(Driver):
"""Genetic algorithm for the OpenMDAO framework, based on the Pyevolve
Genetic algorithm module.
"""
implements(IHasParameters, IHasObjective, IOptimizer)
# pylint: disable-msg=E1101
opt_type = Enum("minimize", values=["minimize", "maximize"],
iotype="in",
desc='Sets the optimization to either minimize or maximize '
'the objective function.')
generations = Int(Consts.CDefGAGenerations, iotype="in",
desc="The maximum number of generations the algorithm "
"will evolve to before stopping.")
population_size = Int(Consts.CDefGAPopulationSize, iotype="in",
desc="The size of the population in each generation.")
crossover_rate = Float(Consts.CDefGACrossoverRate, iotype="in", low=0.0,
high=1.0, desc="The crossover rate used when two "
"parent genomes reproduce to form a child genome.")
mutation_rate = Float(Consts.CDefGAMutationRate, iotype="in", low=0.0,
high=1.0, desc="The mutation rate applied to "
"population members.")
selection_method = Enum("roulette_wheel",
("roulette_wheel",
#"tournament", #this seems to be broken
"rank",
"uniform"),
assembly.connect('project_lifetime','fin_a.project_lifetime')
assembly.connect('fixed_charge_rate','fin_a.fixed_charge_rate')
assembly.connect('construction_finance_rate','fin_a.construction_finance_rate')
assembly.connect('tax_rate','fin_a.tax_rate')
assembly.connect('discount_rate','fin_a.discount_rate')
assembly.connect('construction_time','fin_a.construction_time')
# =============================================================================
# Overall LCOE Assembly
@implement_base(ExtendedFinancialAnalysis)
class lcoe_se_assembly(Assembly):
# Base I/O
# Inputs
turbine_number = Int(iotype = 'in', desc = 'number of turbines at plant')
#Outputs
turbine_cost = Float(iotype='out', desc = 'A Wind Turbine Capital _cost')
bos_costs = Float(iotype='out', desc='A Wind Plant Balance of Station _cost Model')
avg_annual_opex = Float(iotype='out', desc='A Wind Plant Operations Expenditures Model')
net_aep = Float(iotype='out', desc='A Wind Plant Annual Energy Production Model', units='kW*h')
coe = Float(iotype='out', desc='Levelized cost of energy for the wind plant')
opex_breakdown = VarTree(OPEXVarTree(), iotype='out')
bos_breakdown = VarTree(BOSVarTree(), iotype='out', desc='BOS cost breakdown')
# Configuration options
with_new_nacelle = Bool(False, iotype='in', desc='configure with DriveWPACT if false, else configure with DriveSE')
with_landbose = Bool(False, iotype='in', desc='configure with CSM BOS if false, else configure with new LandBOS model')
flexible_blade = Bool(False, iotype='in', desc='configure rotor with flexible blade if True')
with_3pt_drive = Bool(False, iotype='in', desc='only used if configuring DriveSE - selects 3 pt or 4 pt design option') # TODO: change nacelle selection to enumerated rather than nested boolean
with_ecn_opex = Bool(False, iotype='in', desc='configure with CSM OPEX if flase, else configure with ECN OPEX model')