Esempio n. 1
0
# #     '+ optics_cubesat_group_relative_orbit_state_sq_sum'
# #     '+ detector_cubesat_group_relative_orbit_state_sq_sum'
# #     ') / {}'.format(num_times))

obj_comp = ExecComp(
    'obj= 0.01 * total_propellant_used- 1e-5 * total_data_downloaded + 1e-4 * (0'
    '+ masked_normal_distance_sunshade_detector_mm_sq_sum'
    '+ masked_normal_distance_optics_detector_mm_sq_sum'
    '+ masked_distance_sunshade_optics_mm_sq_sum'
    '+ masked_distance_optics_detector_mm_sq_sum)/{}'
    '+ 1e-3 * (sunshade_cubesat_group_relative_orbit_state_sq_sum'
    '+ optics_cubesat_group_relative_orbit_state_sq_sum'
    '+ detector_cubesat_group_relative_orbit_state_sq_sum'
    ') / {}'.format(num_times, num_times))

obj_comp.add_objective('obj', scaler=1.e-3)
# obj_comp.add_objective('obj')
prob.model.add_subsystem('obj_comp', obj_comp, promotes=['*'])
for cubesat_name in ['sunshade', 'optics', 'detector']:
    prob.model.connect(
        '{}_cubesat_group.relative_orbit_state_sq_sum'.format(cubesat_name),
        '{}_cubesat_group_relative_orbit_state_sq_sum'.format(cubesat_name),
    )

prob.driver = pyOptSparseDriver()
prob.driver.options['optimizer'] = 'SNOPT'
prob.driver.opt_settings['Major feasibility tolerance'] = 1e-7
prob.driver.opt_settings['Major optimality tolerance'] = 1e-7
prob.driver.opt_settings['Iterations limit'] = 500000000
prob.driver.opt_settings['Major iterations limit'] = 1000000
prob.driver.opt_settings['Minor iterations limit'] = 500000
Esempio n. 2
0
group = Group()

ivc = IndepVarComp()

ivc.add_output('V0', val=3.)
ivc.add_output('theta', val=0.)
group.add_subsystem('ivc', ivc, promotes=['*'])

t_comp = ExecComp('t = 2 * V0 * sin(theta) / 9.81')

group.add_subsystem('t_comp', t_comp, promotes=['*'])

dx_comp = ExecComp('dx = V0 * cos(theta) * t')
group.add_subsystem('dx_comp', dx_comp, promotes=['*'])

prob.model = group

# Define the optimization problem

ivc.add_design_var('theta', lower=0., upper=90. * np.pi / 180.)
dx_comp.add_objective('dx', scaler=-1.)

# set the optimization algorithm

prob.driver = ScipyOptimizeDriver()  # 'includes the driver into the model'
prob.setup()  # 'this initializes the setup of the problem
prob.run_driver()  # ' this runs the driver(the optimizer) for the model
prob.run_model()  # this runs the model
prob.check_partials(compact_print=True)
prob.model.list_outputs()