atomistics 0.3.8__tar.gz → 0.3.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. {atomistics-0.3.8 → atomistics-0.3.10}/.gitignore +3 -0
  2. {atomistics-0.3.8 → atomistics-0.3.10}/PKG-INFO +23 -28
  3. {atomistics-0.3.8 → atomistics-0.3.10}/README.md +4 -9
  4. {atomistics-0.3.8 → atomistics-0.3.10}/pyproject.toml +20 -18
  5. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/_version.py +2 -2
  6. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/ase.py +15 -1
  7. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/hessian.py +16 -5
  8. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/helpers.py +45 -0
  9. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/libcalculator.py +15 -5
  10. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/evcurve/thermo.py +3 -3
  11. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/langevin.py +21 -3
  12. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/phonons/helper.py +58 -11
  13. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/phonons/units.py +4 -1
  14. {atomistics-0.3.8 → atomistics-0.3.10}/LICENSE +0 -0
  15. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/__init__.py +0 -0
  16. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/__init__.py +0 -0
  17. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/interface.py +0 -0
  18. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/__init__.py +0 -0
  19. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/commands.py +0 -0
  20. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/filecalculator.py +0 -0
  21. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/melting.py +0 -0
  22. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/phonon.py +0 -0
  23. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/lammps/shared.py +0 -0
  24. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/qe.py +0 -0
  25. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/sphinxdft.py +0 -0
  26. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/vasp.py +0 -0
  27. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/calculators/wrapper.py +0 -0
  28. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/referencedata/__init__.py +0 -0
  29. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/referencedata/mendeleev.py +0 -0
  30. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/referencedata/wikipedia.py +0 -0
  31. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/referencedata/wolframalpha.py +0 -0
  32. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/shared/__init__.py +0 -0
  33. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/shared/import_warning.py +0 -0
  34. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/shared/output.py +0 -0
  35. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/shared/parallel.py +0 -0
  36. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/shared/thermal_expansion.py +0 -0
  37. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/shared/tqdm_iterator.py +0 -0
  38. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/__init__.py +0 -0
  39. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/elastic/__init__.py +0 -0
  40. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/elastic/elastic_moduli.py +0 -0
  41. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/elastic/helper.py +0 -0
  42. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/elastic/symmetry.py +0 -0
  43. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/elastic/workflow.py +0 -0
  44. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/evcurve/__init__.py +0 -0
  45. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/evcurve/debye.py +0 -0
  46. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/evcurve/fit.py +0 -0
  47. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/evcurve/helper.py +0 -0
  48. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/evcurve/workflow.py +0 -0
  49. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/interface.py +0 -0
  50. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/molecular_dynamics.py +0 -0
  51. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/phonons/__init__.py +0 -0
  52. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/phonons/workflow.py +0 -0
  53. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/quasiharmonic.py +0 -0
  54. {atomistics-0.3.8 → atomistics-0.3.10}/src/atomistics/workflows/structure_optimization.py +0 -0
@@ -216,3 +216,6 @@ __marimo__/
216
216
 
217
217
  # Streamlit
218
218
  .streamlit/secrets.toml
219
+
220
+ # Git worktrees
221
+ .worktrees/
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: atomistics
3
- Version: 0.3.8
3
+ Version: 0.3.10
4
4
  Summary: Interfaces for atomistic simulation codes and workflows
5
5
  Project-URL: Homepage, https://github.com/pyiron/atomistics
6
6
  Project-URL: Documentation, https://atomistics.readthedocs.io
@@ -49,39 +49,39 @@ Classifier: Programming Language :: Python :: 3.13
49
49
  Classifier: Topic :: Scientific/Engineering :: Physics
50
50
  Requires-Python: <3.15,>=3.9
51
51
  Requires-Dist: ase<=3.29.0,>=3.23.0
52
- Requires-Dist: numpy<=2.4.6,>=1.26.4
53
- Requires-Dist: scipy<=1.17.1,>=1.11.2
52
+ Requires-Dist: numpy<=2.5.3,>=1.26.4
53
+ Requires-Dist: scipy<=1.18.1,>=1.11.2
54
54
  Requires-Dist: spglib<=2.7.0,>=2.0.2
55
55
  Provides-Extra: experimental
56
- Requires-Dist: lxml<=6.1.1,>=4.9.1; extra == 'experimental'
57
- Requires-Dist: mendeleev<=1.1.0,>=0.12.0; extra == 'experimental'
58
- Requires-Dist: pandas<=3.0.3,>=2.0.3; extra == 'experimental'
59
- Requires-Dist: requests<=2.32.5,>=2.24.0; extra == 'experimental'
56
+ Requires-Dist: lxml<=6.1.3,>=4.9.1; extra == 'experimental'
57
+ Requires-Dist: mendeleev<=1.3.0,>=0.12.0; extra == 'experimental'
58
+ Requires-Dist: pandas<=3.0.6,>=2.0.3; extra == 'experimental'
59
+ Requires-Dist: requests<=2.34.2,>=2.24.0; extra == 'experimental'
60
60
  Provides-Extra: gpaw
61
61
  Requires-Dist: gpaw<=25.7.0,>=21.6.0; extra == 'gpaw'
62
62
  Provides-Extra: lammps
63
63
  Requires-Dist: jinja2<=3.1.6,>=2.11.3; extra == 'lammps'
64
- Requires-Dist: lammpsparser<=0.0.6,>=0.0.1; extra == 'lammps'
65
- Requires-Dist: pandas<=3.0.3,>=2.0.3; extra == 'lammps'
66
- Requires-Dist: pylammpsmpi<=0.4.0,>=0.2.1; extra == 'lammps'
64
+ Requires-Dist: lammpsparser<=0.0.10,>=0.0.1; extra == 'lammps'
65
+ Requires-Dist: pandas<=3.0.6,>=2.0.3; extra == 'lammps'
66
+ Requires-Dist: pylammpsmpi<=0.5.2,>=0.2.1; extra == 'lammps'
67
67
  Provides-Extra: lammps-phonons
68
68
  Requires-Dist: dynaphopy<=1.18.0,>=1.17.11; extra == 'lammps-phonons'
69
69
  Requires-Dist: jinja2<=3.1.6,>=2.11.3; extra == 'lammps-phonons'
70
- Requires-Dist: lammpsparser<=0.0.6,>=0.0.1; extra == 'lammps-phonons'
71
- Requires-Dist: pandas<=3.0.3,>=2.0.3; extra == 'lammps-phonons'
72
- Requires-Dist: pylammpsmpi<=0.4.0,>=0.2.1; extra == 'lammps-phonons'
70
+ Requires-Dist: lammpsparser<=0.0.10,>=0.0.1; extra == 'lammps-phonons'
71
+ Requires-Dist: pandas<=3.0.6,>=2.0.3; extra == 'lammps-phonons'
72
+ Requires-Dist: pylammpsmpi<=0.5.2,>=0.2.1; extra == 'lammps-phonons'
73
73
  Provides-Extra: phonopy
74
- Requires-Dist: phonopy<=3.2.0,>=2.20.0; extra == 'phonopy'
74
+ Requires-Dist: phonopy<=4.5.0,>=2.20.0; extra == 'phonopy'
75
75
  Requires-Dist: seekpath<=2.2.1,>=1.9.0; extra == 'phonopy'
76
- Requires-Dist: structuretoolkit<=0.0.45,>=0.0.10; extra == 'phonopy'
76
+ Requires-Dist: structuretoolkit<=0.0.47,>=0.0.10; extra == 'phonopy'
77
77
  Provides-Extra: qe
78
78
  Requires-Dist: pwtools==1.3.0; extra == 'qe'
79
79
  Provides-Extra: sphinxdft
80
- Requires-Dist: sphinx-parser==0.1.9; extra == 'sphinxdft'
80
+ Requires-Dist: sphinx-parser==0.1.11; extra == 'sphinxdft'
81
81
  Provides-Extra: tqdm
82
- Requires-Dist: tqdm==4.68.3; extra == 'tqdm'
82
+ Requires-Dist: tqdm==4.70.1; extra == 'tqdm'
83
83
  Provides-Extra: vasp
84
- Requires-Dist: vaspparser==0.0.6; extra == 'vasp'
84
+ Requires-Dist: vaspparser==0.0.12; extra == 'vasp'
85
85
  Description-Content-Type: text/markdown
86
86
 
87
87
  # atomistics
@@ -133,7 +133,7 @@ task_dict = get_tasks_for_energy_volume_curve(
133
133
  structure=bulk("Al", a=4.05, cubic=True),
134
134
  num_points=11,
135
135
  vol_range=0.05,
136
- axes=['x', 'y', 'z'],
136
+ axes=["x", "y", "z"],
137
137
  )
138
138
  print(task_dict)
139
139
  ```
@@ -166,12 +166,7 @@ from atomistics.calculators import evaluate_with_ase
166
166
  from gpaw import GPAW, PW
167
167
 
168
168
  result_dict = evaluate_with_ase(
169
- task_dict=task_dict,
170
- ase_calculator=GPAW(
171
- xc="PBE",
172
- mode=PW(300),
173
- kpts=(3, 3, 3)
174
- )
169
+ task_dict=task_dict, ase_calculator=GPAW(xc="PBE", mode=PW(300), kpts=(3, 3, 3))
175
170
  )
176
171
  print(result_dict)
177
172
  ```
@@ -200,9 +195,9 @@ the first step:
200
195
  from atomistics.workflows import analyse_results_for_energy_volume_curve
201
196
 
202
197
  fit_dict = analyse_results_for_energy_volume_curve(
203
- output_dict=result_dict,
198
+ output_dict=result_dict,
204
199
  task_dict=task_dict,
205
- fit_type='polynomial',
200
+ fit_type="polynomial",
206
201
  fit_order=3,
207
202
  )
208
203
  print(fit_dict)
@@ -47,7 +47,7 @@ task_dict = get_tasks_for_energy_volume_curve(
47
47
  structure=bulk("Al", a=4.05, cubic=True),
48
48
  num_points=11,
49
49
  vol_range=0.05,
50
- axes=['x', 'y', 'z'],
50
+ axes=["x", "y", "z"],
51
51
  )
52
52
  print(task_dict)
53
53
  ```
@@ -80,12 +80,7 @@ from atomistics.calculators import evaluate_with_ase
80
80
  from gpaw import GPAW, PW
81
81
 
82
82
  result_dict = evaluate_with_ase(
83
- task_dict=task_dict,
84
- ase_calculator=GPAW(
85
- xc="PBE",
86
- mode=PW(300),
87
- kpts=(3, 3, 3)
88
- )
83
+ task_dict=task_dict, ase_calculator=GPAW(xc="PBE", mode=PW(300), kpts=(3, 3, 3))
89
84
  )
90
85
  print(result_dict)
91
86
  ```
@@ -114,9 +109,9 @@ the first step:
114
109
  from atomistics.workflows import analyse_results_for_energy_volume_curve
115
110
 
116
111
  fit_dict = analyse_results_for_energy_volume_curve(
117
- output_dict=result_dict,
112
+ output_dict=result_dict,
118
113
  task_dict=task_dict,
119
- fit_type='polynomial',
114
+ fit_type="polynomial",
120
115
  fit_order=3,
121
116
  )
122
117
  print(fit_dict)
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["ase", "numpy", "scipy", "spglib", "hatchling==1.30.1", "hatch-vcs==0.5.0"]
2
+ requires = ["ase", "numpy", "scipy", "spglib", "hatchling==1.32.4", "hatch-vcs==0.5.0"]
3
3
  build-backend = "hatchling.build"
4
4
 
5
5
  [project]
@@ -26,8 +26,8 @@ classifiers = [
26
26
  ]
27
27
  dependencies = [
28
28
  "ase>=3.23.0,<=3.29.0",
29
- "numpy>=1.26.4,<=2.4.6",
30
- "scipy>=1.11.2,<=1.17.1",
29
+ "numpy>=1.26.4,<=2.5.3",
30
+ "scipy>=1.11.2,<=1.18.1",
31
31
  "spglib>=2.0.2,<=2.7.0",
32
32
  ]
33
33
  dynamic = ["version"]
@@ -39,43 +39,43 @@ Repository = "https://github.com/pyiron/atomistics"
39
39
 
40
40
  [project.optional-dependencies]
41
41
  phonopy = [
42
- "phonopy>=2.20.0,<=3.2.0",
42
+ "phonopy>=2.20.0,<=4.5.0",
43
43
  "seekpath>=1.9.0,<=2.2.1",
44
- "structuretoolkit>=0.0.10,<=0.0.45",
44
+ "structuretoolkit>=0.0.10,<=0.0.47",
45
45
  ]
46
46
  gpaw = [
47
47
  "gpaw>=21.6.0,<=25.7.0",
48
48
  ]
49
49
  lammps = [
50
- "pylammpsmpi>=0.2.1,<=0.4.0",
50
+ "pylammpsmpi>=0.2.1,<=0.5.2",
51
51
  "jinja2>=2.11.3,<=3.1.6",
52
- "pandas>=2.0.3,<=3.0.3",
53
- "lammpsparser>=0.0.1,<=0.0.6",
52
+ "pandas>=2.0.3,<=3.0.6",
53
+ "lammpsparser>=0.0.1,<=0.0.10",
54
54
  ]
55
55
  lammps_phonons = [
56
- "pylammpsmpi>=0.2.1,<=0.4.0",
56
+ "pylammpsmpi>=0.2.1,<=0.5.2",
57
57
  "jinja2>=2.11.3,<=3.1.6",
58
- "pandas>=2.0.3,<=3.0.3",
58
+ "pandas>=2.0.3,<=3.0.6",
59
59
  "dynaphopy>=1.17.11,<=1.18.0",
60
- "lammpsparser>=0.0.1,<=0.0.6",
60
+ "lammpsparser>=0.0.1,<=0.0.10",
61
61
  ]
62
62
  experimental = [
63
- "lxml>=4.9.1,<=6.1.1",
64
- "mendeleev>=0.12.0,<=1.1.0",
65
- "pandas>=2.0.3,<=3.0.3",
66
- "requests>=2.24.0,<=2.32.5",
63
+ "lxml>=4.9.1,<=6.1.3",
64
+ "mendeleev>=0.12.0,<=1.3.0",
65
+ "pandas>=2.0.3,<=3.0.6",
66
+ "requests>=2.24.0,<=2.34.2",
67
67
  ]
68
68
  sphinxdft = [
69
- "sphinx-parser==0.1.9"
69
+ "sphinx-parser==0.1.11"
70
70
  ]
71
71
  qe = [
72
72
  "pwtools==1.3.0"
73
73
  ]
74
74
  tqdm = [
75
- "tqdm==4.68.3"
75
+ "tqdm==4.70.1"
76
76
  ]
77
77
  vasp = [
78
- "vaspparser==0.0.6"
78
+ "vaspparser==0.0.12"
79
79
  ]
80
80
 
81
81
  [tool.hatch.build]
@@ -141,6 +141,8 @@ ignore = [
141
141
  "PLE0605",
142
142
  # Too many arguments in function definition
143
143
  "PLR0913",
144
+ # Too many not-keyword-only arguments,
145
+ "PLR0917",
144
146
  # Magic value used in comparison
145
147
  "PLR2004",
146
148
  # Too many statements
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.3.8'
22
- __version_tuple__ = version_tuple = (0, 3, 8)
21
+ __version__ = version = '0.3.10'
22
+ __version_tuple__ = version_tuple = (0, 3, 10)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -246,6 +246,7 @@ def calc_molecular_dynamics_langevin_with_ase(
246
246
  timestep: float = 1.0,
247
247
  temperature: float = 100.0,
248
248
  friction: float = 0.002,
249
+ seed: int = 4928459,
249
250
  output_keys: tuple[str] = OutputMolecularDynamics.keys(),
250
251
  ) -> dict:
251
252
  """
@@ -259,6 +260,7 @@ def calc_molecular_dynamics_langevin_with_ase(
259
260
  timestep (float): The time step size in fs.
260
261
  temperature (float): The desired temperature in Kelvin.
261
262
  friction (float): The friction coefficient for the Langevin thermostat.
263
+ seed (int): Random seed used to initialise the atomic velocities.
262
264
  output_keys (list[str]): The keys of the properties to include in the output dictionary.
263
265
 
264
266
  Returns:
@@ -276,6 +278,7 @@ def calc_molecular_dynamics_langevin_with_ase(
276
278
  temperature=temperature,
277
279
  run=run,
278
280
  thermo=thermo,
281
+ seed=seed,
279
282
  output_keys=output_keys,
280
283
  )
281
284
 
@@ -381,6 +384,7 @@ def calc_molecular_dynamics_thermal_expansion_with_ase(
381
384
  ttime: float = 100 * units.fs,
382
385
  pfactor: float = 2e6 * units.GPa * (units.fs**2),
383
386
  externalstress: np.ndarray = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) * units.bar,
387
+ seed: int = 4928459,
384
388
  output_keys: Iterable[str] = OutputThermalExpansion.keys(),
385
389
  ) -> dict:
386
390
  """
@@ -398,6 +402,8 @@ def calc_molecular_dynamics_thermal_expansion_with_ase(
398
402
  ttime (float, optional): The total time for the simulation in fs. Defaults to 100 * units.fs.
399
403
  pfactor (float, optional): The pressure factor in GPa * fs^2. Defaults to 2e6 * units.GPa * (units.fs**2).
400
404
  externalstress (np.ndarray, optional): The external stress tensor in bar. Defaults to np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) * units.bar.
405
+ seed (int, optional): Random seed used to initialise the atomic velocities at each temperature step,
406
+ so that results are reproducible. Defaults to ``4928459``.
401
407
  output_keys (list[str], optional): The keys of the properties to include in the output dictionary. Defaults to OutputThermalExpansion.keys().
402
408
 
403
409
  Returns:
@@ -419,6 +425,7 @@ def calc_molecular_dynamics_thermal_expansion_with_ase(
419
425
  pfactor=pfactor,
420
426
  temperature=temperature,
421
427
  externalstress=externalstress,
428
+ seed=seed,
422
429
  )
423
430
  structure_current.set_cell(cell=result_dict["cell"][-1], scale_atoms=True)
424
431
  temperature_md_lst.append(result_dict["temperature"][-1])
@@ -440,6 +447,7 @@ def calc_molecular_dynamics_npt_with_ase(
440
447
  pfactor: float = 2e6 * units.GPa * (units.fs**2),
441
448
  temperature: float = 300.0,
442
449
  externalstress: np.ndarray = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) * units.bar,
450
+ seed: int = 4928459,
443
451
  output_keys: Iterable[str] = OutputMolecularDynamics.keys(),
444
452
  ) -> dict:
445
453
  """
@@ -455,6 +463,7 @@ def calc_molecular_dynamics_npt_with_ase(
455
463
  pfactor (float, optional): The pressure factor in GPa * fs^2. Defaults to 2e6 * units.GPa * (units.fs**2).
456
464
  temperature (float, optional): The desired temperature in Kelvin. Defaults to 300.0.
457
465
  externalstress (np.ndarray, optional): The external stress tensor in bar. Defaults to np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) * units.bar.
466
+ seed (int, optional): Random seed used to initialise the atomic velocities. Defaults to ``4928459``.
458
467
  output_keys (list[str], optional): The keys of the properties to include in the output dictionary. Defaults to OutputMolecularDynamics.keys().
459
468
 
460
469
  Returns:
@@ -480,6 +489,7 @@ def calc_molecular_dynamics_npt_with_ase(
480
489
  temperature=temperature,
481
490
  run=run,
482
491
  thermo=thermo,
492
+ seed=seed,
483
493
  output_keys=output_keys,
484
494
  )
485
495
 
@@ -492,6 +502,7 @@ def _calc_molecular_dynamics_with_ase(
492
502
  run: int,
493
503
  thermo: int,
494
504
  output_keys: Iterable[str],
505
+ seed: int | None = None,
495
506
  ) -> dict:
496
507
  """
497
508
  Perform molecular dynamics simulation using ASE.
@@ -504,12 +515,15 @@ def _calc_molecular_dynamics_with_ase(
504
515
  run (int): The number of MD steps to perform.
505
516
  thermo (int): The interval at which to print thermodynamic properties.
506
517
  output_keys (list[str]): The keys of the properties to include in the output dictionary.
518
+ seed (int, optional): Random seed used to initialise the atomic velocities, so that
519
+ results are reproducible. A ``None`` value falls back to the global numpy random state.
507
520
 
508
521
  Returns:
509
522
  dict: A dictionary containing the calculated properties at each MD step.
510
523
  """
511
524
  structure.calc = ase_calculator
512
- MaxwellBoltzmannDistribution(atoms=structure, temperature_K=temperature)
525
+ rng = np.random.RandomState(seed) if seed is not None else None
526
+ MaxwellBoltzmannDistribution(atoms=structure, temperature_K=temperature, rng=rng)
513
527
  output_key_lst = list(output_keys)
514
528
  cache: dict[str, list[Any]] = {q: [] for q in output_key_lst}
515
529
  for _i in range(int(run / thermo)):
@@ -33,7 +33,7 @@ def check_force_constants(structure: Atoms, force_constants: np.ndarray) -> np.n
33
33
  na = np.newaxis
34
34
  return (
35
35
  np.array(force_constants)[:, na, :, na] * np.eye(3)[na, :, na, :]
36
- ).flatten()
36
+ ).reshape(3 * n_atom, 3 * n_atom)
37
37
  elif len(np.shape(force_constants)) == 4:
38
38
  force_shape = np.shape(force_constants)
39
39
  if force_shape[2] == 3 and force_shape[3] == 3:
@@ -189,10 +189,21 @@ def get_pressure_times_volume(
189
189
  np.linalg.inv(structure_equilibrium.cell),
190
190
  ) - np.eye(3)
191
191
  epsilon = (epsilon + epsilon.T) * 0.5
192
- epsilon = np.append(epsilon.diagonal(), np.roll(epsilon, -1, axis=0).diagonal())
193
- pressure = -np.einsum("ij,j->i", stiffness_tensor, epsilon)
194
- pressure = pressure[3:] * np.roll(np.eye(3), -1, axis=1)
195
- pressure += pressure.T + np.eye(3) * pressure[:3]
192
+ epsilon_voigt = np.array(
193
+ [
194
+ epsilon[0, 0],
195
+ epsilon[1, 1],
196
+ epsilon[2, 2],
197
+ epsilon[1, 2],
198
+ epsilon[0, 2],
199
+ epsilon[0, 1],
200
+ ]
201
+ )
202
+ pressure_voigt = -np.einsum("ij,j->i", stiffness_tensor, epsilon_voigt)
203
+ pressure = np.diag(pressure_voigt[:3])
204
+ pressure[1, 2] = pressure[2, 1] = pressure_voigt[3]
205
+ pressure[0, 2] = pressure[2, 0] = pressure_voigt[4]
206
+ pressure[0, 1] = pressure[1, 0] = pressure_voigt[5]
196
207
  return -np.sum(epsilon * pressure) * structure.get_volume()
197
208
  else:
198
209
  return 0.0
@@ -244,3 +244,48 @@ def lammps_shutdown(
244
244
  lmp_instance.interactive_lib_command("clear")
245
245
  if close_instance:
246
246
  lmp_instance.close()
247
+
248
+
249
+ def lammps_get_structure(
250
+ structure: Atoms,
251
+ lmp_instance: LammpsASELibrary,
252
+ set_velocities: bool = True,
253
+ scale_atoms: bool = True,
254
+ set_cell: bool = True,
255
+ ) -> Atoms:
256
+ """
257
+ Capture the current cell, positions, and velocities of a live LAMMPS session as a
258
+ standalone ``ase.Atoms`` snapshot.
259
+
260
+ The returned snapshot can be passed back into ``lammps_run`` (with an input
261
+ template that does not re-initialise velocities, e.g. omitting the
262
+ ``LAMMPS_VELOCITY`` command) to resume the session state later -- there is no
263
+ ``pylammpsmpi`` API to set velocities on an existing session directly, so a full
264
+ session rebuild from such a snapshot is the only way to restore them.
265
+
266
+ Chemical symbols are copied unchanged from ``structure``; callers that need to
267
+ change species (e.g. after a Monte Carlo swap) should call
268
+ ``structure.set_chemical_symbols(...)`` before passing ``structure`` in.
269
+
270
+ Args:
271
+ structure (Atoms): Template structure to copy (species, constraints, etc.);
272
+ its cell, positions, and velocities are overwritten from ``lmp_instance``.
273
+ lmp_instance (LammpsASELibrary): An active LAMMPS library instance.
274
+ set_velocities (bool): Whether to copy velocities from the LAMMPS session.
275
+ Set to ``False`` if the caller intends to re-initialise velocities later.
276
+ scale_atoms (bool): Whether to scale atomic positions when setting the cell.
277
+ Defaults to ``True`` to preserve fractional coordinates; set to ``False``
278
+ set_cell (bool): Whether to copy the cell from the LAMMPS session. Defaults to ``True``.
279
+
280
+ Returns:
281
+ Atoms: A new ``Atoms`` snapshot of the current session state.
282
+ """
283
+ snapshot = structure.copy()
284
+ if set_cell:
285
+ snapshot.set_cell(
286
+ lmp_instance.interactive_cells_getter(), scale_atoms=scale_atoms
287
+ )
288
+ snapshot.set_positions(lmp_instance.interactive_positions_getter())
289
+ if set_velocities:
290
+ snapshot.set_velocities(lmp_instance.interactive_velocities_getter())
291
+ return snapshot
@@ -24,6 +24,7 @@ from atomistics.calculators.lammps.commands import (
24
24
  )
25
25
  from atomistics.calculators.lammps.helpers import (
26
26
  lammps_calc_md,
27
+ lammps_get_structure,
27
28
  lammps_run,
28
29
  lammps_shutdown,
29
30
  lammps_thermal_expansion_loop,
@@ -97,9 +98,13 @@ def optimize_positions_and_volume_with_lammpslib(
97
98
  lmp=lmp,
98
99
  **kwargs,
99
100
  )
100
- structure_copy = structure.copy()
101
- structure_copy.set_cell(lmp_instance.interactive_cells_getter(), scale_atoms=True)
102
- structure_copy.positions = lmp_instance.interactive_positions_getter()
101
+ structure_copy = lammps_get_structure(
102
+ lmp_instance=lmp_instance,
103
+ structure=structure,
104
+ set_velocities=False,
105
+ scale_atoms=True,
106
+ set_cell=True,
107
+ )
103
108
  lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None)
104
109
  return structure_copy
105
110
 
@@ -149,8 +154,13 @@ def optimize_positions_with_lammpslib(
149
154
  lmp=lmp,
150
155
  **kwargs,
151
156
  )
152
- structure_copy = structure.copy()
153
- structure_copy.positions = lmp_instance.interactive_positions_getter()
157
+ structure_copy = lammps_get_structure(
158
+ lmp_instance=lmp_instance,
159
+ structure=structure,
160
+ set_velocities=False,
161
+ scale_atoms=False,
162
+ set_cell=False,
163
+ )
154
164
  lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None)
155
165
  return structure_copy
156
166
 
@@ -210,7 +210,7 @@ class ThermoBulk:
210
210
  raise ValueError()
211
211
  else:
212
212
  self._energies = (
213
- np.ones((len(self.volumes), len(self.temperatures))) * erg_lst
213
+ np.ones((len(self.temperatures), len(self.volumes))) * erg_lst
214
214
  )
215
215
 
216
216
  def set_temperatures(
@@ -495,8 +495,8 @@ class ThermoBulk:
495
495
  import matplotlib.pyplot as plt
496
496
  if ax is None:
497
497
  fig, ax = plt.subplots(1, 1)
498
- ax.xlabel(r"Volume [$\AA^3$]")
499
- ax.ylabel("Temperature [K]")
498
+ ax.set_xlabel(r"Volume [$\AA^3$]")
499
+ ax.set_ylabel("Temperature [K]")
500
500
  ax.plot(self.get_minimum_energy_path(), self.temperatures, *args, **qwargs)
501
501
  return ax
502
502
 
@@ -17,6 +17,7 @@ def langevin_delta_v(
17
17
  masses: np.ndarray,
18
18
  velocities: np.ndarray,
19
19
  damping_timescale: Optional[float] = None,
20
+ rng: Optional[np.random.Generator] = None,
20
21
  ) -> np.ndarray:
21
22
  """
22
23
  Velocity changes due to the Langevin thermostat.
@@ -27,11 +28,14 @@ def langevin_delta_v(
27
28
  masses (numpy.ndarray): Per-atom masses in u with a shape (N_atoms, 1).
28
29
  damping_timescale (float): The characteristic timescale of the thermostat in fs.
29
30
  velocities (numpy.ndarray): Per-atom velocities in angstrom/fs.
31
+ rng (numpy.random.Generator): Random number generator to use for the thermal noise.
30
32
 
31
33
  Returns:
32
34
  (numpy.ndarray): Per atom accelerations to use for changing velocities.
33
35
  """
34
36
  if damping_timescale is not None:
37
+ if rng is None:
38
+ rng = np.random.default_rng()
35
39
  drag = -0.5 * time_step * velocities / damping_timescale
36
40
  noise = np.sqrt(
37
41
  EV_TO_U_ANGSQ_PER_FSSQ
@@ -39,7 +43,7 @@ def langevin_delta_v(
39
43
  * temperature
40
44
  * time_step
41
45
  / (masses * damping_timescale)
42
- ) * np.random.randn(*velocities.shape)
46
+ ) * rng.standard_normal(velocities.shape)
43
47
  noise -= np.mean(noise, axis=0)
44
48
  return drag + noise
45
49
  else:
@@ -61,7 +65,10 @@ def convert_to_acceleration(forces: np.ndarray, masses: np.ndarray) -> np.ndarra
61
65
 
62
66
 
63
67
  def get_initial_velocities(
64
- temperature: float, masses: np.ndarray, overheat_fraction: float = 2.0
68
+ temperature: float,
69
+ masses: np.ndarray,
70
+ overheat_fraction: float = 2.0,
71
+ rng: Optional[np.random.Generator] = None,
65
72
  ) -> np.ndarray:
66
73
  """
67
74
  Generate initial velocities for the Langevin thermostat.
@@ -70,14 +77,17 @@ def get_initial_velocities(
70
77
  temperature (float): The target temperature in K.
71
78
  masses (numpy.ndarray): Per-atom masses in u with a shape (N_atoms, 1).
72
79
  overheat_fraction (float): The factor to overheat the system by (default: 2.0).
80
+ rng (numpy.random.Generator): Random number generator to use for the initial velocities.
73
81
 
74
82
  Returns:
75
83
  (numpy.ndarray): Per-atom velocities in angstrom/fs.
76
84
  """
85
+ if rng is None:
86
+ rng = np.random.default_rng()
77
87
  vel_scale = np.sqrt(EV_TO_U_ANGSQ_PER_FSSQ * KB * temperature / masses) * np.sqrt(
78
88
  overheat_fraction
79
89
  )
80
- vel_dir = np.random.randn(len(masses), 3)
90
+ vel_dir = rng.standard_normal((len(masses), 3))
81
91
  velocities = vel_scale * vel_dir
82
92
  velocities -= np.mean(velocities, axis=0)
83
93
  return velocities
@@ -112,6 +122,8 @@ class LangevinWorkflow(Workflow):
112
122
  overheat_fraction (float, optional): The fraction by which to overheat the system. Default is 2.0.
113
123
  damping_timescale (float, optional): The damping timescale in fs. Default is 100.0.
114
124
  time_step (int, optional): The time step in fs. Default is 1.
125
+ seed (int, optional): Seed for the random number generator, for reproducible
126
+ trajectories. Default is None, which uses non-deterministic entropy.
115
127
 
116
128
  Attributes:
117
129
  structure (ase.Atoms): The atomic structure.
@@ -138,18 +150,22 @@ class LangevinWorkflow(Workflow):
138
150
  overheat_fraction: float = 2.0,
139
151
  damping_timescale: float = 100.0,
140
152
  time_step: int = 1,
153
+ seed: Optional[int] = None,
141
154
  ):
142
155
  self.structure = structure
143
156
  self.temperature = temperature
144
157
  self.overheat_fraction = overheat_fraction
145
158
  self.damping_timescale = damping_timescale
146
159
  self.time_step = time_step
160
+ self.seed = seed
161
+ self.rng = np.random.default_rng(seed)
147
162
  self.masses = np.array([a.mass for a in self.structure[:]])[:, np.newaxis]
148
163
  self.positions = self.structure.positions
149
164
  self.velocities = get_initial_velocities(
150
165
  temperature=self.temperature,
151
166
  masses=self.masses,
152
167
  overheat_fraction=self.overheat_fraction,
168
+ rng=self.rng,
153
169
  )
154
170
  self.gamma = self.masses / self.damping_timescale
155
171
  self.forces: Optional[np.ndarray] = None
@@ -177,6 +193,7 @@ class LangevinWorkflow(Workflow):
177
193
  masses=self.masses,
178
194
  damping_timescale=self.damping_timescale,
179
195
  velocities=self.velocities,
196
+ rng=self.rng,
180
197
  )
181
198
 
182
199
  # postion update
@@ -211,6 +228,7 @@ class LangevinWorkflow(Workflow):
211
228
  masses=self.masses,
212
229
  damping_timescale=self.damping_timescale,
213
230
  velocities=self.velocities,
231
+ rng=self.rng,
214
232
  )
215
233
 
216
234
  # kinetic energy
@@ -80,7 +80,18 @@ class PhonopyProperties:
80
80
  with_eigenvectors=self._with_eigenvectors,
81
81
  with_group_velocities=self._with_group_velocities,
82
82
  )
83
- self._band_structure_dict = self._phonopy.get_band_structure_dict()
83
+ bs = self._phonopy.band_structure
84
+ if bs is None:
85
+ raise ValueError(
86
+ "Phonopy band structure calculation did not produce a result."
87
+ )
88
+ self._band_structure_dict = {
89
+ "qpoints": bs.qpoints,
90
+ "distances": bs.distances,
91
+ "frequencies": bs.frequencies,
92
+ "eigenvectors": bs.eigenvectors,
93
+ "group_velocities": bs.group_velocities,
94
+ }
84
95
 
85
96
  def _calc_force_constants(self):
86
97
  """
@@ -110,7 +121,18 @@ class PhonopyProperties:
110
121
  with_group_velocities=self._with_group_velocities,
111
122
  is_gamma_center=self._is_gamma_center,
112
123
  )
113
- self._mesh_dict = self._phonopy.get_mesh_dict()
124
+ mesh = self._phonopy.mesh
125
+ if mesh is None:
126
+ raise ValueError(
127
+ "Phonopy mesh calculation did not produce a mesh dictionary."
128
+ )
129
+ self._mesh_dict = {
130
+ "qpoints": mesh.qpoints,
131
+ "weights": mesh.weights,
132
+ "frequencies": mesh.frequencies,
133
+ "eigenvectors": mesh.eigenvectors,
134
+ "group_velocities": mesh.group_velocities,
135
+ }
114
136
  if self._mesh_dict is None:
115
137
  raise ValueError(
116
138
  "Phonopy mesh calculation did not produce a mesh dictionary."
@@ -191,7 +213,22 @@ class PhonopyThermalProperties:
191
213
  phonopy_instance (Phonopy): The Phonopy instance.
192
214
  """
193
215
  self._phonopy = phonopy_instance
194
- self._thermal_properties = phonopy_instance.get_thermal_properties_dict()
216
+ thermal_props = phonopy_instance.thermal_properties
217
+ if thermal_props is None:
218
+ raise RuntimeError(
219
+ "run_thermal_properties has to be done before getting thermal properties."
220
+ )
221
+ tp = thermal_props.thermal_properties
222
+ if tp is None:
223
+ raise RuntimeError(
224
+ "Thermal properties are not available. Run run_thermal_properties first."
225
+ )
226
+ self._thermal_properties = {
227
+ "temperatures": tp[0],
228
+ "free_energy": tp[1],
229
+ "entropy": tp[2],
230
+ "heat_capacity": tp[3],
231
+ }
195
232
 
196
233
  def free_energy(self) -> np.ndarray:
197
234
  """
@@ -304,7 +341,7 @@ def get_tasks_for_harmonic_approximation(
304
341
  interaction_range=interaction_range,
305
342
  cell=unitcell.cell,
306
343
  ),
307
- primitive_matrix=primitive_matrix,
344
+ primitive_matrix="P" if primitive_matrix is None else primitive_matrix,
308
345
  )
309
346
  phonopy_obj.generate_displacements(
310
347
  distance=displacement,
@@ -402,6 +439,10 @@ def get_thermal_properties_for_harmonic_approximation(
402
439
  Returns:
403
440
  dict: The thermal properties as returned by Phonopy.
404
441
  """
442
+ if is_projection:
443
+ raise ValueError(
444
+ "is_projection=True is no longer supported as phonopy removed this parameter from run_thermal_properties()."
445
+ )
405
446
  phonopy.run_thermal_properties(
406
447
  t_step=t_step,
407
448
  t_max=t_max,
@@ -410,7 +451,6 @@ def get_thermal_properties_for_harmonic_approximation(
410
451
  cutoff_frequency=cutoff_frequency,
411
452
  pretend_real=pretend_real,
412
453
  band_indices=band_indices,
413
- is_projection=is_projection,
414
454
  )
415
455
  phono = PhonopyThermalProperties(phonopy_instance=phonopy)
416
456
  return OutputThermodynamic(
@@ -535,7 +575,16 @@ def get_band_structure(
535
575
  with_eigenvectors=with_eigenvectors,
536
576
  with_group_velocities=with_group_velocities,
537
577
  )
538
- results = phonopy.get_band_structure_dict()
578
+ bs = phonopy.band_structure
579
+ if bs is None:
580
+ raise ValueError("Phonopy band structure calculation did not produce a result.")
581
+ results = {
582
+ "qpoints": bs.qpoints,
583
+ "distances": bs.distances,
584
+ "frequencies": bs.frequencies,
585
+ "eigenvectors": bs.eigenvectors,
586
+ "group_velocities": bs.group_velocities,
587
+ }
539
588
  if results["eigenvectors"] is not None:
540
589
  # see https://phonopy.github.io/phonopy/phonopy-module.html#eigenvectors for the way phonopy stores the
541
590
  # eigenvectors
@@ -572,9 +621,7 @@ def plot_band_structure(
572
621
  """
573
622
  import matplotlib.pyplot as plt
574
623
 
575
- results = phonopy.get_band_structure_dict()
576
- # HACK: strictly speaking this breaks phonopy API and could bite us
577
- band_structure = phonopy._band_structure
624
+ band_structure = phonopy.band_structure
578
625
  if band_structure is None:
579
626
  raise ValueError("Phonopy band structure is not available.")
580
627
  path_connections = band_structure.path_connections
@@ -582,8 +629,8 @@ def plot_band_structure(
582
629
  if axis is None:
583
630
  _, axis = plt.subplots(1, 1)
584
631
 
585
- distances = results["distances"]
586
- frequencies = results["frequencies"]
632
+ distances = band_structure.distances
633
+ frequencies = band_structure.frequencies
587
634
 
588
635
  if "color" not in kwargs:
589
636
  kwargs["color"] = "black"
@@ -1,7 +1,10 @@
1
1
  import scipy.constants
2
- from phonopy.units import EvTokJmol, THzToEv
2
+ from phonopy.physical_units import get_physical_units
3
3
 
4
4
  kJ_mol_to_eV = 1000 / scipy.constants.Avogadro / scipy.constants.electron_volt
5
5
  kb = scipy.constants.physical_constants["Boltzmann constant in eV/K"][0]
6
+ _phonopy_units = get_physical_units()
7
+ THzToEv = _phonopy_units.THzToEv
8
+ EvTokJmol = _phonopy_units.EvTokJmol
6
9
 
7
10
  __all__ = ["kb", "kJ_mol_to_eV", "THzToEv", "EvTokJmol"]
File without changes