def configure(self): """ Configure driver and its workflow. """ super(Assembly, self).configure() ## Add some components self.add('omnivorRun', OmnivorRun()) ## Add an optimizer: COBYLAdriver, CONMINdriver, NEWSUMTdriver, SLSQPdriver, Genetic self.add('driver', COBYLAdriver()) self.driver.workflow.add('omnivorRun') ## The parameters of the optimization self.driver.add_parameter('omnivorRun.x', low=0, high=5, start=0.1) self.driver.add_objective('omnivorRun.CP') self.driver.add_constraint('abs(omnivorRun.CT-0.6) <= 0.001') ## This recorder will create a list of cases self.driver.recorders = [ListCaseRecorder()] ## These variables will be recorded self.driver.printvars = ['omnivorRun.x','omnivorRun.CT','omnivorRun.CP'] ## Some optimizer options self.driver.itmax = 100 self.driver.fdch = 0.00001 self.driver.fdchm = 0.000001 self.driver.ctlmin = 0.001 self.driver.delfun = 0.0001
def configure(self): self.add('driver',COBYLAdriver()) self.driver.maxfun = 100000 # select components self.add('spar_assembly',Spar_Assembly()) # workflow self.driver.workflow.add(['spar_assembly']) # objective self.driver.add_objective('spar_assembly.spar.spar_mass') # design variables self.driver.add_parameter('spar_assembly.neutral_axis',low=10.,high=41.9,scaler=0.01) #self.driver.add_parameter('number_of_rings[0]',low=1,high=5) self.driver.add_parameter('spar_assembly.number_of_rings[1]',low=1,high=10) self.driver.add_parameter('spar_assembly.number_of_rings[2]',low=1,high=10) self.driver.add_parameter('spar_assembly.number_of_rings[3]',low=1,high=50) self.driver.add_parameter('spar_assembly.wall_thickness[0]',low=1.,high=10.,scaler=0.01) self.driver.add_parameter('spar_assembly.wall_thickness[1]',low=1.,high=10.,scaler=0.01) self.driver.add_parameter('spar_assembly.wall_thickness[2]',low=1.,high=10.,scaler=0.01) self.driver.add_parameter('spar_assembly.wall_thickness[3]',low=10.,high=100.,scaler=0.001) self.driver.add_parameter('spar_assembly.scope_ratio',low=15.,high=45.,scaler=0.1) self.driver.add_parameter('spar_assembly.pretension_percent',low=2.5,high=10.) self.driver.add_parameter('spar_assembly.mooring_diameter',low=30.,high=100.,scaler=0.001) self.driver.add_parameter('spar_assembly.fixed_ballast_height',low=30.,high=100.,scaler=0.1) self.driver.add_parameter('spar_assembly.permanent_ballast_height',low=30.,high=100.,scaler=0.1) # Constraints self.driver.add_constraint('spar_assembly.spar.water_ballast_height < 7.5') self.driver.add_constraint('spar_assembly.spar.water_ballast_height > 5.5') self.driver.add_constraint('spar_assembly.spar.flange_compactness < 1.') self.driver.add_constraint('spar_assembly.spar.web_compactness < 1.') self.driver.add_constraint('spar_assembly.spar.VAL[0] < 0.99') self.driver.add_constraint('spar_assembly.spar.VAL[1] < 0.99') self.driver.add_constraint('spar_assembly.spar.VAL[2] < 0.99') self.driver.add_constraint('spar_assembly.spar.VAL[3] < 0.99') self.driver.add_constraint('spar_assembly.spar.VAG[0] < 0.99') self.driver.add_constraint('spar_assembly.spar.VAG[1] < 0.99') self.driver.add_constraint('spar_assembly.spar.VAG[2] < 0.99') self.driver.add_constraint('spar_assembly.spar.VAG[3] < 0.99') self.driver.add_constraint('spar_assembly.spar.VEL[0] < 0.99') self.driver.add_constraint('spar_assembly.spar.VEL[1] < 0.99') self.driver.add_constraint('spar_assembly.spar.VEL[2] < 0.99') self.driver.add_constraint('spar_assembly.spar.VEL[3] < 0.99') self.driver.add_constraint('spar.VEG[0] < 0.99') self.driver.add_constraint('spar.VEG[1] < 0.99') self.driver.add_constraint('spar.VEG[2] < 0.99') self.driver.add_constraint('spar.VEG[3] < 0.99') self.driver.add_constraint('spar.platform_stability_check < 1.') self.driver.add_constraint('spar.heel_angle <= 6.') self.driver.add_constraint('spar.min_offset_unity < 1.0') self.driver.add_constraint('spar.max_offset_unity < 1.0')
def configure(self): self.add('paraboloid', Paraboloid()) self.add('driver', COBYLAdriver()) self.driver.add_parameter('paraboloid.x', low=-50, high=50) self.driver.add_parameter('paraboloid.y', low=-50, high=50) self.driver.add_objective('paraboloid.f_xy') self.recorders = [ListCaseRecorder()]
def test_COBYLA(self): top = set_as_top(Assembly()) top.add('parab1', Parab1()) top.add('parab2', Parab2()) top.add('driver', COBYLAdriver()) top.driver.workflow.add(['parab1', 'parab2']) top.driver.add_parameter(['parab1.x', 'parab2.x'], low=-100, high=100) top.driver.add_parameter(['parab1.y', 'parab2.y'], low=-100, high=100) top.driver.add_objective('parab1.f_xy + parab2.f_xy') top.driver.add_constraint('parab1.x-parab1.y >= 15.0') top.run() assert_rel_error(self, top.parab1.x, 7.166, 0.001) assert_rel_error(self, top.parab1.y, -7.833, 0.001) assert_rel_error(self, top._pseudo_0.out0, -27.083, 0.001)
def configure(self): self.add('driver', COBYLAdriver()) self.add('mooring', Mooring()) self.driver.workflow.add('mooring') self.driver.add_objective('mooring.mooring_total_cost') self.driver.add_parameter('mooring.scope_ratio', low=15., high=50., scaler=0.1) self.driver.add_parameter('mooring.pretension_percent', low=2.5, high=20.) self.driver.add_parameter('mooring.mooring_diameter', low=3., high=10., scaler=0.01) self.driver.add_constraint('mooring.heel_angle <= 6.') self.driver.add_constraint('mooring.min_offset_unity < 1.0') self.driver.add_constraint('mooring.max_offset_unity < 1.0')
def configure(self): if OPTIMIZE: self.add('driver', COBYLAdriver()) self.driver.maxfun = 20 # select components self.add('tower_RNA', Tower_RNA()) self.add('spar', Spar()) self.add('mooring', Mooring()) # workflow self.driver.workflow.add(['tower_RNA', 'mooring', 'spar']) # connect inputs self.connect('tower_base_outer_diameter', 'tower_RNA.base_outer_diameter') self.connect('tower_top_outer_diameter', 'tower_RNA.top_outer_diameter') self.connect('tower_length', 'tower_RNA.length') self.connect('air_density', ['tower_RNA.air_density', 'spar.air_density']) self.connect( 'wind_reference_speed', ['tower_RNA.wind_reference_speed', 'spar.wind_reference_speed']) self.connect( 'wind_reference_height', ['tower_RNA.wind_reference_height', 'spar.wind_reference_height']) self.connect('gust_factor', ['tower_RNA.gust_factor', 'spar.gust_factor']) self.connect('alpha', ['tower_RNA.alpha', 'spar.alpha']) self.connect('spar_elevations', [ 'tower_RNA.spar_elevations', 'mooring.spar_elevations', 'spar.elevations' ]) self.connect('example_turbine_size', 'tower_RNA.example_turbine_size') self.connect('rotor_diameter', 'tower_RNA.rotor_diameter') self.connect('RNA_center_of_gravity_x', [ 'tower_RNA.RNA_center_of_gravity_x', 'spar.RNA_center_of_gravity_x' ]) self.connect('RNA_center_of_gravity_y', 'tower_RNA.RNA_center_of_gravity_y') self.connect('cut_out_speed', 'tower_RNA.cut_out_speed') self.connect('tower_mass', ['tower_RNA.tower_mass', 'spar.tower_mass']) self.connect('RNA_mass', ['tower_RNA.RNA_mass', 'spar.RNA_mass']) self.connect('fairlead_depth', 'mooring.fairlead_depth') self.connect('scope_ratio', 'mooring.scope_ratio') self.connect('pretension_percent', 'mooring.pretension_percent') self.connect('mooring_diameter', 'mooring.mooring_diameter') self.connect('number_of_mooring_lines', 'mooring.number_of_mooring_lines') self.connect('water_depth', ['mooring.water_depth', 'spar.water_depth']) self.connect('mooring_type', 'mooring.mooring_type') self.connect('anchor_type', 'mooring.anchor_type') self.connect('fairlead_offset_from_shell', 'mooring.fairlead_offset_from_shell') self.connect('user_MBL', 'mooring.user_MBL') self.connect('user_WML', 'mooring.user_WML') self.connect('user_AE_storm', 'mooring.user_AE_storm') self.connect('user_MCPL', 'mooring.user_MCPL') self.connect('user_anchor_cost', 'mooring.user_anchor_cost') self.connect('misc_cost_factor', 'mooring.misc_cost_factor') self.connect('number_of_discretizations', 'mooring.number_of_discretizations') self.connect('spar_outer_diameter', ['mooring.spar_outer_diameter', 'spar.outer_diameter']) self.connect('water_density', ['mooring.water_density', 'spar.water_density']) self.connect('wall_thickness', 'spar.wall_thickness') self.connect('number_of_rings', 'spar.number_of_rings') self.connect('neutral_axis', 'spar.neutral_axis') #self.connect('stiffener_curve_fit','spar.stiffener_curve_fit') self.connect('stiffener_index', 'spar.stiffener_index') self.connect('number_of_sections', 'spar.number_of_sections') self.connect('bulk_head', 'spar.bulk_head') self.connect('straight_col_cost', 'spar.straight_col_cost') self.connect('tapered_col_cost', 'spar.tapered_col_cost') self.connect('outfitting_cost', 'spar.outfitting_cost') self.connect('ballast_cost', 'spar.ballast_cost') self.connect('gravity', 'spar.gravity') self.connect('load_condition', 'spar.load_condition') self.connect('significant_wave_height', 'spar.significant_wave_height') self.connect('significant_wave_period', 'spar.significant_wave_period') self.connect('material_density', 'spar.material_density') self.connect('E', 'spar.E') self.connect('nu', 'spar.nu') self.connect('yield_stress', 'spar.yield_stress') self.connect('shell_mass_factor', 'spar.shell_mass_factor') self.connect('bulkhead_mass_factor', 'spar.bulkhead_mass_factor') self.connect('ring_mass_factor', 'spar.ring_mass_factor') self.connect('outfitting_factor', 'spar.outfitting_factor') self.connect('spar_mass_factor', 'spar.spar_mass_factor') self.connect('permanent_ballast_height', 'spar.permanent_ballast_height') self.connect('fixed_ballast_height', 'spar.fixed_ballast_height') self.connect('permanent_ballast_density', 'spar.permanent_ballast_density') self.connect('fixed_ballast_density', 'spar.fixed_ballast_density') self.connect('offset_amplification_factor', 'spar.offset_amplification_factor') # connect outputs to inputs self.connect('tower_RNA.RNA_keel_to_CG', 'spar.RNA_keel_to_CG') self.connect('tower_RNA.tower_center_of_gravity', 'spar.tower_center_of_gravity') self.connect('tower_RNA.tower_wind_force', 'spar.tower_wind_force') self.connect('tower_RNA.RNA_wind_force', 'spar.RNA_wind_force') self.connect('mooring.mooring_total_cost', 'spar.mooring_total_cost') self.connect('mooring.mooring_keel_to_CG', 'spar.mooring_keel_to_CG') self.connect('mooring.mooring_vertical_load', 'spar.mooring_vertical_load') self.connect('mooring.mooring_horizontal_stiffness', 'spar.mooring_horizontal_stiffness') self.connect('mooring.mooring_vertical_stiffness', 'spar.mooring_vertical_stiffness') self.connect('mooring.sum_forces_x', 'spar.sum_forces_x') self.connect('mooring.offset_x', 'spar.offset_x') self.connect('mooring.damaged_mooring', 'spar.damaged_mooring') self.connect('mooring.intact_mooring', 'spar.intact_mooring') self.connect('mooring.mooring_mass', 'spar.mooring_mass') if OPTIMIZE: # objective self.driver.add_objective('spar.spar_mass') # design variables self.driver.add_parameter('neutral_axis', low=10., high=41.9, scaler=0.01) #self.driver.add_parameter('number_of_rings[0]',low=1,high=5) self.driver.add_parameter('number_of_rings[1]', low=1, high=10) self.driver.add_parameter('number_of_rings[2]', low=1, high=10) self.driver.add_parameter('number_of_rings[3]', low=1, high=50) self.driver.add_parameter('wall_thickness[0]', low=1., high=10., scaler=0.01) self.driver.add_parameter('wall_thickness[1]', low=1., high=10., scaler=0.01) self.driver.add_parameter('wall_thickness[2]', low=1., high=10., scaler=0.01) self.driver.add_parameter('wall_thickness[3]', low=10., high=100., scaler=0.001) self.driver.add_parameter('scope_ratio', low=15., high=45., scaler=0.1) self.driver.add_parameter('pretension_percent', low=2.5, high=10.) self.driver.add_parameter('mooring_diameter', low=30., high=100., scaler=0.001) self.driver.add_parameter('fixed_ballast_height', low=30., high=100., scaler=0.1) self.driver.add_parameter('permanent_ballast_height', low=30., high=100., scaler=0.1) # Constraints self.driver.add_constraint('spar.water_ballast_height < 7.5') self.driver.add_constraint('spar.water_ballast_height > 5.5') self.driver.add_constraint('spar.flange_compactness < 1.') self.driver.add_constraint('spar.web_compactness < 1.') self.driver.add_constraint('spar.VAL[0] < 0.99') self.driver.add_constraint('spar.VAL[1] < 0.99') self.driver.add_constraint('spar.VAL[2] < 0.99') self.driver.add_constraint('spar.VAL[3] < 0.99') self.driver.add_constraint('spar.VAG[0] < 0.99') self.driver.add_constraint('spar.VAG[1] < 0.99') self.driver.add_constraint('spar.VAG[2] < 0.99') self.driver.add_constraint('spar.VAG[3] < 0.99') self.driver.add_constraint('spar.VEL[0] < 0.99') self.driver.add_constraint('spar.VEL[1] < 0.99') self.driver.add_constraint('spar.VEL[2] < 0.99') self.driver.add_constraint('spar.VEL[3] < 0.99') self.driver.add_constraint('spar.VEG[0] < 0.99') self.driver.add_constraint('spar.VEG[1] < 0.99') self.driver.add_constraint('spar.VEG[2] < 0.99') self.driver.add_constraint('spar.VEG[3] < 0.99') self.driver.add_constraint('spar.platform_stability_check < 1.') self.driver.add_constraint('spar.heel_angle <= 6.') self.driver.add_constraint('spar.min_offset_unity < 1.0') self.driver.add_constraint('spar.max_offset_unity < 1.0')
def configure(self): self.add('driver', COBYLAdriver()) self.driver.maxfun = 100000 self.add('spar', Spar()) self.driver.workflow.add('spar') # objective self.driver.add_objective('spar.total_cost') # design variables self.driver.add_parameter('spar.neutral_axis', low=100., high=419., scaler=0.001) #self.driver.add_parameter('spar.number_of_rings[0]',low=10,high=50,scaler=0.1) self.driver.add_parameter('spar.number_of_rings[1]', low=10, high=100, scaler=0.1) self.driver.add_parameter('spar.number_of_rings[2]', low=10, high=100, scaler=0.1) self.driver.add_parameter('spar.number_of_rings[3]', low=1, high=80) self.driver.add_parameter('spar.wall_thickness[0]', low=100., high=1000., scaler=0.0001) self.driver.add_parameter('spar.wall_thickness[1]', low=100., high=1000., scaler=0.0001) self.driver.add_parameter('spar.wall_thickness[2]', low=100., high=1000., scaler=0.0001) self.driver.add_parameter('spar.wall_thickness[3]', low=100., high=1000., scaler=0.0001) # Constraints self.driver.add_constraint('spar.flange_compactness <= 1.') self.driver.add_constraint('spar.web_compactness <= 1.') self.driver.add_constraint('spar.platform_stability_check <= 1.') #self.driver.add_constraint('spar.heel_angle <= 6.') self.driver.add_constraint('spar.min_offset_unity <= 1.') self.driver.add_constraint('spar.max_offset_unity <= 1.') self.driver.add_constraint('spar.VAL[0] <= 1.') self.driver.add_constraint('spar.VAL[1] <= 1.') self.driver.add_constraint('spar.VAL[2] <= 1.') self.driver.add_constraint('spar.VAL[3] <= 1.') self.driver.add_constraint('spar.VAG[0] <= 1.') self.driver.add_constraint('spar.VAG[1] <= 1.') self.driver.add_constraint('spar.VAG[2] <= 1.') self.driver.add_constraint('spar.VAG[3] <= 1.') self.driver.add_constraint('spar.VEL[0] <= 1.') self.driver.add_constraint('spar.VEL[1] <= 1.') self.driver.add_constraint('spar.VEL[2] <= 1.') self.driver.add_constraint('spar.VEL[3] <= 1.') self.driver.add_constraint('spar.VEG[0] <= 1.') self.driver.add_constraint('spar.VEG[1] <= 1.') self.driver.add_constraint('spar.VEG[2] <= 1.') self.driver.add_constraint('spar.VEG[3] <= 1.')
def configure(self): """Creates a new Assembly containing a chain of Tower_RNA, Spar and Mooring components, as well as a constained optimizer.""" """Create optimizer instance.""" self.add('driver', COBYLAdriver()) self.driver.maxfun = 100000 """Select component instances.""" self.add('tower_RNA', Tower_RNA()) self.add('spar', Spar()) self.add('mooring', Mooring()) """Define iteration hierarchy.""" self.driver.workflow.add(['tower_RNA', 'mooring', 'spar']) """Create a variable in the assembly and connects it to an internal component variable. If the variable is used again in a different component instance, then it is manually connected.""" self.create_passthrough('tower_RNA.base_outer_diameter', 'tower_base_outer_diameter') self.create_passthrough('tower_RNA.top_outer_diameter', 'tower_top_outer_diameter') self.create_passthrough('tower_RNA.length', 'tower_length') self.create_passthrough('tower_RNA.example_turbine_size', 'example_turbine_size') self.create_passthrough('tower_RNA.RNA_center_of_gravity_y', 'RNA_center_of_gravity_y') self.create_passthrough('spar.wall_thickness', 'wall_thickness') self.create_passthrough('tower_RNA.rotor_diameter', 'rotor_diameter') self.create_passthrough('tower_RNA.cut_out_speed', 'cut_out_speed') self.create_passthrough('tower_RNA.air_density', 'air_density') self.connect('air_density', 'spar.air_density') self.create_passthrough('spar.wind_reference_speed', 'wind_reference_speed') self.connect('wind_reference_speed', 'tower_RNA.wind_reference_speed') self.create_passthrough('spar.wind_reference_height', 'wind_reference_height') self.connect('wind_reference_height', 'tower_RNA.wind_reference_height') self.create_passthrough('spar.gust_factor', 'gust_factor') self.connect('gust_factor', 'tower_RNA.gust_factor') self.create_passthrough('spar.alpha', 'alpha') self.connect('alpha', 'tower_RNA.alpha') self.create_passthrough('spar.RNA_center_of_gravity_x', 'RNA_center_of_gravity_x') self.connect('RNA_center_of_gravity_x', 'tower_RNA.RNA_center_of_gravity_x') self.create_passthrough('spar.tower_mass', 'tower_mass') self.connect('tower_mass', 'tower_RNA.tower_mass') self.create_passthrough('spar.RNA_mass', 'RNA_mass') self.connect('RNA_mass', 'tower_RNA.RNA_mass') self.create_passthrough('spar.stiffener_index', 'stiffener_index') self.create_passthrough('spar.number_of_sections', 'number_of_sections') self.create_passthrough('spar.bulk_head', 'bulk_head') self.create_passthrough('spar.number_of_rings', 'number_of_rings') self.create_passthrough('spar.neutral_axis', 'neutral_axis') self.create_passthrough('spar.straight_col_cost', 'straight_col_cost') self.create_passthrough('spar.tapered_col_cost', 'tapered_col_cost') self.create_passthrough('spar.outfitting_cost', 'outfitting_cost') self.create_passthrough('spar.ballast_cost', 'ballast_cost') self.create_passthrough('spar.gravity', 'gravity') self.create_passthrough('spar.load_condition', 'load_condition') self.create_passthrough('spar.significant_wave_height', 'significant_wave_height') self.create_passthrough('spar.significant_wave_period', 'significant_wave_period') self.create_passthrough('spar.material_density', 'material_density') self.create_passthrough('spar.E', 'E') self.create_passthrough('spar.nu', 'nu') self.create_passthrough('spar.yield_stress', 'yield_stress') self.create_passthrough('spar.shell_mass_factor', 'shell_mass_factor') self.create_passthrough('spar.bulkhead_mass_factor', 'bulkhead_mass_factor') self.create_passthrough('spar.ring_mass_factor', 'ring_mass_factor') self.create_passthrough('spar.outfitting_factor', 'outfitting_factor') self.create_passthrough('spar.spar_mass_factor', 'spar_mass_factor') self.create_passthrough('spar.permanent_ballast_height', 'permanent_ballast_height') self.create_passthrough('spar.fixed_ballast_height', 'fixed_ballast_height') self.create_passthrough('spar.permanent_ballast_density', 'permanent_ballast_density') self.create_passthrough('spar.fixed_ballast_density', 'fixed_ballast_density') self.create_passthrough('spar.offset_amplification_factor', 'offset_amplification_factor') self.create_passthrough('spar.water_density', 'water_density') self.create_passthrough('spar.elevations', 'spar_elevations') self.create_passthrough('spar.outer_diameter', 'spar_outer_diameter') self.create_passthrough('spar.water_depth', 'water_depth') # self.create_passthrough('spar.stiffener_curve_fit', 'stiffener_curve_fit') #mooring connections self.create_passthrough('mooring.fairlead_depth', 'fairlead_depth') self.connect('spar_elevations', ['tower_RNA.spar_elevations', 'mooring.spar_elevations']) self.connect('spar_outer_diameter', 'mooring.spar_outer_diameter') self.create_passthrough('mooring.scope_ratio', 'scope_ratio') self.create_passthrough('mooring.pretension_percent', 'pretension_percent') self.create_passthrough('mooring.mooring_diameter', 'mooring_diameter') self.create_passthrough('mooring.number_of_mooring_lines', 'number_of_mooring_lines') self.connect('water_depth', 'mooring.water_depth') self.create_passthrough('mooring.mooring_type', 'mooring_type') self.create_passthrough('mooring.anchor_type', 'anchor_type') self.create_passthrough('mooring.fairlead_offset_from_shell', 'fairlead_offset_from_shell') self.create_passthrough('mooring.user_MBL', 'user_MBL') self.create_passthrough('mooring.user_WML', 'user_WML') self.create_passthrough('mooring.user_AE_storm', 'user_AE_storm') self.create_passthrough('mooring.user_MCPL', 'user_MCPL') self.create_passthrough('mooring.user_anchor_cost', 'user_anchor_cost') self.create_passthrough('mooring.misc_cost_factor', 'misc_cost_factor') self.create_passthrough('mooring.number_of_discretizations', 'number_of_discretizations') self.connect('water_density', 'mooring.water_density') """Connect outputs to inputs.""" self.connect('tower_RNA.RNA_keel_to_CG', 'spar.RNA_keel_to_CG') self.connect('tower_RNA.tower_center_of_gravity', 'spar.tower_center_of_gravity') self.connect('tower_RNA.tower_wind_force', 'spar.tower_wind_force') self.connect('tower_RNA.RNA_wind_force', 'spar.RNA_wind_force') #mooring connections self.connect('mooring.mooring_total_cost', 'spar.mooring_total_cost') self.connect('mooring.mooring_keel_to_CG', 'spar.mooring_keel_to_CG') self.connect('mooring.mooring_vertical_load', 'spar.mooring_vertical_load') self.connect('mooring.mooring_horizontal_stiffness', 'spar.mooring_horizontal_stiffness') self.connect('mooring.mooring_vertical_stiffness', 'spar.mooring_vertical_stiffness') self.connect('mooring.sum_forces_x', 'spar.sum_forces_x') self.connect('mooring.offset_x', 'spar.offset_x') self.connect('mooring.damaged_mooring', 'spar.damaged_mooring') self.connect('mooring.intact_mooring', 'spar.intact_mooring') self.connect('mooring.mooring_mass', 'spar.mooring_mass') """Design variables by adding a range of validity for certain variables.""" self.driver.add_parameter('neutral_axis', low=10., high=41.9, scaler=0.01) #self.driver.add_parameter('number_of_rings[0]',low=1,high=5) self.driver.add_parameter('number_of_rings[1]', low=1, high=10) self.driver.add_parameter('number_of_rings[2]', low=1, high=10) self.driver.add_parameter('number_of_rings[3]', low=1, high=50) self.driver.add_parameter('wall_thickness[0]', low=1., high=10., scaler=0.01) self.driver.add_parameter('wall_thickness[1]', low=1., high=10., scaler=0.01) self.driver.add_parameter('wall_thickness[2]', low=1., high=10., scaler=0.01) self.driver.add_parameter('wall_thickness[3]', low=10., high=100., scaler=0.001) self.driver.add_parameter('scope_ratio', low=15., high=45., scaler=0.1) self.driver.add_parameter('pretension_percent', low=2.5, high=10.) self.driver.add_parameter('mooring_diameter', low=30., high=100., scaler=0.001) self.driver.add_parameter('fixed_ballast_height', low=30., high=100., scaler=0.1) self.driver.add_parameter('permanent_ballast_height', low=30., high=100., scaler=0.1) """Specify objective function (what you want to minimize).""" self.driver.add_objective('spar.spar_mass', name='spar mass') """Add constraints to the driver.""" self.driver.add_constraint('spar.water_ballast_height < 7.5') self.driver.add_constraint('spar.water_ballast_height > 5.5') self.driver.add_constraint('spar.flange_compactness < 1.') self.driver.add_constraint('spar.web_compactness < 1.') self.driver.add_constraint('spar.VAL[0] < 0.99') self.driver.add_constraint('spar.VAL[1] < 0.99') self.driver.add_constraint('spar.VAL[2] < 0.99') self.driver.add_constraint('spar.VAL[3] < 0.99') self.driver.add_constraint('spar.VAG[0] < 0.99') self.driver.add_constraint('spar.VAG[1] < 0.99') self.driver.add_constraint('spar.VAG[2] < 0.99') self.driver.add_constraint('spar.VAG[3] < 0.99') self.driver.add_constraint('spar.VEL[0] < 0.99') self.driver.add_constraint('spar.VEL[1] < 0.99') self.driver.add_constraint('spar.VEL[2] < 0.99') self.driver.add_constraint('spar.VEL[3] < 0.99') self.driver.add_constraint('spar.VEG[0] < 0.99') self.driver.add_constraint('spar.VEG[1] < 0.99') self.driver.add_constraint('spar.VEG[2] < 0.99') self.driver.add_constraint('spar.VEG[3] < 0.99') self.driver.add_constraint('spar.platform_stability_check < 1.') self.driver.add_constraint('spar.heel_angle <= 6.') self.driver.add_constraint('spar.min_offset_unity < 1.0') self.driver.add_constraint('spar.max_offset_unity < 1.0')
def opt_tower(sea_depth=np.array([]), hmax_50yr=None, tp_50yr=None, deck_height=None, d_monopile=None, t_monopile=None, t_jacket=None, \ d_tower_base=None, d_tower_top=None, t_tower_base=None, t_tower_top=None): mytwr = main()[0] MDAOswitch = 'md_pysnopt' # optimization import pyOpt from pyopt_driver.pyopt_driver import pyOptDriver from openmdao.lib.casehandlers.api import DumpCaseRecorder from openmdao.lib.drivers.api import COBYLAdriver if MDAOswitch == 'md_cobyla': mytwr.replace('driver', COBYLAdriver()) mytwr.driver.rhobeg = 0.01 mytwr.driver.rhoend = 1.e-3 mytwr.driver.maxfun = 2000 mytwr.driver.iprint = 1 else: mytwr.replace('driver', pyOptDriver()) if MDAOswitch == 'md_pysnopt': mytwr.driver.optimizer = 'SNOPT' mytwr.driver.pyopt_diff = True #mytwr.driver.sens_step = 1e-8 mytwr.driver.options = { 'Major feasibility tolerance': 1e-4, 'Minor feasibility tolerance': 1e-4, 'Major optimality tolerance': 1e-4, 'Function precision': 1e-6 } elif MDAOswitch == 'md_pyCobyla': mytwr.driver.optimizer = 'COBYLA' mytwr.driver.options = { 'RHOEND': 1.e-2, 'RHOEND': 1.e-3, 'MAXFUN': 2000, 'IPRINT': 1 } else: sys.exit('Error: MDAOswitch must be set to ' 'pyCobyla' ' or ' 'pySNOPT' ' or ' 'md_cobyla' ' or ' 'md_pySNOPT' ' or ' 'md_pyCobyla' '!!!') # ---------------------- # --- Objective --- mytwr.driver.add_objective('(tower1.mass) / 500.e3') # ---------------------- #diameter and thickness variables mytwr.driver.add_parameter('d_monopile', low=3.0, high=15.0) # this is OD monopile mytwr.driver.add_parameter('t_monopile', low=0.01, high=0.1) # this is t of monopile mytwr.driver.add_parameter( 't_jacket', low=0.01, high=0.1 ) # this is t of jacket # d jacket fixed by monopile + t_jacket + t_grout mytwr.driver.add_parameter('d_tower_base', low=3.0, high=15.0) #This is OD at the base mytwr.driver.add_parameter('t_tower_base', low=0.01, high=0.3) #This is t at the base mytwr.driver.add_parameter( 'd_tower_top', low=3.87, high=8.0) #This is OD at the top # OD at top should be fixed mytwr.driver.add_parameter('t_tower_top', low=0.01, high=0.1) #This is t at top # node positioning variables #mytwr.driver.add_parameter('jp.z[5]', low= 0.0, high= 0.99) # this is H2 (can't move this - will have to add extra variable to make that happen) #--- Constraints ---# # frequency mytwr.driver.add_constraint('tower1.f1 >= 0.20') # from 0.28 to 0.26 #mytwr.driver.add_constraint('tower1.f1 <= 0.30') # utilization mytwr.driver.add_constraint('tower1.stress <= 1.0') mytwr.driver.add_constraint('tower2.stress <= 1.0') mytwr.driver.add_constraint('tower1.buckling <= 1.0') mytwr.driver.add_constraint('tower2.buckling <= 1.0') mytwr.driver.add_constraint('tower1.shellBuckling <= 1.0') mytwr.driver.add_constraint('tower2.shellBuckling <= 1.0') mytwr.driver.add_constraint('tower1.damage <= 1.0') #mytwr.driver.add_constraint('gc.weldability <= 0.0') # this goes for entire structure which we don't want #mytwr.driver.add_constraint('gc.manufacturability <= 0.0') # just going to use explicit constraints below # uniformity of diameter and thickness of tower mytwr.driver.add_constraint('d_tower_top <= d_tower_base') mytwr.driver.add_constraint('d_tower_base <= d_monopile') #mytwr.driver.add_constraint('d_monopile - d_tower_base <= 0.4') mytwr.driver.add_constraint('t_tower_top <= t_tower_base') # manufacturing and installation mytwr.driver.add_constraint( 'd_tower_top/d_tower_base >= 0.40' ) # manufacturability - already covered; taper ratio for manufacturing mytwr.driver.add_constraint( 'd_tower_base/t_tower_base >= 120.0' ) # weldibility - already covered; tower DTR for rolling operation mytwr.driver.add_constraint('d_tower_top/t_tower_top >= 120.0') #mytwr.driver.add_constraint('d_monopile/t_monopile <= 100.0') # pile DTR for installation #mytwr.driver.add_constraint('d_tower_base/t_tower_base <= 200.0') # tower DTR for welding (not covered) #mytwr.driver.add_constraint('d_tower_top/t_tower_top <= 200.0') ## mytwr.driver.add_constraint('Lp0rat >= 0.') # was for embedment - not in model # ---------------------- # set optimization variables if sea_depth.size: for i in range(len(sea_depth)): mytwr.sea_depth = sea_depth[i] mytwr.deck_height = deck_height[i] mytwr.wave1.hs = hmax_50yr[i] mytwr.wave1.T = tp_50yr[i] mytwr.wave2.hs = hmax_50yr[i] mytwr.wave2.T = tp_50yr[i] #reset to initial conditions for geometry mytwr.d_monopile = d_monopile[i] mytwr.t_monopile = t_monopile[i] mytwr.t_jacket = t_jacket[i] mytwr.d_tower_base = d_tower_base[i] mytwr.d_tower_top = d_tower_top[i] mytwr.t_tower_base = t_tower_base[i] mytwr.t_tower_top = t_tower_top[i] # print IC print 'Initial condition\n' print 'sea_depth=', mytwr.sea_depth print 'deck_height=', mytwr.deck_height print 'significant wave height=', mytwr.wave1.hs print 'wave period=', mytwr.wave1.T print 'd_monopile=', mytwr.d_monopile print 't_monopile=', mytwr.t_monopile print 't_jacket=', mytwr.t_jacket print 'd_tower_base=', mytwr.d_tower_base print 'd_tower_top=', mytwr.d_tower_top print 't_tower_base=', mytwr.t_tower_base print 't_tower_top=', mytwr.t_tower_top mytwr.driver.options.update({ 'Summary file': 'Case_' + str(i) + '_summary.out', 'Print file': 'Case_' + str(i) + '_print.out' }) if sea_depth[i] > 60.0: # deepwater case mytwr.driver.options['Major optimality tolerance'] = 1e-3 else: mytwr.driver.options['Major optimality tolerance'] = 1e-3 #RUN import time tt = time.time() mytwr.run() print "Final conditions" print "Minimum found at Db=%f, Dt=%f, tb=%f, tt=%f; mass= (%f)" % ( mytwr.tower1.d[0], mytwr.tower1.d[-1], mytwr.tower1.t[0], mytwr.tower1.t[-1], mytwr.tower1.mass) print "Minimum found at z1=%f, D1=%f, t1=%f" % ( mytwr.tower1.z[1], mytwr.tower1.d[1], mytwr.tower1.t[1]) print "Minimum found at DTRb DTRt(%f, %f)" % ( mytwr.tower1.d[0] / mytwr.tower1.t[0], mytwr.tower1.d[-1] / mytwr.tower1.t[-1]) print "\n" # print FC print 'd_monopile=', mytwr.d_monopile print 't_monopile=', mytwr.t_monopile print 't_jacket=', mytwr.t_jacket print 'd_tower_base=', mytwr.d_tower_base print 'd_tower_top=', mytwr.d_tower_top print 't_tower_base=', mytwr.t_tower_base print 't_tower_top=', mytwr.t_tower_top print 'zs=', mytwr.tower1.z print 'ds=', mytwr.tower1.d print 'ts=', mytwr.tower1.t print "\n" print "Minimum found at Freq %f" % (mytwr.tower1.f1) print "Minimum found at GLutil EUutil %f %f" % ( np.max( np.vstack((mytwr.tower1.buckling, mytwr.tower2.buckling))), np.max( np.vstack((mytwr.tower1.shellBuckling, mytwr.tower2.shellBuckling)))) print "Minimum found at GLutil 1 and 2", mytwr.tower1.buckling, mytwr.tower2.buckling print "Minimum found at EUutil 1 and 2", mytwr.tower1.shellBuckling, mytwr.tower2.shellBuckling print "Elapsed time: ", time.time() - tt, "seconds\n" #Plot PlotTower(mytwr, util=True, savefileroot=str(i)) else: #RUN import time tt = time.time() mytwr.run() print "\n" print "Minimum found at Db=%f, Dt=%f, tb=%f, tt=%f; mass= (%f)" % ( mytwr.tower1.d[0], mytwr.tower1.d[-1], mytwr.tower1.t[0], mytwr.tower1.t[-1], mytwr.tower1.mass) print "Minimum found at z1=%f, D1=%f, t1=%f" % ( mytwr.tower1.z[1], mytwr.tower1.d[1], mytwr.tower1.t[1]) print "Minimum found at DTRb DTRt(%f, %f)" % ( mytwr.tower1.d[0] / mytwr.tower1.t[0], mytwr.tower1.d[-1] / mytwr.tower1.t[-1]) print "\n" print 'zs=', mytwr.tower1.z print 'ds=', mytwr.tower1.d print 'ts=', mytwr.tower1.t print "\n" print "Minimum found at Freq %f" % (mytwr.tower1.f1) print "Minimum found at GLutil EUutil %f %f" % ( np.max(np.vstack((mytwr.tower1.buckling, mytwr.tower2.buckling))), np.max( np.vstack( (mytwr.tower1.shellBuckling, mytwr.tower2.shellBuckling)))) print "Minimum found at GLutil 1 and 2", mytwr.tower1.buckling, mytwr.tower2.buckling print "Minimum found at EUutil 1 and 2", mytwr.tower1.shellBuckling, mytwr.tower2.shellBuckling print "Elapsed time: ", time.time() - tt, "seconds" print "Execution count: ", mytwr.exec_count #Plot PlotTower(mytwr, util=True) print mytwr.jp.z print mytwr.jp.towerHeight print(mytwr.jp.z * mytwr.jp.towerHeight) - (mytwr.d_monopile * 1.5 - mytwr.monopile_extension) print mytwr.z_nodes