egqca 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- egqca-1.0.0/LICENSE +21 -0
- egqca-1.0.0/PKG-INFO +144 -0
- egqca-1.0.0/README.md +109 -0
- egqca-1.0.0/pyproject.toml +34 -0
- egqca-1.0.0/setup.cfg +4 -0
- egqca-1.0.0/src/egqca/__init__.py +77 -0
- egqca-1.0.0/src/egqca/_banner.py +109 -0
- egqca-1.0.0/src/egqca/_ml_utils.py +924 -0
- egqca-1.0.0/src/egqca/colors.py +124 -0
- egqca-1.0.0/src/egqca/comparison.py +593 -0
- egqca-1.0.0/src/egqca/constants.py +197 -0
- egqca-1.0.0/src/egqca/create_dft_inputs.py +543 -0
- egqca-1.0.0/src/egqca/eddp_calculator.py +178 -0
- egqca-1.0.0/src/egqca/egqca_model.py +1676 -0
- egqca-1.0.0/src/egqca/io.py +584 -0
- egqca-1.0.0/src/egqca/ml.py +2462 -0
- egqca-1.0.0/src/egqca/properties.py +444 -0
- egqca-1.0.0/src/egqca/py.typed +0 -0
- egqca-1.0.0/src/egqca/subclasses.py +45 -0
- egqca-1.0.0/src/egqca/workflow.py +2114 -0
- egqca-1.0.0/src/egqca.egg-info/PKG-INFO +144 -0
- egqca-1.0.0/src/egqca.egg-info/SOURCES.txt +35 -0
- egqca-1.0.0/src/egqca.egg-info/dependency_links.txt +1 -0
- egqca-1.0.0/src/egqca.egg-info/requires.txt +26 -0
- egqca-1.0.0/src/egqca.egg-info/top_level.txt +1 -0
- egqca-1.0.0/tests/test_aims_inputs.py +83 -0
- egqca-1.0.0/tests/test_band_path.py +48 -0
- egqca-1.0.0/tests/test_clusters_template.py +118 -0
- egqca-1.0.0/tests/test_comparison.py +142 -0
- egqca-1.0.0/tests/test_egqca.py +211 -0
- egqca-1.0.0/tests/test_io.py +453 -0
- egqca-1.0.0/tests/test_ml_collect.py +149 -0
- egqca-1.0.0/tests/test_ml_run_settings.py +590 -0
- egqca-1.0.0/tests/test_package_exports.py +7 -0
- egqca-1.0.0/tests/test_properties.py +61 -0
- egqca-1.0.0/tests/test_qe_inputs.py +145 -0
- egqca-1.0.0/tests/test_workflow_api.py +692 -0
egqca-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Christoph Heil, Pedro Nunes Ferreira, Dominik Spath, Luka Wibmer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
egqca-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: egqca
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Extended Generalized QuasiChemical Approximation
|
|
5
|
+
Author-email: Pedro Nunes Ferreira <nunesferreira@tugraz.at>, Dominik Spath <dominik.spath@tugraz.at>, Luka Wibmer <luka.wibmer@tugraz.at>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/egqca/egqca
|
|
8
|
+
Project-URL: Documentation, https://egqca.github.io/egqca/
|
|
9
|
+
Project-URL: Source, https://github.com/egqca/egqca
|
|
10
|
+
Project-URL: Issues, https://github.com/egqca/egqca/issues
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: scipy
|
|
16
|
+
Requires-Dist: matplotlib
|
|
17
|
+
Requires-Dist: matplotlib-label-lines
|
|
18
|
+
Requires-Dist: ase>=3.25
|
|
19
|
+
Requires-Dist: spglib
|
|
20
|
+
Provides-Extra: upet
|
|
21
|
+
Requires-Dist: upet; extra == "upet"
|
|
22
|
+
Provides-Extra: mace
|
|
23
|
+
Requires-Dist: mace-torch; extra == "mace"
|
|
24
|
+
Provides-Extra: mattersim
|
|
25
|
+
Requires-Dist: mattersim; extra == "mattersim"
|
|
26
|
+
Provides-Extra: grace
|
|
27
|
+
Requires-Dist: tensorpotential>=0.6.1; extra == "grace"
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest<9,>=8; extra == "test"
|
|
30
|
+
Provides-Extra: docs
|
|
31
|
+
Requires-Dist: mkdocs<2,>=1.6; extra == "docs"
|
|
32
|
+
Requires-Dist: mkdocstrings[python]>=0.26; extra == "docs"
|
|
33
|
+
Requires-Dist: black; extra == "docs"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# EGQCA
|
|
37
|
+
|
|
38
|
+
**Extended Generalized Quasichemical Approximation** for (quasi-)binary alloys
|
|
39
|
+
$A_{1-x}B_xC$, with optional vibrational and PV (enthalpy) contributions.
|
|
40
|
+
|
|
41
|
+
EGQCA computes thermodynamic properties of an alloy at arbitrary composition $x$
|
|
42
|
+
and temperature $T$ by statistically averaging over a set of small clusters.
|
|
43
|
+
From the cluster energies it gives the mixing free energy, enthalpy and entropy,
|
|
44
|
+
the cluster occurrence probabilities, the miscibility gap (binodal and spinodal),
|
|
45
|
+
and composition-averaged properties such as lattice parameters.
|
|
46
|
+
|
|
47
|
+
The method is described in
|
|
48
|
+
[doi:10.1016/j.mtphys.2024.101547](https://doi.org/10.1016/j.mtphys.2024.101547).
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- Generation of all non-equivalent clusters of a supercell from a CIF file
|
|
53
|
+
(via the [supercell program](https://orex.github.io/supercell/))
|
|
54
|
+
- Input files for DFT relaxations with FHI-aims, Quantum ESPRESSO or VASP, and
|
|
55
|
+
automatic extraction of the energies and lattice parameters
|
|
56
|
+
- Relaxation and phonons with machine-learned interatomic potentials (UPET, MACE,
|
|
57
|
+
MatterSim, GRACE, or any ASE calculator)
|
|
58
|
+
- Gibbs free energy with mixing energy, configurational entropy, vibrational
|
|
59
|
+
free energy from phonon DOS, and PV term
|
|
60
|
+
- Miscibility gap, averaged properties and cluster reduction
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install egqca
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The ML relaxation needs the package of the chosen model family. Install each
|
|
69
|
+
into its own environment, as their dependencies can conflict:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install "egqca[upet]" # UPET / PET models
|
|
73
|
+
pip install "egqca[mace]" # MACE
|
|
74
|
+
pip install "egqca[mattersim]" # MatterSim
|
|
75
|
+
pip install "egqca[grace]" # GRACE
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Python 3.10 or newer is required.
|
|
79
|
+
|
|
80
|
+
To install the development version from source:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/egqca/egqca
|
|
84
|
+
cd egqca
|
|
85
|
+
pip install -e .
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Quick start
|
|
89
|
+
|
|
90
|
+
With existing input files, a calculation looks like this:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
import numpy as np
|
|
94
|
+
import egqca
|
|
95
|
+
|
|
96
|
+
m = egqca.EGQCA(
|
|
97
|
+
datafile="clusters.dat",
|
|
98
|
+
compound="A$_{1-x}$B$_x$C",
|
|
99
|
+
volume_file="volume.dat", # optional, for the PV term
|
|
100
|
+
pressure_GPa=0.0, # optional
|
|
101
|
+
phonon_file_name="ph_dos", # optional, folder with <cluster_id>.dos files
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
x_grid = np.arange(1e-6, 1.0, 1.0e-3)
|
|
105
|
+
m.thermodynamic_assessment(x_grid, Tlist=[600, 800, 1000, 1400])
|
|
106
|
+
m.average_properties("volume.dat")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Example
|
|
110
|
+
|
|
111
|
+
[`examples/NbV/`](https://github.com/egqca/egqca/tree/main/examples/NbV) covers the full workflow with ML potentials for bcc
|
|
112
|
+
Nb$_{1-x}$V$_x$ with 8-atom clusters:
|
|
113
|
+
|
|
114
|
+
| Script | Step |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `01_generate_clusters.py` | generate the 22 non-equivalent clusters |
|
|
117
|
+
| `02_ml_relaxation_phonons.py` | ML relaxation and phonons with `pet-omatpes-l` |
|
|
118
|
+
| `03_run_egqca.py` | EGQCA without phonons, with phonons, and with phonons + PV |
|
|
119
|
+
|
|
120
|
+
The results of step 2 are included, so `03_run_egqca.py` runs directly.
|
|
121
|
+
|
|
122
|
+
## Documentation
|
|
123
|
+
|
|
124
|
+
The documentation in [`docs/`](https://github.com/egqca/egqca/tree/main/docs) covers the cluster setup, DFT input files,
|
|
125
|
+
the ML workflow, the entropy approximation, property averaging and cluster
|
|
126
|
+
reduction. Build it locally from a source checkout with
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pip install -e ".[docs]"
|
|
130
|
+
mkdocs serve
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Citation
|
|
134
|
+
|
|
135
|
+
If you use EGQCA, please cite
|
|
136
|
+
[doi:10.1016/j.mtphys.2024.101547](https://doi.org/10.1016/j.mtphys.2024.101547).
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
EGQCA is released under the [MIT License](https://github.com/egqca/egqca/blob/main/LICENSE).
|
|
141
|
+
|
|
142
|
+
The ML packages and model weights it can use have their own licenses. Some
|
|
143
|
+
model weights (e.g. MACE-OMAT-0, MACE-MATPES-0, MACE-MH) are for
|
|
144
|
+
non-commercial use only. Check the license of the model you use.
|
egqca-1.0.0/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# EGQCA
|
|
2
|
+
|
|
3
|
+
**Extended Generalized Quasichemical Approximation** for (quasi-)binary alloys
|
|
4
|
+
$A_{1-x}B_xC$, with optional vibrational and PV (enthalpy) contributions.
|
|
5
|
+
|
|
6
|
+
EGQCA computes thermodynamic properties of an alloy at arbitrary composition $x$
|
|
7
|
+
and temperature $T$ by statistically averaging over a set of small clusters.
|
|
8
|
+
From the cluster energies it gives the mixing free energy, enthalpy and entropy,
|
|
9
|
+
the cluster occurrence probabilities, the miscibility gap (binodal and spinodal),
|
|
10
|
+
and composition-averaged properties such as lattice parameters.
|
|
11
|
+
|
|
12
|
+
The method is described in
|
|
13
|
+
[doi:10.1016/j.mtphys.2024.101547](https://doi.org/10.1016/j.mtphys.2024.101547).
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- Generation of all non-equivalent clusters of a supercell from a CIF file
|
|
18
|
+
(via the [supercell program](https://orex.github.io/supercell/))
|
|
19
|
+
- Input files for DFT relaxations with FHI-aims, Quantum ESPRESSO or VASP, and
|
|
20
|
+
automatic extraction of the energies and lattice parameters
|
|
21
|
+
- Relaxation and phonons with machine-learned interatomic potentials (UPET, MACE,
|
|
22
|
+
MatterSim, GRACE, or any ASE calculator)
|
|
23
|
+
- Gibbs free energy with mixing energy, configurational entropy, vibrational
|
|
24
|
+
free energy from phonon DOS, and PV term
|
|
25
|
+
- Miscibility gap, averaged properties and cluster reduction
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install egqca
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The ML relaxation needs the package of the chosen model family. Install each
|
|
34
|
+
into its own environment, as their dependencies can conflict:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install "egqca[upet]" # UPET / PET models
|
|
38
|
+
pip install "egqca[mace]" # MACE
|
|
39
|
+
pip install "egqca[mattersim]" # MatterSim
|
|
40
|
+
pip install "egqca[grace]" # GRACE
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Python 3.10 or newer is required.
|
|
44
|
+
|
|
45
|
+
To install the development version from source:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/egqca/egqca
|
|
49
|
+
cd egqca
|
|
50
|
+
pip install -e .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
With existing input files, a calculation looks like this:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import numpy as np
|
|
59
|
+
import egqca
|
|
60
|
+
|
|
61
|
+
m = egqca.EGQCA(
|
|
62
|
+
datafile="clusters.dat",
|
|
63
|
+
compound="A$_{1-x}$B$_x$C",
|
|
64
|
+
volume_file="volume.dat", # optional, for the PV term
|
|
65
|
+
pressure_GPa=0.0, # optional
|
|
66
|
+
phonon_file_name="ph_dos", # optional, folder with <cluster_id>.dos files
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
x_grid = np.arange(1e-6, 1.0, 1.0e-3)
|
|
70
|
+
m.thermodynamic_assessment(x_grid, Tlist=[600, 800, 1000, 1400])
|
|
71
|
+
m.average_properties("volume.dat")
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Example
|
|
75
|
+
|
|
76
|
+
[`examples/NbV/`](https://github.com/egqca/egqca/tree/main/examples/NbV) covers the full workflow with ML potentials for bcc
|
|
77
|
+
Nb$_{1-x}$V$_x$ with 8-atom clusters:
|
|
78
|
+
|
|
79
|
+
| Script | Step |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `01_generate_clusters.py` | generate the 22 non-equivalent clusters |
|
|
82
|
+
| `02_ml_relaxation_phonons.py` | ML relaxation and phonons with `pet-omatpes-l` |
|
|
83
|
+
| `03_run_egqca.py` | EGQCA without phonons, with phonons, and with phonons + PV |
|
|
84
|
+
|
|
85
|
+
The results of step 2 are included, so `03_run_egqca.py` runs directly.
|
|
86
|
+
|
|
87
|
+
## Documentation
|
|
88
|
+
|
|
89
|
+
The documentation in [`docs/`](https://github.com/egqca/egqca/tree/main/docs) covers the cluster setup, DFT input files,
|
|
90
|
+
the ML workflow, the entropy approximation, property averaging and cluster
|
|
91
|
+
reduction. Build it locally from a source checkout with
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pip install -e ".[docs]"
|
|
95
|
+
mkdocs serve
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Citation
|
|
99
|
+
|
|
100
|
+
If you use EGQCA, please cite
|
|
101
|
+
[doi:10.1016/j.mtphys.2024.101547](https://doi.org/10.1016/j.mtphys.2024.101547).
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
EGQCA is released under the [MIT License](https://github.com/egqca/egqca/blob/main/LICENSE).
|
|
106
|
+
|
|
107
|
+
The ML packages and model weights it can use have their own licenses. Some
|
|
108
|
+
model weights (e.g. MACE-OMAT-0, MACE-MATPES-0, MACE-MH) are for
|
|
109
|
+
non-commercial use only. Check the license of the model you use.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "egqca"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Extended Generalized QuasiChemical Approximation"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = ["numpy", "scipy", "matplotlib", "matplotlib-label-lines", "ase>=3.25", "spglib"]
|
|
12
|
+
optional-dependencies = { upet = ["upet"], mace = ["mace-torch"], mattersim = ["mattersim"], grace = ["tensorpotential>=0.6.1"], test = ["pytest>=8,<9"], docs = ["mkdocs>=1.6,<2", "mkdocstrings[python]>=0.26", "black"] }
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
authors = [
|
|
15
|
+
{ name = "Pedro Nunes Ferreira", email = "nunesferreira@tugraz.at" },
|
|
16
|
+
{ name = "Dominik Spath", email="dominik.spath@tugraz.at"},
|
|
17
|
+
{ name = "Luka Wibmer", email="luka.wibmer@tugraz.at"}
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/egqca/egqca"
|
|
22
|
+
Documentation = "https://egqca.github.io/egqca/"
|
|
23
|
+
Source = "https://github.com/egqca/egqca"
|
|
24
|
+
Issues = "https://github.com/egqca/egqca/issues"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
package-dir = {"" = "src"}
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
31
|
+
|
|
32
|
+
[tool.pytest.ini_options]
|
|
33
|
+
pythonpath = ["src"]
|
|
34
|
+
testpaths = ["tests"]
|
egqca-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
from ._banner import __version__
|
|
2
|
+
from .egqca_model import EGQCA
|
|
3
|
+
from .io import convert_volume_file
|
|
4
|
+
from .workflow import (
|
|
5
|
+
create_bands_in,
|
|
6
|
+
create_phonons_in,
|
|
7
|
+
extract_total_energies,
|
|
8
|
+
set_up_clusters_and_dft,
|
|
9
|
+
set_up_clusters_dat,
|
|
10
|
+
set_up_volume_dat,
|
|
11
|
+
get_directories,
|
|
12
|
+
update_DFT_in,
|
|
13
|
+
write_properties_file,
|
|
14
|
+
extract_eddp_energies,
|
|
15
|
+
)
|
|
16
|
+
from .comparison import (
|
|
17
|
+
EGQCAInput,
|
|
18
|
+
discover_egqca_inputs,
|
|
19
|
+
make_egqca_inputs,
|
|
20
|
+
plot_average_properties_comparison,
|
|
21
|
+
plot_excess_enthalpy_comparison,
|
|
22
|
+
plot_miscibility_gap_comparison,
|
|
23
|
+
plot_occurrence_probabilities_comparison,
|
|
24
|
+
plot_occurrence_probability_difference_from_ideal,
|
|
25
|
+
plot_thermodynamic_comparison,
|
|
26
|
+
run_egqca_comparison,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
from .ml import (
|
|
31
|
+
geometry_relaxation,
|
|
32
|
+
run_ml_relaxation,
|
|
33
|
+
collect_ml_results,
|
|
34
|
+
reset_ml_clusters,
|
|
35
|
+
rerun_nonconverged_ml,
|
|
36
|
+
phonon_dos_from_cache,
|
|
37
|
+
)
|
|
38
|
+
except ImportError: # optional ML stack
|
|
39
|
+
geometry_relaxation = None
|
|
40
|
+
run_ml_relaxation = None
|
|
41
|
+
collect_ml_results = None
|
|
42
|
+
reset_ml_clusters = None
|
|
43
|
+
rerun_nonconverged_ml = None
|
|
44
|
+
phonon_dos_from_cache = None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"__version__",
|
|
49
|
+
"EGQCA",
|
|
50
|
+
"convert_volume_file",
|
|
51
|
+
"set_up_clusters_and_dft",
|
|
52
|
+
"run_ml_relaxation",
|
|
53
|
+
"collect_ml_results",
|
|
54
|
+
"reset_ml_clusters",
|
|
55
|
+
"rerun_nonconverged_ml",
|
|
56
|
+
"extract_total_energies",
|
|
57
|
+
"create_bands_in",
|
|
58
|
+
"create_phonons_in",
|
|
59
|
+
"set_up_clusters_dat",
|
|
60
|
+
"set_up_volume_dat",
|
|
61
|
+
"get_directories",
|
|
62
|
+
"update_DFT_in",
|
|
63
|
+
"write_properties_file",
|
|
64
|
+
"extract_eddp_energies",
|
|
65
|
+
"geometry_relaxation",
|
|
66
|
+
"phonon_dos_from_cache",
|
|
67
|
+
"EGQCAInput",
|
|
68
|
+
"discover_egqca_inputs",
|
|
69
|
+
"make_egqca_inputs",
|
|
70
|
+
"run_egqca_comparison",
|
|
71
|
+
"plot_thermodynamic_comparison",
|
|
72
|
+
"plot_excess_enthalpy_comparison",
|
|
73
|
+
"plot_miscibility_gap_comparison",
|
|
74
|
+
"plot_occurrence_probabilities_comparison",
|
|
75
|
+
"plot_occurrence_probability_difference_from_ideal",
|
|
76
|
+
"plot_average_properties_comparison",
|
|
77
|
+
]
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Start-up banner and input summary printed by the main egqca entry points."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import functools
|
|
5
|
+
import inspect
|
|
6
|
+
import threading
|
|
7
|
+
from collections.abc import Callable, Iterable
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
LOGO = r"""
|
|
12
|
+
_____ ____ ___ ____ _
|
|
13
|
+
| ____/ ___|/ _ \ / ___|/ \
|
|
14
|
+
| _|| | _| | | | | / _ \
|
|
15
|
+
| |__| |_| | |_| | |__/ ___ \
|
|
16
|
+
|_____\____|\__\_\\__/_/ \_\
|
|
17
|
+
"""
|
|
18
|
+
TITLE = "Extended Generalized Quasichemical Approximation"
|
|
19
|
+
#AUTHORS = "Pedro Nunes Ferreira, Dominik Spath, Luka Wibmer"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _get_version() -> str:
|
|
23
|
+
try:
|
|
24
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
25
|
+
return version("egqca")
|
|
26
|
+
except PackageNotFoundError:
|
|
27
|
+
pass
|
|
28
|
+
# not installed, e.g. run from the source tree: read pyproject.toml
|
|
29
|
+
pyproject = Path(__file__).resolve().parents[2] / "pyproject.toml"
|
|
30
|
+
try:
|
|
31
|
+
import tomllib
|
|
32
|
+
with open(pyproject, "rb") as f:
|
|
33
|
+
return tomllib.load(f)["project"]["version"]
|
|
34
|
+
except (OSError, KeyError, ImportError, ValueError):
|
|
35
|
+
return "unknown"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
__version__ = _get_version()
|
|
39
|
+
|
|
40
|
+
_depth = threading.local()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def header_lines() -> list[str]:
|
|
44
|
+
return [LOGO.strip("\n"), "", f" {TITLE}", #f" Authors: {AUTHORS}"
|
|
45
|
+
f" Version: {__version__}"]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def format_summary(task: str, items: Iterable[tuple[str, object]]) -> list[str]:
|
|
49
|
+
items = [(k, v) for k, v in items if v is not None]
|
|
50
|
+
width = max((len(k) for k, _ in items), default=0)
|
|
51
|
+
lines = [f" {task} ({datetime.now():%Y-%m-%d %H:%M:%S})", " " + "-" * 60]
|
|
52
|
+
lines += [f" {k:<{width}} : {v}" for k, v in items]
|
|
53
|
+
return lines
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def print_banner(task: str, items: Iterable[tuple[str, object]]) -> list[str]:
|
|
57
|
+
"""Print logo, authors, version and the input summary; return the summary lines."""
|
|
58
|
+
summary = format_summary(task, items)
|
|
59
|
+
print("\n".join(header_lines() + [""] + summary + [""]), flush=True)
|
|
60
|
+
return summary
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def describe_grid(values, unit: str = "") -> str | None:
|
|
64
|
+
"""Short description of a 1D grid: 'min ... max (N points)'."""
|
|
65
|
+
if values is None:
|
|
66
|
+
return None
|
|
67
|
+
import numpy as np
|
|
68
|
+
arr = np.asarray(values, dtype=float).ravel()
|
|
69
|
+
if arr.size == 0:
|
|
70
|
+
return "empty"
|
|
71
|
+
if arr.size <= 8:
|
|
72
|
+
return ", ".join(f"{v:g}" for v in arr) + (f" {unit}" if unit else "")
|
|
73
|
+
return f"{arr.min():g} ... {arr.max():g}{(' ' + unit) if unit else ''} ({arr.size} points)"
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def entry_point(task: str, summary: Callable[[inspect.BoundArguments], Iterable[tuple[str, object]]] | Iterable[str]):
|
|
77
|
+
"""Decorator printing the banner and an input summary when ``func`` is called.
|
|
78
|
+
|
|
79
|
+
``summary`` is either a list of argument names to show, or a function that
|
|
80
|
+
takes the bound call arguments and returns ``(label, value)`` pairs. Calls
|
|
81
|
+
made from inside another entry point print nothing, so a workflow prints
|
|
82
|
+
its banner once.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
def decorator(func):
|
|
86
|
+
signature = inspect.signature(func)
|
|
87
|
+
|
|
88
|
+
@functools.wraps(func)
|
|
89
|
+
def wrapper(*args, **kwargs):
|
|
90
|
+
depth = getattr(_depth, "value", 0)
|
|
91
|
+
if depth == 0:
|
|
92
|
+
bound = signature.bind(*args, **kwargs)
|
|
93
|
+
bound.apply_defaults()
|
|
94
|
+
if callable(summary):
|
|
95
|
+
# may replace arguments, e.g. turn an iterator into a list it can read twice
|
|
96
|
+
items = list(summary(bound))
|
|
97
|
+
else:
|
|
98
|
+
items = [(name, bound.arguments[name]) for name in summary]
|
|
99
|
+
print_banner(task, items)
|
|
100
|
+
args, kwargs = bound.args, bound.kwargs
|
|
101
|
+
_depth.value = depth + 1
|
|
102
|
+
try:
|
|
103
|
+
return func(*args, **kwargs)
|
|
104
|
+
finally:
|
|
105
|
+
_depth.value = depth
|
|
106
|
+
|
|
107
|
+
return wrapper
|
|
108
|
+
|
|
109
|
+
return decorator
|