Force
– Base Class for Forces¶
-
class
trep.
Force
(system[, name=None])¶ Parameters: This is the base class for all forces in a
System
. It should never be created directly. Forces are created by instantiating a specific type of force..See trep.forces - Forces for the built-in types of forces. Additional forces can be added through either the Python or C-API.
Forces are used to include non-conservative and control forces in a mechanical system. Forces must be expressed in the generalized coordinates of the system. Conservative forces like gravity or spring-like potentials should be implemented using
Potential
instead.
Force Objects¶
-
Force.
name
¶ The name of this force or
None
.
-
Force.
f
(q)¶ Parameters: q ( Config
) – Configuration variableCalculate the force on configuration variable q at the current state of the system.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_dq
(q, q1)¶ Parameters: Calculate the derivative of the force on configuration variable q with respect to the value of q1.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_ddq
(q, dq1)¶ Parameters: Calculate the derivative of the force on configuration variable q with respect to the velocity of dq1.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_du
(q, u1)¶ Parameters: Calculate the derivative of the force on configuration variable q with respect to the value of u1.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_dqdq
(q, q1, q2)¶ Parameters: Calculate the second derivative of the force on configuration variable q with respect to the value of q1 and the value of q2.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_ddqdq
(q, dq1, q2)¶ Parameters: Calculate the second derivative of the force on configuration variable q with respect to the velocity of dq1 and the value of q2.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_ddqddq
(q, dq1, dq2)¶ Parameters: Calculate the second derivative of the force on configuration variable q with respect to the velocity of dq1 and the velocity of q2.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_dudq
(q, u1, q2)¶ Parameters: Calculate the second derivative of the force on configuration variable q with respect to the value of u1 and the value of q2.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_duddq
(q, u1, dq2)¶ Parameters: Calculate the second derivative of the force on configuration variable q with respect to the value of u1 and the velocity of q2.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
-
Force.
f_dudu
(q, u1, u2)¶ Parameters: Calculate the second derivative of the force on configuration variable q with respect to the value of u1 and the value of u2.
¶ Desired Calculation Required Continuous Dynamics ? 1st Derivative ? 2nd Derivative ? Discrete Dynamics ? 1st Derivative ? 2nd Derivative ?
Verifying Derivatives of the Force¶
It is important that the derivatives of f()
are correct. The
easiest way to check their correctness is to approximate each
derivative using numeric differentiation. These methods are provided
to perform this test. The derivatives are only compared at the
current configuration of the system. For improved coverage, try
running each test several times at different configurations.
-
Force.
validate_h_dq
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_ddq
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_du
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_dqdq
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_ddqdq
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_ddqddq
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_dudq
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_duddq
(delta=1e-6, tolerance=1e-6, verbose=False)¶ -
Force.
validate_h_dudu
(delta=1e-6, tolerance=1e-6, verbose=False)¶ Parameters: - delta – Amount to add to each configuration, velocity, or input.
- tolerance – Acceptable difference between the calculated and approximate derivatives
- verbose – Boolean to print error and result messages.
Return type: Boolean indicating if all tests passed
Check the derivatives against the approximate numeric derivative calculated from one less derivative (ie, approximate
f_dq()
fromf()
andf_dudq()
fromf_du()
).See
System.test_derivative_dq()
,System.test_derivative_ddq()
, andSystem.test_derivative_du()
for details of the approximation and comparison.