c4dynamics.states.lib.datapoint.datapoint.inteqm#
- datapoint.inteqm(forces, dt)[source]#
Advances the state vector
datapoint.X
, with respect to the input forces on a single step of time, dt.Integrates equations of three degrees translational motion using the Runge-Kutta method.
This method numerically integrates the equations of motion for a dynamic system using the fourth-order Runge-Kutta method as given by
int3
.The derivatives of the equations are of three dimensional translational motion and produced with
eqm3
- Parameters:
forces (numpy.array or list) – An external forces vector acting on the body, forces = [Fx, Fy, Fz]
dt (float or int) – Interval time step for integration.
- Returns:
out (numpy.float64) – An acceleration array at the final time step.
Warning
This method is not recommanded when the vector of forces depends on the state variables. Since the force vector is provided once at the entrance to the integration, it remains constant for the entire steps. Therefore, when the forces depend on the state variables the results of this method are not accurate and may lead to instability.
Example
Simulation of the motion of a body in a free fall.
Employing the
eqm
module to solve the equations of motion of a point-mass in the three dimensional space. Integrating the equations of motion using the fourth-order Runge-Kutta method.Import required packages:
>>> import c4dynamics as c4d >>> from matplotlib import pyplot as plt >>> import numpy as np
Settings and initial conditions:
>>> dp = c4d.datapoint(z = 100) >>> dt = 1e-2 >>> t = np.arange(0, 10 + dt, dt)
Main loop:
>>> for ti in t: ... dp.store(ti) ... if dp.z < 0: break ... dp.inteqm([0, 0, -c4d.g_ms2], dt)
>>> dp.plot('z') >>> plt.show()