@@ -43,13 +43,9 @@ def from_json_file(cls,
43
43
For the meaning of the other arguments see from_gsr_ddb_paths.
44
44
"""
45
45
data = mjson_load (filepath )
46
-
47
- bo_strains_ac = [data ["strains_a" ], data ["strains_c" ]]
48
- phdos_strains_ac = [data ["strains_a" ], data ["strains_c" ]]
49
-
50
46
return cls .from_gsr_ddb_paths (nqsmall_or_qppa ,
51
47
data ["gsr_relax_paths" ], data ["ddb_relax_paths" ],
52
- bo_strains_ac , phdos_strains_ac ,
48
+ data [ " bo_strains_ac" ], data [ " phdos_strains_ac" ] ,
53
49
anaget_kwargs = anaget_kwargs , smearing_ev = smearing_ev , verbose = verbose )
54
50
55
51
@classmethod
@@ -203,8 +199,8 @@ def plot_energies(self, ax=None, **kwargs) -> Figure:
203
199
ax , fig , plt = get_ax_fig_plt (ax , figsize = (10 , 8 ))
204
200
ax = fig .add_subplot (111 , projection = '3d' ) # Create a 3D subplot
205
201
206
- a0 = self .lattice_a [:,0 ]
207
- c0 = self .lattice_c [0 ,:]
202
+ a0 = self .lattice_a [:,0 ]
203
+ c0 = self .lattice_c [0 ,:]
208
204
209
205
X , Y = np .meshgrid (c0 , a0 )
210
206
@@ -216,7 +212,7 @@ def plot_energies(self, ax=None, **kwargs) -> Figure:
216
212
217
213
initial_guess = [1.005 * self .lattice_a [self .ix0 ,0 ], 1.005 * self .lattice_c [0 ,self .iy0 ]]
218
214
xy_init = np .array (initial_guess )
219
- min_x0 ,min_y0 ,min_energy = self .find_minimum ( f_interp , xy_init , tol = 1e-6 , max_iter = 1000 , step_size = 0.01 )
215
+ min_x0 , min_y0 , min_energy = self .find_minimum ( f_interp , xy_init , tol = 1e-6 , max_iter = 1000 , step_size = 0.01 )
220
216
221
217
x_new = np .linspace (min (self .lattice_a [:,0 ]), max (self .lattice_a [:,0 ]), 100 )
222
218
y_new = np .linspace (min (self .lattice_c [0 ,:]), max (self .lattice_c [0 ,:]), 100 )
@@ -227,10 +223,10 @@ def plot_energies(self, ax=None, **kwargs) -> Figure:
227
223
ax .plot_surface (x_grid , y_grid , energy_interp , cmap = 'viridis' , alpha = 0.6 )
228
224
229
225
# Set labels
230
- ax .set_xlabel ('Lattice Parameter C (Å)' )
231
- ax .set_ylabel ('Lattice Parameter A (Å)' )
226
+ ax .set_xlabel ('Lattice parameter C (Å)' )
227
+ ax .set_ylabel ('Lattice parameter A (Å)' )
232
228
ax .set_zlabel ('Energy (eV)' )
233
- ax .set_title ('Energy Surface in 3D' )
229
+ ax .set_title ('BO Energy Surface in 3D' )
234
230
235
231
return fig
236
232
@@ -266,7 +262,7 @@ def find_minimum(self, f_interp, xy_init, tol=1e-6, max_iter=1000, step_size=0.0
266
262
return xy [0 ], xy [1 ], min_energy
267
263
268
264
@add_fig_kwargs
269
- def plot_free_energies (self , tstart = 800 , tstop = 0 , num = 5 , ax = None , ** kwargs ) -> Figure :
265
+ def plot_free_energies (self , tstart = 800 , tstop = 0 , num = 5 , ax = None , ** kwargs ) -> Figure :
270
266
"""
271
267
Plot free energy as a function of temperature in a 3D plot.
272
268
@@ -286,8 +282,8 @@ def plot_free_energies(self, tstart=800 , tstop=0 ,num=5, ax=None, **kwargs) ->
286
282
287
283
X , Y = np .meshgrid (self .lattice_c [0 ,:], self .lattice_a [:,0 ])
288
284
for e in ( tot_en .T ):
289
- ax .plot_surface (X , Y , e , cmap = 'viridis' , alpha = 0.7 )
290
- ax .plot_wireframe (X , Y , e , cmap = 'viridis' )
285
+ ax .plot_surface (X , Y , e , cmap = 'viridis' , alpha = 0.7 )
286
+ ax .plot_wireframe (X , Y , e , cmap = 'viridis' )
291
287
292
288
min_x = np .zeros (num )
293
289
min_y = np .zeros (num )
@@ -336,23 +332,23 @@ def plot_free_energies(self, tstart=800 , tstop=0 ,num=5, ax=None, **kwargs) ->
336
332
initial_guess = [1.005 * self .lattice_a [self .ix0 ,0 ], 1.005 * self .lattice_c [0 ,self .iy0 ]]
337
333
xy_init = np .array (initial_guess )
338
334
for j , e in enumerate (tot_en2 .T ):
339
- f_interp = RectBivariateSpline (a ,c , e , kx = 4 , ky = 4 )
340
- min_x [j ],min_y [j ],min_tot_en2 [j ]= self .find_minimum ( f_interp , xy_init , tol = 1e-6 , max_iter = 1000 , step_size = 0.01 )
335
+ f_interp = RectBivariateSpline (a , c , e , kx = 4 , ky = 4 )
336
+ min_x [j ],min_y [j ],min_tot_en2 [j ] = self .find_minimum (f_interp , xy_init , tol = 1e-6 , max_iter = 1000 , step_size = 0.01 )
341
337
342
338
X , Y = np .meshgrid (c , a )
343
339
for e in tot_en2 .T :
344
340
ax .plot_wireframe (X , Y , e , cmap = 'viridis' )
345
- ax .plot_surface (X , Y , e , cmap = 'viridis' , alpha = 0.7 )
341
+ ax .plot_surface (X , Y , e , cmap = 'viridis' , alpha = 0.7 )
346
342
347
- ax .scatter (min_y ,min_x ,min_tot_en2 , color = 'c' , s = 100 )
348
- ax .plot (min_y ,min_x ,min_tot_en2 , color = 'c' )
343
+ ax .scatter (min_y , min_x , min_tot_en2 , color = 'c' , s = 100 )
344
+ ax .plot (min_y , min_x , min_tot_en2 , color = 'c' )
349
345
350
346
ax .scatter (self .lattice_c [0 ,self .iy0 ], self .lattice_a [self .ix0 ,0 ], self .energies [self .ix0 , self .iy0 ], color = 'red' , s = 100 )
351
347
352
348
ax .set_xlabel ('C' )
353
349
ax .set_ylabel ('A' )
354
- ax .set_zlabel ('Energy (eV)' )
355
- #ax.set_title('Energies as a 3D Plot')
350
+ ax .set_zlabel ('Free energy (eV)' )
351
+ #ax.set_title('Free energies as a 3D Plot')
356
352
plt .savefig ("energy.pdf" , format = "pdf" , bbox_inches = "tight" )
357
353
358
354
return fig
@@ -403,11 +399,11 @@ def plot_thermal_expansion(self, tstart=800, tstop=0, num=81, ax=None, **kwargs)
403
399
404
400
elif (len (self .lattice_a_from_phdos )== 3 or len (self .lattice_c_from_phdos )== 3 ):
405
401
406
- dF_dA = np .zeros ( num )
407
- dF_dC = np .zeros ( num )
408
- d2F_dA2 = np .zeros ( num )
409
- d2F_dC2 = np .zeros ( num )
410
- d2F_dAdC = np .zeros ( num )
402
+ dF_dA = np .zeros (num )
403
+ dF_dC = np .zeros (num )
404
+ d2F_dA2 = np .zeros (num )
405
+ d2F_dC2 = np .zeros (num )
406
+ d2F_dAdC = np .zeros (num )
411
407
a0 = self .lattice_a_from_phdos [1 ,1 ]
412
408
c0 = self .lattice_c_from_phdos [1 ,1 ]
413
409
da = self .lattice_a_from_phdos [0 ,1 ]- self .lattice_a_from_phdos [1 ,1 ]
@@ -436,7 +432,7 @@ def plot_thermal_expansion(self, tstart=800, tstop=0, num=81, ax=None, **kwargs)
436
432
A0 = self .lattice_a [self .ix0 ,self .iy0 ]
437
433
C0 = self .lattice_c [self .ix0 ,self .iy0 ]
438
434
scale = self .volumes [self .ix0 ,self .iy0 ]/ A0 ** 2 / C0
439
- min_v = min_x ** 2 * min_y * scale
435
+ min_v = min_x ** 2 * min_y * scale
440
436
441
437
dt = tmesh [1 ] - tmesh [0 ]
442
438
alpha_a = (min_x [2 :] - min_x [:- 2 ]) / (2 * dt ) / min_x [1 :- 1 ]
@@ -447,9 +443,10 @@ def plot_thermal_expansion(self, tstart=800, tstop=0, num=81, ax=None, **kwargs)
447
443
#ax.plot(tmesh[1:-1], alpha_v, linestyle='--', color='darkorange', label=r"$\alpha_v$ E$\infty$Vib2")
448
444
449
445
# Save the data
450
- data_to_save = np .column_stack ((tmesh [1 :- 1 ],alpha_v ,alpha_a ,alpha_c ))
451
- columns = [ '#Tmesh' , 'alpha_v' , 'alpha_a' , 'alpha_c' ]
446
+ data_to_save = np .column_stack ((tmesh [1 :- 1 ], alpha_v , alpha_a , alpha_c ))
447
+ columns = ['#Tmesh' , 'alpha_v' , 'alpha_a' , 'alpha_c' ]
452
448
file_path = 'thermal-expansion_data.txt'
449
+ print (f"Writing thermal expansion data to: { file_path } "
453
450
np .savetxt (file_path , data_to_save , fmt = '%4.6e' , delimiter = '\t \t ' , header = '\t \t \t ' .join (columns ), comments = '' )
454
451
455
452
ax .grid (True )
@@ -533,7 +530,7 @@ def plot_lattice(self, tstart=800, tstop=0, num=81, ax=None, **kwargs) -> Figure
533
530
534
531
A0 = self .lattice_a [self .ix0 ,self .iy0 ]
535
532
C0 = self .lattice_c [self .ix0 ,self .iy0 ]
536
- scale = self .volumes [self .ix0 ,self .iy0 ]/ A0 ** 2 / C0
533
+ scale = self .volumes [self .ix0 ,self .iy0 ]/ A0 ** 2 / C0
537
534
min_volumes = min_x ** 2 * min_y * scale
538
535
539
536
axs [0 ].plot (tmesh , min_x , color = 'c' , label = r"$a$ (E$\infty$Vib2)" , linewidth = 2 )
@@ -571,9 +568,10 @@ def get_vib_free_energies(self, tstart: float, tstop: float, num: int) -> np.nda
571
568
Return: A 3D array of vibrational free energies of shape (num_c, num_a, num_temp)
572
569
"""
573
570
f = np .zeros ((len (self .lattice_c_from_phdos [0 ]), len (self .lattice_a_from_phdos [:, 0 ]), num ))
571
+
574
572
for i in range (len (self .lattice_a_from_phdos [:, 0 ])):
575
573
for j in range (len (self .lattice_c_from_phdos [0 ])):
576
- dos = self .phdoses [i ][j ]
577
- if dos is not None :
578
- f [j ][i ] = dos .get_free_energy (tstart , tstop , num ).values
574
+ phdos = self .phdoses [i ][j ]
575
+ if phdos is not None :
576
+ f [j ][i ] = phdos .get_free_energy (tstart , tstop , num ).values
579
577
return f
0 commit comments