@@ -3034,6 +3034,18 @@ def get_energy_forces(self, ase_calculator, compute_stress = True, stress_numeri
30343034 while run :
30353035 try :
30363036 energy = atms .get_total_energy () / Rydberg # eV => Ry
3037+ # Get energy, forces (and stress)
3038+ energy = atms .get_total_energy () / Rydberg # eV => Ry
3039+ forces_ = atms .get_forces () / Rydberg # eV / A => Ry / A
3040+ if compute_stress :
3041+ if not stress_numerical :
3042+ stress [9 * i0 : 9 * i0 + 9 ] = - atms .get_stress (False ).reshape (9 ) * Bohr ** 3 / Rydberg # ev/A^3 => Ry/bohr
3043+ else :
3044+ stress [9 * i0 : 9 * i0 + 9 ] = - ase_calculator .calculate_numerical_stress (atms , voigt = False ).ravel ()* Bohr ** 3 / Rydberg
3045+
3046+ # Copy into the ensemble array
3047+ energies [i0 ] = energy
3048+ forces [nat3 * i0 : nat3 * i0 + nat3 ] = forces_ .reshape ( nat3 )
30373049 run = False
30383050 except :
30393051 print ("Rerun the job %d" % i )
@@ -3043,18 +3055,6 @@ def get_energy_forces(self, ase_calculator, compute_stress = True, stress_numeri
30433055 sys .stderr .write ("Error in the ASE calculator for more than 5 times\n " )
30443056 raise
30453057
3046- # Get energy, forces (and stress)
3047- energy = atms .get_total_energy () / Rydberg # eV => Ry
3048- forces_ = atms .get_forces () / Rydberg # eV / A => Ry / A
3049- if compute_stress :
3050- if not stress_numerical :
3051- stress [9 * i0 : 9 * i0 + 9 ] = - atms .get_stress (False ).reshape (9 ) * Bohr ** 3 / Rydberg # ev/A^3 => Ry/bohr
3052- else :
3053- stress [9 * i0 : 9 * i0 + 9 ] = - ase_calculator .calculate_numerical_stress (atms , voigt = False ).ravel ()* Bohr ** 3 / Rydberg
3054-
3055- # Copy into the ensemble array
3056- energies [i0 ] = energy
3057- forces [nat3 * i0 : nat3 * i0 + nat3 ] = forces_ .reshape ( nat3 )
30583058
30593059
30603060 i0 += 1
0 commit comments