Kane’s Method & Lagrange’s Method (Docstrings)¶
- class sympy.physics.mechanics.kane.KanesMethod(
- frame,
- q_ind,
- u_ind,
- kd_eqs=None,
- q_dependent=None,
- configuration_constraints=None,
- u_dependent=None,
- velocity_constraints=None,
- acceleration_constraints=None,
- u_auxiliary=None,
- bodies=None,
- forcelist=None,
- explicit_kinematics=True,
- kd_eqs_solver='LU',
- constraint_solver='LU',
- nonholonomic_constraints=None,
Kane’s method for forming the equations of motion of a multibody system.
- Parameters:
frame : ReferenceFrame
The inertial reference frame for the system.
q_ind : iterable of dynamicsymbols
Independent generalized coordinates.
u_ind : iterable of dynamicsymbols
Independent generalized speeds.
kd_eqs : iterable of Expr, optional
Kinematic differential equations, which linearly relate the generalized speeds to the time-derivatives of the generalized coordinates.
q_dependent : iterable of dynamicsymbols, optional
Dependent generalized coordinates.
configuration_constraints : iterable of Expr, optional
Constraints on the system’s configuration, i.e. holonomic constraints.
u_dependent : iterable of dynamicsymbols, optional
Dependent generalized speeds.
nonholonomic_constraints : iterable of Expr, optional
Constraints that are strictly nonholonomic in nature. If provided,
velocity_constraintswill be ignored and determined automatically.velocity_constraints : iterable of Expr, optional
Constraints on the system’s velocity, i.e. the combination of the nonholonomic constraints and the time-derivative of the holonomic constraints.
acceleration_constraints : iterable of Expr, optional
Constraints on the system’s acceleration, by default these are the time-derivative of the velocity constraints.
u_auxiliary : iterable of dynamicsymbols, optional
Auxiliary generalized speeds.
bodies : iterable of Particle and/or RigidBody, optional
The particles and rigid bodies in the system.
forcelist : iterable of tuple[Point | ReferenceFrame, Vector], optional
Forces and torques applied on the system.
explicit_kinematics : bool
Boolean whether the mass matrices and forcing vectors should use the explicit form (default) or implicit form for kinematics. See the notes for more details.
kd_eqs_solver : str, callable
Method used to solve the kinematic differential equations. If a string is supplied, it should be a valid method that can be used with the
sympy.matrices.matrixbase.MatrixBase.solve(). If a callable is supplied, it should have the formatf(A, rhs), where it solves the equations and returns the solution. The default utilizes LU solve. See the notes for more information.constraint_solver : str, callable
Method used to solve the velocity constraints. If a string is supplied, it should be a valid method that can be used with the
sympy.matrices.matrixbase.MatrixBase.solve(). If a callable is supplied, it should have the formatf(A, rhs), where it solves the equations and returns the solution. The default utilizes LU solve. See the notes for more information.nonholonomic_constraints : iterable of Expr, optional
Nonholonomic constraint residuals. Can be supplied instead of
velocity_constraints, but not together with. If supplied, thevelocity_constraintsare automatically generated by time differentiating the holonomic constraints.
Explanation
This class is used to do the bookkeeping as you form equations of motion in method presented in [R999].
Kane’s dynamical differential equations are given as:
\[F_r + F_r^* = 0\]For \(r = 1, ..., p\) of \(p\) independent generalized speeds.
These can be expressed in a matrix for with the linear mass matrix exposed:
\[\mathbf{M} \dot{\vec{u}} = \mathbf{F}\]Notes
The mass matrices and forcing vectors related to kinematic equations are given in the explicit form by default. In other words, the kinematic mass matrix is \(\mathbf{k_{k\dot{q}}} = \mathbf{I}\). In order to get the implicit form of those matrices/vectors, you can set the
explicit_kinematicsattribute toFalse. So \(\mathbf{k_{k\dot{q}}}\) is not necessarily an identity matrix. This can provide more compact equations for non-simple kinematics.Two linear solvers can be supplied to
KanesMethod: one for solving the kinematic differential equations and one to solve the velocity constraints. Both of these sets of equations can be expressed as a linear systemAx = rhs, which have to be solved in order to obtain the equations of motion.The default solver
'LU', which stands for LU solve, results relatively low number of operations. The weakness of this method is that it can result in zero division errors.If zero divisions are encountered, a possible solver which may solve the problem is
"CRAMER". This method uses Cramer’s rule to solve the system. This method is slower and results in more operations than the default solver. However it only uses a single division by default per entry of the solution.While a valid list of solvers can be found at
solve(), it is also possible to supply a “callable”. This way it is possible to use a different solver routine. If the kinematic differential equations are not too complex it can be worth it to simplify the solution by usinglambda A, b: simplify(Matrix.LUsolve(A, b)). Another option solver one may use islinsolve(). This can be done usinglambda A, b: tuple(linsolve((A, b)))[0], where we select the first solution as our system should have only one unique solution.Examples
This is a simple example for a one degree of freedom translational spring-mass-damper.
In this example, we first need to do the kinematics. This involves creating generalized speeds and coordinates and their derivatives. Then we create a point and set its velocity in a frame.
>>> from sympy import symbols >>> from sympy.physics.mechanics import dynamicsymbols, ReferenceFrame >>> from sympy.physics.mechanics import Point, Particle, KanesMethod >>> q, u = dynamicsymbols('q u') >>> qd, ud = dynamicsymbols('q u', 1) >>> m, c, k = symbols('m c k') >>> N = ReferenceFrame('N') >>> P = Point('P') >>> P.set_vel(N, u * N.x)
Next we need to arrange/store information in the way that KanesMethod requires. The kinematic differential equations should be an iterable of expressions. A list of forces/torques must be constructed, where each entry in the list is a (Point, Vector) or (ReferenceFrame, Vector) tuple, where the Vectors represent the Force or Torque. Next a particle needs to be created, and it needs to have a point and mass assigned to it. Finally, a list of all bodies and particles needs to be created.
>>> kd = [qd - u] >>> FL = [(P, (-k * q - c * u) * N.x)] >>> pa = Particle('pa', P, m) >>> BL = [pa]
Finally we can generate the equations of motion. First we create the KanesMethod object and supply an inertial frame, coordinates, generalized speeds, and the kinematic differential equations. Additional quantities such as configuration and motion constraints, dependent coordinates and speeds, and auxiliary speeds are also supplied here (see the online documentation). Next we form FR* and FR to complete: Fr + Fr* = 0. We have the equations of motion at this point. It makes sense to rearrange them though, so we calculate the mass matrix and the forcing terms, for E.o.M. in the form: [MM] udot = forcing, where MM is the mass matrix, udot is a vector of the time derivatives of the generalized speeds, and forcing is a vector representing “forcing” terms.
>>> KM = KanesMethod(N, q_ind=[q], u_ind=[u], kd_eqs=kd) >>> (fr, frstar) = KM.kanes_equations(BL, FL) >>> MM = KM.mass_matrix >>> forcing = KM.forcing >>> rhs = MM.inv() * forcing >>> rhs Matrix([[(-c*u(t) - k*q(t))/m]]) >>> KM.linearize(A_and_B=True)[0] Matrix([ [ 0, 1], [-k/m, -c/m]])
Please look at the documentation pages for more information on how to perform linearization and how to deal with dependent coordinates & speeds, and how do deal with bringing non-contributing forces into evidence.
References
Attributes
Specific to Kane’s method:
mass_matrix_kin
(Matrix) The “mass matrix” for kinematic differential equations: k_kqdot
forcing_kin
(Matrix) The forcing vector for kinematic differential equations: -(k_ku*u + f_k)
auxiliary_eqs
(Matrix) If applicable, the set of auxiliary Kane’s equations used to solve for non-contributing forces.
bodylist
(list) List of the particles and rigid bodies in the system. Deprecated: use
bodiesinstead.forcelist
(list) List of the forces and torques acting on the system. Deprecated: use
loadsinstead.Shared by all methods:
frame
(ReferenceFrame) Inertial reference frame that the equations of motion were formulated with respect to.
q
(Matrix) Column matrix of the generalized coordinates.
u
(Matrix) Column matrix of the generalized speeds.
holonomic_constraints
(Matrix, shape(len(q_dependent), 1)) Column matrix of the holonomic constraint residuals.
nonholonomic_constraints
(Matrix, shape(len(u_dependent), 1)) Column matrix of the nonholonomic constraint residuals.
velocity_constraints
(Matrix, shape(len(q_dependent) + len(u_dependent), 1)) Column matrix of the time differentiated holonomic constraint residuals stacked on top of the nonholonomic constraint residuals.
acceleration_constraints
(Matrix, shape(len(q_dependent) + len(u_dependent), 1)) Column matrix of the time differentiated velocity constraints or user supplied.
constraints_jacobian
(Matrix, shape(len(u_dependent), len(u))) Linear coefficient matrix with respect to the generalized speeds is extracted from the velocity constraints.
bodies
(list) List of Particle and RigidBody objects in the system.
loads
(list) List of (Point, vector) or (ReferenceFrame, vector) tuples describing the forces on the system.
mass_matrix
(Matrix) The system’s dynamics mass matrix: [k_d; k_dnh]
forcing
(Matrix) The system’s dynamics forcing vector: -[f_d; f_dnh]
mass_matrix_full
(Matrix) The “mass matrix” for the u’s and q’s with dynamics and kinematics
forcing_full
(Matrix) The “forcing vector” for the u’s and q’s with dynamics and kinematics
- property acceleration_constraints¶
Column matrix of acceleration constraint residuals.
- property auxiliary_eqs¶
A matrix containing the auxiliary equations.
- property bodylist¶
List of particles and/or rigid bodies in the system.
Deprecated since version 1.15: KanesMethod now uses consistent attribute names among all methods classes. Use
bodiesinstead.
- property constraints_jacobian¶
Coefficient matrix
Cwhich is the Jacobian of the constraints with respect to the generalized speedsu.Explanation
The matrix is extracted from
velocity_constraints.fv = C*u + gv(q, t) = C*u + gv(q, t) = 0
- property forcelist¶
List of (Point, Vector) or (ReferenceFrame, Vector) tuples representing forces and torques applied to the system.
Deprecated since version 1.15: KanesMethod now uses consistent attribute names among all methods classes. Use
loadsinstead.
- property forcing¶
The forcing vector of the system.
- property forcing_full¶
The forcing vector of the system, augmented by the kinematic differential equations in explicit or implicit form.
- property forcing_kin¶
The kinematic “forcing vector” of the system.
- property frame¶
Inertial reference frame that the equations of motion were formulated with respect to.
- property holonomic_constraints¶
Column matrix holonomic configuration constraint residuals.
- kanes_equations(
- bodies=None,
- loads=None,
Method to form Kane’s equations, Fr + Fr* = 0.
- Parameters:
bodies : iterable
An iterable of all RigidBody’s and Particle’s in the system. A system must have at least one body.
loads : iterable
Takes in an iterable of (Particle, Vector) or (ReferenceFrame, Vector) tuples which represent the force at a point or torque on a frame. Must be either a non-empty iterable of tuples or None which corresponds to a system with no constraints.
Explanation
Returns (Fr, Fr*). In the case where auxiliary generalized speeds are present (say, s auxiliary speeds, o generalized speeds, and m motion constraints) the length of the returned vectors will be o - m + s in length. The first o - m equations will be the constrained Kane’s equations, then the s auxiliary Kane’s equations. These auxiliary equations can be accessed with the auxiliary_eqs property.
- linearize(
- *,
- new_method=None,
- linear_solver='LU',
- **kwargs,
Linearize the equations of motion about a symbolic operating point.
- Parameters:
new_method
Deprecated, does nothing and will be removed.
linear_solver : str, callable
Method used to solve the several symbolic linear systems of the form
A*x=bin the linearization process. If a string is supplied, it should be a valid method that can be used with thesympy.matrices.matrixbase.MatrixBase.solve(). If a callable is supplied, it should have the formatx = f(A, b), where it solves the equations and returns the solution. The default is'LU'which corresponds to SymPy’sA.LUsolve(b).LUsolve()is fast to compute but will often result in divide-by-zero and thusnanresults.**kwargs
Extra keyword arguments are passed to
sympy.physics.mechanics.linearize.Linearizer.linearize().
Explanation
If kwarg A_and_B is False (default), returns M, A, B, r for the linearized form, M*[q’, u’]^T = A*[q_ind, u_ind]^T + B*r.
If kwarg A_and_B is True, returns A, B, r for the linearized form dx = A*x + B*r, where x = [q_ind, u_ind]^T. Note that this is computationally intensive if there are many symbolic parameters. For this reason, it may be more desirable to use the default A_and_B=False, returning M, A, and B. Values may then be substituted in to these matrices, and the state space form found as A = P.T*M.inv()*A, B = P.T*M.inv()*B, where P = Linearizer.perm_mat.
In both cases, r is found as all dynamicsymbols in the equations of motion that are not part of q, u, q’, or u’. They are sorted in canonical form.
The operating points may be also entered using the
op_pointkwarg. This takes a dictionary of {symbol: value}, or a an iterable of such dictionaries. The values may be numeric or symbolic. The more values you can specify beforehand, the faster this computation will run.For more documentation, please see the
Linearizerclass.
- property loads¶
List of
Force,Torque, tuple(Point,Vector), tuple(ReferenceFrame,Vector) loads applied to multibody system.
- property mass_matrix¶
The mass matrix of the system.
- property mass_matrix_full¶
The mass matrix of the system, augmented by the kinematic differential equations in explicit or implicit form.
- property mass_matrix_kin¶
The kinematic “mass matrix” \(\mathbf{k_{k\dot{q}}}\) of the system.
- property nonholonomic_constraints¶
Column matrix of nonholonomic constraint residuals.
- property q¶
Column matrix of the independent generalized coordinates followed by the dependent coordinates.
- rhs(inv_method=None)[source]¶
Returns the system’s equations of motion in first order form. The output is the right hand side of:
x' = |q'| =: f(q, u, r, p, t) |u'|
The right hand side is what is needed by most numerical ODE integrators.
- Parameters:
inv_method : str
The specific sympy inverse matrix calculation method to use. For a list of valid methods, see
inv()
- to_linearizer(linear_solver='LU')[source]¶
Returns an instance of the Linearizer class, initiated from the data in the KanesMethod class. This may be more desirable than using the linearize class method, as the Linearizer object will allow more efficient recalculation (i.e. about varying operating points).
- Parameters:
linear_solver : str, callable
Method used to solve the several symbolic linear systems of the form
A*x=bin the linearization process. If a string is supplied, it should be a valid method that can be used with thesympy.matrices.matrixbase.MatrixBase.solve(). If a callable is supplied, it should have the formatx = f(A, b), where it solves the equations and returns the solution. The default is'LU'which corresponds to SymPy’sA.LUsolve(b).LUsolve()is fast to compute but will often result in divide-by-zero and thusnanresults.- Returns:
Linearizer
An instantiated
sympy.physics.mechanics.linearize.Linearizer.
- property u¶
Column matrix of the independent generalized speeds followed by the dependent generalized speeds.
- property velocity_constraints¶
Column matrix of velocity constraint residuals. Time differentiated holonomic constraint residuals stacked on top of the nonholonomic constraint residuals.
- class sympy.physics.mechanics.lagrange.LagrangesMethod(
- Lagrangian,
- qs,
- forcelist=None,
- bodies=None,
- frame=None,
- hol_coneqs=None,
- nonhol_coneqs=None,
Lagrange’s method for forming the equations of motion of a multibody system.
- Parameters:
Lagrangian : Sympifyable
Scalar expression comprised of the sum of the system’s kinetic energy and potential energy that is a function of q and q’.
qs : iterable of functions of time
Generalized coordinates q of the multibody system.
hol_coneqs : iterable of Expr, optional
Holonomic constraint residuals.
nonhol_coneqs : iterable of Expr, optional
Nonholonomic constraint residuals.
forcelist : iterable, optional
Iterable of (Point, Vector) or (ReferenceFrame, Vector) tuples or Force and Torque objects which represent the force at a point or torque on a frame. Only nonconservative forces and/or torques should be included if the conservative forces are already present in the Lagrangian.
bodies : iterable, optional
frame : ReferenceFrame, optional
Inertial reference frame that should match the one used to form the Lagrangian. Only required if
forcelistis provided.
Explanation
This object generates the equations of motion in a two step procedure. The first step involves the initialization of LagrangesMethod by supplying the Lagrangian and the generalized coordinates, at the bare minimum. If there are any constraint equations, they can be supplied as keyword arguments. The Lagrange multipliers are automatically generated and are equal in number to the constraint equations. Similarly any non-conservative forces can be supplied in an iterable (as described below and also shown in the example) along with a ReferenceFrame.
Examples
This is a simple example for a one degree of freedom translational spring-mass-damper.
In this example, we first need to do the kinematics. This involves creating generalized coordinates and their derivatives. Then we create a point and set its velocity in a frame.
>>> from sympy.physics.mechanics import LagrangesMethod, Lagrangian >>> from sympy.physics.mechanics import ReferenceFrame, Particle, Point >>> from sympy.physics.mechanics import dynamicsymbols >>> from sympy import symbols >>> q = dynamicsymbols('q') >>> qd = dynamicsymbols('q', 1) >>> m, k, b = symbols('m k b') >>> N = ReferenceFrame('N') >>> P = Point('P') >>> P.set_vel(N, qd * N.x)
We need to then prepare the information as required by LagrangesMethod to generate equations of motion. First we create the Particle, which has a point attached to it. Following this the lagrangian is created from the kinetic and potential energies. Then, an iterable of nonconservative forces/torques must be constructed, where each item is a (Point, Vector) or (ReferenceFrame, Vector) tuple, with the Vectors representing the nonconservative forces or torques.
>>> Pa = Particle('Pa', P, m) >>> Pa.potential_energy = k * q**2 / 2 >>> L = Lagrangian(N, Pa) >>> fl = [(P, -b * qd * N.x)]
Finally we can generate the equations of motion. First we create the LagrangesMethod object. To do this one must supply the Lagrangian, and the generalized coordinates. The constraint equations, the forcelist, and the inertial frame may also be provided, if relevant. Next we generate Lagrange’s equations of motion, such that: Lagrange’s equations of motion = 0. We have the equations of motion at this point.
>>> l = LagrangesMethod(L, [q], forcelist = fl, frame = N) >>> print(l.form_lagranges_equations()) Matrix([[b*Derivative(q(t), t) + k*q(t) + m*Derivative(q(t), (t, 2))]])
We can also solve for the states using the
rhs()method.>>> print(l.rhs()) Matrix([[Derivative(q(t), t)], [(-b*Derivative(q(t), t) - k*q(t))/m]])
Please refer to the docstrings on each method for more details.
Attributes
Specific to LagrangesMethod:
inertial
(None or ReferenceFrame) Inertial reference frame for the system.
coneqs
(m + M) Velocity constraints [time differentiated holonomic, nonholonomic].
lam_vec
(Matrix, shape(m + M, 1)) Column matrix of functions of time representing the Lagrange multipliers λ , one for each constraint in
velocity_constraints.lam_coeffs
(Matrix, shape(m + M, n)) Jacobian of the constraints, i.e. linear coefficients of the speeds in the velocity constraints.
eom
(None or Matrix, shape(n,)) Second order ordinary differential equations in q. Includes constraint forces that are functions of the Lagrange multipliers λ if constraints are present.
forcelist
(list) List of the forces and torques acting on the system. Deprecated: use
loadsinstead.Shared by all methods classes:
frame
(ReferenceFrame) Inertial reference frame that the equations of motion were formulated with respect to.
q
(Matrix, shape(n, 1)) Column matrix of the n generalized coordinates.
u
(Matrix, shape(n, 1)) Column matrix of the n generalized speeds: u = q’.
holonomic_constraints
(Matrix, shape(M, 1)) Column matrix of holonomic configuration constraint residuals.
nonholonomic_constraints
(Matrix, shape(m, 1)) Column matrix of shape(m, 1) of nonholonomic constraint residuals.
velocity_constraints
(Matrix, shape(M + m, 1)) Column matrix of shape(M + m, 1) velocity constraint residuals comprised of the time differentiated configuration constraints stacked on top of the nonholonomic constraints.
acceleration_constraints
(Matrix, shape(M + m, 1)) Column matrix acceleration constraint residuals which are the time differentiated velocity constraints.
loads
(list) List of (Point, vector) or (ReferenceFrame, vector) tuples or, similarly, Force or Torque objects describing the nonconservative loads applied to the system.
bodies
(list) List containing the rigid bodies and particles of the system.
mass_matrix
(Matrix) The system’s mass matrix representing the linear coefficients of x = q’’ or x = [q’’, λ] if constraints are present:
mass_matrix*x = forcing.forcing
(Matrix) The system’s forcing vector representing all terms not linear in q’’ or [q’’, λ] if constraints are present.
mass_matrix_full
(Matrix) The mass matrix for the first order form of the equations of motion with state vector [q’, u’, λ].
forcing_full
(Matrix) The forcing vector for the first order form of the equations of motion.
- property acceleration_constraints¶
Column matrix of acceleration constraint residuals.
- property constraints_jacobian¶
Jacobian of the constraints. A matrix of shape(M + m, n) which are equivalently the linear coefficients of q’ in the velocity constraints and the linear coefficients of q’’ in the acceleration constraints.
- property forcelist¶
List of
Force,Torque, tuple(Point,Vector), tuple(ReferenceFrame,Vector) loads applied to multibody system.Deprecated since version 1.15: LagrangesMethod now uses consistent attribute names among all methods classes. Use
loadsinstead.
- property forcing¶
Returns the forcing vector from ‘lagranges_equations’ method.
- property forcing_full¶
Augments qdots to the forcing vector above.
- form_lagranges_equations()[source]¶
Method to form Lagrange’s equations of motion.
Returns a vector of equations of motion using Lagrange’s equations of the second kind.
- property frame¶
Inertial reference frame that the equations of motion were formulated with respect to.
- property holonomic_constraints¶
Column matrix holonomic configuration constraint residuals.
- linearize(
- q_ind=None,
- qd_ind=None,
- q_dep=None,
- qd_dep=None,
- linear_solver='LU',
- **kwargs,
Linearize the equations of motion about a symbolic operating point.
- Parameters:
linear_solver : str, callable
Method used to solve the several symbolic linear systems of the form
A*x=bin the linearization process. If a string is supplied, it should be a valid method that can be used with thesympy.matrices.matrixbase.MatrixBase.solve(). If a callable is supplied, it should have the formatx = f(A, b), where it solves the equations and returns the solution. The default is'LU'which corresponds to SymPy’sA.LUsolve(b).LUsolve()is fast to compute but will often result in divide-by-zero and thusnanresults.**kwargs
Extra keyword arguments are passed to
sympy.physics.mechanics.linearize.Linearizer.linearize().
Explanation
If kwarg A_and_B is False (default), returns M, A, B, r for the linearized form, M*[q’, u’]^T = A*[q_ind, u_ind]^T + B*r.
If kwarg A_and_B is True, returns A, B, r for the linearized form dx = A*x + B*r, where x = [q_ind, u_ind]^T. Note that this is computationally intensive if there are many symbolic parameters. For this reason, it may be more desirable to use the default A_and_B=False, returning M, A, and B. Values may then be substituted in to these matrices, and the state space form found as A = P.T*M.inv()*A, B = P.T*M.inv()*B, where P = Linearizer.perm_mat.
In both cases, r is found as all dynamicsymbols in the equations of motion that are not part of q, u, q’, or u’. They are sorted in canonical form.
The operating points may be also entered using the
op_pointkwarg. This takes a dictionary of {symbol: value}, or a an iterable of such dictionaries. The values may be numeric or symbolic. The more values you can specify beforehand, the faster this computation will run.For more documentation, please see the
Linearizerclass.
- property loads¶
List of
Force,Torque, tuple(Point,Vector), tuple(ReferenceFrame,Vector) loads applied to multibody system.
- property mass_matrix¶
Returns the mass matrix, which is augmented by the Lagrange multipliers, if necessary.
Explanation
If the system is described by ‘n’ generalized coordinates and there are no constraint equations then an n X n matrix is returned.
If there are ‘n’ generalized coordinates and ‘m’ constraint equations have been supplied during initialization then an n X (n+m) matrix is returned. The (n + m - 1)th and (n + m)th columns contain the coefficients of the Lagrange multipliers.
- property mass_matrix_full¶
Augments the coefficients of qdots to the mass_matrix.
- property nonholonomic_constraints¶
Column matrix of nonholonomic constraint residuals.
- property q¶
Column matrix of shape(n, 1) containing the generalized coordinates.
- solve_multipliers(
- op_point=None,
- sol_type='dict',
Solves for the values of the lagrange multipliers symbolically at the specified operating point.
- Parameters:
op_point : dict or iterable of dicts, optional
Point at which to solve at. The operating point is specified as a dictionary or iterable of dictionaries of {symbol: value}. The value may be numeric or symbolic itself.
sol_type : str, optional
Solution return type. Valid options are: - ‘dict’: A dict of {symbol : value} (default) - ‘Matrix’: An ordered column matrix of the solution
- to_linearizer(
- q_ind=None,
- qd_ind=None,
- q_dep=None,
- qd_dep=None,
- linear_solver='LU',
Returns an instance of the Linearizer class, initiated from the data in the LagrangesMethod class. This may be more desirable than using the linearize class method, as the Linearizer object will allow more efficient recalculation (i.e. about varying operating points).
- Parameters:
q_ind, qd_ind : array_like, optional
The independent generalized coordinates and speeds.
q_dep, qd_dep : array_like, optional
The dependent generalized coordinates and speeds.
linear_solver : str, callable
Method used to solve the several symbolic linear systems of the form
A*x=bin the linearization process. If a string is supplied, it should be a valid method that can be used with thesympy.matrices.matrixbase.MatrixBase.solve(). If a callable is supplied, it should have the formatx = f(A, b), where it solves the equations and returns the solution. The default is'LU'which corresponds to SymPy’sA.LUsolve(b).LUsolve()is fast to compute but will often result in divide-by-zero and thusnanresults.- Returns:
Linearizer
An instantiated
sympy.physics.mechanics.linearize.Linearizer.
- property u¶
Column matrix of shape(n, 1) containing the time derivatives of the generalized coordinates.
- property velocity_constraints¶
Column matrix of shape(M + m, 1) motion constraint residuals made up of the M time differentiated holonomic constraints stacked on the m nonholonomic constraints.