Author Topic: How to calculate the total energy of a system using Ovito?  (Read 1171 times)

Atreya

  • Newbie
  • *
  • Posts: 1
How to calculate the total energy of a system using Ovito?
« on: February 18, 2017, 04:55:59 PM »
I have 1000 water molecules whose kinetic and potential energies are stored in a LAMMPS dump file. How do I use Ovito to compute the total energy of the system?

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 555
Re: How to calculate the total energy of a system using Ovito?
« Reply #1 on: February 18, 2017, 06:55:22 PM »
Hi,

OVITO doesn't have a built-in function for computing global quantities from per-atom properties, but you can implemented this with a little Python modifier script. Simply apply a Python script modifier to the dataset and copy-paste the following script:

Code: [Select]
import bumpy as np

def modify(frame, input, output):
    total_pot_energy = np.sum(input.particle_properties['poteng'])
    total_kin_energy = np.sum(input.particle_properties['kineng'])
    total_energy = total_pot_energy + total_kin_energy
    print(total_energy)
    output.attributes['total_energy'] = total_energy

Here I have assumed that the per-atom potential energy and kinetic energy are stored in the poteng and kineng particle properties respectively. You have to adjust the names in the script to your case.

The last line in the script saves the computed total energy in a so-called attribute. You can then use OVITO's file export function to export this quantity as a function of simulation time to a text file.