Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 178

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 183

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 184

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 220

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 223

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 235

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 250

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 252

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 257

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 268

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 270

Deprecated: Function create_function() is deprecated in /homepages/8/d18699663/htdocs/clickandbuilds/SMF/ovito_forum/Sources/Load.php on line 273
How to calculate the total energy of a system using Ovito?

Author Topic: How to calculate the total energy of a system using Ovito?  (Read 1755 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: 638
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.