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
+
1
9
import os
2
10
import abc
3
11
import numpy as np
4
12
import abipy .core .abinit_units as abu
5
13
6
- #from scipy.interpolate import UnivariateSpline
7
14
#from monty.collections import dict2namedtuple
8
15
#from monty.functools import lazy_property
9
16
from abipy .tools .plotting import add_fig_kwargs , get_ax_fig_plt , get_axarray_fig_plt
17
+ from abipy .tools .typing import Figure
10
18
from abipy .electrons .gsr import GsrFile
11
19
from abipy .dfpt .ddb import DdbFile
12
20
from abipy .dfpt .phonons import PhdosFile # PhononBandsPlotter, PhononDos,
@@ -52,7 +60,7 @@ def __init__(self, structures, doses, energies, structures_from_phdos, eos_name=
52
60
self .min_energy_idx = np .unravel_index (np .nanargmin (self .energies ), self .energies .shape )
53
61
54
62
@add_fig_kwargs
55
- def plot_energies (self , ax = None , ** kwargs ):
63
+ def plot_energies (self , ax = None , ** kwargs ) -> Figure :
56
64
"""
57
65
Plot energy surface and visualize minima in a 3D plot.
58
66
@@ -127,14 +135,13 @@ def find_minimum(self, f_interp, xy_init, tol=1e-6, max_iter=1000, step_size=0.0
127
135
return xy [0 ], xy [1 ], min_energy
128
136
129
137
@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 :
131
139
"""
132
140
Plot free energy as a function of temperature in a 3D plot.
133
141
134
142
Args:
135
143
ax: Matplotlib axis for the plot.
136
144
"""
137
-
138
145
ax , fig , plt = get_ax_fig_plt (ax , figsize = (10 , 8 ))
139
146
ax = fig .add_subplot (111 , projection = '3d' ) # Create a 3D subplot
140
147
@@ -222,7 +229,7 @@ def plot_free_energies(self, tstart=800 , tstop=0 ,num=5, ax=None, **kwargs):
222
229
return fig
223
230
224
231
@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 :
226
233
"""
227
234
Plots thermal expansion coefficients along the a-axis, c-axis, and volumetric alpha.
228
235
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)
234
241
ax: Matplotlib axis object for plotting.
235
242
**kwargs: Additional arguments for customization.
236
243
"""
237
-
238
244
tmesh = np .linspace (tstart , tstop , num )
239
245
ph_energies = self .get_vib_free_energies (tstart , tstop , num )
240
246
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)
321
327
np .savetxt (file_path , data_to_save , fmt = '%4.6e' , delimiter = '\t \t ' , header = '\t \t \t ' .join (columns ), comments = '' )
322
328
323
329
ax .grid (True )
324
- ax .legend ()
330
+ ax .legend (loc = "best" , shadow = True )
325
331
ax .set_xlabel ('Temperature (K)' )
326
332
ax .set_ylabel (r'Thermal Expansion Coefficients ($\alpha$)' )
327
333
plt .savefig ("thermal_expansion.pdf" , format = "pdf" , bbox_inches = "tight" )
328
334
329
335
return fig
330
336
331
337
@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 :
333
339
"""
334
340
Plots thermal expansion coefficients along the a-axis, c-axis, and volumetric alpha.
335
341
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):
416
422
417
423
418
424
axs [0 ].set_ylabel ("a" )
419
- axs [0 ].legend ()
425
+ axs [0 ].legend (loc = "best" , shadow = True )
420
426
axs [0 ].grid (True )
421
427
axs [0 ].set_xlabel ("Temperature (T)" )
422
428
axs [1 ].set_ylabel ("c" )
423
- axs [1 ].legend ()
429
+ axs [1 ].legend (loc = "best" , shadow = True )
424
430
axs [1 ].grid (True )
425
431
axs [1 ].set_xlabel ("Temperature (T)" )
426
432
axs [2 ].set_xlabel ("Temperature (T)" )
427
433
axs [2 ].set_ylabel ("Volume" )
428
- axs [2 ].legend ()
434
+ axs [2 ].legend (loc = "best" , shadow = True )
429
435
axs [2 ].grid (True )
430
436
431
437
# Adjust layout and show the figure
0 commit comments