def initialise(self, data, custom_settings=None): if custom_settings: self.settings = custom_settings else: try: self.settings = data.settings['LinearAssembler'][ 'linear_system_settings'] except KeyError: pass settings.to_custom_types(self.settings, self.settings_types, self.settings_default, self.settings_options, no_ctype=True) beam = lingebm.FlexDynamic(data.linear.tsstruct0, data.structure, self.settings) self.sys = beam self.tsstruct0 = data.linear.tsstruct0 # State variables num_dof_flex = self.sys.structure.num_dof.value num_dof_rig = self.sys.Mstr.shape[0] - num_dof_flex state_db = { 'eta': [0, num_dof_flex], 'V_bar': [num_dof_flex, num_dof_flex + 3], 'W_bar': [num_dof_flex + 3, num_dof_flex + 6], 'orient_bar': [num_dof_flex + 6, num_dof_flex + num_dof_rig], 'dot_eta': [num_dof_flex + num_dof_rig, 2 * num_dof_flex + num_dof_rig], 'V': [ 2 * num_dof_flex + num_dof_rig, 2 * num_dof_flex + num_dof_rig + 3 ], 'W': [ 2 * num_dof_flex + num_dof_rig + 3, 2 * num_dof_flex + num_dof_rig + 6 ], 'orient': [ 2 * num_dof_flex + num_dof_rig + 6, 2 * num_dof_flex + 2 * num_dof_rig ] } self.state_variables = LinearVector(state_db, self.sys_id) if num_dof_rig == 0: self.clamped = True self.linearisation_vectors['eta'] = self.tsstruct0.q self.linearisation_vectors['eta_dot'] = self.tsstruct0.dqdt self.linearisation_vectors[ 'forces_struct'] = self.tsstruct0.steady_applied_forces.reshape( -1, order='C')
sys.path.append('/home/ng213/code/sharpy/') import matplotlib.pyplot as plt import scipy as sc import sharpy.linear.src.lingebm as lingebm import sharpy.sharpy_main solver_file_path = './cases/flexible_beam_static.solver.txt' data = sharpy.sharpy_main.main(['', solver_file_path]) tsstruct0 = data.structure.timestep_info[-1] # dt = 0.0001 beam = lingebm.FlexDynamic(tsstruct0, dt=None, wv=None, use_euler=True) # Rigid body equation only beam.U = np.zeros((69, 2)) # omega_y mode beam.U[-5, 0] = 1 beam.U[-2, 1] = 1 # Normalise eigenmodes beam.U[-5, 0] = 1 / np.sqrt(beam.U[:, 0].T.dot(beam.Mstr.dot(beam.U[:, 0]))) beam.U[-2, 1] = 1 / np.sqrt(beam.U[:, 1].T.dot(beam.Mstr.dot(beam.U[:, 1]))) beam.modal = True beam.inout_coords = 'modes' beam.Nmodes = 2
'modal_projection': True, 'inout_coords': 'modes', 'discrete_time': False, 'proj_modes': 'undamped', 'use_euler': True, 'num_modes': 13 } # Modify the A frame orientation from the NL SHARPy solution euler_init = np.array([0, 5 * np.pi / 180, 0]) # tsstruct0.quat = algebra.euler2quat_ag(euler_init) # tsstruct0.mb_quat[0] = algebra.euler2quat_ag(euler_init) tsstruct0.quat = tsstruct0.mb_quat[0] beam = lingebm.FlexDynamic(tsstruct0, structure=data.structure, custom_settings=beam_settings) beam.update_modal() beam.Nmodes = 3 # Retain the rotational rigid degree of freedom only through the two rigid body modes phi_rr = np.zeros((69, 2)) # Rigid body modes of interest phi_rr[-5, 0] = 1 # Omega_y mode phi_rr[-2, 1] = 1 # Theta mode # Get the flexible modes phi = beam.U[:, 10:10 + beam.Nmodes - 2] phi = np.hstack((phi, phi_rr))
def __init__(self, data, custom_settings_linear=None, uvlm_block=False, chosen_ts=None): self.data = data if custom_settings_linear is None: settings_here = data.settings['LinearUvlm'] else: settings_here = custom_settings_linear sharpy.utils.settings.to_custom_types(settings_here, linuvlm.settings_types_dynamic, linuvlm.settings_default_dynamic) if chosen_ts is None: self.chosen_ts = self.data.ts else: self.chosen_ts = chosen_ts ## TEMPORARY - NEED TO INCLUDE PROPER INTEGRATION OF SETTINGS try: self.rigid_body_motions = settings_here['rigid_body_motion'] except KeyError: self.rigid_body_motions = False try: self.use_euler = settings_here['use_euler'] except KeyError: self.use_euler = False if self.rigid_body_motions and settings_here['track_body']: self.track_body = True else: self.track_body = False ## ------- ### extract aeroelastic info self.dt = settings_here['dt'].value ### reference to timestep_info # aero aero = data.aero self.tsaero = aero.timestep_info[self.chosen_ts] # structure structure = data.structure self.tsstr = structure.timestep_info[self.chosen_ts] # --- backward compatibility try: rho = settings_here['density'].value except KeyError: warnings.warn( "Key 'density' not found in 'LinearUvlm' solver settings. '\ 'Trying to read it from 'StaticCoupled'." ) rho = data.settings['StaticCoupled']['aero_solver_settings']['rho'] if type(rho) == str: rho = np.float(rho) if hasattr(rho, 'value'): rho = rho.value self.tsaero.rho = rho # --- backward compatibility ### gebm if self.use_euler: self.num_dof_rig = 9 else: self.num_dof_rig = 10 self.num_dof_flex = np.sum(self.data.structure.vdof >= 0) * 6 self.num_dof_str = self.num_dof_flex + self.num_dof_rig self.reshape_struct_input() try: beam_settings = settings_here['beam_settings'] except KeyError: beam_settings = dict() self.lingebm_str = lingebm.FlexDynamic(self.tsstr, structure, beam_settings) cga = algebra.quat2rotation(self.tsstr.quat) ### uvlm if uvlm_block: self.linuvlm = linuvlm.DynamicBlock( self.tsaero, dt=settings_here['dt'].value, dynamic_settings=settings_here, RemovePredictor=settings_here['remove_predictor'].value, UseSparse=settings_here['use_sparse'].value, integr_order=settings_here['integr_order'].value, ScalingDict=settings_here['ScalingDict'], for_vel=np.hstack((cga.dot(self.tsstr.for_vel[:3]), cga.dot(self.tsstr.for_vel[3:])))) else: self.linuvlm = linuvlm.Dynamic( self.tsaero, dt=settings_here['dt'].value, dynamic_settings=settings_here, RemovePredictor=settings_here['remove_predictor'].value, UseSparse=settings_here['use_sparse'].value, integr_order=settings_here['integr_order'].value, ScalingDict=settings_here['ScalingDict'], for_vel=np.hstack((cga.dot(self.tsstr.for_vel[:3]), cga.dot(self.tsstr.for_vel[3:]))))