I am writing a simple computer simulation of a system (in 2 dimensions), with several circular bodies. They all affect each other by their gravity and some of them are connected via damped springs (one body can be connected to multiple springs). Springs are massless themselves, they just connect to objects with mass. Springs should heat up due to damping and distribute that heat to two masses spring connects.

I wanted to find out how much energy goes into the heat of each body because of damped springs.

I thought I could just subtract energy (kinetic and potential) before and after the integration step, and use that as heat energy. However, I can only calculate gravitational energy of the whole system (using gravitational potential), and I don't know how to split that energy among all masses (or springs), so that the sum of kinetic and potential energy is constant for a non-damped spring (maybe it is impossible to do so).

Also, it is not obvious how to split resulting heat energy of a spring among its two bodies (evenly or weighted).

So, how do I find the amount of energy which goes to heat, per each body, in a system of multiple bodies connected via damped springs in a gravity field?

I calculate gravity forces for each mass pair via

$$\overrightarrow{F_{g,i,j}}=-G \frac{m_i m_2 \overrightarrow{n_{ij}}}{|\overrightarrow{p_j}-\overrightarrow{p_i}|^2}$$

And spring forces between some mass pairs via

$$\overrightarrow{F_{s,i,j}}= \overrightarrow{n_{ij}} ( k_{ij} ( l_{ij} - |\overrightarrow{p_j}-\overrightarrow{p_i}| ) + b_{ij}( (\overrightarrow{v_j} - \overrightarrow{v_i}) \cdot \overrightarrow{n_{ij}}))$$

where $\overrightarrow{n_{ij}}= \frac{\overrightarrow{p_j}-\overrightarrow{p_i}}{|\overrightarrow{p_j}-\overrightarrow{p_i}|}$; ${p_i}$ - position of mass with index $i$; $\overrightarrow{v_i}$ - velocity of mass with index $i$; $l_{ij}$ - rest length of spring between masses $i$ and $j$; $G$, $k_{ij}$ and $b_{ij}$ - constants.

I use symplectic integrator of order 3 and update positions and velocities by timesteps.

Calculating heat energy would be easy if there would be no gravity by subtracting this after and before integration step:

$E_{t,i,j}=E_{k,i,j}+E_{p,i,j}=\frac{m_i |\overrightarrow{v_i}|^2+m_j |\overrightarrow{v_i}|^2}{2}+\frac{k_{ij} ( l_{ij} - |\overrightarrow{p_j}-\overrightarrow{p_i}| )^2}{2}$

But with gravity, kinetic energy is split between potential gravitational energy and potential spring energy, and I don't know how how to calculate gravitational energy of one mass (or two from spring). Also, one mass being connected via several springs complicates this as well.

EDIT for close voters: this is not homework, it is my personal project. And I am not asking to check my work, I am asking about physics concept - how to calculate heat energy of a damped spring, which I am unable to find answer anywhere.

  • $\begingroup$ If the objects are in thermal equilibrium with each other (which they eventually will be, since presumably the springs can conduct heat between themselves and the masses) then the amount of thermal energy that goes into each body will be proportional to its heat capacity. $\endgroup$ Commented Mar 14, 2023 at 17:04
  • $\begingroup$ @MichaelSeifert Yes, I know that, I am diving heat energy by mass and specific heat capacity. Heat energy can be found (seems to be approximate) by last formula from accepted answer, which with my variable names is $E=b_{ij}( (\overrightarrow{v_j} - \overrightarrow{v_i}) \cdot \overrightarrow{n_{ij}}))^{2}dt$ $\endgroup$
    – Somnium
    Commented Mar 14, 2023 at 22:06

1 Answer 1


So, to be clear, you have several bodies that gravitationally attract each other, with some have spring-dampers connected between them too?

Assuming Newtonian gravity and Hookian springs, the PE is given by the gravitational portion:

$$ U_{g,ij} = -\frac{Gm_{i}m_{j}}{r_{ij}} $$

and the elastic portion:

$$ U_{s,ij} = \frac{1}{2}k_{ij}\left( r_{ij} - l_{ij} \right)^{2} $$

for bodies $i$ and $j$. It should be clear that these are the masses of bodies $i$ and $j$, the distance between them, the universal gravitational constant, and the spring between them. The $l$ is what I am using for the "natural length" of the spring connecting body $i$ and $j$.

The kinetic energy is obviously

$$ T_{i} = \frac{1}{2}m_{i}\dot{r}^2 $$

for body $i$.

It should be the case that if you add up all the kinetic and potential energy, you see it decrease over time to some minimum when the system has found equilibrium. It should also be the case that at each step you can calculate the work of all the dampers, and the work of these dampers will equal the total change in energy.

I am not sure what sort of damper equation you are using, but assuming it is something like

$$ F_{d,ij} = -b\dot{r}_{ij} $$

then the work done by the damper in any time step of your simulation will be given by

$$ \begin{align} dW_{d,ij} &= P_{d,ij}dt \\ dW_{d,ij} &= F_{d,ij}\dot{r}_{ij}dt \\ dW_{d,ij} &= -b\dot{r}_{ij}^{2}dt \end{align} $$

You are saying the heat goes "into the mass" but the way I understand the set up, it should be going "into the damper" in my opinion, unless the damper is somehow in the mass. When a vibrating system has a damper, it is the damper that gets warm. The vibrating object only gets warm if the damping originates from internal frictions. For example, helicopter blades have dampers connected between themselves and the hub (usually), or possibly between them. It is those dampers that get hot, not the blades, as the dampers limit the blade oscillations (there is drag on the blades of course too).

  • $\begingroup$ Yes, these are all formulas I use now to calculate total potential and kinetic energy, but I don't know how to calculate energy for each individual mass, to find out how much heat energy went into exactly this mass. You mention damper work, can you elaborate please, how can I calculate it and use for heat energy? $\endgroup$
    – Somnium
    Commented Mar 12, 2023 at 0:30
  • $\begingroup$ I added damping. Please let me know if that helps. $\endgroup$ Commented Mar 12, 2023 at 0:46
  • $\begingroup$ Actually your last formula helped me! However it needed coefficient 0.5. After checking in my simulation formula $0.5 b v_{ij}^2 dt$ appears to be equal to energy lost during damping, which I can use as heat energy. $\endgroup$
    – Somnium
    Commented Mar 13, 2023 at 15:46
  • $\begingroup$ Actually ignore what I said about 0.5, it was a bug in my code which caused to add energy twice, so your formula is correct. $\endgroup$
    – Somnium
    Commented Mar 14, 2023 at 8:30
  • $\begingroup$ You were adding for each of the objects haha. You need to have a loop for i from 1 to n, and then a loop from for j from 1 to i. $\endgroup$ Commented Mar 14, 2023 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.