Skip to content

Commit

Permalink
Merge branch 'develop' into publish-gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Feb 7, 2025
2 parents 15f04fe + 5bcb753 commit b41f859
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 5 deletions.
4 changes: 4 additions & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Change Log

## Feb-7-2025: Version 3.14.0

- Release to follow the change of phonopy

## Feb-5-2025: Version 3.13.0

- Release to follow the change of phonopy
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# built documents.
#
# The short X.Y version.
version = "3.13"
version = "3.14"
# The full version, including alpha/beta/rc tags.
release = "3.13.0"
release = "3.14.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
3 changes: 2 additions & 1 deletion phono3py/cui/create_force_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ def parse_forces(
distance_to_A=physical_units["distance_to_A"],
force_to_eVperA=physical_units["force_to_eVperA"],
)
assert dataset is not None
if dataset is None:
raise RuntimeError("Dataset is not found.")

if "natom" in dataset and dataset["natom"] != natom:
raise RuntimeError(
Expand Down
8 changes: 8 additions & 0 deletions phono3py/cui/phono3py_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,14 @@ def get_parser(fc_symmetry=False, is_nac=False, load_phono3py_yaml=False):
default=None,
help="Use symfc for generating force constants",
)
if load_phono3py_yaml:
parser.add_argument(
"--symfc-memshow",
dest="show_symfc_memory_usage",
action="store_true",
default=None,
help="Show symfc memory usage with respect to cutoff distance",
)
parser.add_argument(
"--spf",
dest="is_spectral_function",
Expand Down
25 changes: 25 additions & 0 deletions phono3py/cui/phono3py_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
write_fc3_to_hdf5,
write_phonon_to_hdf5,
)
from phono3py.interface.fc_calculator import estimate_symfc_memory_usage
from phono3py.interface.phono3py_yaml import Phono3pyYaml
from phono3py.phonon.grid import get_grid_point_from_address, get_ir_grid_points
from phono3py.phonon3.dataset import forces_in_dataset
Expand Down Expand Up @@ -1042,6 +1043,30 @@ def main(**argparse_control):
"and supercell structures."
)

###############################
# Memory estimation for symfc #
###############################
if settings.show_symfc_memory_usage and load_phono3py_yaml:
print("Quick estimation of memory size required for solving fc3 by symfc")
vecs, _ = ph3py.primitive.get_smallest_vectors()
dists = np.unique(
np.round(np.linalg.norm(vecs @ ph3py.primitive.cell, axis=-1), decimals=1)
)
print("cutoff memsize")
print("------ -------")
for cutoff in dists[1:] + 0.1:
memsize, memsize2 = estimate_symfc_memory_usage(
ph3py.supercell, ph3py.symmetry, cutoff
)
print(
f"{cutoff:5.1f} {memsize + memsize2:6.2f} GB "
f"({memsize:.2f}+{memsize2:.2f})"
)

if log_level:
print_end_phono3py()
sys.exit(0)

##################
# Check settings #
##################
Expand Down
16 changes: 16 additions & 0 deletions phono3py/cui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Phono3pySettings(Settings):
"sigma_cutoff_width": None,
"solve_collective_phonon": False,
"emulate_v2": False,
"show_symfc_memory_usage": False,
"subtract_forces": None,
"subtract_forces_fc2": None,
"temperatures": None,
Expand Down Expand Up @@ -323,6 +324,10 @@ def set_solve_collective_phonon(self, val):
"""Set solve_collective_phonon."""
self._v["solve_collective_phonon"] = val

def set_show_symfc_memory_usage(self, val):
"""Set show_symfc_memory_usage."""
self._v["show_symfc_memory_usage"] = val

def set_subtract_forces(self, val):
"""Set subtract_forces."""
self._v["subtract_forces"] = val
Expand Down Expand Up @@ -615,6 +620,10 @@ def _read_options(self):
if self._args.solve_collective_phonon:
self._confs["collective_phonon"] = ".true."

if "show_symfc_memory_usage" in self._args:
if self._args.show_symfc_memory_usage:
self._confs["show_symfc_memory_usage"] = ".true."

if "subtract_forces" in self._args:
if self._args.subtract_forces:
self._confs["subtract_forces"] = self._args.subtract_forces
Expand Down Expand Up @@ -695,6 +704,7 @@ def _parse_conf(self):
"N_U",
"spectral_function",
"reducible_collision_matrix",
"show_symfc_memory_usage",
"symmetrize_fc2",
"symmetrize_fc3_q",
"symmetrize_fc3_r",
Expand Down Expand Up @@ -1035,6 +1045,12 @@ def _set_settings(self):
if "scattering_event_class" in params:
self._settings.set_scattering_event_class(params["scattering_event_class"])

# Show symfc memory usage
if "show_symfc_memory_usage" in params:
self._settings.set_show_symfc_memory_usage(
params["show_symfc_memory_usage"]
)

# Cutoff width of smearing function (ratio to sigma value)
if "sigma_cutoff_width" in params:
self._settings.set_sigma_cutoff_width(params["sigma_cutoff_width"])
Expand Down
19 changes: 19 additions & 0 deletions phono3py/interface/fc_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from typing import Optional, Union

import numpy as np
from phonopy.interface.symfc import SymfcFCSolver
from phonopy.structure.atoms import PhonopyAtoms
from phonopy.structure.cells import Primitive
from phonopy.structure.symmetry import Symmetry
Expand Down Expand Up @@ -173,3 +174,21 @@ def update_cutoff_fc_calculator_options(
fc_calc_opts = f"cutoff = {cutoff_pair_distance}"

return fc_calc_opts


def estimate_symfc_memory_usage(
supercell: PhonopyAtoms, symmetry: Symmetry, cutoff: float, batch_size: int = 100
):
"""Estimate memory usage to run symfc for fc3 with cutoff.
Total memory usage is memsize + memsize2. These are separated because
they behave differently with respect to cutoff distance.
batch_size is hardcoded to 100 because it is so in symfc.
"""
symfc_solver = SymfcFCSolver(supercell, symmetry, options={"cutoff": {3: cutoff}})
basis_size = symfc_solver.estimate_basis_size(orders=[3])[3]
memsize = basis_size**2 * 3 * 8 / 10**9
memsize2 = len(supercell) * 3 * batch_size * basis_size * 8 / 10**9
return memsize, memsize2
2 changes: 1 addition & 1 deletion phono3py/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

__version__ = "3.13.0"
__version__ = "3.14.0"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"matplotlib",
"h5py",
"spglib",
"phonopy>=2.36,<2.37",
"phonopy>=2.37,<2.38",
]
license = { file = "LICENSE" }

Expand Down

0 comments on commit b41f859

Please sign in to comment.