heyoka.lagrangian#
- heyoka.lagrangian(L: expression, qs: list[expression], qdots: list[expression], D: expression = expression(0.)) list[tuple[expression, expression]] #
Formulate the Euler-Lagrange equations for a Lagrangian.
Added in version 4.0.0.
Note
A tutorial illustrating the use of this function is available.
This function will formulate the differential equations for the Lagrangian L. The lists of generalised coordinates and velocities are given in qs and qdots respectively. D is an optional Rayleigh dissipation function - a quadratic form in the generalised velocities that can be used to add dissipative forces to the dynamical system.
An error will be raised if one or more input arguments are malformed. Specifically:
qs and qdots must be non-empty and have the same length,
all expressions in qs and qdots must be variables,
qs and qdots must not contain duplicates, and a variable appearing in one list cannot appear in the other,
L must depend only on the variables listed in qs and qdots,
D must depend only on the variables listed in qdots.
- Parameters:
L – the Lagrangian.
qs – the generalised coordinates.
qdots – the generalised velocities.
D – the Rayleigh dissipation function.
- Returns:
the Euler-Lagrange equations in explicit form for the Lagrangian L.
- Raises:
ValueError – if one or more input arguments are malformed, as explained above.