def map_forces(self, aero_kstep, structural_kstep, unsteady_forces_coeff=1.0): # set all forces to 0 structural_kstep.steady_applied_forces.fill(0.0) structural_kstep.unsteady_applied_forces.fill(0.0) # aero forces to structural forces struct_forces = mapping.aero2struct_force_mapping( aero_kstep.forces, self.data.aero.struct2aero_mapping, aero_kstep.zeta, structural_kstep.pos, structural_kstep.psi, self.data.structure.node_master_elem, self.data.structure.master, structural_kstep.cag()) dynamic_struct_forces = unsteady_forces_coeff * mapping.aero2struct_force_mapping( aero_kstep.dynamic_forces, self.data.aero.struct2aero_mapping, aero_kstep.zeta, structural_kstep.pos, structural_kstep.psi, self.data.structure.node_master_elem, self.data.structure.master, structural_kstep.cag()) # prescribed forces + aero forces structural_kstep.steady_applied_forces = ( (struct_forces + self.data.structure.ini_info.steady_applied_forces).astype( dtype=ct.c_double, order='F', copy=True)) structural_kstep.unsteady_applied_forces = (( dynamic_struct_forces + self.data.structure.dynamic_input[max( self.data.ts - 1, 0)]['dynamic_forces']).astype( dtype=ct.c_double, order='F', copy=True))
def map_forces(self, aero_kstep, structural_kstep, unsteady_forces_coeff=1.0): # set all forces to 0 structural_kstep.steady_applied_forces.fill(0.0) structural_kstep.unsteady_applied_forces.fill(0.0) # aero forces to structural forces struct_forces = mapping.aero2struct_force_mapping( aero_kstep.forces, self.data.aero.struct2aero_mapping, aero_kstep.zeta, structural_kstep.pos, structural_kstep.psi, self.data.structure.node_master_elem, self.data.structure.connectivities, structural_kstep.cag(), self.data.aero.aero_dict) dynamic_struct_forces = unsteady_forces_coeff * mapping.aero2struct_force_mapping( aero_kstep.dynamic_forces, self.data.aero.struct2aero_mapping, aero_kstep.zeta, structural_kstep.pos, structural_kstep.psi, self.data.structure.node_master_elem, self.data.structure.connectivities, structural_kstep.cag(), self.data.aero.aero_dict) if self.correct_forces: struct_forces = self.correct_forces_function(self.data, aero_kstep, structural_kstep, struct_forces, rho=self.get_rho()) # dynamic_struct_forces = self.correct_forces_function(self.data, # aero_kstep, # structural_kstep, # dynamic_struct_forces) # prescribed forces + aero forces try: structural_kstep.steady_applied_forces = ( (struct_forces + self.data.structure.ini_info.steady_applied_forces).astype( dtype=ct.c_double, order='F', copy=True)) structural_kstep.unsteady_applied_forces = (( dynamic_struct_forces + self.data.structure.dynamic_input[max( self.data.ts - 1, 0)]['dynamic_forces']).astype( dtype=ct.c_double, order='F', copy=True)) except KeyError: structural_kstep.steady_applied_forces = ( (struct_forces + self.data.structure.ini_info.steady_applied_forces).astype( dtype=ct.c_double, order='F', copy=True)) structural_kstep.unsteady_applied_forces = dynamic_struct_forces
def run(self): cout.cout_wrap('Running static coupled solver...', 1) for i_step in range(self.settings['n_load_steps'].value): # load step coefficient if not self.settings['n_load_steps'].value == 0: load_step_multiplier = ( i_step + 1.0) / self.settings['n_load_steps'].value else: load_step_multiplier = 1.0 # new storage every load step if i_step > 0: self.increase_ts() for i_iter in range(self.settings['max_iter'].value): cout.cout_wrap('i_step: %u, i_iter: %u' % (i_step, i_iter)) # run aero self.data = self.aero_solver.run() print('Beam last node: ') print( self.data.structure.timestep_info[self.data.ts].pos[20, :]) # map force struct_forces = mapping.aero2struct_force_mapping( self.data.aero.timestep_info[self.data.ts].forces, self.data.aero.struct2aero_mapping, self.data.aero.timestep_info[self.data.ts].zeta, self.data.structure.timestep_info[self.data.ts].pos, self.data.structure.timestep_info[self.data.ts].psi, self.data.structure.node_master_elem, self.data.structure.master, algebra.quat2rot(self.data.structure.timestep_info[ self.data.ts].quat).T) if not self.settings['relaxation_factor'].value == 0.: if i_iter == 0: self.previous_force = struct_forces.copy() temp = struct_forces.copy() struct_forces = ( (1.0 - self.settings['relaxation_factor'].value) * struct_forces + self.settings['relaxation_factor'].value * self.previous_force) self.previous_force = temp # copy force in beam temp1 = load_step_multiplier * struct_forces self.data.structure.timestep_info[ self.data.ts].steady_applied_forces = temp1.astype( dtype=ct.c_double, order='F') # update gravity direction # TODO # run beam self.data = self.structural_solver.run() # update grid self.aero_solver.update_step() # convergence if self.convergence(i_iter, i_step): break # for i_step in range(self.settings['n_load_steps']): # coeff = ct.c_double((i_step + 1.0)/(self.settings['n_load_steps'])) # for i_iter in range(self.settings['max_iter']): # cout.cout_wrap('Iter: %u, step: %u' % (i_iter, i_step), 2) # # self.aero_solver.initialise(self.data, update_flightcon=False, quiet=True) # self.data = self.aero_solver.run() # # struct_forces = mapping.aero2struct_force_mapping( # self.data.grid.timestep_info[self.ts].forces, # self.data.grid.struct2aero_mapping, # self.data.grid.timestep_info[self.ts].zeta, # self.data.beam.timestep_info[self.ts].pos_def, # self.data.beam.timestep_info[self.ts].psi_def, # self.data.beam.node_master_elem, # self.data.beam.master, # self.data.grid.inertial2aero) # # if self.relaxation_factor > 0.0: # struct_forces = ((1.0 - self.relaxation_factor)*struct_forces + # self.relaxation_factor*self.previous_forces) # # self.previous_forces = struct_forces # self.data.beam.update_forces(struct_forces) # self.structural_solver.initialise(self.data) # self.data = self.structural_solver.run(coeff) # # if self.convergence(i_iter): # self.data.flightconditions['FlightCon']['u_inf'] = self.original_u_inf # self.aero_solver.initialise(self.data, quiet=True) # self.data = self.aero_solver.run() # if i_step == self.settings['n_load_steps'] - 1: # cout.cout_wrap('Converged in %u iterations' % (i_iter + 1), 2) # break cout.cout_wrap('...Finished', 1) return self.data
def run(self): for i_step in range(self.settings['n_load_steps'].value + 1): if (i_step == self.settings['n_load_steps'].value and self.settings['n_load_steps'].value > 0): break # load step coefficient if not self.settings['n_load_steps'].value == 0: load_step_multiplier = ( i_step + 1.0) / self.settings['n_load_steps'].value else: load_step_multiplier = 1.0 # new storage every load step if i_step > 0: self.increase_ts() for i_iter in range(self.settings['max_iter'].value): # run aero self.data = self.aero_solver.run() # map force struct_forces = mapping.aero2struct_force_mapping( self.data.aero.timestep_info[self.data.ts].forces, self.data.aero.struct2aero_mapping, self.data.aero.timestep_info[self.data.ts].zeta, self.data.structure.timestep_info[self.data.ts].pos, self.data.structure.timestep_info[self.data.ts].psi, self.data.structure.node_master_elem, self.data.structure.connectivities, self.data.structure.timestep_info[self.data.ts].cag(), self.data.aero.aero_dict) if not self.settings['relaxation_factor'].value == 0.: if i_iter == 0: self.previous_force = struct_forces.copy() temp = struct_forces.copy() struct_forces = ( (1.0 - self.settings['relaxation_factor'].value) * struct_forces + self.settings['relaxation_factor'].value * self.previous_force) self.previous_force = temp # copy force in beam old_g = self.structural_solver.settings['gravity'].value self.structural_solver.settings[ 'gravity'] = old_g * load_step_multiplier temp1 = load_step_multiplier * ( struct_forces + self.data.structure.ini_info.steady_applied_forces) self.data.structure.timestep_info[ self.data.ts].steady_applied_forces[:] = temp1 # run beam self.data = self.structural_solver.run() self.structural_solver.settings['gravity'] = ct.c_double(old_g) (self.data.structure.timestep_info[ self.data.ts].total_forces[0:3], self.data.structure.timestep_info[self.data.ts]. total_forces[3:6]) = (self.extract_resultants( self.data.structure.timestep_info[self.data.ts])) # update grid self.aero_solver.update_step() # convergence if self.convergence(i_iter, i_step): # create q and dqdt vectors self.structural_solver.update( self.data.structure.timestep_info[self.data.ts]) self.cleanup_timestep_info() break return self.data
def run(self): # Include the rbm # print("ts", self.data.ts) self.data.structure.timestep_info[ -1].for_vel = self.data.structure.dynamic_input[0]['for_vel'] for i_step in range(self.settings['n_load_steps'].value + 1): if (i_step == self.settings['n_load_steps'].value and self.settings['n_load_steps'].value > 0): break # load step coefficient if not self.settings['n_load_steps'].value == 0: load_step_multiplier = ( i_step + 1.0) / self.settings['n_load_steps'].value else: load_step_multiplier = 1.0 # new storage every load step if i_step > 0: self.increase_ts() for i_iter in range(self.settings['max_iter'].value): if self.settings['print_info'].value: cout.cout_wrap('i_step: %u, i_iter: %u' % (i_step, i_iter)) # run aero self.data = self.aero_solver.run() # map force struct_forces = mapping.aero2struct_force_mapping( self.data.aero.timestep_info[self.data.ts].forces, self.data.aero.struct2aero_mapping, self.data.aero.timestep_info[self.data.ts].zeta, self.data.structure.timestep_info[self.data.ts].pos, self.data.structure.timestep_info[self.data.ts].psi, self.data.structure.node_master_elem, self.data.structure.connectivities, self.data.structure.timestep_info[self.data.ts].cag()) if not self.settings['relaxation_factor'].value == 0.: if i_iter == 0: self.previous_force = struct_forces.copy() temp = struct_forces.copy() struct_forces = ( (1.0 - self.settings['relaxation_factor'].value) * struct_forces + self.settings['relaxation_factor'].value * self.previous_force) self.previous_force = temp # copy force in beam with_gravity_setting = True try: old_g = self.structural_solver.settings['gravity'].value self.structural_solver.settings[ 'gravity'] = old_g * load_step_multiplier except KeyError: with_gravity_setting = False temp1 = load_step_multiplier * ( struct_forces + self.data.structure.ini_info.steady_applied_forces) self.data.structure.timestep_info[ self.data.ts].steady_applied_forces[:] = temp1 # run beam prev_quat = self.data.structure.timestep_info[ self.data.ts].quat.copy() self.data = self.structural_solver.run() # The following line removes the rbm self.data.structure.timestep_info[ self.data.ts].quat = prev_quat.copy() if with_gravity_setting: self.structural_solver.settings['gravity'] = ct.c_double( old_g) # update grid self.aero_solver.update_step() # print("psi[-1]", self.data.structure.timestep_info[-1].psi[-1,1,:]) # convergence if self.convergence(i_iter): # create q and dqdt vectors self.structural_solver.update( self.data.structure.timestep_info[self.data.ts]) self.data = self.aero_solver.run() self.cleanup_timestep_info() break if self.settings['print_info']: resultants = self.extract_resultants() cout.cout_wrap('Resultant forces and moments: ' + str(resultants)) return self.data