Skip to content

refactor: move ase import into function #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all 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
30 changes: 17 additions & 13 deletions dpgen2/op/run_caly_model_devi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@
)

import numpy as np
from ase import ( # type: ignore
Atoms,
)
from ase.build import ( # type: ignore
make_supercell,
)
from ase.geometry import ( # type: ignore
cellpar_to_cell,
)
from ase.io import ( # type: ignore
read,
write,
)
from dflow.python import (
OP,
OPIO,
Expand Down Expand Up @@ -159,6 +146,13 @@ def atoms2lmpdump(atoms, struc_idx, type_map):

ref: https://docs.lammps.org/Howto_triclinic.html
"""
from ase import ( # type: ignore
Atoms,
)
from ase.geometry import ( # type: ignore
cellpar_to_cell,
)

dump_str = "ITEM: TIMESTEP\n"
dump_str += f"{struc_idx}\n"
dump_str += "ITEM: NUMBER OF ATOMS\n"
Expand Down Expand Up @@ -202,6 +196,16 @@ def atoms2lmpdump(atoms, struc_idx, type_map):


def parse_traj(traj_file):
from ase import ( # type: ignore
Atoms,
)
from ase.build import ( # type: ignore
make_supercell,
)
from ase.io import ( # type: ignore
read,
)

# optimization will at least return one structures in traj file
trajs: List[Atoms] = read(traj_file, index=":", format="traj") # type: ignore

Expand Down