ai2_kit.tool.ase module#

class ai2_kit.tool.ase.AseTool(atoms_list: List[Atoms] | None = None)[source]#

Bases: object

delete_atoms(id: 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, **kwargs)[source]#
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

set_by_ref(ref_file: str, **kwargs)[source]#
set_cell(cell, scale_atoms=False, apply_constraint=True)[source]#
set_pbc(pbc)[source]#
size()[source]#

size of loaded data

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

write(filename: str, **kwargs)[source]#
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