diff --git a/Modules/Ensemble.py b/Modules/Ensemble.py index 36d01504f..2aea06791 100644 --- a/Modules/Ensemble.py +++ b/Modules/Ensemble.py @@ -1439,7 +1439,7 @@ class is created. # # Get the symmetries from spglib # super_structure = self.current_dyn.structure.generate_supercell(self.supercell) - # spglib_syms = spglib.get_symmetry(super_structure.get_ase_atoms()) + # spglib_syms = spglib.get_symmetry(super_structure.get_spglib_cell()) # # Convert them into the cellconstructor format # cc_syms = CC.symmetries.GetSymmetriesFromSPGLIB(spglib_syms, False) @@ -1534,7 +1534,7 @@ def _unwrap_symmetries_(self): # Get the symmetries from spglib super_structure = self.current_dyn.structure.generate_supercell(self.supercell) - spglib_syms = spglib.get_symmetry(super_structure.get_ase_atoms()) + spglib_syms = spglib.get_symmetry(super_structure.get_spglib_cell()) # Convert them into the cellconstructor format cc_syms = CC.symmetries.GetSymmetriesFromSPGLIB(spglib_syms, False) @@ -3655,6 +3655,15 @@ def get_free_energy_hessian(self, include_v4 = False, get_full_hessian = True, v # """ # raise NotImplementedError(ERROR_MSG) + # Check if the ensemble has been initialized + if len(self.forces) == 0: + n_forces = len(self.forces) + raise ValueError( + f"Cannot evaluate free-energy Hessian: 'self.forces' is empty (len={n_forces}). " + "Initialize or load the ensemble and compute energies and forces first." + ) + + # Convert anything into the Ha units # This is needed for the Fortran subroutines self.convert_units(UNITS_HARTREE) diff --git a/Modules/SchaMinimizer.py b/Modules/SchaMinimizer.py index 976981687..c837d5f24 100644 --- a/Modules/SchaMinimizer.py +++ b/Modules/SchaMinimizer.py @@ -948,7 +948,7 @@ def print_info(self): print (" use spglib = ", self.use_spglib) if self.use_spglib: import spglib - print (" Symmetry group = {}".format(spglib.get_spacegroup(self.dyn.structure.get_ase_atoms()))) + print (" Symmetry group = {}".format(spglib.get_spacegroup(self.dyn.structure.get_spglib_cell()))) print (" Number of symmetries in the unit cell = ", self.N_symmetries) print () @@ -1097,7 +1097,7 @@ def init(self, verbosity = False, delete_previous_data = True, init_timer = True import spglib if verbosity: - print("Symmetry group: ", spglib.get_spacegroup(self.dyn.structure.get_ase_atoms())) + print("Symmetry group: ", spglib.get_spacegroup(self.dyn.structure.get_spglib_cell())) self.N_symmetries = qe_sym.QE_nsym @@ -1337,7 +1337,7 @@ def run(self, verbose = 1, custom_function_pre = None, custom_function_post = No print ("") print("Number of symmetries before the step: ", self.N_symmetries) if self.use_spglib: - print("Group space: ", spglib.get_spacegroup(self.dyn.structure.get_ase_atoms())) + print("Group space: ", spglib.get_spacegroup(self.dyn.structure.get_spglib_cell())) print ("Harmonic contribution to free energy = %16.8f meV" % (harm_fe * __RyTomev__)) print ("Anharmonic contribution to free energy = %16.8f +- %16.8f meV" % (anharm_fe * __RyTomev__, np.real(err) * __RyTomev__)) diff --git a/Tutorials/LaH10/VariableCellRelaxation.ipynb b/Tutorials/LaH10/VariableCellRelaxation.ipynb index 1f5db69d3..7f84f070b 100644 --- a/Tutorials/LaH10/VariableCellRelaxation.ipynb +++ b/Tutorials/LaH10/VariableCellRelaxation.ipynb @@ -222,7 +222,7 @@ ], "source": [ "import spglib\n", - "print (\"The original spacegroup is:\", spglib.get_spacegroup(dyn.structure.get_ase_atoms(), 0.05))" + "print (\"The original spacegroup is:\", spglib.get_spacegroup(dyn.structure.get_spglib_cell(), 0.05))" ] }, { @@ -244,7 +244,7 @@ "# we define a function that prints the space group during the optimization\n", "space_groups = []\n", "def print_spacegroup(minim):\n", - " spgroup = spglib.get_spacegroup(minim.dyn.structure.get_ase_atoms(), 0.05)\n", + " spgroup = spglib.get_spacegroup(minim.dyn.structure.get_spglib_cell(), 0.05)\n", " space_groups.append(spgroup)\n", " \n", " # We can save them in the output at each minimization step\n", @@ -370,7 +370,7 @@ } ], "source": [ - "spglib.get_spacegroup(relax.minim.dyn.structure.get_ase_atoms(), 0.05)" + "spglib.get_spacegroup(relax.minim.dyn.structure.get_spglib_cell(), 0.05)" ] }, { @@ -390,7 +390,7 @@ } ], "source": [ - "spglib.get_spacegroup(dyn.structure.get_ase_atoms(), 0.1)" + "spglib.get_spacegroup(dyn.structure.get_spglib_cell(), 0.1)" ] }, {