11
11
import pandas as pd
12
12
import abipy .core .abinit_units as abu
13
13
14
- from collections import defaultdict
15
14
from monty .string import marquee
16
15
from monty .functools import lazy_property
17
- from monty .termcolor import cprint
16
+ # from monty.termcolor import cprint
18
17
from abipy .core .func1d import Function1D
19
18
from abipy .core .structure import Structure
20
- from abipy .core .kpoints import kpoints_indices , kmesh_from_mpdivs , map_grid2ibz , IrredZone
19
+ from abipy .core .kpoints import kpoints_indices , kmesh_from_mpdivs , map_grid2ibz # , IrredZone
21
20
from abipy .core .mixins import AbinitNcFile , Has_Structure , Has_ElectronBands , NotebookWriter
22
21
from abipy .tools .typing import PathLike
23
22
from abipy .tools .plotting import (add_fig_kwargs , get_ax_fig_plt , get_axarray_fig_plt , set_axlims , set_visible ,
@@ -107,7 +106,6 @@ class Entry:
107
106
# Convert to dictionary: name --> Entry
108
107
_ALL_ENTRIES = {e .name : e for e in _ALL_ENTRIES }
109
108
110
-
111
109
class VarpeqFile (AbinitNcFile , Has_Structure , Has_ElectronBands , NotebookWriter ):
112
110
"""
113
111
This file stores the results of a VARPEQ calculations: SCF cycle, A_nk, B_qnu coefficients
@@ -174,7 +172,7 @@ def params(self) -> dict:
174
172
def __str__ (self ) -> str :
175
173
return self .to_string ()
176
174
177
- def to_string (self , verbose : int = 0 ) -> str :
175
+ def to_string (self , verbose : int = 0 ) -> str :
178
176
"""String representation with verbosiy level ``verbose``."""
179
177
lines = []; app = lines .append
180
178
@@ -197,7 +195,7 @@ def to_string(self, verbose: int=0) -> str:
197
195
for spin in range (self .nsppol ):
198
196
polaron = self .polaron_spin [spin ]
199
197
df = polaron .get_final_results_df ()
200
- app (f "Last SCF iteration. Energies in eV units" )
198
+ app ("Last SCF iteration. Energies in eV units" )
201
199
app (str (df ))
202
200
app ("" )
203
201
@@ -322,7 +320,7 @@ def ufact_k(k):
322
320
323
321
return df_list
324
322
325
- def get_final_results_df (self , with_params : bool = False ) -> pd .DataFrame :
323
+ def get_final_results_df (self , with_params : bool = False ) -> pd .DataFrame :
326
324
"""
327
325
Return daframe with the last iteration for all polaronic states.
328
326
NB: Energies are in eV.
@@ -342,7 +340,7 @@ def get_final_results_df(self, with_params: bool=False) -> pd.DataFrame:
342
340
def __str__ (self ) -> str :
343
341
return self .to_string ()
344
342
345
- def to_string (self , verbose : int = 0 ) -> str :
343
+ def to_string (self , verbose : int = 0 ) -> str :
346
344
"""
347
345
String representation with verbosiy level verbose.
348
346
"""
@@ -380,7 +378,7 @@ def ngkpt_and_shifts(self) -> tuple:
380
378
381
379
return ngkpt , shifts
382
380
383
- def get_title (self , with_gaps : bool = True ) -> str :
381
+ def get_title (self , with_gaps : bool = True ) -> str :
384
382
"""
385
383
Return string with title for matplotlib plots.
386
384
"""
@@ -462,7 +460,7 @@ def get_b2_interpolator_state(self, interp_method) -> BzRegularGridInterpolator:
462
460
return [BzRegularGridInterpolator (self .structure , shifts , np .abs (b_data [pstate ])** 2 , method = interp_method )
463
461
for pstate in range (self .nstates )]
464
462
465
- def write_a2_bxsf (self , filepath : PathLike , fill_value : float = 0.0 ) -> None :
463
+ def write_a2_bxsf (self , filepath : PathLike , fill_value : float = 0.0 ) -> None :
466
464
r"""
467
465
Export \sum_n |A_{pnk}|^2 in BXSF format suitable for visualization with xcrysden (use ``xcrysden --bxsf FILE``).
468
466
Requires gamma-centered k-mesh.
@@ -480,7 +478,7 @@ def write_a2_bxsf(self, filepath: PathLike, fill_value: float=0.0) -> None:
480
478
481
479
bxsf_write (filepath , self .structure , 1 , self .nstates , ngkpt , a2_data , fermie , unit = "Ha" )
482
480
483
- def write_b2_bxsf (self , filepath : PathLike , fill_value : float = 0.0 ) -> None :
481
+ def write_b2_bxsf (self , filepath : PathLike , fill_value : float = 0.0 ) -> None :
484
482
r"""
485
483
Export \sum_{\nu} |B_{q\nu}|^2 in BXSF format suitable for visualization with xcrysden (use ``xcrysden --bxsf FILE``).
486
484
@@ -554,9 +552,9 @@ def plot_scf_cycle(self, ax_mat=None, fontsize=8, **kwargs) -> Figure:
554
552
555
553
@add_fig_kwargs
556
554
def plot_ank_with_ebands (self , ebands_kpath ,
557
- ebands_kmesh = None , lpratio : int = 5 ,
558
- with_ibz_a2dos = True , method = "gaussian" , step : float = 0.05 , width : float = 0.1 ,
559
- nksmall : int = 20 , normalize : bool = False , with_title = True , interp_method = "linear" ,
555
+ ebands_kmesh = None , lpratio : int = 5 ,
556
+ with_ibz_a2dos = True , method = "gaussian" , step : float = 0.05 , width : float = 0.1 ,
557
+ nksmall : int = 20 , normalize : bool = False , with_title = True , interp_method = "linear" ,
560
558
ax_mat = None , ylims = None , scale = 10 , marker_color = "gold" , fontsize = 12 , ** kwargs ) -> Figure :
561
559
"""
562
560
Plot electron bands with markers whose size is proportional to |A_nk|^2.
@@ -721,7 +719,7 @@ def plot_bqnu_with_ddb(self, ddb, with_phdos=True, anaddb_kwargs=None, **kwargs)
721
719
722
720
@add_fig_kwargs
723
721
def plot_bqnu_with_phbands (self , phbands_qpath ,
724
- phdos_file = None , ddb = None , width = 0.001 , normalize : bool = True ,
722
+ phdos_file = None , ddb = None , width = 0.001 , normalize : bool = True ,
725
723
verbose = 0 , anaddb_kwargs = None , with_title = True , interp_method = "linear" ,
726
724
ax_mat = None , scale = 10 , marker_color = "gold" , fontsize = 12 , ** kwargs ) -> Figure :
727
725
"""
@@ -773,7 +771,8 @@ def plot_bqnu_with_phbands(self, phbands_qpath,
773
771
774
772
if not with_phdos :
775
773
# Return immediately.
776
- if with_title : fig .suptitle (self .get_title (with_gaps = True ))
774
+ if with_title :
775
+ fig .suptitle (self .get_title (with_gaps = True ))
777
776
return fig
778
777
779
778
####################
@@ -803,7 +802,6 @@ def plot_bqnu_with_phbands(self, phbands_qpath,
803
802
#with_ibz_b2dos = False
804
803
805
804
for pstate in range (self .nstates ):
806
-
807
805
# Compute B2(E) by looping over the full BZ.
808
806
bqnu_dos = np .zeros (len (phdos_mesh ))
809
807
for iq_bz , qpoint in enumerate (phbands_qmesh .qpoints ):
@@ -815,7 +813,7 @@ def plot_bqnu_with_phbands(self, phbands_qpath,
815
813
for w , b2 in zip (freqs_nu , b2_interp_state [pstate ].eval_kpoint (qpoint ), strict = True ):
816
814
bqnu_dos += q_weight * b2 * gaussian (phdos_mesh , width , center = w )
817
815
818
- bqnu_dos = Function1D (wmesh , bqnu_dos )
816
+ bqnu_dos = Function1D (phdos_mesh , bqnu_dos )
819
817
820
818
ax = ax_mat [pstate , 1 ]
821
819
phdos .plot_ax (ax , exchange_xy = True , normalize = normalize , label = "phDOS(E)" , color = "black" )
@@ -946,7 +944,7 @@ def to_string(self, verbose=0) -> str:
946
944
947
945
return "\n " .join (lines )
948
946
949
- def get_final_results_df (self , spin = None , sortby = None , with_params : bool = True ) -> pd .DataFrame :
947
+ def get_final_results_df (self , spin = None , sortby = None , with_params : bool = True ) -> pd .DataFrame :
950
948
"""
951
949
Return dataframe with the last iteration for all polaronic states.
952
950
NB: Energies are in eV.
@@ -1046,4 +1044,4 @@ def write_notebook(self, nbpath=None) -> str:
1046
1044
#nbv.new_code_cell("ebands_plotter = robot.get_ebands_plotter()"),
1047
1045
])
1048
1046
1049
- return self ._write_nb_nbpath (nb , nbpath )
1047
+ return self ._write_nb_nbpath (nb , nbpath )
0 commit comments