Skip to content

Commit

Permalink
refactor: move ase import into function (#194)
Browse files Browse the repository at this point in the history
move ase into `run_caly_model_devi`
  • Loading branch information
wangzyphysics committed Feb 22, 2024
1 parent b6c31a5 commit c4d7142
Showing 1 changed file with 17 additions and 13 deletions.
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

0 comments on commit c4d7142

Please sign in to comment.