Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPHINX eigen values parser #1159

Closed
wants to merge 100 commits into from
Closed

SPHINX eigen values parser #1159

wants to merge 100 commits into from

Conversation

ahmedabdelkawy
Copy link
Contributor

@ahmedabdelkawy ahmedabdelkawy commented Sep 7, 2023

  1. With the current Pyiron sphinx parser, the eigenvalues from the eps.*.dat files are not parsed
  • in pyiron_atomistics/pyiron_atomistics/sphinx/base.py The collect function gives priority to the final eigen values in the log file self.collect_sphinx_log(file_name="sphinx.log", cwd=directory) before self.collect_eps_dat()
        def collect(self, directory=os.getcwd()):
        """
        The collect function, collects all the output from a SPHInX simulation.

        Args:
            directory (str): the directory to collect the output from.
        """
        self.collect_energy_struct(file_name="energy-structOpt.dat", cwd=directory)
        self.collect_sphinx_log(file_name="sphinx.log", cwd=directory)
        self.collect_energy_dat(file_name="energy.dat", cwd=directory)
        self.collect_residue_dat(file_name="residue.dat", cwd=directory)
        if self._job._spin_enabled:
            self.collect_eps_dat(file_name="eps.dat", cwd=directory)
        else:
            self.collect_eps_dat(
                file_name=[f"eps.{i}.dat" for i in [0, 1]], cwd=directory
            )
        self.collect_spins_dat(file_name="spins.dat", cwd=directory)
        self.collect_relaxed_hist(file_name="relaxHist.sx", cwd=directory)
        self.collect_electrostatic_potential(file_name="vElStat-eV.sxb", cwd=directory)
        self.collect_charge_density(file_name="rho.sxb", cwd=directory)
  • This is then followed by
    def collect_eps_dat(self, file_name="eps.dat", cwd=None):
        """

        Args:
            file_name:
            cwd:

        Returns:

        """
        if isinstance(file_name, str):
            file_name = [file_name]
        values = []
        for f in file_name:
            file_tmp = posixpath.join(cwd, f)
            if not os.path.isfile(file_tmp):
                return
            values.append(np.loadtxt(file_tmp)[..., 1:])
        values = np.stack(values, axis=0)
        if "bands_eigen_values" not in self.generic.dft.list_nodes():
            self.generic.dft.bands_eigen_values = values.reshape((-1,) + values.shape)
  • Which does not import values from the eps.*.dat files because it already imported the values from the log file
  1. The problem with importing eigenvalues from the logfile is that pyiron expects to have the eigenvalues of all kpoints from the 1st spin channel (in case of spin-polarized calculations) followed by the eigenvalues at all kpoint from the second spin channel. Which happens here:
    def _parse_band(self, term):
        arr = np.loadtxt(re.findall(term, self.log_main, re.MULTILINE))
        shape = (-1, len(self.k_points), arr.shape[-1])
        if self.spin_enabled:
            shape = (-1, 2, len(self.k_points), shape[-1])
        return arr.reshape(shape)
  • However, in sphinx, this is true from the eps.*.dat but from the log file, the eigenvalues are printed for spin up and then spin down for each kpoint in alternating fashion.
  1. This appears as a problem only in the case of ferromagnetic systems (metals) where the 2 spin channels are different (while in nonmagnetic systems you have one spin channel and in antiferromagnetic systems you two identical but opposite dos)

  2. I did not change the current parser priority. However, I changed the order of the parsed eigenvalues to match what pyiron expects: arr = np.vstack((arr[::2], arr[1::2]))

@ahmedabdelkawy ahmedabdelkawy added bug Something isn't working enhancement New feature or request labels Sep 7, 2023
@@ -2286,6 +2286,7 @@ def _parse_band(self, term):
arr = np.loadtxt(re.findall(term, self.log_main, re.MULTILINE))
shape = (-1, len(self.k_points), arr.shape[-1])
if self.spin_enabled:
arr = np.vstack((arr[::2], arr[1::2]))
Copy link
Contributor

@freyso freyso Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment in the code why this is needed. Otherwise, this will cause a lot of headache for later devels.

@samwaseda
Copy link
Member

I'm actually a bit concerned that it may or may not work depending on the SPHInX version? I'm saying this because it was correct in an earlier version and stopped being so with the current version. Maybe we need a version check inside the parser.

@freyso
Copy link
Contributor

freyso commented Sep 8, 2023 via email

@pmrv
Copy link
Contributor

pmrv commented Sep 9, 2023 via email

@stale
Copy link

stale bot commented Oct 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 15, 2023
pyiron-runner and others added 27 commits November 13, 2023 12:06
Bumps [mp-api](https://github.com/materialsproject/api) from 0.37.2 to 0.37.3.
- [Release notes](https://github.com/materialsproject/api/releases)
- [Commits](materialsproject/api@v0.37.2...v0.37.3)

---
updated-dependencies:
- dependency-name: mp-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [mp-api](https://github.com/materialsproject/api) from 0.37.3 to 0.37.5.
- [Release notes](https://github.com/materialsproject/api/releases)
- [Commits](materialsproject/api@v0.37.3...v0.37.5)

---
updated-dependencies:
- dependency-name: mp-api
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [h5py](https://github.com/h5py/h5py) from 3.9.0 to 3.10.0.
- [Release notes](https://github.com/h5py/h5py/releases)
- [Changelog](https://github.com/h5py/h5py/blob/master/docs/release_guide.rst)
- [Commits](h5py/h5py@3.9.0...3.10.0)

---
updated-dependencies:
- dependency-name: h5py
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Currently calphy complains if this value is set to None.
Bumps [pandas](https://github.com/pandas-dev/pandas) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/pandas-dev/pandas/releases)
- [Commits](pandas-dev/pandas@v2.1.1...v2.1.2)

---
updated-dependencies:
- dependency-name: pandas
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [scikit-learn](https://github.com/scikit-learn/scikit-learn) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/scikit-learn/scikit-learn/releases)
- [Commits](scikit-learn/scikit-learn@1.3.1...1.3.2)

---
updated-dependencies:
- dependency-name: scikit-learn
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [matplotlib](https://github.com/matplotlib/matplotlib) from 3.8.0 to 3.8.1.
- [Release notes](https://github.com/matplotlib/matplotlib/releases)
- [Commits](matplotlib/matplotlib@v3.8.0...v3.8.1)

---
updated-dependencies:
- dependency-name: matplotlib
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants