sparc.sparc_parsers.atoms module

Convert ase atoms to structured dict following SPARC format and vice versa

sparc.sparc_parsers.atoms.atoms_bc_to_sparc(atoms)[source]

Use atoms’ internal pbc and info to construct inpt blocks

Returns: a dict containing ‘BC’ or ‘TWIST_ANGLE’

sparc.sparc_parsers.atoms.atoms_to_dict(atoms, sort=True, direct=False, wrap=False, ignore_constraints=False, psp_dir=None, pseudopotentials={}, comments='')[source]

Given an ASE Atoms object, convert to SPARC ion and inpt data dict

psp_dir: search path for psp8 files pseudopotentials: a mapping between symbol and psp file names, similar to QE like ‘Na’: ‘Na-pbe.psp8’. If the file name does not contain path information, use psp_dir / filname, otherwise use the file path.

We don’t do any env variable replace ment for psp_dir, it should be handled by the explicit _write_ion_and_inpt() function

At this step, the copy_psp is not applied, since we don’t yet know the location to write

sparc.sparc_parsers.atoms.constraints_from_relax(relax_dict)[source]

Convert the SPARC RELAX fields to ASE’s constraints

Arguments relax: bool vector of size Nx3, i.e. [[True, True, True], [True, False, False]]

Supported ase constraints will be FixAtoms, FixedLine and FixedPlane. For constraints in the same direction, all indices will be gathered.

Note: ase>=3.22 will have FixedLine and FixedPlane accepting only 1 index at a time!

The relax vector must be already sorted!

sparc.sparc_parsers.atoms.count_symbols(symbols)[source]

Count the number of consecutive elements. Output tuple is: element, start, end For example, “CHCHHO” –> [(‘C’, 0, 1), (‘H’, 1, 2), (‘C’, 2, 3), (‘H’, 3, 5), (‘O’, 5, 6)]

sparc.sparc_parsers.atoms.dict_to_atoms(data_dict)[source]

Given a SPARC struct dict, construct the ASE atoms object

Note: this method supports only 1 Atoms at a time

sparc.sparc_parsers.atoms.modify_atoms_bc(atoms, sparc_bc, twist_angle=0)[source]

Modify the atoms boundary conditions in-place from the bc information sparc_bc is a keyword from inpt twist_angle is the helix twist angle in inpt

conversion rules: BC: P –> pbc=True BC: D, H, C –> pbc=False

sparc.sparc_parsers.atoms.relax_from_all_constraints(constraints, natoms)[source]

converts ASE atom constraints to SPARC relaxed dimensions for the atoms

sparc.sparc_parsers.atoms.relax_from_constraint(constraint)[source]

returns dict of {atom_index: relax_dimensions} for the given constraint