Skip to content

Commit 5f744f2

Browse files
benrich37mkhortonshyuep
authored
Outputs - JDFTx IO Module (#4190)
* 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 <[email protected]> Co-authored-by: Shyue Ping Ong <[email protected]>
1 parent eb66a63 commit 5f744f2

30 files changed

+43222
-0
lines changed

src/pymatgen/io/jdftx/_output_utils.py

Lines changed: 644 additions & 0 deletions
Large diffs are not rendered by default.

src/pymatgen/io/jdftx/jdftxoutfileslice.py

Lines changed: 1188 additions & 0 deletions
Large diffs are not rendered by default.

src/pymatgen/io/jdftx/jelstep.py

Lines changed: 532 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
"""Store generic minimization settings read from a JDFTx out file.
2+
3+
This module contains the JMinSettings class for storing generic minimization
4+
and mutants for storing specific minimization settings read from a JDFTx out
5+
file.
6+
7+
@mkhorton - this file is ready to review.
8+
"""
9+
10+
from __future__ import annotations
11+
12+
import pprint
13+
from dataclasses import dataclass
14+
from typing import Any
15+
16+
17+
@dataclass
18+
class JMinSettings:
19+
"""Store generic minimization settings read from a JDFTx out file.
20+
21+
Store generic minimization settings read from a JDFTx out file.
22+
"""
23+
24+
params: dict[str, Any] | None = None
25+
26+
def __init__(
27+
self,
28+
params: dict[str, Any] | None = None,
29+
) -> None:
30+
"""Initialize a generic JMinSettings class.
31+
32+
Args:
33+
params (dict[str, Any] | None): A dictionary of minimization settings.
34+
"""
35+
self.params = None if params is None else dict(params)
36+
37+
def __str__(self) -> str:
38+
"""Return a string representation of the minimization settings."""
39+
return pprint.pformat(self)
40+
41+
42+
@dataclass
43+
class JMinSettingsElectronic(JMinSettings):
44+
"""JMInSettings mutant for electronic minimization settings.
45+
46+
A class for storing electronic minimization settings read from a JDFTx out file.
47+
"""
48+
49+
start_flag: str = "electronic-minimize"
50+
51+
def __init__(
52+
self,
53+
params: dict[str, Any] | None = None,
54+
) -> None:
55+
super().__init__(params=params)
56+
57+
58+
@dataclass
59+
class JMinSettingsFluid(JMinSettings):
60+
"""JMInSettings mutant for fluid minimization settings.
61+
62+
A class for storing fluid minimization settings read from a JDFTx out file.
63+
"""
64+
65+
start_flag: str = "fluid-minimize"
66+
67+
def __init__(
68+
self,
69+
params: dict[str, Any] | None = None,
70+
) -> None:
71+
super().__init__(params=params)
72+
73+
74+
@dataclass
75+
class JMinSettingsLattice(JMinSettings):
76+
"""JMInSettings mutant for lattice minimization settings.
77+
78+
A class for storing lattice minimization settings read from a JDFTx out file.
79+
"""
80+
81+
start_flag: str = "lattice-minimize"
82+
83+
def __init__(
84+
self,
85+
params: dict[str, Any] | None = None,
86+
) -> None:
87+
super().__init__(params=params)
88+
89+
90+
@dataclass
91+
class JMinSettingsIonic(JMinSettings):
92+
"""JMInSettings mutant for ionic minimization settings.
93+
94+
A class for storing ionic minimization settings read from a JDFTx out file.
95+
"""
96+
97+
start_flag: str = "ionic-minimize"
98+
99+
def __init__(
100+
self,
101+
params: dict[str, Any] | None = None,
102+
) -> None:
103+
super().__init__(params=params)

0 commit comments

Comments
 (0)