Source code for sharpy.solvers.nonlineardynamicprescribedstep

"""
@modified   Alfonso del Carre
"""

import sharpy.structure.utils.xbeamlib as xbeamlib
from sharpy.utils.solver_interface import solver, BaseSolver, solver_from_string
import sharpy.utils.settings as settings_utils

_BaseStructural = solver_from_string('_BaseStructural')

[docs]@solver class NonLinearDynamicPrescribedStep(_BaseStructural): """ Structural solver used for the dynamic simulation of clamped structures or those subject to a prescribed motion. This solver provides an interface to the structural library (``xbeam``) and updates the structural parameters for every k-th step in the FSI iteration. This solver can be called as part of a standalone structural simulation or as the structural solver of a coupled aeroelastic simulation. """ solver_id = 'NonLinearDynamicPrescribedStep' solver_classification = 'structural' settings_types = _BaseStructural.settings_types.copy() settings_default = _BaseStructural.settings_default.copy() settings_description = _BaseStructural.settings_description.copy() settings_table = settings_utils.SettingsTable() __doc__ += settings_table.generate(settings_types, settings_default, settings_description) def __init__(self): self.data = None self.settings = None def initialise(self, data, custom_settings=None, restart=False): self.data = data if custom_settings is None: self.settings = data.settings[self.solver_id] else: self.settings = custom_settings settings_utils.to_custom_types(self.settings, self.settings_types, self.settings_default) # load info from dyn dictionary self.data.structure.add_unsteady_information(self.data.structure.dyn_dict, self.settings['num_steps']) def run(self, **kwargs): structural_step = settings_utils.set_value_or_default(kwargs, 'structural_step', self.data.structure.timestep_info[-1]) dt = settings_utils.set_value_or_default(kwargs, 'dt', self.settings['dt']) if self.data.ts > 0: try: structural_step.for_vel[:] = self.data.structure.dynamic_input[self.data.ts - 1]['for_vel'] structural_step.for_acc[:] = self.data.structure.dynamic_input[self.data.ts - 1]['for_acc'] except IndexError: pass xbeamlib.cbeam3_step_nlndyn(self.data.structure, self.settings, self.data.ts, structural_step, dt=dt) # self.extract_resultants(structural_step) self.data.structure.integrate_position(structural_step, dt) return self.data def add_step(self): self.data.structure.next_step() def next_step(self): pass # self.data.structure.next_step() # ts = len(self.data.structure.timestep_info) - 1 # if ts > 0: # self.data.structure.timestep_info[ts].for_vel[:] = self.data.structure.dynamic_input[ts - 1]['for_vel'] # self.data.structure.timestep_info[ts].for_acc[:] = self.data.structure.dynamic_input[ts - 1]['for_acc'] # self.data.structure.timestep_info[ts].unsteady_applied_forces[:] = self.data.structure.dynamic_input[ts - 1]['dynamic_forces'] def extract_resultants(self, tstep=None): if tstep is None: tstep = self.data.structure.timestep_info[self.data.ts] steady, unsteady, grav = tstep.extract_resultants(self.data.structure, force_type=['steady', 'unsteady', 'grav']) totals = steady + unsteady + grav return totals[0:3], totals[3:6] def update(self, tstep=None): self.create_q_vector(tstep) def create_q_vector(self, tstep=None): import sharpy.structure.utils.xbeamlib as xb if tstep is None: tstep = self.data.structure.timestep_info[-1] xb.xbeam_solv_disp2state(self.data.structure, tstep)