How to use the pyiron.sphinx.base.Group function in pyiron

To help you get started, we’ve selected a few pyiron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyiron / pyiron / pyiron / sphinx / base.py View on Github external
charge_density_file = ff
        wave_function_file = None
        for ff in self.restart_file_list:
            if "waves.sxb" in ff.split("/")[-1]:
                wave_function_file = ff

        self.input.sphinx.initialGuess.setdefault("waves", Group())
        self.input.sphinx.initialGuess.waves.setdefault("lcao", Group())
        self.input.sphinx.initialGuess.waves.setdefault("pawBasis", True)
        if wave_function_file is not None:
            self.input.sphinx.initialGuess.setdefault("exchange", Group())
            self.input.sphinx.initialGuess.exchange.setdefault(
                "file", '"' + wave_function_file + '"'
            )
        if charge_density_file is None:
            self.input.sphinx.initialGuess.setdefault("rho", Group({"atomicOrbitals": True}))
        else:
            self.input.sphinx.initialGuess.setdefault(
                "rho", Group({"file": '"' + charge_density_file + '"'})
                )
        if self._spin_enabled:
            if any(
                [
                    True
                    if isinstance(spin, list) or isinstance(spin, np.ndarray)
                    else False
                    for spin in self.structure.get_initial_magnetic_moments()
                ]
            ):
                raise ValueError("Sphinx only supports collinear spins.")
            else:
                rho = self.input.sphinx.initialGuess.rho
github pyiron / pyiron / pyiron / sphinx / base.py View on Github external
def load_species_group(self, check_overlap=True, potformat='VASP'):
        """
        Build the species Group object based on self.structure

        Args:
            check_overlap (bool): Whether to check overlap
                (see set_check_overlap)
            potformat (str): type of pseudopotentials that will be
                read. Options are JTH or VASP.
        """

        self.input.sphinx.pawPot = Group({"species": []})
        for species_obj in self.structure.get_species_objects():
            if species_obj.Parent is not None:
                elem = species_obj.Parent
            else:
                elem = species_obj.Abbreviation
            if potformat == "JTH":
                self.input.sphinx.pawPot["species"].append({
                            "name": '"' + elem + '"',
                            "potType": '"AtomPAW"',
                            "element": '"' + elem + '"',
                            "potential": f'"{elem}_GGA.atomicdata"',
                })
            elif potformat == "VASP":
                self.input.sphinx.pawPot["species"].append({
                            "name": '"' + elem + '"',
                            "potType": '"VASP"',
github pyiron / pyiron / pyiron / sphinx / base.py View on Github external
xc=self.input["Xcorr"],
            cwd=self.working_directory
            )

        # Write spin constraints, if set via _generic_input.
        all_groups = [
            self.input.sphinx.pawPot,
            self.input.sphinx.structure,
            self.input.sphinx.basis,
            self.input.sphinx.PAWHamiltonian,
            self.input.sphinx.initialGuess,
            self.input.sphinx.main
        ]

        if self._generic_input["fix_spin_constraint"]:
            self.input.sphinx.spinConstraint = Group()
            all_groups.append(self.input.sphinx.spinConstraint)
            self.input_writer.write_spin_constraints(
                cwd=self.working_directory
                )
            self.input.sphinx.spinConstraint.setdefault("file", '"spins.in"')

        # In case the entire group was
        # set/overwritten as a normal dict.
        for group in all_groups:
            group = Group(group)

        # write input.sx
        file_name = posixpath.join(self.working_directory, "input.sx")
        with open(file_name, "w") as f:
            f.write(f"//{self.job_name}\n")
            f.write("//SPHInX input file generated by pyiron\n\n")
github pyiron / pyiron / pyiron / sphinx / base.py View on Github external
self.input.sphinx.initialGuess,
            self.input.sphinx.main
        ]

        if self._generic_input["fix_spin_constraint"]:
            self.input.sphinx.spinConstraint = Group()
            all_groups.append(self.input.sphinx.spinConstraint)
            self.input_writer.write_spin_constraints(
                cwd=self.working_directory
                )
            self.input.sphinx.spinConstraint.setdefault("file", '"spins.in"')

        # In case the entire group was
        # set/overwritten as a normal dict.
        for group in all_groups:
            group = Group(group)

        # write input.sx
        file_name = posixpath.join(self.working_directory, "input.sx")
        with open(file_name, "w") as f:
            f.write(f"//{self.job_name}\n")
            f.write("//SPHInX input file generated by pyiron\n\n")
            f.write("format paw;\n")
            f.write("include ;\n\n")
            f.write(self.input.sphinx.to_sphinx(indent=0))
github pyiron / pyiron / pyiron / sphinx / base.py View on Github external
"""
        Load the main Group.

        The group is populated based on the type of calculation and settings in
        the self.input.
        """

        if len(self.restart_file_list) != 0 \
        and not self._generic_input["restart_for_band_structure"]:
            self.input.sphinx.main.get("scfDiag", create = True).append(
                self.get_scf_group(
                    maxSteps=10, keepRhoFixed=True, dEnergy=1.0e-4
                )
            )
        if "Istep" in self.input:
            self.input.sphinx.main["ricQN"] = Group(table_name = "input")
            self.input.sphinx.main["ricQN"]["maxSteps"] = str(self.input["Istep"])
            if "dE" in self.input and "dF" in self.input:
                self.input["dE"] = 1e-3
            if "dE" in self.input:
                self.input.sphinx.main["ricQN"]["dEnergy"] = str(
                    self.input["dE"] / HARTREE_TO_EV
                    )
            if "dF" in self.input:
                self.input.sphinx.main["ricQN"]["dF"] = str(
                    self.input["dF"] / HARTREE_OVER_BOHR_TO_EV_OVER_ANGSTROM
                )
            self.input.sphinx.main.ricQN.create_group("bornOppenheimer")
            self.input.sphinx.main.ricQN.bornOppenheimer["scfDiag"] = \
                self.get_scf_group()
        else:
            scf = self.input.sphinx.main.get("scfDiag", create = True)
github pyiron / pyiron / pyiron / sphinx / base.py View on Github external
else False
                    for spin in self.structure.get_initial_magnetic_moments()
                ]
            ):
                raise ValueError("Sphinx only supports collinear spins.")
            else:
                rho = self.input.sphinx.initialGuess.rho
                rho.get("atomicSpin", create = True)
                if update_spins:
                    rho.atomicSpin.clear()
                if len(rho.atomicSpin) == 0:
                    for spin in self.structure.get_initial_magnetic_moments()[
                        self.id_pyi_to_spx
                    ]:
                        rho["atomicSpin"].append(
                            Group({
                                "label": '"spin_' + str(spin) + '"',
                                "spin": str(spin)
                            })
                        )

        if "noWavesStorage" not in self.input.sphinx.initialGuess:
            self.input.sphinx.initialGuess["noWavesStorage"] = \
                    not self.input["WriteWaves"]
    def calc_static(