text
stringlengths
81
112k
Shows the plot using pylab. Usually I won"t do imports in methods, but since plotting is a fairly expensive library to load and not all machines have matplotlib installed, I have done it this way. def _get_3d_plot(self, label_stable=True): """ Shows the plot using pylab. Usually I won...
Writes the phase diagram to an image in a stream. Args: stream: stream to write to. Can be a file stream or a StringIO stream. image_format format for image. Can be any of matplotlib supported formats. Defaults to svg for best results for ...
Plot the chemical potential range _map. Currently works only for 3-component PDs. Args: elements: Sequence of elements to be considered as independent variables. E.g., if you want to show the stability ranges of all Li-Co-O phases wrt to uLi and uO, you will ...
Returns a plot of the chemical potential range _map. Currently works only for 3-component PDs. Args: elements: Sequence of elements to be considered as independent variables. E.g., if you want to show the stability ranges of all Li-Co-O phases wrt to uLi and ...
Plot a contour phase diagram plot, where phase triangles are colored according to degree of instability by interpolation. Currently only works for 3-component phase diagrams. Returns: A matplotlib plot object. def get_contour_pd_plot(self): """ Plot a contour phase ...
Returns all input files as a dict of {filename: feffio object} def all_input(self): """ Returns all input files as a dict of {filename: feffio object} """ d = {"HEADER": self.header(), "PARAMETERS": self.tags} if "RECIPROCAL" not in self.tags: d.update({"POTENTIALS"...
Writes a set of FEFF input to a directory. Args: output_dir: Directory to output the FEFF input files make_dir_if_not_present: Set to True if you want the directory ( and the whole path) to be created if it is not present. def write_input(self, output_dir=".", make_dir_...
FEFF job parameters. Returns: Tags def tags(self): """ FEFF job parameters. Returns: Tags """ if "RECIPROCAL" in self.config_dict: if self.small_system: self.config_dict["CIF"] = "{}.cif".format( s...
Read in a set of FEFF input files from a directory, which is useful when existing FEFF input needs some adjustment. def from_directory(input_dir): """ Read in a set of FEFF input files from a directory, which is useful when existing FEFF input needs some adjustment. """ ...
Method that compares two functions Args: f1: First function to compare f2: Second function to compare x1: Lower bound of the interval to compare x2: Upper bound of the interval to compare numpoints_check: Number of points used to compare the functions...
Method that creates two quarter-ellipse functions based on points xx and yy. The ellipsis is supposed to be aligned with the axes. The two ellipsis pass through the two points xx and yy. Args: xx: First point yy: Second point Returns: A dictionary with the l...
Method that creates two (upper and lower) spline functions based on points lower_points and upper_points. Args: lower_points: Points defining the lower function. upper_points: Points defining the upper function. degree: Degree for the spline function ...
Method that creates two upper and lower functions based on points xx and yy as well as intercepts defined by y_x0 and x_y0. The resulting functions form kind of a distorted diamond-like structure aligned from point xx to point yy. Schematically : xx is symbolized by x, yy is symbolized by y, y_x0 ...
Method to calculate the surface of the intersection of a rectangle (aligned with axes) and another surface defined by two functions f_lower and f_upper. Args: rectangle: Rectangle defined as : ((x1, x2), (y1, y2)). f_lower: Function defining the lower bound of the surfac...
Helper method to calculate the solid angle of a set of coords from the center. Args: center: Center to measure solid angle from. coords: List of coords to determine solid angle. Returns: The solid angle. def my_solid_angle(center, coords): """ Helpe...
Performs the vector multiplication of the elements of two vectors, constructing the 3x3 matrix. :param aa: One vector of size 3 :param bb: Another vector of size 3 :return: A 3x3 matrix M composed of the products of the elements of aa and bb : M_ij = aa_i * bb_j def vectorsToMatrix(aa, bb): """ ...
Rotate the list of points using rotation matrix R :param coords: List of points to be rotated :param R: Rotation matrix :return: List of rotated points def rotateCoords(coords, R): """ Rotate the list of points using rotation matrix R :param coords: List of points to be rotated :param R: Ro...
For a list of points given in standard coordinates (in terms of e1, e2 and e3), returns the same list expressed in the basis (uu, vv, nn), which is supposed to be orthonormal. :param uu: First vector of the basis :param vv: Second vector of the basis :param nn: Third vector of the bais :param pps: L...
Checks if the three points p1, p2 and p3 are collinear or not within a given tolerance. The collinearity is checked by computing the area of the triangle defined by the three points p1, p2 and p3. If the area of this triangle is less than (tolerance x largest_triangle), then the three points are considered coll...
Sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Sorted list of points def anticlockwise_sort(pps): """ Sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Sorted list of points """ newpps = lis...
Returns the indices that would sort a list of 2D points in anticlockwise order :param pps: List of points to be sorted :return: Indices of the sorted list of points def anticlockwise_sort_indices(pps): """ Returns the indices that would sort a list of 2D points in anticlockwise order :param pps: Li...
Checks if the separation indices of a plane are already in the list :param separation_indices: list of separation indices (three arrays of integers) :param separation_indices_list: list of the list of separation indices to be compared to :return: True if the separation indices are already in the list, False...
Checks if two given sites are an anion and a cation. :param valences: list of site valences :param ii: index of a site :param jj: index of another site :return: True if one site is an anion and the other is a cation (from the valences) def is_anion_cation_bond(valences, ii, jj): """ Checks if t...
Determines if point pp is in the plane within the tolerance dist_tolerance :param pp: point to be tested :param dist_tolerance: tolerance on the distance to the plane within which point pp is considered in the plane :return: True if pp is in the plane, False otherwise def is_in_plane(self, pp, ...
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 o...
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 p...
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 ...
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...
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 ...
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 distan...
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 ...
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 other strange error def orthonormal_vectors_old(s...
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_ind...
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 fro...
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 molecul...
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 alrea...
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...
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.eferm...
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 CHOP or ICOHP for the input spin. If Spin is ...
Returns the COHP for a particular energy. Args: energy: Energy to return the COHP value for. def get_interpolated_value(self, energy, integrated=False): """ Returns the COHP for a particular energy. Args: energy: Energy to return the COHP value for. """...
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 s...
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()} ...
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, "efe...
Get specific COHP object. Args: label: string (for newer Lobster versions: a number) Returns: Returns the COHP object to simplify plotting def get_cohp_by_label(self, label): """ Get specific COHP object. Args: label: string (for newer Lobs...
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 divided by this divisor Returns: Returns a COHP object including ...
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 of orbitals for the COHPs that should be included in the summed cohp (same order as label_list) di...
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, orbital2)]. Orbitals can either be str, int, or Orbital. ...
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 "bon...
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: cohp_file: Name of the COHP output file. Defaults to COPL for LMTO and COHPCAR.lobster/CO...
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 """ ...
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: ...
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 ...
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...
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 val...
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 f...
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, this spin indicates which spin channel should be returned Returns: lowe...
Get distance between two sites. Args: other: Other site. Returns: Distance (float) def distance(self, other): """ Get distance between two sites. Args: other: Other site. Returns: Distance (float) """ re...
Returns distance between the site and a point in space. Args: pt: Cartesian coordinates of point. Returns: Distance (float) def distance_from_point(self, pt): """ Returns distance between the site and a point in space. Args: pt: Cartesian c...
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()) ...
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.speci...
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"] ...
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"]): ...
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 Period...
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): Whether to check if the two sites have the same lattice. Returns: ...
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 ...
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. def as_dict(self, verbosity=0): """ Jso...
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 = SimpleVaspToComputedEntry...
Calculates the powder neutron diffraction pattern for a structure. Args: structure (Structure): Input structure scaled (bool): Whether to return scaled intensities. The maximum peak is set to a value of 100. Defaults to True. Use False if you need the abs...
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. def find_equivalent_sites(self, site): """ Finds all symmetrically equivalen...
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, ...
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_...
: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') ...
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...
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) ...
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 ...
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 "FUL...
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): """ ...
: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(d...
: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_o...
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:") ...
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 def from_string(cls, string_input): """ Read an FiestaInput from a string. Cur...
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 def from_file(cls, filename): """ Read an Fiesta input from a file. Currently tested t...
Undo the last change in the TransformedStructure. Raises: IndexError: If already at the oldest change. def undo_last_change(self): """ Undo the last change in the TransformedStructure. Raises: IndexError: If already at the oldest change. """ if ...
Redo the last undone change in the TransformedStructure. Raises: IndexError: If already at the latest change. def redo_next_change(self): """ Redo the last undone change in the TransformedStructure. Raises: IndexError: If already at the latest change. "...
Appends a transformation to the TransformedStructure. Args: transformation: Transformation to append return_alternatives: Whether to return alternative TransformedStructures for one-to-many transformations. return_alternatives can be a number, which stipu...
Adds a filter. Args: structure_filter (StructureFilter): A filter implementating the AbstractStructureFilter API. Tells transmuter waht structures to retain. def append_filter(self, structure_filter): """ Adds a filter. Args: str...
Extends a sequence of transformations to the TransformedStructure. Args: transformations: Sequence of Transformations return_alternatives: Whether to return alternative TransformedStructures for one-to-many transformations. return_alternatives can be a nu...
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 def get_vasp_input(self, vasp_input_set=MPRelaxSet, **kwargs): """ Returns VASP input as a dict of vasp obj...
Writes VASP input to an output_dir. Args: vasp_input_set: pymatgen.io.vaspio_set.VaspInputSet like object that creates vasp input files from structures output_dir: Directory to output files create_directory: Create the directory if not present...
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.f...
Generates TransformedStructure from a cif string. Args: cif_string (str): Input cif string. Should contain only one structure. For cifs containing multiple structures, please use CifTransmuter. transformations ([Transformations]): Sequence of transformati...
Generates TransformedStructure from a poscar string. Args: poscar_string (str): Input POSCAR string. transformations ([Transformations]): Sequence of transformations to be applied to the input structure. def from_poscar_string(poscar_string, transformations=None): ...
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...
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. Args: snl (StructureNL): Starting snl Returns: TransformedStructure def from_snl(cls, snl): """ Create TransformedStructure from SNL. Args: snl (StructureNL): Starting snl Returns: ...
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 ldos_file (str): output ldos file of run to obtain dos info, etc. def from_file(fe...