jarvis.core.atoms ================= .. py:module:: jarvis.core.atoms .. autoapi-nested-parse:: This module provides classes to specify atomic structure. Attributes ---------- .. autoapisummary:: jarvis.core.atoms.amu_gm jarvis.core.atoms.ang_cm jarvis.core.atoms.mineral_json_file Classes ------- .. autoapisummary:: jarvis.core.atoms.Atoms jarvis.core.atoms.VacuumPadding jarvis.core.atoms.OptimadeAdaptor Functions --------- .. autoapisummary:: jarvis.core.atoms.fix_pbc jarvis.core.atoms.add_atoms jarvis.core.atoms.get_supercell_dims jarvis.core.atoms.pmg_to_atoms jarvis.core.atoms.ase_to_atoms jarvis.core.atoms.crop_square jarvis.core.atoms.compare_atoms jarvis.core.atoms.build_xanes_poscar Module Contents --------------- .. py:data:: amu_gm :value: 1.66054e-24 .. py:data:: ang_cm :value: 1e-08 .. py:data:: mineral_json_file .. py:class:: Atoms(lattice_mat=None, coords=None, elements=None, props=None, cartesian=False, show_props=False) Bases: :py:obj:`object` Generate Atoms python object. >>> box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]] >>> coords = [[0, 0, 0], [0.25, 0.2, 0.25]] >>> elements = ["Si", "Si"] >>> Si = Atoms(lattice_mat=box, coords=coords, elements=elements) >>> print(round(Si.volume,2)) 40.03 >>> Si.composition {'Si': 2} >>> round(Si.density,2) 2.33 >>> round(Si.packing_fraction,2) 0.28 >>> Si.atomic_numbers [14, 14] >>> Si.num_atoms 2 >>> Si.frac_coords[0][0] 0 >>> Si.cart_coords[0][0] 0.0 >>> coords = [[0, 0, 0], [1.3575 , 1.22175, 1.22175]] >>> round(Si.density,2) 2.33 >>> Si.spacegroup() 'C2/m (12)' >>> Si.pymatgen_converter()!={} True .. py:attribute:: lattice_mat .. py:attribute:: show_props :value: False .. py:attribute:: lattice .. py:attribute:: coords .. py:attribute:: elements :value: None .. py:attribute:: cartesian :value: False .. py:attribute:: props :value: None .. py:method:: write_cif(filename='atoms.cif', comment=None, with_spg_info=True) Write CIF format file from Atoms object. Caution: can't handle fractional occupancies right now .. py:method:: read_with_cif2cell(filename='1000000.cif', get_primitive_atoms=False) :staticmethod: Use cif2cell package to read cif files. .. py:method:: from_pdb_old(filename='abc.pdb') :staticmethod: Read PDB file, kept of checking, use from_pdb instead. .. py:method:: from_pdb(filename='abc.pdb', max_lat=200) :staticmethod: Read pdb/sdf/mol2 etc. file and make Atoms object, using pytraj. .. py:method:: from_cif(filename='atoms.cif', from_string='', get_primitive_atoms=True, use_cif2cell=True) :staticmethod: Read .cif format file. .. py:method:: write_poscar(filename='POSCAR') Write POSCAR format file from Atoms object. .. py:property:: get_xyz_string Get xyz string for atoms. .. py:method:: write_xyz(filename='atoms.xyz') Write XYZ format file. .. py:method:: from_xyz(filename='dsgdb9nsd_057387.xyz', box_size=40) :classmethod: Read XYZ file from to make Atoms object. .. py:method:: from_poscar(filename='POSCAR') :classmethod: Read POSCAR/CONTCAR file from to make Atoms object. .. py:property:: check_polar Check if the surface structure is polar. Comparing atom types at top and bottom. Applicable for sufcae with vaccums only. Args: file:atoms object (surface with vacuum) Returns: polar:True/False .. py:method:: strain_atoms(strain) Apply volumetric strain to atoms. .. py:method:: apply_strain(strain) Apply a strain(e.g. 0.01, [0,0,.01]) to the lattice. .. py:method:: to_dict() Provide dictionary representation of the atoms object. .. py:method:: from_dict(d={}) :classmethod: Form atoms object from the dictionary. .. py:method:: remove_site_by_index(site=0) Remove an atom by its index number. .. py:method:: remove_sites_by_indices(indices=[0], in_place=False) Remove multiple atoms by their corresponding indices number. .. py:method:: add_site(element='Si', coords=[0.1, 0.1, 0.1], props=[], index=0) Ad an atom, coords in fractional coordinates. .. py:property:: get_conventional_atoms Get conventional Atoms using spacegroup information. .. py:property:: get_spacegroup Get spacegroup information. .. py:property:: get_primitive_atoms Get primitive Atoms using spacegroup information. .. py:method:: get_all_neighbors(r=5, bond_tol=0.15) Get neighbors for each atom in the unit cell, out to a distance r. Contains [index_i, index_j, distance, image] array. Adapted from pymatgen. .. py:method:: get_neighbors_cutoffs(max_cut=10, r=5, bond_tol=0.15) Get neighbors within cutoff. .. py:method:: rotate_pos(phi=0.0, theta=90.0, psi=0.0, center=(0, 0, 0)) Rotate atom sites via Euler angles (in degrees). See e.g http://mathworld.wolfram.com/EulerAngles.html for explanation. Adapted from https://wiki.fysik.dtu.dk/ase/_modules/ase/atoms.html#Atoms.rotate center : The point to rotate about. A sequence of length 3 with the coordinates. phi : The 1st rotation angle around the z axis. theta : Rotation around the x axis. psi : 2nd rotation around the z axis. .. py:method:: rotate_cell(phi=0.0, theta=90.0, psi=0.0, center=(0, 0, 0)) Rotate atom cell via Euler angles (in degrees). See e.g http://mathworld.wolfram.com/EulerAngles.html for explanation. Adapted from https://wiki.fysik.dtu.dk/ase/_modules/ase/atoms.html#Atoms.rotate center : The point to rotate about. A sequence of length 3 with the coordinates. phi : The 1st rotation angle around the z axis. theta : Rotation around the x axis. psi : 2nd rotation around the z axis. .. py:method:: atomwise_angle_and_radial_distribution(r=5, bond_tol=0.15, c_size=10, verbose=False) Get atomwise distributions. .. py:property:: raw_distance_matrix Provide distance matrix. .. py:property:: raw_angle_matrix Provide distance matrix. .. py:method:: center(axis=2, vacuum=18.0, about=None) Center structure with vacuum padding. Args: vacuum:vacuum size axis: direction .. py:property:: volume Get volume of the atoms object. .. py:property:: composition Get composition of the atoms object. .. py:property:: density Get density in g/cm3 of the atoms object. .. py:method:: plot_atoms(colors=[], sizes=[], cutoff=1.9, opacity=0.5, bond_width=2, filename=None) Plot atoms using plotly. .. py:property:: atomic_numbers Get list of atomic numbers of atoms in the atoms object. .. py:property:: num_atoms Get number of atoms. .. py:property:: uniq_species Get unique elements. .. py:method:: get_center_of_mass() Get center of mass of the atoms object. .. py:method:: get_origin() Get center of mass of the atoms object. .. py:method:: center_around_origin(new_origin=[0.0, 0.0, 0.5]) Center around given origin. .. py:method:: pymatgen_converter() Get pymatgen representation of the atoms object. .. py:method:: phonopy_converter(pbc=True) Get phonopy representation of the atoms object. .. py:method:: ase_converter(pbc=True) Get ASE representation of the atoms object. .. py:method:: spacegroup(symprec=0.001) Get spacegroup of the atoms object. .. py:property:: packing_fraction Get packing fraction of the atoms object. .. py:method:: get_alignn_feats(model_name='jv_formation_energy_peratom_alignn', max_neighbors=12, neighbor_strategy='k-nearest', use_canonize=True, atom_features='cgcnn', line_graph=True, cutoff=8, model='') Get ALIGNN features. .. py:method:: get_mineral_prototype_name(prim=True, include_c_over_a=False, digits=3) Get mineral_prototype_name. .. py:method:: get_minaral_name(model='') Get mineral prototype. .. py:method:: lattice_points_in_supercell(supercell_matrix) Adapted from Pymatgen. Returns the list of points on the original lattice contained in the supercell in fractional coordinates (with the supercell basis). e.g. [[2,0,0],[0,1,0],[0,0,1]] returns [[0,0,0],[0.5,0,0]] Args: supercell_matrix: 3x3 matrix describing the supercell Returns: numpy array of the fractional coordinates .. py:method:: describe(xrd_peaks=5, xrd_round=1, cutoff=4, take_n_bonds=2, include_spg=True, include_mineral_name=False) Describe for NLP applications. .. py:method:: make_supercell_matrix(scaling_matrix) Adapted from Pymatgen. Makes a supercell. Allowing to have sites outside the unit cell. Args: scaling_matrix: A scaling matrix for transforming the lattice vectors. Has to be all integers. Several options are possible: a. A full 3x3 scaling matrix defining the linear combination the old lattice vectors. E.g., [[2,1,0],[0,3,0],[0,0, 1]] generates a new structure with lattice vectors a' = 2a + b, b' = 3b, c' = c where a, b, and c are the lattice vectors of the original structure. b. An sequence of three scaling factors. E.g., [2, 1, 1] specifies that the supercell should have dimensions 2a x b x c. c. A number, which simply scales all lattice vectors by the same factor. Returns: Supercell structure. Note that a Structure is always returned, even if the input structure is a subclass of Structure. This is to avoid different arguments signatures from causing problems. If you prefer a subclass to return its own type, you need to override this method in the subclass. .. py:method:: make_supercell(dim=[2, 2, 2]) Make supercell of dimension dim. .. py:method:: make_supercell_old(dim=[2, 2, 2]) Make supercell of dimension dim using for loop. .. py:method:: get_lll_reduced_structure() Get LLL algorithm based reduced structure. .. py:method:: __repr__() Get representation during print statement. .. py:method:: get_string(cart=True, sort_order='X') Convert Atoms to string. Optional arguments below. Args: cart:True/False for cartesian/fractional coords. sort_order: sort by chemical properties of elements. Default electronegativity. .. py:method:: clone() Clones the class instance. .. py:class:: VacuumPadding(atoms, vacuum=20.0) Bases: :py:obj:`object` Adds vaccum padding to make 2D structure or making molecules. .. py:attribute:: atoms .. py:attribute:: vacuum :value: 20.0 .. py:method:: get_effective_2d_slab() Add 2D vacuum to a system. .. py:method:: get_effective_molecule() Add vacuum around a system. .. py:function:: fix_pbc(atoms) Use for making Atoms with vacuum. .. py:function:: add_atoms(top, bottom, distance=[0, 0, 1], apply_strain=False, add_tags=True) Add top and bottom Atoms with a distance array. Bottom Atoms lattice-matrix is chosen as final lattice. .. py:function:: get_supercell_dims(atoms, enforce_c_size=10, extend=1) Get supercell dimensions. .. py:function:: pmg_to_atoms(pmg='') Convert pymatgen structure to Atoms. .. py:function:: ase_to_atoms(ase_atoms='', cartesian=True) Convert ase structure to Atoms. .. py:function:: crop_square(atoms=None, csize=10) Crop a sqaur portion from a surface/2D system. .. py:class:: OptimadeAdaptor(atoms=None) Bases: :py:obj:`object` Module to work with optimade. .. py:attribute:: atoms :value: None .. py:method:: reduce(content={}) Reduce chemical formula. .. py:method:: optimade_reduced_formula(content={}, sort_alphabetical=True) Get chemical formula. .. py:method:: get_optimade_prototype(content={}) Get chemical prototypes such as A, AB etc. .. py:method:: get_optimade_species() Get optimade species. .. py:method:: from_optimade(info={}) Get Atoms from optimade. .. py:method:: to_optimade(idx='x', itype='structures', source='JARVIS-DFT-3D', reference_url='https://www.ctcms.nist.gov/~knc6/static/JARVIS-DFT/', now=datetime.datetime.now(datetime.timezone.utc).isoformat()) Get optimade format data. .. py:function:: compare_atoms(atoms1=[], atoms2=[], primitive_cell=True, verbose=True) Compare atomic strutures. .. py:function:: build_xanes_poscar(atoms=None, selected_element='Si', prefix='-', extend=1, enforce_c_size=12, dir='.', filename_with_prefix=False) Generate POSCAR file for XANES, note the element ordering.