Skip to content

Commit

Permalink
abiml.py ph now computes phdos automatically and abiopen supports pho…
Browse files Browse the repository at this point in the history
…nopy_params.yaml files
  • Loading branch information
gmatteo committed Jul 30, 2024
1 parent 8eafb93 commit f08ce91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
5 changes: 5 additions & 0 deletions abipy/abilab.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ def abiopen(filepath: str):
# Assume Abinit log file.
return AbinitLogFile.from_file(filepath)

if os.path.basename(filepath) == "phonopy_params.yaml":
# Handle phonopy object.
import phonopy
return phonopy.load(filepath)

cls = abifile_subclass_from_filename(filepath)
return cls.from_file(filepath)

Expand Down
23 changes: 10 additions & 13 deletions abipy/ml/ml_phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ def _run_nn_name(self, nn_name: str) -> None:
#from phonopy.file_IO import write_FORCE_CONSTANTS
#write_FORCE_CONSTANTS(force_constants, filename=str(self.workdir / f"{nn_name}_FORCE_CONSTANTS"))

show = False
#from abipy.dfpt.phonons import PhononBands, PhononBandsPlotter
#with Timer(header="Starting phonopy ph-bands computation...", footer=""):
# phonon.run_band_structure(self.py_qpoints, with_eigenvectors=True)
Expand All @@ -458,22 +457,20 @@ def _run_nn_name(self, nn_name: str) -> None:
filename=workdir / f"{nn_name}_band.yml",
)
plt.savefig(workdir / f"phonopy_{nn_name}_phbands.png")
if show: plt.show()
plt.close()

# Save phonopy object in Yaml format.
phonon.save(filename=workdir / f"phonopy_params.yaml", settings={'force_constants': True})

#mesh = [20, 20, 20]
#phonon.run_mesh(mesh)
#mesh_dict = phonon.get_mesh_dict()
#qpoints = mesh_dict['qpoints']
#weights = mesh_dict['weights']
#frequencies = mesh_dict['frequencies']
#eigenvectors = mesh_dict['eigenvectors']
#group_velocities = mesh_dict['group_velocities']

#phonon.auto_total_dos(plot=True).show()
#phonon.auto_projected_dos(plot=True).show()
# Compute phonon DOS and generate file with figure.
phonon.auto_total_dos(plot=True)
plt.savefig(workdir / f"phonopy_{nn_name}_phdos.png")
plt.close()

# Compute site-project phonon DOS and generate file with figure.
#phonon.auto_projected_dos(plot=True)
#plt.savefig(workdir / f"phonopy_{nn_name}_pjdos.png")
#plt.close()

#phon#on.run_mesh([20, 20, 20])
#phonon.run_thermal_properties(t_step=10, t_max=1000, t_min=0)
Expand Down

0 comments on commit f08ce91

Please sign in to comment.