variational_integrator Derived Type

type, public :: variational_integrator

Implements the maximal-coordinate variational integrator in Brudigam et al. (2023), equations (18)-(20). The nonlinear system is solved with damped Newton iterations and either dense LU or the paper's graph-structured block factorization.


Contents


Components

Type Visibility Attributes Name Initial
type(variational_integrator_settings), public :: settings

Numerical settings used by the integrator.


Type-Bound Procedures

procedure, public :: solve => vi_solve

Computes the solution.

  • private function vi_solve(this, bodies, state, dt, ntime, constraint_count, constraint, force_function, constraint_jacobian, multipliers, args, info) result(rst)

    Computes the solution for the rigid-body system for the specified number of sequential time steps.

    Arguments

    Type IntentOptional Attributes Name
    class(variational_integrator), intent(in) :: this

    The variational integrator.

    type(rigid_body), intent(in), dimension(:) :: bodies

    The body mass and body-frame inertia properties.

    type(variational_state), intent(inout) :: state

    On input, the initial state; on output, the final completed state.

    real(kind=real64), intent(in) :: dt

    The positive fixed time step.

    integer(kind=int32), intent(in) :: ntime

    The number of times steps to take.

    integer(kind=int32), intent(in), optional :: constraint_count

    The number of scalar equality constraints. The default is zero.

    procedure(variational_constraint), intent(in), optional, pointer :: constraint

    The holonomic equality-constraint callback. It is required when constraint_count is greater than zero.

    procedure(variational_force), intent(in), optional, pointer :: force_function

    The external force and torque callback. When omitted, all applied forces and torques are zero.

    procedure(variational_constraint_jacobian), intent(in), optional, pointer :: constraint_jacobian

    An optional analytic reduced constraint Jacobian. When omitted, the Jacobian is evaluated by finite differences.

    real(kind=real64), intent(out), optional, allocatable, dimension(:,:) :: multipliers

    The Nconstraint-by-Ntime Lagrange multiplier history on success. On recoverable failure, contains only multipliers for completed steps; the final column requires a successful noncommitting look-ahead. A multiplier for the interval beginning at time point i is in column i because the discrete force uses the constraint Jacobian at that point.

    class(*), intent(inout), optional :: args

    Optional user-supplied data forwarded to all callbacks.

    type(variational_integrator_info), intent(out), optional :: info

    Optional diagnostics; iterations are summed over attempted steps, including the look-ahead when multipliers are requested. On failure, rst contains the initial state and all completed steps.

    Return Value type(variational_state), allocatable, dimension(:)

    The solution at each time step.

procedure, public :: step => vi_step

Advances a maximal-coordinate rigid-body state by one step.

  • private subroutine vi_step(this, bodies, state, dt, constraint_count, constraint, force_function, constraint_jacobian, multipliers, args, info)

    Advances a rigid-body system by one fixed time step. The unknown vector contains the next translational and body-frame angular velocities, followed by the equality-constraint multipliers. Orientations are advanced with the unit quaternion increment

    Arguments

    Type IntentOptional Attributes Name
    class(variational_integrator), intent(in) :: this

    The variational integrator.

    type(rigid_body), intent(in), dimension(:) :: bodies

    The body mass and body-frame inertia properties.

    type(variational_state), intent(inout) :: state

    On input, the current state; on output, the converged next state. On recoverable failure, the state is unchanged.

    real(kind=real64), intent(in) :: dt

    The positive fixed time step.

    integer(kind=int32), intent(in), optional :: constraint_count

    The number of scalar equality constraints. The default is zero.

    procedure(variational_constraint), intent(in), optional, pointer :: constraint

    The holonomic equality-constraint callback. It is required when constraint_count is greater than zero.

    procedure(variational_force), intent(in), optional, pointer :: force_function

    The external force and torque callback. When omitted, all applied forces and torques are zero.

    procedure(variational_constraint_jacobian), intent(in), optional, pointer :: constraint_jacobian

    An optional analytic reduced constraint Jacobian. When omitted, the Jacobian is evaluated by finite differences.

    real(kind=real64), intent(out), optional, allocatable, dimension(:) :: multipliers

    The converged Lagrange multipliers; unallocated on recoverable failure.

    class(*), intent(inout), optional :: args

    Optional user-supplied data forwarded to all callbacks.

    type(variational_integrator_info), intent(out), optional :: info

    Optional convergence diagnostics. When present, convergence failures are returned instead of terminating execution; when absent, the legacy error-stop behavior is retained.