def solve_nonlinear_dynamic(component, t0, t_end): system, formulation = create_mechanical_system( component, constant_mass=True, constant_damping=True, constraint_formulation='boolean') solfac = SolverFactory() solfac.set_system(system) solfac.set_analysis_type('transient') solfac.set_integrator('genalpha') solfac.set_large_deflection(True) solfac.set_nonlinear_solver('newton') solfac.set_linear_solver('scipy-sparse') solfac.set_acceleration_intializer('zero') solfac.set_newton_maxiter(30) solfac.set_newton_atol(1e-6) solfac.set_newton_rtol(1e-8) solfac.set_dt_initial(0.001) solver = solfac.create_solver() solution_writer = AmfeSolution() def write_callback(t, x, dx, ddx): u, du, ddu = formulation.recover(x, dx, ddx, t) solution_writer.write_timestep(t, u, None, None) no_of_dofs = system.dimension q0 = np.zeros(no_of_dofs) dq0 = q0 solver.solve(write_callback, t0, q0, dq0, t_end) return solution_writer
# ----------------------------------------- NONLINEAR DYNAMIC ANALYSIS ------------------------------------------------ system, formulation = create_constrained_mechanical_system_from_component( my_component, constant_mass=True, constant_damping=True, constraint_formulation='lagrange', scaling=10.0, penalty=3.0) solfac = SolverFactory() solfac.set_system(system) solfac.set_analysis_type('transient') solfac.set_integrator('genalpha') solfac.set_large_deflection(True) solfac.set_nonlinear_solver('newton') solfac.set_linear_solver('scipy-sparse') solfac.set_acceleration_intializer('zero') solfac.set_newton_maxiter(30) solfac.set_newton_atol(1e-6) solfac.set_newton_rtol(1e-8) solfac.set_dt_initial(0.001) residuals = list() mysolver = solfac.create_solver() writer = AmfeSolution() def write_callback(t, x, dx, ddx):