narupatools.physics.energy

Methods relating to energies and work.

Functions

cumulative_work

Calculate the cumulative work performed by a force at each timestep.

kinetic_energy

Calculate the translational kinetic energy of a system of particles.

total_work

Calculate the total work performed by a force.

work_per_step

Calculate the work performed by a force at each timestep.

narupatools.physics.energy.cumulative_work(*, forces: numpy.ndarray, positions: numpy.ndarray, time_axis: int = - 2)numpy.ndarray

Calculate the cumulative work performed by a force at each timestep.

The work is defined by the line integral:

\[W = \int \vec F \cdot d \vec s\]

This is discretized into a sum using the trapezoid rule:

\[W_{\text{cumulative}}(t_n) = \frac{1}{2} \sum_{k=0}^n (\vec F(t_k) + \vec F(t_{k+1}) ) \cdot (\vec r(t_{k+1}) - \vec r(t_{k}) )\]
Parameters
  • forces – Forces \(\vec F_i\) of each particle.

  • positions – Velocities \(\vec r_i\) of each particle.

  • time_axis – Axis of the forces and positions arrays that represent time.

narupatools.physics.energy.kinetic_energy(*, masses: numpy.ndarray, velocities: numpy.ndarray)Union[float, numpy.ndarray]

Calculate the translational kinetic energy of a system of particles.

The kinetic energy \(K\) is defined as:

\[K = \frac{1}{2} \sum_i m_i | \vec v_i |^2\]
Parameters
  • masses – Masses \(m_i\) of each particle.

  • velocities – Velocities \(\vec v_i\) of each particle.

narupatools.physics.energy.total_work(*, forces: numpy.ndarray, positions: numpy.ndarray, time_axis: int = - 2)Union[float, numpy.ndarray]

Calculate the total work performed by a force.

The work is defined by the line integral:

\[W = \int \vec F \cdot d \vec s\]

This is discretized into a sum using the trapezoid rule:

\[W = \frac{1}{2} \sum_k (\vec F(t_k) + \vec F(t_{k+1}) ) \cdot (\vec r(t_{k+1}) - \vec r(t_{k}) )\]
Parameters
  • forces – Forces \(\vec F_i\) of each particle.

  • positions – Velocities \(\vec r_i\) of each particle.

  • time_axis – Axis of the forces and positions arrays that represent time.

narupatools.physics.energy.work_per_step(*, forces: numpy.ndarray, positions: numpy.ndarray, time_axis: int = - 2)numpy.ndarray

Calculate the work performed by a force at each timestep.

The work is defined by the line integral:

\[W = \int \vec F \cdot d \vec s\]

This is discretized into a sum using the trapezoid rule. The work for each step is therefore given by:

\[W_{k} = \frac{1}{2} (\vec F(t_k) + \vec F(t_{k-1}) ) \cdot (\vec r(t_{k}) - \vec r(t_{k-1}) )\]

The first value \(W_0\) is \(0\).

The axis parameter determines the axis of the forces and position array that represents individual timesteps. If the forces and position arrays are of shape […, timestep, component], then the default axis of -2 should be used. If the forces and positions cover a set of particles, and hence are of the form […, timestep, particle, component], then an axis of -3 should be used.

Parameters
  • forces – Forces \(\vec F_i\) of each particle.

  • positions – Velocities \(\vec r_i\) of each particle.

  • time_axis – Axis of the forces and positions arrays that represent time.