Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci_support/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ dependencies:
- sphinx_parser =0.0.1
- tqdm =4.67.1
- pyiron_vasp =0.2.5
- semantikon =0.0.16
64 changes: 37 additions & 27 deletions atomistics/calculators/lammps/libcalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import pandas
from jinja2 import Template
from pylammpsmpi import LammpsASELibrary
from semantikon.converter import units
from semantikon.typing import u

from atomistics.calculators.interface import get_quantities_from_tasks
from atomistics.calculators.lammps.commands import (
Expand Down Expand Up @@ -40,12 +42,13 @@
from atomistics.calculators.interface import TaskName


@units
def optimize_positions_and_volume_with_lammpslib(
structure: Atoms,
potential_dataframe: DataFrame,
min_style: str = "cg",
etol: float = 0.0,
ftol: float = 0.0001,
ftol: u(float, units="eV/angstrom") = 0.0001,
maxiter: int = 100000,
maxeval: int = 10000000,
thermo: int = 10,
Expand Down Expand Up @@ -82,12 +85,13 @@ def optimize_positions_and_volume_with_lammpslib(
return structure_copy


@units
def optimize_positions_with_lammpslib(
structure: Atoms,
potential_dataframe: DataFrame,
min_style: str = "cg",
etol: float = 0.0,
ftol: float = 0.0001,
ftol: u(float, units="eV/angstrom") = 0.0001,
maxiter: int = 100000,
maxeval: int = 10000000,
thermo: int = 10,
Expand Down Expand Up @@ -143,15 +147,16 @@ def calc_static_with_lammpslib(
return result_dict


@units
def calc_molecular_dynamics_nvt_with_lammpslib(
structure: Atoms,
potential_dataframe: pandas.DataFrame,
Tstart: float = 100.0,
Tstop: float = 100.0,
Tdamp: float = 0.1,
Tstart: u(float, units="kelvin") = 100.0,
Tstop: u(float, units="kelvin") = 100.0,
Tdamp: u(float, units="picosecond") = 0.1,
run: int = 100,
thermo: int = 10,
timestep: float = 0.001,
timestep: u(float, units="picosecond") = 0.001,
seed: int = 4928459,
dist: str = "gaussian",
lmp=None,
Expand Down Expand Up @@ -197,18 +202,19 @@ def calc_molecular_dynamics_nvt_with_lammpslib(
return result_dict


@units
def calc_molecular_dynamics_npt_with_lammpslib(
structure: Atoms,
potential_dataframe: pandas.DataFrame,
Tstart: float = 100.0,
Tstop: float = 100.0,
Tdamp: float = 0.1,
Tstart: u(float, units="kelvin") = 100.0,
Tstop: u(float, units="kelvin") = 100.0,
Tdamp: u(float, units="picosecond") = 0.1,
run: int = 100,
thermo: int = 100,
timestep: float = 0.001,
Pstart: float = 0.0,
Pstop: float = 0.0,
Pdamp: float = 1.0,
timestep: u(float, units="picosecond") = 0.001,
Pstart: u(float, units="bar") = 0.0,
Pstop: u(float, units="bar") = 0.0,
Pdamp: u(float, units="picosecond") = 1.0,
seed: int = 4928459,
dist: str = "gaussian",
lmp=None,
Expand Down Expand Up @@ -257,16 +263,17 @@ def calc_molecular_dynamics_npt_with_lammpslib(
return result_dict


@units
def calc_molecular_dynamics_nph_with_lammpslib(
structure: Atoms,
potential_dataframe: pandas.DataFrame,
run: int = 100,
thermo: int = 100,
timestep: float = 0.001,
Tstart: float = 100.0,
Pstart: float = 0.0,
Pstop: float = 0.0,
Pdamp: float = 1.0,
Tstart: u(float, units="kelvin") = 100.0,
Pstart: u(float, units="bar") = 0.0,
Pstop: u(float, units="bar") = 0.0,
Pdamp: u(float, units="picosecond") = 1.0,
seed: int = 4928459,
dist: str = "gaussian",
lmp=None,
Expand Down Expand Up @@ -312,21 +319,23 @@ def calc_molecular_dynamics_nph_with_lammpslib(
return result_dict


@units
def calc_molecular_dynamics_langevin_with_lammpslib(
structure: Atoms,
potential_dataframe: pandas.DataFrame,
run: int = 100,
thermo: int = 100,
timestep: float = 0.001,
Tstart: float = 100.0,
Tstop: float = 100,
Tdamp: float = 0.1,
timestep: u(float, units="picosecond") = 0.001,
Tstart: u(float, units="kelvin") = 100.0,
Tstop: u(float, units="kelvin") = 100.0,
Tdamp: u(float, units="picosecond") = 0.1,
seed: int = 4928459,
dist: str = "gaussian",
lmp=None,
output_keys=OutputMolecularDynamics.keys(),
**kwargs,
):
print("Force", timestep)
init_str = (
LAMMPS_THERMO_STYLE
+ "\n"
Expand Down Expand Up @@ -368,19 +377,20 @@ def calc_molecular_dynamics_langevin_with_lammpslib(
return result_dict


@units
def calc_molecular_dynamics_thermal_expansion_with_lammpslib(
structure: Atoms,
potential_dataframe: pandas.DataFrame,
Tstart: float = 15.0,
Tstop: float = 1500.0,
Tstart: u(float, units="kelvin") = 15.0,
Tstop: u(float, units="kelvin") = 1500.0,
Tstep: int = 5,
Tdamp: float = 0.1,
Tdamp: u(float, units="picosecond") = 0.1,
run: int = 100,
thermo: int = 100,
timestep: float = 0.001,
Pstart: float = 0.0,
Pstop: float = 0.0,
Pdamp: float = 1.0,
Pstart: u(float, units="bar") = 0.0,
Pstop: u(float, units="bar") = 0.0,
Pdamp: u(float, units="picosecond") = 1.0,
seed: int = 4928459,
dist: str = "gaussian",
lmp=None,
Expand Down
5 changes: 4 additions & 1 deletion atomistics/workflows/phonons/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import structuretoolkit
from ase.atoms import Atoms
from phonopy import Phonopy
from semantikon.converter import units
from semantikon.typing import u

from atomistics.shared.output import OutputPhonons, OutputThermodynamic
from atomistics.workflows.phonons.units import VaspToTHz, kJ_mol_to_eV
Expand Down Expand Up @@ -260,10 +262,11 @@ def restore_magmoms(
return structure


@units
def generate_structures_helper(
structure: Atoms,
primitive_matrix: Optional[np.ndarray] = None,
displacement: float = 0.01,
displacement: u(float, units="angstrom") = 0.01,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Good unit specification for displacement parameter.

The displacement parameter is appropriately annotated with angstrom units, which clearly communicates its physical meaning and enables automatic unit conversion.

There is a similar function in atomistics/workflows/quasiharmonic.py that also has a displacement parameter. Consider adding unit annotations there as well for consistency:


🏁 Script executed:

#!/bin/bash
# Check if there are other similar functions that might benefit from unit annotations
grep -rn "def generate_structures_helper" --include="*.py" .

Length of output: 368


🏁 Script executed:

#!/bin/bash
# Display the signature of generate_structures_helper in each file to check for displacement unit annotations
sed -n '1,40p' atomistics/workflows/elastic/helper.py
sed -n '180,240p' atomistics/workflows/evcurve/helper.py
sed -n '357,407p' atomistics/workflows/quasiharmonic.py

Length of output: 5925


Add unit annotation for displacement in QuasiHarmonic helper

The phonons helper correctly uses

displacement: u(float, units="angstrom") = 0.01

to convey units, but the QuasiHarmonic generate_structures_helper still has a plain float:

• File: atomistics/workflows/quasiharmonic.py
• Around line 367 in the def generate_structures_helper(...) signature

Update the parameter to match the phonons helper:

-    displacement: float = 0.01,
+    displacement: u(float, units="angstrom") = 0.01,

And add the corresponding import for u if it’s not already present:

from atomistics.shared.units import u

number_of_snapshots: Optional[int] = None,
interaction_range: float = 10.0,
factor: float = VaspToTHz,
Expand Down
Loading