INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Checks whether the plane is identical to one of the Planes in the plane_list list of Planes: param plane_list: List of Planes to be compared to: return: True if the plane is in the list False otherwise
def is_in_list(self, plane_list): """ Checks whether the plane is identical to one of the Planes in the plane_list list of Planes :param plane_list: List of Planes to be compared to :return: True if the plane is in the list, False otherwise """ for plane in plane_list: ...
Returns three lists containing the indices of the points lying on one side of the plane on the plane and on the other side of the plane. The dist_tolerance parameter controls the tolerance to which a point is considered to lie on the plane or not ( distance to the plane ): param points: list of points: param dist_toler...
def indices_separate(self, points, dist_tolerance): """ Returns three lists containing the indices of the points lying on one side of the plane, on the plane and on the other side of the plane. The dist_tolerance parameter controls the tolerance to which a point is considered to lie on t...
Computes the absolute distance from the plane to the point: param point: Point for which distance is computed: return: Distance between the plane and the point
def distance_to_point(self, point): """ Computes the absolute distance from the plane to the point :param point: Point for which distance is computed :return: Distance between the plane and the point """ return np.abs(np.dot(self.normal_vector, point) + self.d)
Computes the distances from the plane to each of the points. Positive distances are on the side of the normal of the plane while negative distances are on the other side: param points: Points for which distances are computed: return: Distances from the plane to the points ( positive values on the side of the normal to ...
def distances(self, points): """ Computes the distances from the plane to each of the points. Positive distances are on the side of the normal of the plane while negative distances are on the other side :param points: Points for which distances are computed :return: Distances fro...
Computes the distances from the plane to each of the points. Positive distances are on the side of the normal of the plane while negative distances are on the other side. Indices sorting the points from closest to furthest is also computed.: param points: Points for which distances are computed: param sign: Whether to ...
def distances_indices_sorted(self, points, sign=False): """ Computes the distances from the plane to each of the points. Positive distances are on the side of the normal of the plane while negative distances are on the other side. Indices sorting the points from closest to furthest is al...
Computes the distances from the plane to each of the points. Positive distances are on the side of the normal of the plane while negative distances are on the other side. Indices sorting the points from closest to furthest is also computed. Grouped indices are also given for which indices of the distances that are sepa...
def distances_indices_groups(self, points, delta=None, delta_factor=0.05, sign=False): """ Computes the distances from the plane to each of the points. Positive distances are on the side of the normal of the plane while negative distances are on the other side. Indices sorting the points from cl...
Projects each points in the point list pps on plane and returns the list of projected points: param pps: List of points to project on plane: return: List of projected point on plane
def projectionpoints(self, pps): """ Projects each points in the point list pps on plane and returns the list of projected points :param pps: List of points to project on plane :return: List of projected point on plane """ return [pp - np.dot(pp - self.p1, self.normal_vec...
Returns a list of three orthogonal vectors the two first being parallel to the plane and the third one is the normal vector of the plane: return: List of orthogonal vectors: raise: ValueError if all the coefficients are zero or if there is some other strange error
def orthonormal_vectors(self): """ Returns a list of three orthogonal vectors, the two first being parallel to the plane and the third one is the normal vector of the plane :return: List of orthogonal vectors :raise: ValueError if all the coefficients are zero or if there is some...
Returns a list of three orthogonal vectors the two first being parallel to the plane and the third one is the normal vector of the plane: return: List of orthogonal vectors: raise: ValueError if all the coefficients are zero or if there is some other strange error
def orthonormal_vectors_old(self): """ Returns a list of three orthogonal vectors, the two first being parallel to the plane and the third one is the normal vector of the plane :return: List of orthogonal vectors :raise: ValueError if all the coefficients are zero or if there is ...
Projects each points in the point list pps on plane and returns the indices that would sort the list of projected points in anticlockwise order: param pps: List of points to project on plane: return: List of indices that would sort the list of projected points
def project_and_to2dim_ordered_indices(self, pps, plane_center='mean'): """ Projects each points in the point list pps on plane and returns the indices that would sort the list of projected points in anticlockwise order :param pps: List of points to project on plane :return: List...
Projects the list of points pps to the plane and changes the basis from 3D to the 2D basis of the plane: param pps: List of points to be projected: return:: raise:
def project_and_to2dim(self, pps, plane_center): """ Projects the list of points pps to the plane and changes the basis from 3D to the 2D basis of the plane :param pps: List of points to be projected :return: :raise: """ proj = self.projectionpoints(pps) [u1, u2, ...
Function to actually open a ring using OpenBabel s local opt. Given a molecule graph and a bond convert the molecule graph into an OpenBabel molecule remove the given bond perform the local opt with the number of steps determined by self. steps and then convert the resulting structure back into a molecule graph to be r...
def open_ring(mol_graph, bond, opt_steps): """ Function to actually open a ring using OpenBabel's local opt. Given a molecule graph and a bond, convert the molecule graph into an OpenBabel molecule, remove the given bond, perform the local opt with the number of steps determined by self.steps, and t...
Perform one step of iterative fragmentation on a list of molecule graphs. Loop through the graphs then loop through each graph s edges and attempt to remove that edge in order to obtain two disconnected subgraphs aka two new fragments. If successful check to see if the new fragments are already present in self. unique_...
def _fragment_one_level(self, mol_graphs): """ Perform one step of iterative fragmentation on a list of molecule graphs. Loop through the graphs, then loop through each graph's edges and attempt to remove that edge in order to obtain two disconnected subgraphs, aka two new fragments. If ...
Having already generated all unique fragments that did not require ring opening now we want to also obtain fragments that do require opening. We achieve this by looping through all unique fragments and opening each bond present in any ring we find. We also temporarily add the principle molecule graph to self. unique_fr...
def _open_all_rings(self): """ Having already generated all unique fragments that did not require ring opening, now we want to also obtain fragments that do require opening. We achieve this by looping through all unique fragments and opening each bond present in any ring we find....
Json - serializable dict representation of COHP.
def as_dict(self): """ Json-serializable dict representation of COHP. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "are_coops": self.are_coops, "efermi": self.efermi, "energies": self.energies.tolist...
Returns the COHP or ICOHP for a particular spin.
def get_cohp(self, spin=None, integrated=False): """ Returns the COHP or ICOHP for a particular spin. Args: spin: Spin. Can be parsed as spin object, integer (-1/1) or str ("up"/"down") integrated: Return COHP (False) or ICOHP (True) Returns: ...
Returns the COHP for a particular energy.
def get_interpolated_value(self, energy, integrated=False): """ Returns the COHP for a particular energy. Args: energy: Energy to return the COHP value for. """ inter = {} for spin in self.cohp: if not integrated: inter[spin] = get...
Returns dict indicating if there are antibonding states below the Fermi level depending on the spin spin: Spin limit: - COHP smaller - limit will be considered.
def has_antibnd_states_below_efermi(self, spin=None, limit=0.01): """ Returns dict indicating if there are antibonding states below the Fermi level depending on the spin spin: Spin limit: -COHP smaller -limit will be considered. """ warnings.warn("This method has...
Returns a COHP object from a dict representation of the COHP.
def from_dict(cls, d): """ Returns a COHP object from a dict representation of the COHP. """ if "ICOHP" in d: icohp = {Spin(int(key)): np.array(val) for key, val in d["ICOHP"].items()} else: icohp = None return Cohp(d["efermi"...
Json - serializable dict representation of CompleteCohp.
def as_dict(self): """ Json-serializable dict representation of CompleteCohp. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "are_coops": self.are_coops, "efermi": self.efermi, "structure": self.struct...
Get specific COHP object.
def get_cohp_by_label(self, label): """ Get specific COHP object. Args: label: string (for newer Lobster versions: a number) Returns: Returns the COHP object to simplify plotting """ if label.lower() == "average": return Cohp(efermi=s...
Returns a COHP object that includes a summed COHP divided by divisor
def get_summed_cohp_by_label_list(self, label_list, divisor=1): """ Returns a COHP object that includes a summed COHP divided by divisor Args: label_list: list of labels for the COHP that should be included in the summed cohp divisor: float/int, the summed cohp will be d...
Returns a COHP object that includes a summed COHP divided by divisor
def get_summed_cohp_by_label_and_orbital_list(self, label_list, orbital_list, divisor=1): """ Returns a COHP object that includes a summed COHP divided by divisor Args: label_list: list of labels for the COHP that should be included in the summed cohp orbital_list: list ...
Get orbital - resolved COHP.
def get_orbital_resolved_cohp(self, label, orbitals): """ Get orbital-resolved COHP. Args: label: bond label (Lobster: labels as in ICOHPLIST/ICOOPLIST.lobster). orbitals: The orbitals as a label, or list or tuple of the form [(n1, orbital1), (n2, orbita...
Returns CompleteCohp object from dict representation.
def from_dict(cls, d): """ Returns CompleteCohp object from dict representation. """ cohp_dict = {} efermi = d["efermi"] energies = d["energies"] structure = Structure.from_dict(d["structure"]) if "bonds" in d.keys(): bonds = {bond: {"length": ...
Creates a CompleteCohp object from an output file of a COHP calculation. Valid formats are either LMTO ( for the Stuttgart LMTO - ASA code ) or LOBSTER ( for the LOBSTER code ).
def from_file(cls, fmt, filename=None, structure_file=None, are_coops=False): """ Creates a CompleteCohp object from an output file of a COHP calculation. Valid formats are either LMTO (for the Stuttgart LMTO-ASA code) or LOBSTER (for the LOBSTER code). Args: ...
Args: spin: Spin. up or Spin. down Returns: icohpvalue ( float ) corresponding to chosen spin
def icohpvalue(self, spin=Spin.up): """ Args: spin: Spin.up or Spin.down Returns: icohpvalue (float) corresponding to chosen spin """ if not self.is_spin_polarized and spin == Spin.down: raise ValueError("The calculation was not performed with ...
Adds ICOHPs of both spin channels for spin polarized compounds Returns: icohp value in eV
def summed_icohp(self): """ Adds ICOHPs of both spin channels for spin polarized compounds Returns: icohp value in eV """ if self._is_spin_polarized: sum_icohp = self._icohp[Spin.down] + self._icohp[Spin.up] else: sum_icohp = self._ico...
get an icohp value for a certain bond as indicated by the label ( bond labels starting by 1 as in ICOHPLIST/ ICOOPLIST ) Args: label: label in str format ( usually the bond number in Icohplist. lobster/ Icooplist. lobster summed_spin_channels: Boolean to indicate whether the ICOHPs/ ICOOPs of both spin channels should ...
def get_icohp_by_label(self, label, summed_spin_channels=True, spin=Spin.up): """ get an icohp value for a certain bond as indicated by the label (bond labels starting by "1" as in ICOHPLIST/ICOOPLIST) Args: label: label in str format (usually the bond number in Icohplist.lobster/Ico...
get the sum of several ICOHP values that are indicated by a list of labels ( labels of the bonds are the same as in ICOHPLIST/ ICOOPLIST ) Args: label_list: list of labels of the ICOHPs/ ICOOPs that should be summed divisor: is used to divide the sum summed_spin_channels: Boolean to indicate whether the ICOHPs/ ICOOPs ...
def get_summed_icohp_by_label_list(self, label_list, divisor=1.0, summed_spin_channels=True, spin=Spin.up): """ get the sum of several ICOHP values that are indicated by a list of labels (labels of the bonds are the same as in ICOHPLIST/ICOOPLIST) Args: label_list: list of labels of ...
get a dict of IcohpValues corresponding to certaind bond lengths Args: minbondlength: defines the minimum of the bond lengths of the bonds maxbondlength: defines the maximum of the bond lengths of the bonds Returns: dict of IcohpValues the keys correspond to the values from the initial list_labels
def get_icohp_dict_by_bondlengths(self, minbondlength=0.0, maxbondlength=8.0): """ get a dict of IcohpValues corresponding to certaind bond lengths Args: minbondlength: defines the minimum of the bond lengths of the bonds maxbondlength: defines the maximum of the bond len...
get a dict of IcohpValue for a certain site ( indicated by integer ) Args: site: integer describing the site of interest order as in Icohplist. lobster/ Icooplist. lobster starts at 0 minsummedicohp: float minimal icohp/ icoop of the bonds that are considered. It is the summed ICOHP value from both spin channels for sp...
def get_icohp_dict_of_site(self, site, minsummedicohp=None, maxsummedicohp=None, minbondlength=0.0, maxbondlength=8.0, only_bonds_to=None): """ get a dict of IcohpValue for a certain site (indicated by integer) Args: site: integer describing the site of...
get ICOHP/ ICOOP of strongest bond Args: summed_spin_channels: Boolean to indicate whether the ICOHPs/ ICOOPs of both spin channels should be summed
def extremum_icohpvalue(self, summed_spin_channels=True, spin=Spin.up): """ get ICOHP/ICOOP of strongest bond Args: summed_spin_channels: Boolean to indicate whether the ICOHPs/ICOOPs of both spin channels should be summed spin: if summed_spin_channels is equal to False,...
Get distance between two sites.
def distance(self, other): """ Get distance between two sites. Args: other: Other site. Returns: Distance (float) """ return np.linalg.norm(other.coords - self.coords)
Returns distance between the site and a point in space.
def distance_from_point(self, pt): """ Returns distance between the site and a point in space. Args: pt: Cartesian coordinates of point. Returns: Distance (float) """ return np.linalg.norm(np.array(pt) - self.coords)
String representation of species on the site.
def species_string(self): """ String representation of species on the site. """ if self.is_ordered: return list(self.species.keys())[0].__str__() else: sorted_species = sorted(self.species.keys()) return ", ".join(["{}:{:.3f}".format(sp, self.s...
True if site is an ordered site i. e. with a single species with occupancy 1.
def is_ordered(self): """ True if site is an ordered site, i.e., with a single species with occupancy 1. """ totaloccu = self.species.num_atoms return totaloccu == 1 and len(self.species) == 1
Json - serializable dict representation for Site.
def as_dict(self): """ Json-serializable dict representation for Site. """ species_list = [] for spec, occu in self.species.items(): d = spec.as_dict() del d["@module"] del d["@class"] d["occu"] = occu species_list.appen...
Create Site from dict representation
def from_dict(cls, d): """ Create Site from dict representation """ atoms_n_occu = {} for sp_occu in d["species"]: if "oxidation_state" in sp_occu and Element.is_valid_symbol( sp_occu["element"]): sp = Specie.from_dict(sp_occu) ...
Sets Lattice associated with PeriodicSite
def lattice(self, lattice): """ Sets Lattice associated with PeriodicSite """ self._lattice = lattice self._coords = self._lattice.get_cartesian_coords(self._frac_coords)
Fractional a coordinate
def coords(self, coords): """ Fractional a coordinate """ self._coords = np.array(coords) self._frac_coords = self._lattice.get_fractional_coords(self._coords)
Fractional a coordinate
def frac_coords(self, frac_coords): """ Fractional a coordinate """ self._frac_coords = np.array(frac_coords) self._coords = self._lattice.get_cartesian_coords(self._frac_coords)
Move frac coords to within the unit cell cell.
def to_unit_cell(self, in_place=False): """ Move frac coords to within the unit cell cell. """ frac_coords = np.mod(self.frac_coords, 1) if in_place: self.frac_coords = frac_coords else: return PeriodicSite(self.species, frac_coords, self.lattice, ...
Returns True if sites are periodic images of each other.
def is_periodic_image(self, other, tolerance=1e-8, check_lattice=True): """ Returns True if sites are periodic images of each other. Args: other (PeriodicSite): Other site tolerance (float): Tolerance to compare fractional coordinates check_lattice (bool): Wh...
Gets distance between site and a fractional coordinate assuming periodic boundary conditions. If the index jimage of two sites atom j is not specified it selects the j image nearest to the i atom and returns the distance and jimage indices in terms of lattice vector translations. If the index jimage of atom j is specif...
def distance_and_image_from_frac_coords(self, fcoords, jimage=None): """ Gets distance between site and a fractional coordinate assuming periodic boundary conditions. If the index jimage of two sites atom j is not specified it selects the j image nearest to the i atom and returns...
Json - serializable dict representation of PeriodicSite.
def as_dict(self, verbosity=0): """ Json-serializable dict representation of PeriodicSite. Args: verbosity (int): Verbosity level. Default of 0 only includes the matrix representation. Set to 1 for more details such as cartesian coordinates, etc. ...
Doc string.
def get_energies(rootdir, reanalyze, verbose, detailed, sort, fmt): """ Doc string. """ if verbose: logformat = "%(relativeCreated)d msecs : %(message)s" logging.basicConfig(level=logging.INFO, format=logformat) if not detailed: drone = SimpleVaspToComputedEntryDrone(inc_str...
Calculates the powder neutron diffraction pattern for a structure.
def get_pattern(self, structure, scaled=True, two_theta_range=(0, 90)): """ Calculates the powder neutron diffraction pattern for a structure. Args: structure (Structure): Input structure scaled (bool): Whether to return scaled intensities. The maximum pe...
Finds all symmetrically equivalent sites for a particular site
def find_equivalent_sites(self, site): """ Finds all symmetrically equivalent sites for a particular site Args: site (PeriodicSite): A site in the structure Returns: ([PeriodicSite]): List of all symmetrically equivalent sites. """ for sites in s...
Performs actual NWCHEM2FIESTA run
def run(self): """ Performs actual NWCHEM2FIESTA run """ init_folder = os.getcwd() os.chdir(self.folder) with zopen(self.log_file, 'w') as fout: subprocess.call([self._NWCHEM2FIESTA_cmd, self._nwcheminput_fn, self._nwchemoutput_f...
Performs FIESTA ( gw ) run
def gw_run(self): """ Performs FIESTA (gw) run """ if self.folder != os.getcwd(): init_folder = os.getcwd() os.chdir(self.folder) with zopen(self.log_file, 'w') as fout: subprocess.call(["mpirun", "-n", str(self.mpi_procs), "fiesta", ...
: return: the number of nlm orbitals for the basis set
def set_n_nlmo(self): """ :return: the number of nlm orbitals for the basis set """ nnlmo = 0 data_tmp = self.data data_tmp.pop('lmax') data_tmp.pop('n_nlo') data_tmp.pop('preamble') for l_zeta_ng in data_tmp: l = l_zeta_ng.s...
infos on the basis set as in Fiesta log
def infos_on_basis_set(self): """ infos on the basis set as in Fiesta log """ o = [] o.append("=========================================") o.append("Reading basis set:") o.append("") o.append(" Basis set for {} atom ".format(str(self.filename))) o....
copy in the desired folder the needed auxiliary basis set X2. ion where X is a specie.: param auxiliary_folder: folder where the auxiliary basis sets are stored: param auxiliary_basis_set_type: type of basis set ( string to be found in the extension of the file name ; must be in lower case ) ex: C2. ion_aug_cc_pvtz_RI_...
def set_auxiliary_basis_set(self, folder, auxiliary_folder, auxiliary_basis_set_type="aug_cc_pvtz"): """ copy in the desired folder the needed auxiliary basis set "X2.ion" where X is a specie. :param auxiliary_folder: folder where the auxiliary basis sets are stor...
Set parameters in cell. in for a GW computation: param nv__band: number of valence bands to correct with GW: param nc_band: number of conduction bands to correct with GW: param n_iteration: number of iteration: param n_grid and dE_grid:: number of points and spacing in eV for correlation grid
def set_GW_options(self, nv_band=10, nc_band=10, n_iteration=5, n_grid=6, dE_grid=0.5): """ Set parameters in cell.in for a GW computation :param nv__band: number of valence bands to correct with GW :param nc_band: number of conduction bands to correct with GW ...
mkdir FULL_BSE_Densities folder ( needed for bse run ) in the desired folder
def make_FULL_BSE_Densities_folder(self, folder): """ mkdir "FULL_BSE_Densities" folder (needed for bse run) in the desired folder """ if os.path.exists(folder + "/FULL_BSE_Densities"): return "FULL_BSE_Densities folder already exists" else: os.makedirs(f...
Set parameters in cell. in for a BSE computation: param nv_bse: number of valence bands: param nc_bse: number of conduction bands: param n_excitations: number of excitations: param nit_bse: number of iterations
def set_BSE_options(self, n_excitations=10, nit_bse=200): """ Set parameters in cell.in for a BSE computation :param nv_bse: number of valence bands :param nc_bse: number of conduction bands :param n_excitations: number of excitations :param nit_bse: number of iterations ...
: param BSE_dump: boolean: return: set the do_bse variable to one in cell. in
def dump_BSE_data_in_GW_run(self, BSE_dump=True): """ :param BSE_dump: boolean :return: set the "do_bse" variable to one in cell.in """ if BSE_dump: self.BSE_TDDFT_options.update(do_bse=1, do_tddft=0) else: self.BSE_TDDFT_options.update(do_bse=0, ...
: param TDDFT_dump: boolen: return: set the do_tddft variable to one in cell. in
def dump_TDDFT_data_in_GW_run(self, TDDFT_dump=True): """ :param TDDFT_dump: boolen :return: set the do_tddft variable to one in cell.in """ if TDDFT_dump == True: self.BSE_TDDFT_options.update(do_bse=0, do_tddft=1) else: self.BSE_TDDFT_options.upd...
Returns infos on initial parameters as in the log file of Fiesta
def infos_on_system(self): """ Returns infos on initial parameters as in the log file of Fiesta """ o = [] o.append("=========================================") o.append("Reading infos on system:") o.append("") o.append(" Number of atoms = {} ; number of ...
Read an FiestaInput from a string. Currently tested to work with files generated from this class itself.
def from_string(cls, string_input): """ Read an FiestaInput from a string. Currently tested to work with files generated from this class itself. Args: string_input: string_input to parse. Returns: FiestaInput object """ correlation_grid =...
Read an Fiesta input from a file. Currently tested to work with files generated from this class itself.
def from_file(cls, filename): """ Read an Fiesta input from a file. Currently tested to work with files generated from this class itself. Args: filename: Filename to parse. Returns: FiestaInput object """ with zopen(filename) as f: ...
Undo the last change in the TransformedStructure.
def undo_last_change(self): """ Undo the last change in the TransformedStructure. Raises: IndexError: If already at the oldest change. """ if len(self.history) == 0: raise IndexError("Can't undo. Already at oldest change.") if 'input_structure' no...
Redo the last undone change in the TransformedStructure.
def redo_next_change(self): """ Redo the last undone change in the TransformedStructure. Raises: IndexError: If already at the latest change. """ if len(self._undone) == 0: raise IndexError("Can't redo. Already at latest change.") h, s = self._und...
Appends a transformation to the TransformedStructure.
def append_transformation(self, transformation, return_alternatives=False, clear_redo=True): """ Appends a transformation to the TransformedStructure. Args: transformation: Transformation to append return_alternatives: Whether to return alte...
Adds a filter.
def append_filter(self, structure_filter): """ Adds a filter. Args: structure_filter (StructureFilter): A filter implementating the AbstractStructureFilter API. Tells transmuter waht structures to retain. """ hdict = structure_filter.a...
Extends a sequence of transformations to the TransformedStructure.
def extend_transformations(self, transformations, return_alternatives=False): """ Extends a sequence of transformations to the TransformedStructure. Args: transformations: Sequence of Transformations return_alternatives: Whether to return a...
Returns VASP input as a dict of vasp objects.
def get_vasp_input(self, vasp_input_set=MPRelaxSet, **kwargs): """ Returns VASP input as a dict of vasp objects. Args: vasp_input_set (pymatgen.io.vaspio_set.VaspInputSet): input set to create vasp input files from structures """ d = vasp_input_set(se...
Writes VASP input to an output_dir.
def write_vasp_input(self, vasp_input_set=MPRelaxSet, output_dir=".", create_directory=True, **kwargs): """ Writes VASP input to an output_dir. Args: vasp_input_set: pymatgen.io.vaspio_set.VaspInputSet like object that creates ...
Copy of all structures in the TransformedStructure. A structure is stored after every single transformation.
def structures(self): """ Copy of all structures in the TransformedStructure. A structure is stored after every single transformation. """ hstructs = [Structure.from_dict(s['input_structure']) for s in self.history if 'input_structure' in s] return hst...
Generates TransformedStructure from a cif string.
def from_cif_string(cif_string, transformations=None, primitive=True, occupancy_tolerance=1.): """ Generates TransformedStructure from a cif string. Args: cif_string (str): Input cif string. Should contain only one structure. For cifs containi...
Generates TransformedStructure from a poscar string.
def from_poscar_string(poscar_string, transformations=None): """ Generates TransformedStructure from a poscar string. Args: poscar_string (str): Input POSCAR string. transformations ([Transformations]): Sequence of transformations to be applied to the inp...
Dict representation of the TransformedStructure.
def as_dict(self): """ Dict representation of the TransformedStructure. """ d = self.final_structure.as_dict() d["@module"] = self.__class__.__module__ d["@class"] = self.__class__.__name__ d["history"] = jsanitize(self.history) d["version"] = __version__ ...
Creates a TransformedStructure from a dict.
def from_dict(cls, d): """ Creates a TransformedStructure from a dict. """ s = Structure.from_dict(d) return cls(s, history=d["history"], other_parameters=d.get("other_parameters", None))
Create TransformedStructure from SNL.
def from_snl(cls, snl): """ Create TransformedStructure from SNL. Args: snl (StructureNL): Starting snl Returns: TransformedStructure """ hist = [] for h in snl.history: d = h.description d['_snl'] = {'url': h.url,...
Creates LDos object from raw Feff ldos files by by assuming they are numbered consecutively i. e. ldos01. dat ldos02. dat...
def from_file(feff_inp_file='feff.inp', ldos_file='ldos'): """" Creates LDos object from raw Feff ldos files by by assuming they are numbered consecutively, i.e. ldos01.dat ldos02.dat... Args: feff_inp_file (str): input file of run to obtain structure ldo...
Get charge transfer from file.
def charge_transfer_from_file(feff_inp_file, ldos_file): """ Get charge transfer from file. Args: feff_inp_file (str): name of feff.inp file for run ldos_file (str): ldos filename for run, assume consequetive order, i.e., ldos01.dat, ldos02.dat.... ...
returns shrage transfer as string
def charge_transfer_to_string(self): """returns shrage transfer as string""" ch = self.charge_transfer chts = ['\nCharge Transfer\n\nabsorbing atom'] for i in range(len(ch)): for atom, v2 in ch[str(i)].items(): a = ['\n', atom, '\n', 's ', str(v2['s']), '\n'...
Get Xmu from file.
def from_file(xmu_dat_file="xmu.dat", feff_inp_file="feff.inp"): """ Get Xmu from file. Args: xmu_dat_file (str): filename and path for xmu.dat feff_inp_file (str): filename and path of feff.inp input file Returns: Xmu object """ dat...
Returns chemical formula of material from feff. inp file
def material_formula(self): """ Returns chemical formula of material from feff.inp file """ try: form = self.header.formula except IndexError: form = 'No formula provided' return "".join(map(str, form))
Returns dict representations of Xmu object
def as_dict(self): """ Returns dict representations of Xmu object """ d = MSONable.as_dict(self) d["data"] = self.data.tolist() return d
A generator form of s. split ( \ n ) for reducing memory overhead.
def iterlines(s): """ A generator form of s.split('\n') for reducing memory overhead. Parameters ---------- s : str A multi-line string. Yields ------ line : str A string. """ prevnl = -1 while True: nextnl = s.find('\n', prevnl + 1) if next...
Return the option string.
def _options_string(self): """ Return the option string. """ if len(self.options) > 0: s = "" for op in self.options: if self._sized_op: s += "{:s}={:s} ".format(*map(str, op)) else: s += "{:s...
Return True if this AdfKey contains the given subkey.
def has_subkey(self, subkey): """ Return True if this AdfKey contains the given subkey. Parameters ---------- subkey : str or AdfKey A key name or an AdfKey object. Returns ------- has : bool True if this key contains the given ke...
Add a new subkey to this key.
def add_subkey(self, subkey): """ Add a new subkey to this key. Parameters ---------- subkey : AdfKey A new subkey. Notes ----- Duplicate check will not be performed if this is an 'Atoms' block. """ if self.key.lower() == 'at...
Remove the given subkey if existed from this AdfKey.
def remove_subkey(self, subkey): """ Remove the given subkey, if existed, from this AdfKey. Parameters ---------- subkey : str or AdfKey The subkey to remove. """ if len(self.subkeys) > 0: key = subkey if isinstance(subkey, str) else subk...
Add a new option to this key.
def add_option(self, option): """ Add a new option to this key. Parameters ---------- option : Sized or str or int or float A new option to add. This must have the same format with exsiting options. Raises ------ TypeError ...
Remove an option.
def remove_option(self, option): """ Remove an option. Parameters ---------- option : str or int The name (str) or index (int) of the option to remove. Raises ------ TypeError If the option has a wrong type. """ i...
Return True if the option is included in this key.
def has_option(self, option): """ Return True if the option is included in this key. Parameters ---------- option : str The option. Returns ------- has : bool True if the option can be found. Otherwise False will be returned. ...
A JSON serializable dict representation of self.
def as_dict(self): """ A JSON serializable dict representation of self. """ d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "name": self.name, "options": self.options} if len(self.subkeys) > 0: subkeys = [] ...
Construct a MSONable AdfKey object from the JSON dict.
def from_dict(cls, d): """ Construct a MSONable AdfKey object from the JSON dict. Parameters ---------- d : dict A dict of saved attributes. Returns ------- adfkey : AdfKey An AdfKey object recovered from the JSON dict ``d``. ...
Construct an AdfKey object from the string.
def from_string(string): """ Construct an AdfKey object from the string. Parameters ---------- string : str A string. Returns ------- adfkey : AdfKey An AdfKey object recovered from the string. Raises ------ ...
Setup the block Geometry given subkeys and the task.
def _setup_task(self, geo_subkeys): """ Setup the block 'Geometry' given subkeys and the task. Parameters ---------- geo_subkeys : Sized User-defined subkeys for the block 'Geometry'. Notes ----- Most of the run types of ADF are specified in ...
A JSON serializable dict representation of self.
def as_dict(self): """ A JSON serializable dict representation of self. """ return {"@module": self.__class__.__module__, "@class": self.__class__.__name__, "operation": self.operation, "title": self.title, "xc": self.xc.as_dict(), "basis_s...
Construct a MSONable AdfTask object from the JSON dict.
def from_dict(cls, d): """ Construct a MSONable AdfTask object from the JSON dict. Parameters ---------- d : dict A dict of saved attributes. Returns ------- task : AdfTask An AdfTask object recovered from the JSON dict ``d``. ...
Write an ADF input file.
def write_file(self, molecule, inpfile): """ Write an ADF input file. Parameters ---------- molecule : Molecule The molecule for this task. inpfile : str The name where the input file will be saved. """ mol_blocks = [] at...
Parse the ADF outputs. There are two files: one is logfile the other is the ADF output file. The final energy and structures are parsed from the logfile. Frequencies and normal modes are parsed from the ADF output file.
def _parse(self): """ Parse the ADF outputs. There are two files: one is 'logfile', the other is the ADF output file. The final energy and structures are parsed from the 'logfile'. Frequencies and normal modes are parsed from the ADF output file. """ workdir = os....
Parse the formatted logfile.
def _parse_logfile(self, logfile): """ Parse the formatted logfile. """ cycle_patt = re.compile(r"Coordinates\sin\sGeometry\sCycle\s(\d+)") coord_patt = re.compile(r"\s+([0-9]+)\.([A-Za-z]+)"+3*r"\s+([-\.0-9]+)") energy_patt = re.compile(r"<.*>\s<.*>\s+current\senergy\s+...
Parse the standard ADF output file.
def _parse_adf_output(self): """ Parse the standard ADF output file. """ numerical_freq_patt = re.compile( r"\s+\*\s+F\sR\sE\sQ\sU\sE\sN\sC\sI\sE\sS\s+\*") analytic_freq_patt = re.compile( r"\s+\*\s+F\sR\sE\sQ\sU\sE\sN\sC\sY\s+A\sN\sA\sL\sY\sS\sI\sS\s+\*")...
This method takes a list of band structures and reconstructs one band structure object from all of them.
def get_reconstructed_band_structure(list_bs, efermi=None): """ This method takes a list of band structures and reconstructs one band structure object from all of them. This is typically very useful when you split non self consistent band structure runs in several independent jobs and want to merge...