# Calculating energies

In the multisysten framework, the total energy (total_energy) of a calculation consists of various contributions, where we follow the standard definitions of thermodynamics (see here)

• The kinetic energy (kinetic_energy)
• The internal energy (internal_energy)
• The potential energy (potential_energy)

### Kinetic energy

We use the term kinetic energy in the usual sense. The only slight exception is for container systems:

multisystem_update_kinetic_energy()

Specific systems need their specific routines to calculate the kinetic energy.

### Interaction energies

Everything else is treated as an interaction energy. Here we have to distinguish between the interactions between two different systems (which can be of the same type), and the interaction of a system with itself (intra-interaction).

#### inter-interactions

The interactions between two different systems do not require any further thought, as by definition no physical self-interaction can occur. As the method to calculate the interactions are part of the interaction class, it is independent of the actual system and can be implemented at the level of the classsystem_t.

system_update_potential_energy()

The exception are containers. Here we need to loop over the constituents. In order to distinguish inter- from intra-interactions, we need to query each interaction for its interaction partner, and skip the interaction, if the partner is part of the container.

multisystem_update_potential_energy()

#### intra-interactions

Systems may contain more than one physical particle (e.g. the electrons, a set of ions or container systems). In order to account for the interaction of these particles with other particles of the same system, we decided to treat this case as a system interacting with itself, which we call intra-interaction.

In some cases, such as a single particle, this intra interaction has to be zero, while in other cases with many particles, the interactions have to be calculated, where – of course – the interaction of one particle with itself has to be removed (at least approximatively).

Another important aspect of the implementation is that Octopus deals with one-sided interactions. This has the implication that there is no double counting when calculating the interaction energies. Both contributions have to be counted: for each system, we add the the energy of the system in the field of the partner.

system_update_internal_energy()
multisystem_update_internal_energy()

### Total energy

The total energy of the whole simulation (top level container) is clearly defined. It contains the sum of all internal and interaction energies.

For a specific system (e.g. electrons), the total energy also is the sum of the internal energy and the interaction energies (including the intra interaction energy).

system_update_total_energy()