Example: Ase calculator

This example illustrates the usage of atomicrex as a calculator in the Atomic Simulation Environment (ASE). A bcc-Fe structure is created and the forces, stress and total energy are calculated using an ABOP [MulErhAlb07a]

Location

examples/python_ase_calculator

Input files

  • calculate_energy.py: main input file

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    from atomicrex.ase_calculator import Atomicrex
    from ase.lattice.cubic import BodyCenteredCubic
    
    __doc__ = """ This script demonstrates the usage of the Atomicrex ase
    calculator.  """
    
    
    atoms = BodyCenteredCubic(size=(2, 2, 2), symbol='Fe', latticeconstant=2.86)
    calc = Atomicrex(file_name="main.xml")
    
    atoms.set_calculator(calc)
    
    f = atoms.get_forces()
    print("Forces: {}".format(f))
    
    e = atoms.get_potential_energy()
    print("Total energy: {}".format(e))
    
    p = atoms.get_stress()
    print("Stress: {}".format(p))
    
  • main.xml: file with definition of potential

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    <?xml version='1.0' encoding='iso-8859-1'?>
    <job>
      <name>ase calculator</name>
    
      <atom-types>
        <species>Fe</species>
      </atom-types>
    
      <potentials>
        <abop id='Fe-Potential' species-a='*' species-b='*'>
          <param-file>Fe.tersoff</param-file>
        </abop>  
      </potentials>
    
      <structures>
      </structures>
    
    </job>
    
  • Fe.tersoff: definition of potential parameters in Lammps/Tersoff format

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    # Values taken from:
    # Michael Mueller et al
    # J. Phys.: Condens. Matter 19 (2007) 326220
    
    # Potential file was prepared by A. Stukowski (TU Darmstadt)
    
    # Parameters converted from K. Albe's analytical bond-order formalism to LAMMPS Tersoff format:
    # gamma = gamma
    # lambda3 = 2*mu
    # c = c
    # d = d
    # R = Rc
    # D = Dc
    # costheta0 = -h
    # lambda1 = beta*sqrt(2*S) 
    # lambda2 = beta*sqrt(2/S) 
    # A = D0/(S-1)*exp(lambda1*r0) 
    # B = S*D0/(S-1)*exp(lambda2*r0) 
    
    Fe Fe Fe 1.0 0.0115751 0 1.2898716 0.3413219 0.26 1.0 1.0 1.37635404 67.8647723 3.15 0.2 2.84810441 953.948593
    

Output (files)

  • log.calculate_energy: stdout from run calculating the energy

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    Forces: [[  1.25940924e-15   1.70523318e-15   3.91180144e-15]
     [  1.36522738e-15   1.25420507e-15   1.49533164e-15]
     [  1.25940924e-15   1.48145385e-15   1.77375475e-16]
     [ -2.65412692e-15   1.65048097e-15   6.85974715e-16]
     [  2.10508694e-15   2.58690638e-15  -7.86697096e-16]
     [  1.67487552e-15  -3.68021585e-15  -1.69742692e-15]
     [ -2.21409993e-16   4.46458545e-16  -1.64822005e-15]
     [ -1.97758476e-15  -2.64371858e-15   0.00000000e+00]
     [  1.03216047e-16   7.70217223e-16  -1.87697080e-15]
     [  1.21343907e-15   6.57460197e-16  -3.11469600e-15]
     [ -4.66640615e-16  -5.74193471e-16  -3.43995665e-15]
     [ -4.17808149e-15   1.88737914e-15  -4.78393367e-15]
     [  2.89698820e-16   8.91647867e-16  -2.60208521e-15]
     [  1.44328993e-15  -4.43568793e-15  -5.62267247e-15]
     [  7.97105437e-16   1.68268177e-15  -4.16333634e-17]
     [ -2.98892855e-15  -4.32100636e-15  -3.89618893e-15]]
    Total energy: -68.48002450272035
    Stress: [  3.47784417e+02   3.47784417e+02   3.47784417e+02   6.13341821e-12
       1.36628202e-12  -2.32045181e-11]