Assembling equations of motion is done within the C++ class CSystem
, see the file CSystem.cpp
.
The general idea is to assemble, i.e. to sum up, (parts of) residuals attributed by different objects. The summation process is based on coordinate indices to which the single equations belong to.
Let's assume that we have two simple ObjectMass1D
objects, with object indices o0 and o1 and having mass m_0 and m_1. They are connected to nodes of type Node1D
n0 and n1, with global coordinate indices c0 and c1.
The partial object residuals, which are fully independent equations, read
m_0 \cdot \ddot q_{c0} &=& RHS_{c0} , \\ m_1 \cdot \ddot q_{c1} &=& RHS_{c1} ,
where RHS_{c0} and RHS_{c1} the right-hand-side of the respective equations/coordinates. They represent forces, e.g., from LoadCoordinate
items (which directly are applied to coordinates of nodes), say f_{c0} and f_{c1}, that are in case also summed up on the right hand side.
Let us for now assume that
RHS_{c0} = f_{c0} \quad \mathrm{and} \quad RHS_{c1} = f_{c1} .
Now we add another ObjectMass1D
object with object index o2, having mass m_2, but letting the object * again* use node n0 with coordinate c0.
In this case, the total object residuals read
(m_0+m_2) \cdot \ddot q_{c0} &=& RHS_{c0} , \\ m_1 \cdot \ddot q_{c1} &=& RHS_{c1} .
It is clear, that now the mass in the first equation is increased due to the fact that two objects contribute to the same coordinate. The same would happen, if several loads are applied to the same coordinate.
Finally, if we add a CoordinateSpringDamper
, assuming a spring k between coordinates c0 and c1, the :ref:`RHS <RHS>` of equations related to c0 and c1 is now augmented to
RHS_{c0} &=& f_{c0} + k \cdot (q_{c1} - q_{c0}) , \\ RHS_{c1} &=& f_{c1} + k \cdot (q_{c0} - q_{c1}) .
The system of equation would therefore read
(m_0+m_2) \cdot \ddot q_{c0} &=& f_{c0} + k \cdot (q_{c1} - q_{c0}) , \\ m_1 \cdot \ddot q_{c1} &=& f_{c1} + k \cdot (q_{c0} - q_{c1}) .
It should be noted, that all (components of) residuals ('equations') are summed up for the according coordinates, and also all contributions to the mass matrix. Only constraint equations, which are related to Lagrange parameters always get their 'own' Lagrange multipliers, which are automatically assigned by the system and therefore independent for every constraint.