dpdata.abacus package#
Submodules#
dpdata.abacus.md module#
dpdata.abacus.relax module#
- dpdata.abacus.relax.get_coords_from_log(loglines, natoms)[source]#
NOTICE: unit of coords and cells is Angstrom order:
coordinate cell (no output if cell is not changed) energy (no output, if SCF is not converged) force (no output, if cal_force is not setted or abnormal ending) stress (no output, if set cal_stress is not setted or abnormal ending).
dpdata.abacus.scf module#
- dpdata.abacus.scf.get_mag_force(outlines)[source]#
Read atomic magmom and magnetic force from OUT.ABACUS/running_scf.log.
- Returns:
- magmom: list of list of atomic magnetic moments (three dimensions: ION_STEP * NATOMS * 1/3)
- magforce: list of list of atomic magnetic forces (three dimensions: ION_STEP * NATOMS * 1/3)
- e.g.:
- Total Magnetism (uB)
Fe 0.0000000001 0.0000000000 3.0000000307 Fe -0.0000000000 -0.0000000000 3.0000001151
- Magnetic force (eV/uB)
Fe 0.0000000000 0.0000000000 -1.2117698671 Fe 0.0000000000 0.0000000000 -1.2117928796
dpdata.abacus.stru module#
- dpdata.abacus.stru.get_atom_mag_cartesian(atommag, angle1, angle2)[source]#
Transform atommag, angle1, angle2 to magmom in cartesian coordinates.
- Parameters:
- atommagfloat/list of float/None
Atom magnetic moment.
- angle1float/None
value of angle1.
- angle2float/None
value of angle2.
- ABACUS support defining mag, angle1, angle2 at the same time.
- angle1 is the angle between z-axis and real spin (in degrees).
- angle2 is the angle between x-axis and real spin projection in xy-plane (in degrees).
- If only mag is defined, then transfer it to magmom directly.
- And if mag, angle1, angle2 are defined, then mag is only the norm of magmom, and the direction is defined by angle1 and angle2.
- dpdata.abacus.stru.get_carteisan_coords(coords, coord_type, celldm, cell)[source]#
Transform the atomic coordinates to cartesian coordinates.
- Args:
coords (np.ndarray): atomic coordinates read from the STRU file. coord_type (str): the coordination type, either “cartesian” or “direct”. celldm (float): the lattice constant. cell (np.ndarray): the cell vectors in angstrom.
- Returns:
- np.ndarray: the cartesian coordinates in angstrom.
- dpdata.abacus.stru.get_frame_from_stru(stru)[source]#
Read the ABACUS STRU file and return the dpdata frame.
The description of ABACUS STRU can be found in https://abacus.deepmodeling.com/en/latest/advanced/input_files/stru.html
- Args:
stru (str): path to the ABACUS STRU file.
- Returns:
- data: the parsed stru information in dictionary.
- {
“atom_names”: list of atom names, “atom_numbs”: list of atom numbers, “atom_types”: list of atom types, “masses”: list of atomic masses, “pp_files”, list of pseudo potential files, “orb_files”, list of orbital files, “dpks_descriptor”: the deepks descriptor file,
# below are the information in each frame
“cells”: list of cell vectors, “coords”: list of atomic coordinates, “spins”: list of magnetic moments, # return only when set “mag xxx” for each atom in STRU file “moves”: list of move flags,
- }
- For some keys, if the information is not provided in the STRU file, then it will not be included in the dictionary.
- “spins” is designed for delta spin calculation, and when dpdata.System is write to lmp format, the spin will be written as magmom.
- But we should note that this file format is valid only for a spin lammps job, not for a normal job.
- If you want to use dpgen to run the non-spin job, then you should not define “mag x x x” in the STRU file.
- dpdata.abacus.stru.make_unlabeled_stru(data, frame_idx, pp_file=None, numerical_orbital=None, numerical_descriptor=None, mass=None, move=None, velocity=None, mag=None, angle1=None, angle2=None, sc=None, lambda_=None, link_file=False, dest_dir=None, **kwargs)[source]#
Make an unlabeled STRU file from a dictionary.
- Parameters:
- datadict
System data
- frame_idxint
The index of the frame to dump
- pp_filelist of string or dict
List of pseudo potential files, or a dictionary of pseudo potential files for each atomnames
- numerical_orbitallist of string or dict, optional
List of orbital files, or a dictionary of orbital files for each atomnames
- numerical_descriptorstr, optional
numerical descriptor file
- masslist of float, optional
List of atomic masses
- movelist of (list of list of bool), optional
List of the move flag of each xyz direction of each atom for each frame
- velocitylist of list of float, optional
List of the velocity of each xyz direction of each atom
- maglist of (list of float or float), optional
List of the magnetic moment of each atom, can be a list of three floats or one float For noncollinear, three floats are the xyz component of the magnetic moment. For collinear, one float is the norm of the magnetic moment.
- angle1list of float, optional
List of the angle1 of each atom. For noncollinear calculation, it is the angle between the magnetic moment and the z-axis.
- angle2list of float, optional
List of the angle2 of each atom. For noncollinear calculation, it is the angle between the projection of magnetic moment on xy plane and the x-axis.
- sclist of (bool or list of 3 bool), optional
List of the spin constraint flag of each atom. Each element can be a bool or a list of three bools or None.
- lambda_list of (float or list of 3 float), optional
List of the lambda of each atom. Each element can be a float or a list of three floats.
- link_filebool, optional
Whether to link the pseudo potential files and orbital files in the STRU file. If True, then only filename will be written in the STRU file, and make a soft link to the real file.
- dest_dirstr, optional
The destination directory to make the soft link of the pseudo potential files and orbital files.
- For velocity, mag, angle1, angle2, sc, and lambda_, if the value is None, then the corresponding information will not be written.
- ABACUS support defining “mag” and “angle1”/”angle2” at the same time, and in this case, the “mag” only define the norm of the magnetic moment, and “angle1” and “angle2” define the direction of the magnetic moment.
- If data has spins, then it will be written as mag to STRU file; while if mag is passed at the same time, then mag will be used.
- dpdata.abacus.stru.parse_atomic_species_block(lines)[source]#
Parse the ATOMIC_SPECIES block.
- Args:
lines (list): list of lines in the ATOMIC_SPECIES block.
- Returns:
- tuple: tuple of atom_names, masses, and pp_files.
- dpdata.abacus.stru.parse_lattice_constant_block(lines)[source]#
Parse the LATTICE_CONSTANT block.
- Args:
lines (list): list of lines in the LATTICE_CONSTANT block.
- Returns:
- float: the lattice constant.
- dpdata.abacus.stru.parse_lattice_vectors_block(lines)[source]#
Parse the LATTICE_VECTORS block.
- Args:
lines (list): list of lines in the LATTICE_VECTORS block.
- Returns:
- np.ndarray: the cell vectors.
- dpdata.abacus.stru.parse_numerical_orbital_block(lines)[source]#
Parse the NUMERICAL_ORBITAL block.
- Args:
lines (list): list of lines in the NUMERICAL_ORBITAL block.
- Returns:
- list: list of orbital files.
- dpdata.abacus.stru.parse_pos(coords_lines, atom_names, celldm, cell)[source]#
Read the atomic positions block in the ABACUS STRU file.
- Args:
coords_lines (list): list of lines in the atomic positions block. atom_names (list): list of atom names. celldm (float): the lattice constant. cell (np.ndarray): the cell vectors in angstrom, and has multipy celldm.
- Returns:
- tuple: tuple of atom_numbs, coords, move, mags, velocity, sc, lambda_
- Note: for atomic magnetic moment, we finnaly transform it to non-collinear magnetic moment in cartesian coordinates,
and do not return the angle1 and angle2, and the magnetic moment of each atom type.
- dpdata.abacus.stru.parse_pos_oneline(pos_line)[source]#
Parses a line from the atom position block in a structure file.
The content in atom position block can include: - m or NO key word: Three numbers (0 or 1) controlling atom movement in geometry relaxation calculations. - v, vel, or velocity: Three components of initial velocity of atoms in geometry relaxation calculations. - mag or magmom: Start magnetization for each atom. Can be one number (colinear) or three numbers (non-colinear). - angle1: In non-colinear case, angle between c-axis and real spin (in degrees). - angle2: In non-colinear case, angle between a-axis and real spin projection in ab-plane (in degrees). - cs or constrain: Three numbers (0 or 1) controlling the spin constraint of the atom. - lambda: Three numbers controlling the lambda of the atom.
- Parameters:
- pos_lineA line from the atom position block.
- Returns:
- tuple: A tuple containing:
pos (list of float): The position coordinates.
move (list of int or None): Movement control values.
velocity (list of float or None): Initial velocity components.
magmom (float, list of float, or None): Magnetization values.
angle1 (float or None): Angle1 value.
angle2 (float or None): Angle2 value.
constrain (list of bool or None): Spin constraint values.
lambda1 (float, list of float, or None): Lambda values.
e.g.:
` Fe 1.0 2 0.0 0.0 0.0 m 0 0 0 mag 1.0 angle1 90 angle2 0 cs 0 0 0 0.5 0.5 0.5 m 1 1 1 mag 1.0 angle1 90 angle2 180 `