amfe.solver module

Module for solving static and dynamic problems.

amfe.solver.integrate_nonlinear_gen_alpha(mechanical_system, q0, dq0, time_range, dt, rho_inf=0.9, rtol=1e-09, atol=1e-06, verbose=False, n_iter_max=30, conv_abort=True, write_iter=False, track_niter=True, matrix_type='symm')[source]

Time integration of the non-linear second-order system using the gerneralized-alpha scheme.

Parameters:
  • mechanical_system (instance of MechanicalSystem) –
  • of MechanicalSystem, which should be integrated. (Instance) –
q0
: ndarray
Start displacement.
dq0
: ndarray
Start velocity.
time_range
: ndarray
Array of discrete timesteps, at which the solution is saved.
dt
: float
Time step size of the integrator.
rho_inf
: float, optional
high-frequency spectral radius, has to be 0 <= rho_inf <= 1. For 1 no damping is apparent, for 0 maximum damping is there. Default value: 0.9
rtol
: float, optional
Relative tolerance with respect to the maximum external force for the Newton-Raphson iteration. Default value: 1E-8.
atol
: float, optional
Absolute tolerance for the Newton_Raphson iteration. Default value: 1E-6.
verbose
: bool, optional
Flag setting verbose output. Default: False.
n_iter_max
: int, optional
Number of maximum iterations per Newton-Raphson-procedure. Default value is 30.
conv_abort
: bool, optional
Flag setting, if time integration is aborted in the case when no convergence is gained in the Newton-Raphson-Loop. Default value is True.
write_iter
: bool, optional
Flag setting, if every step of the Newton-Raphson iteration is written to the MechanicalSystem object. Useful only for debugging, when no convergence is gained. Default value: False.
track_niter
: bool, optional
Flag for the iteration-count. If True, the number of iterations in the Newton-Raphson-Loop is counted and saved to iteration_info in the mechanical system.

References

[R2]J. Chung and G. Hulbert. A time integration algorithm for structural dynamics with improved numerical dissipation: the generalized-α method. Journal of applied mechanics, 60(2):371–375, 1993.
[R3]O. A. Bauchau: Flexible Multibody Dynamics. Springer, 2011. pp. 664.
amfe.solver.integrate_linear_gen_alpha(mechanical_system, q0, dq0, time_range, dt, rho_inf=0.9)[source]

Time integration of the linearized second-order system using the gerneralized-alpha scheme.

Parameters:
  • mechanical_system (instance of MechanicalSystem) – Mechanical System which is linearized about the zero displacement.
  • q0 (ndarray) – initial displacement
  • dq0 (ndarray) – initial velocity
  • time_range (ndarray) – array containing the time steps to be exported
  • dt (float) – time step size.
  • rho_inf (float, >= 0, <= 1) – high-frequency spectral radius, has to be 0 <= rho_inf <= 1. For 1 no damping is apparent, for 0 maximum damping is there. Default value: 0.9
  • ..
  • rho_inf – high-frequency spectral radius
  • ..
  • TODO
Returns:

Return type:

None

amfe.solver.solve_linear_displacement(mechanical_system, t=1, verbose=True)[source]

Solve the linear static problem of the mechanical system and print the results directly to the mechanical system.

Parameters:
  • mechanical_system (Instance of the class MechanicalSystem) – Mechanical system to be solved.
  • t (float) – time for the external force call in MechanicalSystem.
  • verbose (bool) – Flag for verbose output.
Returns:

u – Static solution displacement field

Return type:

ndaray

amfe.solver.solve_nonlinear_displacement(mechanical_system, no_of_load_steps=10, t=0, rtol=1e-08, atol=1e-14, newton_damping=1, n_max_iter=1000, smplfd_nwtn_itr=1, verbose=True, track_niter=False, write_iter=False, conv_abort=True, save=True)[source]

Solver for the nonlinear system applied directly on the mechanical system.

Prints the results directly to the mechanical system

Parameters:
  • mechanical_system (MechanicalSystem) – Instance of the class MechanicalSystem
  • no_of_load_steps (int) – Number of equally spaced load steps which are applied in order to receive the solution
  • t (float, optional) – time for the external force call in mechanical_system
  • rtol (float, optional) – Relative tolerance to external force for estimation, when a loadstep has converged
  • atol (float, optional) – Absolute tolerance for estimation, of loadstep has converged
  • newton_damping (float, optional) – Newton-Damping factor applied in the solution routine; 1 means no damping, 0 < newton_damping < 1 means damping
  • n_max_iter (int, optional) – Maximum number of interations in the Newton-Loop
  • smplfd_nwtn_itr (int, optional) – Number at which the jacobian is updated; if 1, then a full newton scheme is applied; if very large, it’s a fixpoint iteration with constant jacobian
  • verbose (bool, optional) – print messages if necessary
  • track_niter (bool, optional) – Flag for the iteration-count. If True, the number of iterations in the Newton-Raphson-Loop is counted and saved to iteration_info in the mechanical system.
  • write_iter (bool, optional) – Flag setting, if every step of the Newton-Raphson iteration is written to the MechanicalSystem object. Useful only for debugging, when no convergence is gained. Default value: False.
  • conv_abort (bool, optional) – Flag setting, if time integration is aborted in the case when no convergence is gained in the Newton-Raphson-Loop. Default value is True.
  • save (bool, optional) – Write the resulting load steps to the MechanicalSystem to export it afterwards. Default value: True
Returns:

u – Solution displacements; u[:,-1] is the last displacement

Return type:

ndarray, shape(ndim, no_of_load_steps)

Examples

TODO

amfe.solver.give_mass_and_stiffness(mechanical_system)[source]

Determine mass and stiffness matrix of a mechanical system.

Parameters:mechanical_system (MechanicalSystem) – Instance of the class MechanicalSystem
Returns:
  • M (ndarray) – Mass matrix of the mechanical system
  • K (ndarray) – Stiffness matrix of the mechanical system
amfe.solver.integrate_linear_system(mechanical_system, q0, dq0, time_range, dt, alpha=0)[source]

Perform an implicit time integration of the linearized system given with the linear system.

Parameters:
  • mechanical_system (instance of MechanicalSystem) – Mechanical System which is linearized about the zero displacement.
  • q0 (ndarray) – initial displacement
  • dq0 (ndarray) – initial velocity
  • time_range (ndarray) – array containing the time steps to be exported
  • dt (float) – time step size.
  • alpha (float) – general damping factor of the generalized-alpha method.
Returns:

Return type:

None

Notes

Due to round-off-errors, the internal time step width is h and is very close to dt, but adjusted to fit the steps exactly.

amfe.solver.integrate_nonlinear_system(mechanical_system, q0, dq0, time_range, dt, alpha=0.01, rtol=1e-08, atol=1e-06, verbose=False, n_iter_max=30, conv_abort=True, write_iter=False, track_niter=False)[source]

Time integrate the nonlinear system using a Newmark-scheme.

Parameters:
  • mechanical_system (instance of MechanicalSystem) – Instance of MechanicalSystem, which should be integrated.
  • q0 (ndarray) – Start displacement.
  • dq0 (ndarray) – Start velocity.
  • time_range (ndarray) – Array of discrete timesteps, at which the solution is saved.
  • dt (float) – Time step size of the integrator.
  • alpha (float, optional) – HHT-damping factor for numerical damping. If alpha=0, no numerical damping is introduced, if alpha=0.3, the maximum numerical damping is introduced. Default value: 0.01
  • rtol (float, optional) – Relative tolerance with respect to the maximum external force for the Newton-Raphson iteration. Default value: 1E-8.
  • atol (float, optional) – Absolute tolerance for the Newton_Raphson iteration. Default value: 1E-6.
  • verbose (bool, optional) – Flag setting verbose output. Default: False.
  • n_iter_max (int, optional) – Number of maximum iterations per Newton-Raphson-procedure. Default value is 30.
  • conv_abort (bool, optional) – Flag setting, if time integration is aborted in the case when no convergence is gained in the Newton-Raphson-Loop. Default value is True.
  • write_iter (bool, optional) – Flag setting, if every step of the Newton-Raphson iteration is written to the MechanicalSystem object. Useful only for debugging, when no convergence is gained. Default value: False.
  • track_niter (bool, optional) – Flag for the iteration-count. If True, the number of iterations in the Newton-Raphson-Loop is counted and saved to iteration_info in the mechanical system.
Returns:

Return type:

None

References

[R4]M. Géradin and D. J. Rixen. Mechanical vibrations: theory and application to structural dynamics. John Wiley & Sons, 2014. pp. 564.
[R5]O. A. Bauchau: Flexible Multibody Dynamics. Springer, 2011. pp. 664.
amfe.solver.solve_sparse(A, b, matrix_type='symm', verbose=False)[source]

Abstractoin of the solution of the sparse system Ax=b using the fastest solver available for sparse and non-sparse matrices.

Parameters:
  • A (sp.sparse.CSR) – sparse matrix in CSR-format
  • b (ndarray) – right hand side of equation
  • matrixd_type ({'spd', 'symm', 'unsymm'}, optional) –

    Specifier for the matrix type:

    • ‘spd’ : symmetric positive definite
    • ‘symm’ : symmetric indefinite, default.
    • ‘unsymm’ : generally unsymmetric
Returns:

x – solution of system Ax=b

Return type:

ndarray

Notes

This tool uses the Intel MKL library provided by Anaconda. If the Intel MKL is not installed, especially for large systems the computation time can go crazy. To adjust the number of threads used for the computation, it is recommended to use the mkl-service module provided by Anaconda:

>>> import mkl
>>> mkl.get_max_threads()
2
>>> mkl.set_num_threads(1)
>>> mkl.get_max_threads()
1
class amfe.solver.SpSolve(A, matrix_type='symm', verbose=False)[source]

Bases: object

Solver class for solving the sparse system Ax=b for multiple right hand sides b using the fastest solver available, i.e. the Intel MKL Pardiso, if available.

clear()[source]

Clear the memory, if possible.

solve(b)[source]

Solve the system for the given right hand side b.

Parameters:b (ndarray) – right hand side of equation
Returns:x – solution of the sparse equation Ax=b
Return type:ndarray