ai2_kit.tool.ase module#
- class ai2_kit.tool.ase.AseTool(atoms_arr: Optional[List[Atoms]] = None)[source]#
Bases:
object
- delete_atoms(id: Union[int, List[int]], start_id=0)[source]#
delete atoms by id or list of id
- Parameters:
id – id or list of id
start_id – the start id of first item, for example, in LAMMPS the id of first item is 1, in ASE it is 0
- read(*file_path_or_glob: str, nat_sort=False, **kwargs)[source]#
read atoms from file, support multiple files and glob pattern
- Parameters:
file_path_or_glob – path or glob pattern to locate data path
nat_sort – sort files by natural order, default is False
kwargs – other arguments for ase.io.read
- sample(size: int, method: Literal['even', 'random', 'truncate'] = 'even', **kwargs)[source]#
sample data
- Parameters:
size – size of sample, if size is larger than data size, return all data
method – method to sample, can be ‘even’, ‘random’, ‘truncate’, default is ‘even’
seed – seed for random sample, only used when method is ‘random’
Note that by default the seed is length of input list, if you want to generate different sample each time, you should set random seed manually
- slice(expr: str)[source]#
slice systems by python slice expression, for example 10:, :10, ::2, etc
- Parameters:
start – start index
stop – stop index
step – step
- to_dpdata(labeled=False)[source]#
convert to dpdata format and use dpdata tool to handle
- Parameters:
labeled – if True, use dpdata.LabeledSystem, else use dpdata.System
- to_model_devi(*md_files: str)[source]#
Hand over atoms array to model-devi tool
- Parameters:
md_files – paths to model_devi file, support multiple files and glob pattern
- write_dplr_lammps_data(filename: str, type_map: List[str], sel_type: List[int], sys_charge_map: List[float], model_charge_map: List[float])[source]#
write atoms to LAMMPS data file for DPLR the naming convention of params follows Deepmd-Kit’s
about dplr: https://docs.deepmodeling.com/projects/deepmd/en/master/model/dplr.html about fitting tensor: https://docs.deepmodeling.com/projects/deepmd/en/master/model/train-fitting-tensor.html
- Parameters:
filename – the filename of LAMMPS data file, use {i} to represent the index, for example, ‘frame_{i}.lammps.data’
type_map – the type map of atom type, for example, [O,H]
sel_type – the selected type of atom, for example, [0] means atom type 0, aka O is selected
sys_charge_map – the charge map of atom in system, for example, [6, 1]
model_charge_map – the charge map of atom in model, for example, [-8]
- property write_each_frame#
- write_frames(filename: str, **kwargs)[source]#
write each frame to a separate file, useful to write to format only support single frame, POSCAR for example
- Parameters:
filename – the filename template, use {i} to represent the index, for example, ‘frame_{i}.xyz’
kwargs – other arguments for ase.io.write