Skip to content

Commit 8aedb34

Browse files
committed
Add test_qha_general_stress.py
1 parent 3275f0a commit 8aedb34

File tree

10 files changed

+385
-369
lines changed

10 files changed

+385
-369
lines changed

.github/workflows/gh-pages.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ jobs:
6666
mkdir -p $HOME/.abinit/abipy/
6767
cp abipy/data/managers/gh_manager.yml $HOME/.abinit/abipy/manager.yml
6868
cp abipy/data/managers/gh_scheduler.yml $HOME/.abinit/abipy/scheduler.yml
69-
# FIXME TEMPORARY HACK
70-
#pip install git+https://github.com/gmatteo/pymatgen.git@master -U
69+
70+
# TEMPORARY HACK THAT MIGHT BE NEEDED IF THE PYMATGEN GUYS BREAK STUFF
71+
pip install git+https://github.com/gmatteo/pymatgen.git@master -U
7172
7273
- name: Build docs with Sphinx
7374
run: |
7475
conda activate abipy
7576
cd docs
7677
source install.sh
77-
make
78+
make -j
7879
7980
- name: Upload artifact
8081
uses: actions/upload-pages-artifact@v2

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ jobs:
6363
mkdir -p $HOME/.abinit/abipy/
6464
cp abipy/data/managers/gh_manager.yml $HOME/.abinit/abipy/manager.yml
6565
cp abipy/data/managers/gh_scheduler.yml $HOME/.abinit/abipy/scheduler.yml
66+
# TEMPORARY HACK THAT MIGHT BE NEEDED IF THE PYMATGEN GUYS BREAK STUFF
67+
pip install git+https://github.com/gmatteo/pymatgen.git@master -U
6668
6769
- name: pytest
6870
run: |

abipy/dfpt/qha_2D.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
"""
2+
Added to compute ZSISA-QHA for systems with two degrees of freedom (2DOF).
3+
Capable of calculating anisotropic thermal expansion and lattice constants for uniaxial configurations.
4+
Requires PHDOS.nc and DDB files for GSR calculations or _GSR.nc files.
5+
If PHDOS.nc is available for all structures, normal interpolation for QHA will be applied.
6+
Supports the use of six PHDOS.nc files for specific structures to employ the E_infVib2 approximation.
7+
"""
8+
19
import os
210
import abc
311
import numpy as np
412
import abipy.core.abinit_units as abu
513

6-
#from scipy.interpolate import UnivariateSpline
714
#from monty.collections import dict2namedtuple
815
#from monty.functools import lazy_property
916
from abipy.tools.plotting import add_fig_kwargs, get_ax_fig_plt, get_axarray_fig_plt
17+
from abipy.tools.typing import Figure
1018
from abipy.electrons.gsr import GsrFile
1119
from abipy.dfpt.ddb import DdbFile
1220
from abipy.dfpt.phonons import PhdosFile # PhononBandsPlotter, PhononDos,
@@ -52,7 +60,7 @@ def __init__(self, structures, doses, energies, structures_from_phdos, eos_name=
5260
self.min_energy_idx = np.unravel_index(np.nanargmin(self.energies), self.energies.shape)
5361

5462
@add_fig_kwargs
55-
def plot_energies(self, ax=None, **kwargs):
63+
def plot_energies(self, ax=None, **kwargs) -> Figure:
5664
"""
5765
Plot energy surface and visualize minima in a 3D plot.
5866
@@ -127,14 +135,13 @@ def find_minimum(self, f_interp, xy_init, tol=1e-6, max_iter=1000, step_size=0.0
127135
return xy[0], xy[1], min_energy
128136

129137
@add_fig_kwargs
130-
def plot_free_energies(self, tstart=800 , tstop=0 ,num=5, ax=None, **kwargs):
138+
def plot_free_energies(self, tstart=800 , tstop=0 ,num=5, ax=None, **kwargs) -> Figure:
131139
"""
132140
Plot free energy as a function of temperature in a 3D plot.
133141
134142
Args:
135143
ax: Matplotlib axis for the plot.
136144
"""
137-
138145
ax, fig, plt = get_ax_fig_plt(ax, figsize=(10, 8))
139146
ax = fig.add_subplot(111, projection='3d') # Create a 3D subplot
140147

@@ -222,7 +229,7 @@ def plot_free_energies(self, tstart=800 , tstop=0 ,num=5, ax=None, **kwargs):
222229
return fig
223230

224231
@add_fig_kwargs
225-
def plot_thermal_expansion(self, tstart=800, tstop=0, num=81, ax=None, **kwargs):
232+
def plot_thermal_expansion(self, tstart=800, tstop=0, num=81, ax=None, **kwargs) -> Figure:
226233
"""
227234
Plots thermal expansion coefficients along the a-axis, c-axis, and volumetric alpha.
228235
Uses both QHA and a 9-point stencil for comparison.
@@ -234,7 +241,6 @@ def plot_thermal_expansion(self, tstart=800, tstop=0, num=81, ax=None, **kwargs)
234241
ax: Matplotlib axis object for plotting.
235242
**kwargs: Additional arguments for customization.
236243
"""
237-
238244
tmesh = np.linspace(tstart, tstop, num)
239245
ph_energies = self.get_vib_free_energies(tstart, tstop, num)
240246
ax, fig, plt = get_ax_fig_plt(ax, figsize=(10, 8)) # Ensure a valid plot axis
@@ -321,15 +327,15 @@ def plot_thermal_expansion(self, tstart=800, tstop=0, num=81, ax=None, **kwargs)
321327
np.savetxt(file_path, data_to_save, fmt='%4.6e', delimiter='\t\t', header='\t\t\t'.join(columns), comments='')
322328

323329
ax.grid(True)
324-
ax.legend()
330+
ax.legend(loc="best", shadow=True)
325331
ax.set_xlabel('Temperature (K)')
326332
ax.set_ylabel(r'Thermal Expansion Coefficients ($\alpha$)')
327333
plt.savefig("thermal_expansion.pdf", format="pdf", bbox_inches="tight")
328334

329335
return fig
330336

331337
@add_fig_kwargs
332-
def plot_lattice(self, tstart=800, tstop=0, num=81, ax=None, **kwargs):
338+
def plot_lattice(self, tstart=800, tstop=0, num=81, ax=None, **kwargs) -> Figure:
333339
"""
334340
Plots thermal expansion coefficients along the a-axis, c-axis, and volumetric alpha.
335341
Uses both QHA and a 9-point stencil for comparison.
@@ -416,16 +422,16 @@ def plot_lattice(self, tstart=800, tstop=0, num=81, ax=None, **kwargs):
416422

417423

418424
axs[0].set_ylabel("a")
419-
axs[0].legend()
425+
axs[0].legend(loc="best", shadow=True)
420426
axs[0].grid(True)
421427
axs[0].set_xlabel("Temperature (T)")
422428
axs[1].set_ylabel("c")
423-
axs[1].legend()
429+
axs[1].legend(loc="best", shadow=True)
424430
axs[1].grid(True)
425431
axs[1].set_xlabel("Temperature (T)")
426432
axs[2].set_xlabel("Temperature (T)")
427433
axs[2].set_ylabel("Volume")
428-
axs[2].legend()
434+
axs[2].legend(loc="best", shadow=True)
429435
axs[2].grid(True)
430436

431437
# Adjust layout and show the figure

0 commit comments

Comments
 (0)