KeyError when accessing gravity if not defined in structural solver fixed
@@ -154,8 +154,12 @@ class StaticCoupledRBM(BaseSolver):
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
@@ -163,6 +167,7 @@ class StaticCoupledRBM(BaseSolver):
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
