@@ -3026,6 +3026,7 @@ def get_energy_forces(self, ase_calculator, compute_stress = True, stress_numeri
30263026 ----------
30273027 ase_calculator : ase.calculator
30283028 The ASE interface to the calculator to run the calculation.
3029+ also a CellConstructor calculator is accepted
30293030 compute_stress : bool
30303031 If true, the stress is requested from the ASE calculator. Be shure
30313032 that the calculator you provide supports stress calculation
@@ -3120,10 +3121,10 @@ def get_energy_forces(self, ase_calculator, compute_stress = True, stress_numeri
31203121
31213122
31223123 struct = structures [i ]
3123- atms = struct .get_ase_atoms ()
3124+ # atms = struct.get_ase_atoms()
31243125
31253126 # Setup the ASE calculator
3126- atms .set_calculator (ase_calculator )
3127+ # atms.set_calculator(ase_calculator)
31273128
31283129
31293130 # Print the status
@@ -3136,15 +3137,21 @@ def get_energy_forces(self, ase_calculator, compute_stress = True, stress_numeri
31363137 count_fails = 0
31373138 while run :
31383139 try :
3139- energy = atms . get_total_energy () / Rydberg # eV => Ry
3140- # Get energy, forces (and stress)
3141- energy = atms . get_total_energy () / Rydberg # eV => Ry
3142- forces_ = atms . get_forces () / Rydberg # eV / A => Ry / A
3140+ results = CC . calculators . get_results ( ase_calculator , struct , get_stress = compute_stress )
3141+ energy = results [ " energy" ] / Rydberg # eV => Ry
3142+ forces_ = results [ "forces" ] / Rydberg
3143+
31433144 if compute_stress :
3144- if not stress_numerical :
3145- stress [9 * i0 : 9 * i0 + 9 ] = - atms .get_stress (False ).reshape (9 ) * Bohr ** 3 / Rydberg # ev/A^3 => Ry/bohr
3146- else :
3147- stress [9 * i0 : 9 * i0 + 9 ] = - ase_calculator .calculate_numerical_stress (atms , voigt = False ).ravel ()* Bohr ** 3 / Rydberg
3145+ stress [9 * i0 : 9 * i0 + 9 ] = - results ["stress" ].reshape (9 )* Bohr ** 3 / Rydberg
3146+ #energy = atms.get_total_energy() / Rydberg # eV => Ry
3147+ # Get energy, forces (and stress)
3148+ #energy = atms.get_total_energy() / Rydberg # eV => Ry
3149+ #forces_ = atms.get_forces() / Rydberg # eV / A => Ry / A
3150+ #if compute_stress:
3151+ # if not stress_numerical:
3152+ # stress[9*i0 : 9*i0 + 9] = -atms.get_stress(False).reshape(9) * Bohr**3 / Rydberg # ev/A^3 => Ry/bohr
3153+ # else:
3154+ # stress[9*i0 : 9*i0 + 9] = -ase_calculator.calculate_numerical_stress(atms, voigt = False).ravel()* Bohr**3 / Rydberg
31483155
31493156 # Copy into the ensemble array
31503157 energies [i0 ] = energy
0 commit comments