6
$\begingroup$

This is my configuration in extended xyz format

8
Lattice="5.30478009012 0.0312272946092 0.308531804143 0.296228192315 5.4283625362 -0.153770906252 0.107142908862 0.25388495613 5.28850183842" Properties=species:S:1:pos:R:3:force:R:3:Z:I:1 pbc="T T T" config_type=A15 energy=-100.15189673 virial="-27.731569708 -3.64512142325 -4.97162055576 -3.64512142325 -34.1913582966 -0.581410761343 -4.97162055576 -0.581410761343 -27.551736916"
W 0.0 0.0 0.0 0.0 -0.0 0.0 74
W 2.8540756 2.85673739 2.72163137 0.0 0.0 -0.0 74
W 1.47430912 2.72198809 0.0002475 0.01822982 0.09589153 -0.13879486 74
W 4.12669916 2.73760174 0.1545134 -0.01822982 -0.09589153 0.13879486 74
W 0.1276285 1.48403311 2.60580819 -0.09922348 -0.00455073 0.02076133 74
W 0.2757426 4.19821438 2.52892274 0.09922348 0.00455073 -0.02076133 74
W 2.67917577 0.07908489 1.47639136 0.12483693 -0.01838436 0.00975602 74
W 2.73274723 0.20602736 4.12064228 -0.12483693 0.01838436 -0.00975602 74

How can we build supercell out of current unit cell with mapped energy, forces, and stresses for arbitrary periodic repetition inside ASE?

$\endgroup$
3
  • $\begingroup$ The forces and stress technically depends on the current atomic arrangement and the parameters of the calculator used. So would'nt just creating a supercell with atoms.repeat(supercellx, supercelly, supercellz) suffice? $\endgroup$
    – Atom
    Mar 21 at 14:42
  • $\begingroup$ @Atom how stress scale with supecell? $\endgroup$ Mar 22 at 15:08
  • $\begingroup$ shouldnt the stress remain the same? for the unit cell and the supercell $\endgroup$
    – Atom
    Mar 31 at 16:33

1 Answer 1

3
+25
$\begingroup$

Here is a simple Python script that can read forces and stress and store in atoms.arrays. Note that you cannot do get_stress() nor get_forces() because ase.io.read only assigns a SinglePointCalculator() with only 'energy' implemented, while properties like 'forces' and 'stress' are not implemented:

from ase.io import read, write
from ase.visualize import view
import numpy as np

atoms = read('test.extxyz')
stress = -atoms.info['virial'] / atoms.get_volume()
atoms.arrays['stress'] = stress
results = []
with open('test.extxyz', 'r') as f:
    lines = f.readlines()
    for x in lines:
        if x != '\n':
            results.append(x.split(' '))
forces = np.array(results[2:])[:,4:7].astype(float)
atoms.arrays['forces'] = forces
print(forces)
#[[ 0.         -0.          0.        ]
# [ 0.          0.         -0.        ]
# [ 0.01822982  0.09589153 -0.13879486]
# [-0.01822982 -0.09589153  0.13879486]
# [-0.09922348 -0.00455073  0.02076133]
# [ 0.09922348  0.00455073 -0.02076133]
# [ 0.12483693 -0.01838436  0.00975602]
# [-0.12483693  0.01838436 -0.00975602]]
print(stress)
#[[0.18209646 0.02393531 0.03264563]
# [0.02393531 0.22451399 0.00381777]
# [0.03264563 0.00381777 0.18091561]]
$\endgroup$
3
  • 1
    $\begingroup$ please read question again, I asked for supercell to mapped. $\endgroup$ Mar 22 at 15:08
  • 1
    $\begingroup$ @Pranavkumar maybe you should elaborate your question better then $\endgroup$
    – Shaun Han
    Mar 22 at 15:43
  • 1
    $\begingroup$ Please modify the previous response to include instructions for constructing a supercell with mapped energy, forces, and stresses for arbitrary periodic repetition. $\endgroup$ Mar 22 at 17:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .