|
| 1 | +""" |
| 2 | + Script to set the required SHARPy settings for all cases within |
| 3 | + the UDP Control example notebook. |
| 4 | +""" |
| 5 | +def get_settings_udp(model, flow, **kwargs): |
| 6 | + gust = kwargs.get('gust', False) |
| 7 | + |
| 8 | + horseshoe = kwargs.get('horseshoe', False) |
| 9 | + gravity = kwargs.get('gravity', True) |
| 10 | + wake_length_factor = kwargs.get('wake_length_factor', 10) |
| 11 | + |
| 12 | + num_cores = kwargs.get('num_cores', 2) |
| 13 | + num_modes = kwargs.get('num_modes', 20) |
| 14 | + free_flight = kwargs.get('free_flight', False) |
| 15 | + tolerance = kwargs.get('tolerance', 1e-6) |
| 16 | + n_load_steps = kwargs.get('n_load_steps', 5) |
| 17 | + fsi_tolerance = kwargs.get('fsi_tolerance', 1e-6) |
| 18 | + relaxation_factor = kwargs.get('relaxation_factor', 0.1) |
| 19 | + newmark_damp = kwargs.get('newmark_damp', 0.5e-4) |
| 20 | + output_folder = kwargs.get('output_folder', './output/') |
| 21 | + model.config['SHARPy'] = {'case': model.case_name, |
| 22 | + 'route': model.route, |
| 23 | + 'flow': flow, |
| 24 | + 'write_screen': kwargs.get('write_screen', 'on'), |
| 25 | + 'write_log': 'on', |
| 26 | + 'save_settings': 'on', |
| 27 | + 'log_folder': output_folder + '/', |
| 28 | + 'log_file': model.case_name + '.log'} |
| 29 | + |
| 30 | + |
| 31 | + model.config['BeamLoader'] = {'unsteady': 'off', |
| 32 | + 'orientation': model.quat} |
| 33 | + |
| 34 | + model.config['AerogridLoader'] = {'unsteady': 'on', |
| 35 | + 'aligned_grid': 'on', |
| 36 | + 'mstar': wake_length_factor*model.M, #int(20/tstep_factor), |
| 37 | + 'wake_shape_generator': 'StraightWake', |
| 38 | + 'wake_shape_generator_input': { |
| 39 | + 'u_inf':model.u_inf, |
| 40 | + 'u_inf_direction': [1., 0., 0.], |
| 41 | + 'dt':model.dt, |
| 42 | + }, |
| 43 | + } |
| 44 | + if horseshoe: |
| 45 | + model.config['AerogridLoader']['mstar'] = 1 |
| 46 | + |
| 47 | + model.config['StaticCoupled'] = { |
| 48 | + 'print_info': 'on', |
| 49 | + 'max_iter': 200, |
| 50 | + 'n_load_steps': n_load_steps, |
| 51 | + 'tolerance': 1e-5, |
| 52 | + 'relaxation_factor': relaxation_factor, |
| 53 | + 'aero_solver': 'StaticUvlm', |
| 54 | + 'aero_solver_settings': { |
| 55 | + 'rho': model.rho, |
| 56 | + 'print_info': 'off', |
| 57 | + 'horseshoe': 'on', |
| 58 | + 'num_cores': num_cores, |
| 59 | + 'n_rollup': 0, |
| 60 | + 'velocity_field_generator': 'SteadyVelocityField', |
| 61 | + 'velocity_field_input': { |
| 62 | + 'u_inf': model.u_inf, |
| 63 | + 'u_inf_direction': model.u_inf_direction}, |
| 64 | + 'vortex_radius': 1e-9}, |
| 65 | + 'structural_solver': 'NonLinearStatic', |
| 66 | + 'structural_solver_settings': {'print_info': 'off', |
| 67 | + 'max_iterations': 200, |
| 68 | + 'num_load_steps': 5, |
| 69 | + 'delta_curved': 1e-6, |
| 70 | + 'min_delta': 1e-8, |
| 71 | + 'gravity': gravity, |
| 72 | + 'gravity': 9.81}, |
| 73 | + } |
| 74 | + |
| 75 | + |
| 76 | + model.config['AerogridPlot'] = {'include_rbm': 'off', |
| 77 | + 'include_applied_forces': 'on', |
| 78 | + 'minus_m_star': 0} |
| 79 | + model.config['BeamPlot'] = {'include_rbm': 'off', |
| 80 | + 'include_applied_forces': 'on'} |
| 81 | + |
| 82 | + model.config['WriteVariablesTime'] = {'structure_variables': ['pos'], |
| 83 | + 'structure_nodes': list(range(0, model.num_node_surf)), |
| 84 | + 'cleanup_old_solution': 'on', |
| 85 | + } |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + model.config['DynamicCoupled'] = {'print_info': 'on', |
| 90 | + 'structural_substeps': 10, |
| 91 | + 'dynamic_relaxation': 'on', |
| 92 | + 'cleanup_previous_solution': 'on', |
| 93 | + 'structural_solver': 'NonLinearDynamicPrescribedStep', |
| 94 | + 'structural_solver_settings': {'print_info': 'off', |
| 95 | + 'max_iterations': 950, |
| 96 | + 'delta_curved': 1e-1, |
| 97 | + 'min_delta': tolerance, |
| 98 | + 'newmark_damp': newmark_damp, |
| 99 | + 'gravity': gravity, |
| 100 | + 'gravity': 9.81, |
| 101 | + 'num_steps': model.n_tstep, |
| 102 | + 'dt':model.dt, |
| 103 | + }, |
| 104 | + 'aero_solver': 'StepUvlm', |
| 105 | + 'aero_solver_settings': {'print_info': 'on', |
| 106 | + 'num_cores': num_cores, |
| 107 | + 'convection_scheme': 2, |
| 108 | + 'velocity_field_generator': 'SteadyVelocityField', |
| 109 | + 'velocity_field_input': {'u_inf': model.u_inf, |
| 110 | + 'u_inf_direction': [1., 0., 0.]}, |
| 111 | + 'rho': model.rho, |
| 112 | + 'n_time_steps': model.n_tstep, |
| 113 | + 'vortex_radius': 1e-9, |
| 114 | + 'dt': model.dt, |
| 115 | + 'gamma_dot_filtering': 3}, |
| 116 | + 'fsi_substeps': 200, |
| 117 | + 'fsi_tolerance': fsi_tolerance, |
| 118 | + 'relaxation_factor': model.relaxation_factor, |
| 119 | + 'minimum_steps': 1, |
| 120 | + 'relaxation_steps': 150, |
| 121 | + 'final_relaxation_factor': 0.0, |
| 122 | + 'n_time_steps': model.n_tstep, |
| 123 | + 'dt': model.dt, |
| 124 | + 'include_unsteady_force_contribution': kwargs.get('unsteady_force_distribution', True), |
| 125 | + 'postprocessors': ['WriteVariablesTime', 'BeamPlot', 'AerogridPlot'], |
| 126 | + 'postprocessors_settings': {'BeamPlot': {'include_rbm': 'on', |
| 127 | + 'include_applied_forces': 'on'}, |
| 128 | + 'StallCheck': {}, |
| 129 | + 'AerogridPlot': { |
| 130 | + 'u_inf': model.u_inf, |
| 131 | + 'include_rbm': 'on', |
| 132 | + 'include_applied_forces': 'on', |
| 133 | + 'minus_m_star': 0}, |
| 134 | + 'WriteVariablesTime': { |
| 135 | + 'structure_variables': ['pos', 'psi'], |
| 136 | + 'structure_nodes': [model.num_node_surf - 1, |
| 137 | + model.num_node_surf, |
| 138 | + model.num_node_surf + 1], |
| 139 | + }, |
| 140 | + }, |
| 141 | + 'network_settings': kwargs.get('network_settings', {}), |
| 142 | + } |
| 143 | + |
| 144 | + if gust: |
| 145 | + gust_settings = kwargs.get('gust_settings', {'gust_shape': '1-cos', |
| 146 | + 'gust_length': 10., |
| 147 | + 'gust_intensity': 0.01, |
| 148 | + 'gust_offset': 0.}) |
| 149 | + model.config['DynamicCoupled']['aero_solver_settings']['velocity_field_generator'] = 'GustVelocityField' |
| 150 | + model.config['DynamicCoupled']['aero_solver_settings']['velocity_field_input'] = {'u_inf': model.u_inf, |
| 151 | + 'u_inf_direction': [1., 0, 0], |
| 152 | + 'relative_motion': bool(not free_flight), |
| 153 | + 'offset': gust_settings['gust_offset'], |
| 154 | + 'gust_shape': gust_settings['gust_shape'], |
| 155 | + 'gust_parameters': { |
| 156 | + 'gust_length': gust_settings['gust_length'], |
| 157 | + 'gust_intensity': gust_settings['gust_intensity'] * model.u_inf, |
| 158 | + } |
| 159 | + } |
| 160 | + |
| 161 | + model.config['PickleData'] = {} |
| 162 | + |
| 163 | + model.config['LinearAssembler'] = {'linear_system': 'LinearAeroelastic', |
| 164 | + 'inout_coordinates': 'nodes', |
| 165 | + # 'recover_accelerations': True, |
| 166 | + 'linear_system_settings': { |
| 167 | + 'beam_settings': {'modal_projection': True, |
| 168 | + 'inout_coords': 'modes', |
| 169 | + 'discrete_time': True, |
| 170 | + 'newmark_damp': newmark_damp, |
| 171 | + 'discr_method': 'newmark', |
| 172 | + 'dt': model.dt, |
| 173 | + 'proj_modes': 'undamped', |
| 174 | + 'num_modes': num_modes, |
| 175 | + 'print_info': 'on', |
| 176 | + 'gravity': gravity, |
| 177 | + 'remove_dofs': []}, |
| 178 | + 'aero_settings': {'dt': model.dt, |
| 179 | + 'integr_order': 2, |
| 180 | + 'density': model.rho, |
| 181 | + 'remove_predictor': True, |
| 182 | + 'use_sparse': 'off', |
| 183 | + 'gust_assembler': 'LeadingEdge', |
| 184 | + 'ScalingDict': kwargs.get('scaling_dict', {'length':1, 'speed': 1, 'density': 1}), |
| 185 | + }, |
| 186 | + 'track_body': free_flight, |
| 187 | + 'use_euler': free_flight, |
| 188 | + }} |
| 189 | + model.config['Modal'] = {'print_info': True, |
| 190 | + 'use_undamped_modes': True, |
| 191 | + 'NumLambda': num_modes, |
| 192 | + 'rigid_body_modes': free_flight, |
| 193 | + 'write_modes_vtk': False, |
| 194 | + 'print_matrices': False, |
| 195 | + 'continuous_eigenvalues': 'off', |
| 196 | + 'dt': model.dt, |
| 197 | + 'plot_eigenvalues': False, |
| 198 | + } |
| 199 | + model.config['SaveData']['save_linear'] = True |
| 200 | + if kwargs.get('remove_gust_input_in_statespace', False): |
| 201 | + model.config['LinearAssembler']['linear_system_settings']['aero_settings']['remove_inputs'] = ['u_gust'] |
| 202 | + |
| 203 | + rom_settings = kwargs.get('rom_settings', {'use': False}) |
| 204 | + if rom_settings['use']: |
| 205 | + model.config['LinearAssembler']['linear_system_settings']['aero_settings']['rom_method'] = rom_settings['rom_method'], |
| 206 | + model.config['LinearAssembler']['linear_system_settings']['aero_settings']['rom_method_settings'] = rom_settings['rom_method_settings'] |
| 207 | + return model.config |
0 commit comments