atomict 1.2.16__tar.gz → 1.2.19__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.
- {atomict-1.2.16 → atomict-1.2.19}/PKG-INFO +2 -1
- atomict-1.2.19/atomict/__version__.py +1 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/ase/atatoms.py +1 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/simulation/kpoint.py +1 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/core/client.py +1 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/ext/custom_classes.py +1 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/main.py +30 -29
- atomict-1.2.19/atomict/infra/__init__.py +3 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/infra/distwork/task.py +14 -9
- atomict-1.2.16/atomict/io/msgpack.py → atomict-1.2.19/atomict/io/atoms.py +87 -237
- atomict-1.2.19/atomict/io/formats/atraj.py +99 -0
- atomict-1.2.19/atomict/io/formats/tess.py +319 -0
- atomict-1.2.19/atomict/io/formats/traj.py +62 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/project/project.py +1 -2
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/fhi_aims.py +5 -4
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/mlrelax.py +35 -16
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/models.py +2 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/qe.py +1 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/utils.py +3 -3
- {atomict-1.2.16 → atomict-1.2.19}/atomict/user/files.py +11 -8
- {atomict-1.2.16 → atomict-1.2.19}/atomict/user/workspace.py +1 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict.egg-info/PKG-INFO +2 -1
- {atomict-1.2.16 → atomict-1.2.19}/atomict.egg-info/SOURCES.txt +4 -2
- {atomict-1.2.16 → atomict-1.2.19}/atomict.egg-info/requires.txt +1 -0
- {atomict-1.2.16 → atomict-1.2.19}/requirements.txt +1 -0
- atomict-1.2.16/atomict/__version__.py +0 -1
- atomict-1.2.16/atomict/io/trajectory.py +0 -437
- atomict-1.2.16/atomict/utils/fhiaims/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/LICENSE +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/README.md +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/api.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/auth.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/adsorbate.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/ai_assist.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/catalysis.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/common.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/exploration/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/exploration/soec.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/exploration/sqs.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/helpers.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/k8s.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/login.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/organization.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/project.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/simulation/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/simulation/catalysis.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/simulation/fhiaims.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/simulation/vibes.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/simulation.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/task.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/token.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/traj.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/upload.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/commands/user.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/core/config.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/cli/core/utils.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/env.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/exceptions.py +0 -0
- {atomict-1.2.16/atomict/infra → atomict-1.2.19/atomict/infra/distwork}/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/infra/distwork/environment.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/infra/logging.py +0 -0
- {atomict-1.2.16/atomict/infra/distwork → atomict-1.2.19/atomict/io}/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/io/cif.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/io/fhiaims.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/io/utils.py +0 -0
- {atomict-1.2.16/atomict/io → atomict-1.2.19/atomict/ml}/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/ml/model.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/project/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/project/link.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/project/note.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/project/tags.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/project/workbench.py +0 -0
- {atomict-1.2.16/atomict/ml → atomict-1.2.19/atomict/reality}/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/reality/oqmd.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/reality/slabs.py +0 -0
- {atomict-1.2.16/atomict/reality → atomict-1.2.19/atomict/simulation}/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/cantera.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/catalysis.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/counterfactual.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/defect.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/ea.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/impact.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/kpoint.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/mattergen.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/md.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/phonon.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/sh.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/simulation/sqs.py +0 -0
- {atomict-1.2.16/atomict/simulation → atomict-1.2.19/atomict/user}/__init__.py +0 -0
- {atomict-1.2.16/atomict/user → atomict-1.2.19/atomict/utils/fhiaims}/__init__.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/utils/fhiaims/geometry.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/utils/tenacity.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict/utils/traj.py +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict.egg-info/dependency_links.txt +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict.egg-info/entry_points.txt +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/atomict.egg-info/top_level.txt +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/pyproject.toml +0 -0
- {atomict-1.2.16 → atomict-1.2.19}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: atomict
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.19
|
|
4
4
|
Summary: The client application for the https://atomictessellator.com/
|
|
5
5
|
Author-email: Steven Anderson <steven@atomictessellator.com>, Alain Richardt <alain@atomictessellator.com>
|
|
6
6
|
License: MIT
|
|
@@ -23,6 +23,7 @@ Requires-Dist: httpx
|
|
|
23
23
|
Requires-Dist: click~=8.0
|
|
24
24
|
Requires-Dist: rich~=13.0
|
|
25
25
|
Requires-Dist: deepdiff
|
|
26
|
+
Requires-Dist: lz4
|
|
26
27
|
Provides-Extra: utils
|
|
27
28
|
Requires-Dist: ase>=3.23.0; extra == "utils"
|
|
28
29
|
Requires-Dist: spglib==2.5.0; extra == "utils"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.2.19"
|
|
@@ -22,7 +22,7 @@ handler = logging.StreamHandler(sys.stdout)
|
|
|
22
22
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
23
23
|
handler.setFormatter(formatter)
|
|
24
24
|
logger.addHandler(handler)
|
|
25
|
-
logger.setLevel(logging.
|
|
25
|
+
logger.setLevel(logging.ERROR)
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class ATAtomsError(Exception):
|
|
@@ -356,7 +356,7 @@ def get_analysis(
|
|
|
356
356
|
|
|
357
357
|
@kpoint_group.command()
|
|
358
358
|
@click.argument("analysis")
|
|
359
|
-
@click.option("--exploration", required=True, help="Exploration
|
|
359
|
+
@click.option("--exploration", required=True, help="Exploration ID")
|
|
360
360
|
def create_analysis(exploration: str, analysis: str):
|
|
361
361
|
"""Create a new K-point analysis. Takes JSON analysis data as main argument."""
|
|
362
362
|
client = get_client()
|
|
@@ -128,7 +128,7 @@ class APIClient:
|
|
|
128
128
|
)
|
|
129
129
|
|
|
130
130
|
console.print(
|
|
131
|
-
"[yellow]For help, join the Atomic Tessellator discord community: https://discord.com/invite/
|
|
131
|
+
"[yellow]For help, join the Atomic Tessellator discord community: https://discord.com/invite/atomictessellator[/yellow]"
|
|
132
132
|
)
|
|
133
133
|
logger.debug(f"Server error response: {error_data}")
|
|
134
134
|
sys.exit(1)
|
|
@@ -41,6 +41,6 @@ class DefaultCommandGroup(click.Group):
|
|
|
41
41
|
# Add additional resources section with extra spacing
|
|
42
42
|
additional_resources = "\n\nAdditional Resources:\n"
|
|
43
43
|
additional_resources += " To get help join the Atomic Tessellator discord community at this link:\n"
|
|
44
|
-
additional_resources += " https://discord.com/invite/
|
|
44
|
+
additional_resources += " https://discord.com/invite/atomictessellator\n"
|
|
45
45
|
|
|
46
46
|
return help_text + additional_resources
|
|
@@ -61,8 +61,7 @@ def cli(ctx, verbose: bool):
|
|
|
61
61
|
@cli.command(default_command=True)
|
|
62
62
|
@click.argument("input_file", required=True)
|
|
63
63
|
@click.argument("output_file", required=True)
|
|
64
|
-
|
|
65
|
-
def convert(input_file, output_file, strict_map_keys):
|
|
64
|
+
def convert(input_file, output_file):
|
|
66
65
|
"""Convert between atomic structure file formats using ASE
|
|
67
66
|
|
|
68
67
|
Supports all formats that ASE can read/write, with special handling for .atm and .atraj files.
|
|
@@ -71,14 +70,13 @@ def convert(input_file, output_file, strict_map_keys):
|
|
|
71
70
|
tess input.xyz output.atm
|
|
72
71
|
tess input.traj output.atraj
|
|
73
72
|
|
|
74
|
-
Options:
|
|
75
|
-
--strict-map-keys Enable strict map keys in msgpack files (default: False)
|
|
76
73
|
"""
|
|
77
74
|
try:
|
|
78
75
|
import os.path
|
|
79
76
|
from ase.io import read, write
|
|
80
77
|
from ase.io.formats import UnknownFileTypeError
|
|
81
|
-
from atomict.io.
|
|
78
|
+
from atomict.io.formats.atraj import read_atraj, write_atraj
|
|
79
|
+
from atomict.io.formats.tess import read_tess, write_tess
|
|
82
80
|
except ImportError:
|
|
83
81
|
console.print("[red]Error: ASE (Atomic Simulation Environment) is required for file conversion.[/red]")
|
|
84
82
|
console.print("[yellow]Install it with: pip install ase[/yellow]")
|
|
@@ -103,30 +101,34 @@ def convert(input_file, output_file, strict_map_keys):
|
|
|
103
101
|
console.print(f"[red]Error: Input file '{input_file}' not found.[/red]")
|
|
104
102
|
return
|
|
105
103
|
|
|
106
|
-
|
|
107
|
-
traj_msgpack_formats = ["atraj"]
|
|
104
|
+
traj_msgpack_formats = ["atraj", "tess"]
|
|
108
105
|
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
def _is_supported(ext: str) -> bool:
|
|
107
|
+
return (
|
|
108
|
+
ext in RW_FORMATS
|
|
109
|
+
or ext in traj_msgpack_formats
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
def _print_supported_error(ext: str, action: str) -> None:
|
|
113
|
+
console.print(f"[red]Error: Format '{ext}' is not supported for {action}.[/red]")
|
|
111
114
|
console.print("[yellow]Supported read/write formats include:[/yellow]")
|
|
112
115
|
for i in range(0, len(RW_FORMATS), 5):
|
|
113
116
|
console.print("[yellow] " + ", ".join(RW_FORMATS[i:i+5]) + "[/yellow]")
|
|
114
|
-
console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory)[/yellow]")
|
|
117
|
+
console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory), tess (msgpack trajectory)[/yellow]")
|
|
118
|
+
|
|
119
|
+
if not _is_supported(input_ext):
|
|
120
|
+
_print_supported_error(input_ext, "reading")
|
|
115
121
|
return
|
|
116
|
-
|
|
117
|
-
if
|
|
118
|
-
|
|
119
|
-
console.print("[yellow]Supported read/write formats include:[/yellow]")
|
|
120
|
-
for i in range(0, len(RW_FORMATS), 5):
|
|
121
|
-
console.print("[yellow] " + ", ".join(RW_FORMATS[i:i+5]) + "[/yellow]")
|
|
122
|
-
console.print("[yellow]Special formats: atm (msgpack), atraj (msgpack trajectory)[/yellow]")
|
|
122
|
+
|
|
123
|
+
if not _is_supported(output_ext):
|
|
124
|
+
_print_supported_error(output_ext, "writing")
|
|
123
125
|
return
|
|
124
126
|
|
|
125
127
|
try:
|
|
126
|
-
if input_ext
|
|
127
|
-
atoms =
|
|
128
|
-
elif input_ext
|
|
129
|
-
atoms, _ =
|
|
128
|
+
if input_ext == "atraj":
|
|
129
|
+
atoms, _ = read_atraj(input_file)
|
|
130
|
+
elif input_ext == "tess":
|
|
131
|
+
atoms, _ = read_tess(input_file)
|
|
130
132
|
else:
|
|
131
133
|
atoms = read(input_file, index=":")
|
|
132
134
|
except UnknownFileTypeError:
|
|
@@ -140,15 +142,14 @@ def convert(input_file, output_file, strict_map_keys):
|
|
|
140
142
|
return
|
|
141
143
|
|
|
142
144
|
try:
|
|
143
|
-
if output_ext
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
save_msgpack_trajectory(atoms, output_file)
|
|
148
|
-
console.print(f"[green]Successfully converted {input_file} to {output_file} (MSGPACK trajectory format)[/green]")
|
|
145
|
+
if output_ext == "atraj":
|
|
146
|
+
write_atraj(atoms, output_file)
|
|
147
|
+
elif output_ext == "tess":
|
|
148
|
+
write_tess(atoms, output_file)
|
|
149
149
|
else:
|
|
150
150
|
write(output_file, atoms)
|
|
151
|
-
|
|
151
|
+
|
|
152
|
+
console.print(f"[green]Successfully converted {input_file} to {output_file}[/green]")
|
|
152
153
|
|
|
153
154
|
except UnknownFileTypeError:
|
|
154
155
|
console.print(f"[red]Error: Unknown file type for output file '{output_file}'[/red]")
|
|
@@ -199,7 +200,7 @@ if type -q tess
|
|
|
199
200
|
end
|
|
200
201
|
"""
|
|
201
202
|
click.echo(f"# Shell completion for {shell}")
|
|
202
|
-
click.echo(completion_script.strip())
|
|
203
|
+
click.echo((completion_script or "").strip())
|
|
203
204
|
click.echo(
|
|
204
205
|
"# Don't forget to source your rc file! `source ~/.bashrc` or `source ~/.zshrc` ..."
|
|
205
206
|
)
|
|
@@ -4,6 +4,11 @@ from atomict.api import get, patch
|
|
|
4
4
|
from atomict.exceptions import UserTaskAbortException
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
class SimulationAction(Enum):
|
|
8
|
+
SAVE_DRAFT = "DRAFT"
|
|
9
|
+
LAUNCH = "LAUNCH"
|
|
10
|
+
|
|
11
|
+
|
|
7
12
|
class TaskStatus(Enum):
|
|
8
13
|
DRAFT = 0
|
|
9
14
|
READY = 1
|
|
@@ -14,22 +19,22 @@ class TaskStatus(Enum):
|
|
|
14
19
|
USER_ABORTED = 6
|
|
15
20
|
|
|
16
21
|
|
|
17
|
-
def get_task(
|
|
18
|
-
return get(f"api/tasks/{
|
|
22
|
+
def get_task(task_id: str):
|
|
23
|
+
return get(f"api/tasks/{task_id}/")
|
|
19
24
|
|
|
20
25
|
|
|
21
|
-
def task_should_abort(
|
|
22
|
-
task = get_task(
|
|
26
|
+
def task_should_abort(task_id: str) -> bool:
|
|
27
|
+
task = get_task(task_id)
|
|
23
28
|
return task["user_aborted_flag"]
|
|
24
29
|
|
|
25
30
|
|
|
26
|
-
def except_on_user_abort(
|
|
27
|
-
if task_should_abort(
|
|
28
|
-
raise UserTaskAbortException(f"User aborted task {
|
|
31
|
+
def except_on_user_abort(task_id: str):
|
|
32
|
+
if task_should_abort(task_id):
|
|
33
|
+
raise UserTaskAbortException(f"User aborted task {task_id}")
|
|
29
34
|
|
|
30
35
|
|
|
31
36
|
def update_task_status(
|
|
32
|
-
|
|
37
|
+
task_id: str, status: TaskStatus = None, error_msg: str = None, percent: int = None, progress_indeterminate: bool = None
|
|
33
38
|
):
|
|
34
39
|
payload = {}
|
|
35
40
|
|
|
@@ -45,5 +50,5 @@ def update_task_status(
|
|
|
45
50
|
if progress_indeterminate is not None:
|
|
46
51
|
payload["progress_indeterminate"] = progress_indeterminate
|
|
47
52
|
|
|
48
|
-
res = patch(f"api/tasks/{
|
|
53
|
+
res = patch(f"api/tasks/{task_id}/", payload=payload)
|
|
49
54
|
return res
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import numpy as np
|
|
2
|
+
from ase import Atoms
|
|
3
|
+
from ase.constraints import dict2constraint
|
|
4
|
+
from ase.calculators.singlepoint import SinglePointCalculator
|
|
2
5
|
|
|
3
6
|
|
|
4
7
|
def atoms_to_dict(atoms_list, selective=False):
|
|
@@ -16,7 +19,6 @@ def atoms_to_dict(atoms_list, selective=False):
|
|
|
16
19
|
Dict
|
|
17
20
|
Dictionary with all extracted properties
|
|
18
21
|
"""
|
|
19
|
-
import numpy as np
|
|
20
22
|
|
|
21
23
|
# Create data structure with common properties
|
|
22
24
|
data = {
|
|
@@ -205,91 +207,113 @@ def dict_to_atoms(data):
|
|
|
205
207
|
List[Atoms]
|
|
206
208
|
List of ASE Atoms objects
|
|
207
209
|
"""
|
|
208
|
-
try:
|
|
209
|
-
import numpy as np
|
|
210
|
-
from ase import Atoms
|
|
211
|
-
from ase.constraints import dict2constraint
|
|
212
|
-
from ase.calculators.singlepoint import SinglePointCalculator
|
|
213
|
-
except ImportError:
|
|
214
|
-
raise ImportError("You need to install with `pip install atomict[tools]` to use msgpack I/O")
|
|
215
210
|
|
|
216
211
|
n_frames = data['n_frames']
|
|
217
|
-
atoms_list = []
|
|
218
|
-
|
|
219
|
-
#
|
|
212
|
+
atoms_list = [None] * n_frames # type: ignore[assignment]
|
|
213
|
+
|
|
214
|
+
# Cache lookups outside loop for speed
|
|
220
215
|
unique_symbols = data['unique_symbols']
|
|
216
|
+
unique_symbols_array = np.asarray(unique_symbols, dtype=object)
|
|
221
217
|
symbols_map = data['symbols']
|
|
222
|
-
|
|
223
|
-
|
|
218
|
+
positions = data['positions']
|
|
219
|
+
cells = data['cell']
|
|
220
|
+
pbc = data['pbc']
|
|
221
|
+
n_atoms_seq = data['n_atoms']
|
|
222
|
+
|
|
223
|
+
numbers_data = data.get('numbers')
|
|
224
|
+
has_numbers = numbers_data is not None
|
|
225
|
+
|
|
226
|
+
tags = data.get('tags')
|
|
227
|
+
masses = data.get('masses')
|
|
228
|
+
momenta = data.get('momenta')
|
|
229
|
+
initial_charges = data.get('initial_charges')
|
|
230
|
+
initial_magmoms = data.get('initial_magmoms')
|
|
231
|
+
top_mask = data.get('top_mask')
|
|
232
|
+
constraints = data.get('constraints')
|
|
233
|
+
ase_objtype = data.get('ase_objtype')
|
|
234
|
+
forces = data.get('forces')
|
|
235
|
+
stress = data.get('stress')
|
|
236
|
+
atom_infos = data.get('atom_infos')
|
|
237
|
+
custom_arrays = data.get('custom_arrays')
|
|
238
|
+
calc_results = data.get('calc_results')
|
|
239
|
+
|
|
224
240
|
for i in range(n_frames):
|
|
225
|
-
|
|
226
|
-
if isinstance(
|
|
227
|
-
|
|
241
|
+
symbols_entry = symbols_map[i]
|
|
242
|
+
if isinstance(symbols_entry, np.ndarray):
|
|
243
|
+
symbols_idx = symbols_entry
|
|
228
244
|
else:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
245
|
+
start_idx = i * n_atoms_seq[i]
|
|
246
|
+
symbols_idx = symbols_map[start_idx:start_idx + n_atoms_seq[i]]
|
|
247
|
+
|
|
248
|
+
if has_numbers:
|
|
249
|
+
atoms = Atoms(
|
|
250
|
+
numbers=numbers_data[i],
|
|
251
|
+
positions=positions[i],
|
|
252
|
+
cell=cells[i],
|
|
253
|
+
pbc=pbc[i],
|
|
254
|
+
)
|
|
255
|
+
else:
|
|
256
|
+
# Avoid numpy conversion and tolist() for small arrays
|
|
257
|
+
if isinstance(symbols_idx, np.ndarray):
|
|
258
|
+
frame_symbols = [unique_symbols[idx] for idx in symbols_idx]
|
|
259
|
+
else:
|
|
260
|
+
frame_symbols = [unique_symbols[idx] for idx in symbols_idx]
|
|
261
|
+
atoms = Atoms(
|
|
262
|
+
symbols=frame_symbols,
|
|
263
|
+
positions=positions[i],
|
|
264
|
+
cell=cells[i],
|
|
265
|
+
pbc=pbc[i],
|
|
266
|
+
)
|
|
240
267
|
|
|
241
268
|
# Set optional properties if they exist
|
|
242
|
-
if
|
|
243
|
-
atoms.set_tags(
|
|
244
|
-
|
|
245
|
-
if
|
|
246
|
-
atoms.set_masses(
|
|
247
|
-
|
|
248
|
-
if
|
|
249
|
-
atoms.set_momenta(
|
|
250
|
-
|
|
251
|
-
if
|
|
252
|
-
atoms.set_initial_charges(
|
|
253
|
-
|
|
254
|
-
if
|
|
255
|
-
atoms.set_initial_magnetic_moments(
|
|
256
|
-
|
|
257
|
-
if 'top_mask' in data and i < len(data['top_mask']) and data['top_mask'][i] is not None:
|
|
258
|
-
atoms.top_mask = np.array(data['top_mask'][i], dtype=bool)
|
|
269
|
+
if tags is not None:
|
|
270
|
+
atoms.set_tags(tags[i])
|
|
271
|
+
|
|
272
|
+
if masses is not None:
|
|
273
|
+
atoms.set_masses(masses[i])
|
|
274
|
+
|
|
275
|
+
if momenta is not None:
|
|
276
|
+
atoms.set_momenta(momenta[i])
|
|
277
|
+
|
|
278
|
+
if initial_charges is not None:
|
|
279
|
+
atoms.set_initial_charges(initial_charges[i])
|
|
280
|
+
|
|
281
|
+
if initial_magmoms is not None:
|
|
282
|
+
atoms.set_initial_magnetic_moments(initial_magmoms[i])
|
|
259
283
|
|
|
260
|
-
if
|
|
261
|
-
atoms.
|
|
284
|
+
if top_mask is not None and i < len(top_mask) and top_mask[i] is not None:
|
|
285
|
+
atoms.top_mask = np.asarray(top_mask[i], dtype=bool)
|
|
262
286
|
|
|
263
|
-
if
|
|
264
|
-
for c in
|
|
287
|
+
if constraints is not None and i < len(constraints):
|
|
288
|
+
for c in constraints[i]:
|
|
265
289
|
atoms.constraints.append(dict2constraint(c))
|
|
266
290
|
|
|
267
|
-
if
|
|
268
|
-
atoms.ase_objtype =
|
|
291
|
+
if ase_objtype is not None and i < len(ase_objtype) and ase_objtype[i] is not None:
|
|
292
|
+
atoms.ase_objtype = ase_objtype[i]
|
|
269
293
|
|
|
270
|
-
if
|
|
271
|
-
atoms.arrays['forces'] =
|
|
294
|
+
if forces is not None and i < len(forces):
|
|
295
|
+
atoms.arrays['forces'] = forces[i]
|
|
272
296
|
|
|
273
|
-
if
|
|
274
|
-
atoms.stress = np.array(
|
|
297
|
+
if stress is not None and i < len(stress):
|
|
298
|
+
atoms.stress = np.array(stress[i], dtype=np.float64).copy()
|
|
275
299
|
|
|
276
300
|
# Restore atom info
|
|
277
|
-
if
|
|
278
|
-
atoms.info.update(
|
|
301
|
+
if atom_infos is not None and i < len(atom_infos):
|
|
302
|
+
atoms.info.update(atom_infos[i])
|
|
279
303
|
|
|
280
304
|
# Restore custom arrays
|
|
281
|
-
if
|
|
282
|
-
for key, values in
|
|
305
|
+
if custom_arrays is not None:
|
|
306
|
+
for key, values in custom_arrays.items():
|
|
283
307
|
if i < len(values) and values[i] is not None:
|
|
284
308
|
atoms.arrays[key] = values[i]
|
|
285
309
|
|
|
286
310
|
# Restore calculator if present
|
|
287
311
|
calc_created = False
|
|
288
312
|
calc_data = {}
|
|
289
|
-
|
|
313
|
+
|
|
290
314
|
# First try from calc_results (new format)
|
|
291
|
-
if
|
|
292
|
-
calc_data =
|
|
315
|
+
if calc_results is not None and i < len(calc_results):
|
|
316
|
+
calc_data = calc_results[i]
|
|
293
317
|
|
|
294
318
|
if calc_data and len(calc_data) > 1: # Only create calculator if there's data beyond just the name
|
|
295
319
|
# Initialize a SinglePointCalculator
|
|
@@ -320,180 +344,6 @@ def dict_to_atoms(data):
|
|
|
320
344
|
calc.results[key] = value
|
|
321
345
|
atoms.calc = calc
|
|
322
346
|
|
|
323
|
-
atoms_list
|
|
347
|
+
atoms_list[i] = atoms
|
|
324
348
|
|
|
325
349
|
return atoms_list
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
def load_msgpack(filename: str, strict_map_key: bool = True) -> Union['ase.Atoms', List['ase.Atoms']]:
|
|
329
|
-
"""Load atoms from a msgpack file with high efficiency and speed.
|
|
330
|
-
|
|
331
|
-
Parameters:
|
|
332
|
-
-----------
|
|
333
|
-
filename : str
|
|
334
|
-
The input filename
|
|
335
|
-
strict_map_key : bool, default=False
|
|
336
|
-
If True, only allow string keys in msgpack dictionaries
|
|
337
|
-
If False, allow integer and other keys in msgpack dictionaries
|
|
338
|
-
"""
|
|
339
|
-
|
|
340
|
-
try:
|
|
341
|
-
import msgpack
|
|
342
|
-
import msgpack_numpy as m
|
|
343
|
-
except ImportError:
|
|
344
|
-
raise ImportError("You need to install with `pip install atomict[tools]` to use msgpack I/O")
|
|
345
|
-
|
|
346
|
-
# Enable numpy array deserialization
|
|
347
|
-
m.patch()
|
|
348
|
-
|
|
349
|
-
# Load data
|
|
350
|
-
with open(filename, 'rb') as f:
|
|
351
|
-
data = msgpack.unpack(f, raw=False, strict_map_key=strict_map_key)
|
|
352
|
-
|
|
353
|
-
# Convert to atoms objects
|
|
354
|
-
atoms_list = dict_to_atoms(data)
|
|
355
|
-
|
|
356
|
-
# Return single atom or list based on input
|
|
357
|
-
return atoms_list[0] if data['n_frames'] == 1 else atoms_list
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
def save_msgpack(atoms: Union['ase.Atoms', List['ase.Atoms']], filename: str):
|
|
361
|
-
"""Save atoms to a msgpack file with high efficiency and speed."""
|
|
362
|
-
|
|
363
|
-
try:
|
|
364
|
-
import msgpack
|
|
365
|
-
import msgpack_numpy as m
|
|
366
|
-
from ase import Atoms
|
|
367
|
-
except ImportError:
|
|
368
|
-
raise ImportError("You need to install with `pip install atomict[tools]` to use msgpack I/O")
|
|
369
|
-
|
|
370
|
-
# Enable numpy array serialization
|
|
371
|
-
m.patch()
|
|
372
|
-
|
|
373
|
-
# Single atoms case - convert to list
|
|
374
|
-
if isinstance(atoms, Atoms):
|
|
375
|
-
atoms_list = [atoms]
|
|
376
|
-
else:
|
|
377
|
-
atoms_list = atoms
|
|
378
|
-
|
|
379
|
-
# Extract properties to dictionary - use selective mode for single atoms
|
|
380
|
-
# to avoid storing default properties
|
|
381
|
-
selective = len(atoms_list) == 1
|
|
382
|
-
data = atoms_to_dict(atoms_list, selective=selective)
|
|
383
|
-
|
|
384
|
-
# Pack and save
|
|
385
|
-
with open(filename, 'wb') as f:
|
|
386
|
-
msgpack.pack(data, f, use_bin_type=True)
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
def save_msgpack_trajectory(atoms: Union['ase.Atoms', List['ase.Atoms']], filename: str, metadata: Dict = None):
|
|
390
|
-
"""Save atoms to a msgpack trajectory file with metadata.
|
|
391
|
-
|
|
392
|
-
Parameters:
|
|
393
|
-
-----------
|
|
394
|
-
atoms : Atoms or list of Atoms
|
|
395
|
-
The atoms to save
|
|
396
|
-
filename : str
|
|
397
|
-
The output filename
|
|
398
|
-
metadata : dict, optional
|
|
399
|
-
Additional metadata to store with the trajectory
|
|
400
|
-
"""
|
|
401
|
-
try:
|
|
402
|
-
import msgpack
|
|
403
|
-
import msgpack_numpy as m
|
|
404
|
-
from ase import Atoms
|
|
405
|
-
except ImportError:
|
|
406
|
-
raise ImportError("You need to install with `pip install atomict[tools]` to use msgpack I/O")
|
|
407
|
-
|
|
408
|
-
# Enable numpy array serialization
|
|
409
|
-
m.patch()
|
|
410
|
-
|
|
411
|
-
# Single atoms case - convert to list
|
|
412
|
-
if isinstance(atoms, Atoms):
|
|
413
|
-
atoms_list = [atoms]
|
|
414
|
-
else:
|
|
415
|
-
atoms_list = atoms
|
|
416
|
-
|
|
417
|
-
# Create container for the trajectory data
|
|
418
|
-
traj_data = {
|
|
419
|
-
'format_version': 1, # Version for future compatibility
|
|
420
|
-
'metadata': metadata or {},
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
# Extract properties to dictionary - no selective mode for trajectories
|
|
424
|
-
atoms_data = atoms_to_dict(atoms_list, selective=False)
|
|
425
|
-
|
|
426
|
-
# Add atoms data to the trajectory container
|
|
427
|
-
traj_data['atoms_data'] = atoms_data
|
|
428
|
-
|
|
429
|
-
# Pack and save
|
|
430
|
-
with open(filename, 'wb') as f:
|
|
431
|
-
msgpack.pack(traj_data, f, use_bin_type=True)
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
def load_msgpack_trajectory(filename: str, strict_map_key: bool = True) -> Tuple[List['ase.Atoms'], Dict]:
|
|
435
|
-
"""Load atoms from a msgpack trajectory file with metadata.
|
|
436
|
-
|
|
437
|
-
Parameters:
|
|
438
|
-
-----------
|
|
439
|
-
filename : str
|
|
440
|
-
The input filename
|
|
441
|
-
strict_map_key : bool, default=False
|
|
442
|
-
If True, only allow string keys in msgpack dictionaries
|
|
443
|
-
If False, allow integer and other keys in msgpack dictionaries
|
|
444
|
-
|
|
445
|
-
Returns:
|
|
446
|
-
--------
|
|
447
|
-
atoms_list : list of Atoms
|
|
448
|
-
The loaded atoms
|
|
449
|
-
metadata : dict
|
|
450
|
-
The metadata stored with the trajectory
|
|
451
|
-
"""
|
|
452
|
-
try:
|
|
453
|
-
import msgpack
|
|
454
|
-
import msgpack_numpy as m
|
|
455
|
-
except ImportError:
|
|
456
|
-
raise ImportError("You need to install with `pip install atomict[tools]` to use msgpack I/O")
|
|
457
|
-
|
|
458
|
-
# Enable numpy array deserialization
|
|
459
|
-
m.patch()
|
|
460
|
-
|
|
461
|
-
# Load data
|
|
462
|
-
with open(filename, 'rb') as f:
|
|
463
|
-
traj_data = msgpack.unpack(f, raw=False, strict_map_key=strict_map_key)
|
|
464
|
-
|
|
465
|
-
# Check if this is a new-style trajectory with format_version
|
|
466
|
-
if isinstance(traj_data, dict) and 'format_version' in traj_data:
|
|
467
|
-
metadata = traj_data.get('metadata', {})
|
|
468
|
-
atoms_data = traj_data.get('atoms_data', {})
|
|
469
|
-
else:
|
|
470
|
-
# Legacy format - just raw atoms data
|
|
471
|
-
metadata = {}
|
|
472
|
-
atoms_data = traj_data
|
|
473
|
-
|
|
474
|
-
# Ensure that calculated properties are transferred to the calculator in dict_to_atoms
|
|
475
|
-
if 'calc_results' not in atoms_data and hasattr(atoms_data, 'get') and atoms_data.get('forces') is not None:
|
|
476
|
-
# If we have forces in the data but no calc_results, create calc_results entries
|
|
477
|
-
calc_data_list = []
|
|
478
|
-
n_frames = atoms_data.get('n_frames', 0)
|
|
479
|
-
|
|
480
|
-
for i in range(n_frames):
|
|
481
|
-
calc_data = {'name': 'SinglePointCalculator'}
|
|
482
|
-
if 'forces' in atoms_data and i < len(atoms_data['forces']):
|
|
483
|
-
calc_data['forces'] = atoms_data['forces'][i]
|
|
484
|
-
if 'stress' in atoms_data and i < len(atoms_data['stress']):
|
|
485
|
-
calc_data['stress'] = atoms_data['stress'][i]
|
|
486
|
-
if 'energy' in atoms_data and i < len(atoms_data['energy']):
|
|
487
|
-
calc_data['energy'] = atoms_data['energy'][i]
|
|
488
|
-
calc_data_list.append(calc_data)
|
|
489
|
-
|
|
490
|
-
atoms_data['calc_results'] = calc_data_list
|
|
491
|
-
|
|
492
|
-
# Convert to atoms objects
|
|
493
|
-
atoms_list = dict_to_atoms(atoms_data)
|
|
494
|
-
|
|
495
|
-
# Make sure atoms_list is always a list
|
|
496
|
-
if not isinstance(atoms_list, list):
|
|
497
|
-
atoms_list = [atoms_list]
|
|
498
|
-
|
|
499
|
-
return atoms_list, metadata
|