Skip to content

Commit 223d6cd

Browse files
committed
Fixed the two save_extxyz and save_enhanced_xyz subroutines
1 parent f984f21 commit 223d6cd

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

Modules/Ensemble.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ def save_extxyz(self, filename, append_mode = True):
822822
for i, s in enumerate(self.structures):
823823
energy = self.energies[i] * Rydberg # Ry -> eV
824824
forces = self.forces[i, :, :] * Rydberg # Ry/A -> eV/A
825-
stress = self.stresses[i, :, :] * Rydberg / Bohr**3 # Ry/Bohr^3 -> eV/A^3
825+
stress = -self.stresses[i, :, :] * Rydberg / Bohr**3 # Ry/Bohr^3 -> eV/A^3
826826
struct = s.get_ase_atoms()
827827

828828
calculator = ase.calculators.singlepoint.SinglePointCalculator(struct, energy = energy,
@@ -835,7 +835,7 @@ def save_extxyz(self, filename, append_mode = True):
835835
ase.io.write(filename, ase_structs, format = "extxyz", append = append_mode)
836836

837837

838-
def save_enhanced_xyz(self, filename, append_mode = True, stress_key = "virial", forces_key = "force", energy_key = "energy"):
838+
def save_enhanced_xyz(self, filename, append_mode = True, stress_key = "stress", forces_key = "forces", energy_key = "energy"):
839839
"""
840840
Save the ensemble as an enhanced xyz.
841841
@@ -866,7 +866,8 @@ def save_enhanced_xyz(self, filename, append_mode = True, stress_key = "virial",
866866
info += '{}={:.16f} '.format(energy_key, self.energies[i] * Rydberg)
867867

868868
# Add the virial stress
869-
info += '{}="{:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f}" '.format(stress_key, *list(self.stresses[i].ravel()))
869+
stress_data = - self.stresses[i].ravel * CC.Units.RY_PER_BOHR3_TO_EV_PER_A3
870+
info += '{}="{:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f} {:20.16f}" '.format(stress_key, *list(stress_data))
870871

871872
# Add the secription of the xyz format
872873
info += 'Properties=species:S:1:pos:R:3:{}:R:3\n'.format(forces_key)
@@ -1376,7 +1377,6 @@ def update_weights(self, new_dynamical_matrix, newT, update_q = False, timer=Non
13761377

13771378
# Check if the dynamical matrix has changed
13781379
changed_dyn = np.max([np.max(np.abs(self.current_dyn.dynmats[i] - new_dynamical_matrix.dynmats[i])) for i in range(len(self.current_dyn.q_tot))])
1379-
print("DYN CHANGED BY:", changed_dyn)
13801380
changed_dyn = changed_dyn > 1e-30
13811381

13821382
# Prepare the new displacements
@@ -1902,14 +1902,11 @@ def get_preconditioned_gradient_parallel(self, *args, timer=None, **kwargs):
19021902
For documentation, see get_preconditioned_gradient
19031903
"""
19041904

1905-
print("force length:", len(self.force_computed))
19061905

19071906
def work_function(argument, timer=None):
1908-
print("force length [inside]:", len(self.force_computed))
19091907
ensemble_start_config, ensemble_end_config = argument
19101908
mask = np.zeros(self.N, dtype = bool)
19111909
mask[ensemble_start_config : ensemble_end_config] = True
1912-
print("mask length:", np.sum(mask.astype(int))," total N:", len(mask))
19131910
new_ensemble = self.split(mask)
19141911

19151912
gradient, _ = new_ensemble.get_preconditioned_gradient(*args, timer=timer, **kwargs)
@@ -3229,10 +3226,7 @@ def split(self, split_mask):
32293226
N = np.sum(split_mask.astype(int))
32303227
ens = Ensemble(self.dyn_0, self.T0, self.dyn_0.GetSupercell())
32313228
ens.init_from_structures(structs)
3232-
print("Split length:", len(split_mask))
3233-
print("original force legnth:", len(self.force_computed))
3234-
print("Expected length:", len(ens.force_computed))
3235-
print("Splitting force length:", len(self.force_computed[split_mask]))
3229+
32363230

32373231
ens.force_computed[:] = self.force_computed[split_mask]
32383232
ens.stress_computed[:] = self.stress_computed[split_mask]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
# Prepare the compilation of the Python Conde
9191
setup( name = "python-sscha",
92-
version = "1.3",
92+
version = "1.3.1",
9393
description = "Python implementation of the sscha code",
9494
author = "Lorenzo Monacelli",
9595
url = "https://github.com/mesonepigreco/python-sscha",

0 commit comments

Comments
 (0)