Skip to content

Commit

Permalink
Outputs - JDFTx IO Module (#4190)
Browse files Browse the repository at this point in the history
* sourcing output code from master to this branch

* sourcing output code from master to this branch

* Update from master

* source from master

* update from master

* changing enumeration of valence electrons (the `valences` method does not exactly what I thought it did. I still think its a helpful function to have but not what I need here)

* added "to_dict" method to JDFTXOutfile

* adding `JDFTXOutfileSlice` to "test_dict_repr" in "test_repr_out.py"

* removing fatal error from retrieving t_s from a JOutStructure that is None

* Correction for ruff - PLC0206 (Extracting value from dictionary without calling `.items()`) - This does not appear in my local pre-commit (which I believe is running correctly) but started causing the "lint" action to fail starting around 11/22 (along with other failures from unrelated pre-existing parts of pymatgen)

* We found some weird behavior when trying to export the JDFTXOutfile object to a mongo-db. A lot of the mystery in this output module was in how properties were being forced into memory through getattr, so here all properties are now attributes set up in post_init , get getatr is no longer explicitly defined (this also takes up a lot less lines to make reviewing easier). The only exception is charges and magnetic_moments for JOutStructure

* adding **kwargs for JOutStructure for flexibility

* Partial cleanup of tests

* Partial cleanup of tests

* Partial cleanup of tests

* Adding "structure" attribute to JOutStructure for convenient way to avoid any issues with using a JOutStructure in place of a Structure, adding eigenvals and bandProjections to JDFTXOutputs

* fixes for trajectory

* fix "structure" attribute being initialized as a JOutStructure

* old updates

* Changing all "zopen" to just "open" due to an error raised when monty.io tries to raise an "EncondingWarning", changing the dump files dir to be a fixture that creates itself, yields the path, and then removes itself (parts after a "yield" only run once the test using the fixture has finished)

* missing updated from master

* Oversight that causes ionic positions from previous strucure to be passed incorrectly

---------

Co-authored-by: Matthew Horton <mkhorton@users.noreply.github.com>
Co-authored-by: Shyue Ping Ong <shyuep@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 24, 2025
1 parent eb66a63 commit 5f744f2
Show file tree
Hide file tree
Showing 30 changed files with 43,222 additions and 0 deletions.
644 changes: 644 additions & 0 deletions src/pymatgen/io/jdftx/_output_utils.py

Large diffs are not rendered by default.

1,188 changes: 1,188 additions & 0 deletions src/pymatgen/io/jdftx/jdftxoutfileslice.py

Large diffs are not rendered by default.

532 changes: 532 additions & 0 deletions src/pymatgen/io/jdftx/jelstep.py

Large diffs are not rendered by default.

103 changes: 103 additions & 0 deletions src/pymatgen/io/jdftx/jminsettings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
"""Store generic minimization settings read from a JDFTx out file.
This module contains the JMinSettings class for storing generic minimization
and mutants for storing specific minimization settings read from a JDFTx out
file.
@mkhorton - this file is ready to review.
"""

from __future__ import annotations

import pprint
from dataclasses import dataclass
from typing import Any


@dataclass
class JMinSettings:
"""Store generic minimization settings read from a JDFTx out file.
Store generic minimization settings read from a JDFTx out file.
"""

params: dict[str, Any] | None = None

def __init__(
self,
params: dict[str, Any] | None = None,
) -> None:
"""Initialize a generic JMinSettings class.
Args:
params (dict[str, Any] | None): A dictionary of minimization settings.
"""
self.params = None if params is None else dict(params)

def __str__(self) -> str:
"""Return a string representation of the minimization settings."""
return pprint.pformat(self)


@dataclass
class JMinSettingsElectronic(JMinSettings):
"""JMInSettings mutant for electronic minimization settings.
A class for storing electronic minimization settings read from a JDFTx out file.
"""

start_flag: str = "electronic-minimize"

def __init__(
self,
params: dict[str, Any] | None = None,
) -> None:
super().__init__(params=params)


@dataclass
class JMinSettingsFluid(JMinSettings):
"""JMInSettings mutant for fluid minimization settings.
A class for storing fluid minimization settings read from a JDFTx out file.
"""

start_flag: str = "fluid-minimize"

def __init__(
self,
params: dict[str, Any] | None = None,
) -> None:
super().__init__(params=params)


@dataclass
class JMinSettingsLattice(JMinSettings):
"""JMInSettings mutant for lattice minimization settings.
A class for storing lattice minimization settings read from a JDFTx out file.
"""

start_flag: str = "lattice-minimize"

def __init__(
self,
params: dict[str, Any] | None = None,
) -> None:
super().__init__(params=params)


@dataclass
class JMinSettingsIonic(JMinSettings):
"""JMInSettings mutant for ionic minimization settings.
A class for storing ionic minimization settings read from a JDFTx out file.
"""

start_flag: str = "ionic-minimize"

def __init__(
self,
params: dict[str, Any] | None = None,
) -> None:
super().__init__(params=params)
Loading

0 comments on commit 5f744f2

Please sign in to comment.