Skip to content

Commit 9a948e7

Browse files
committed
fixed type of g_ph, reformatting
1 parent 665a5dd commit 9a948e7

5 files changed

Lines changed: 59 additions & 54 deletions

File tree

src/edipack2py/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import ctypes as ct
22
import importlib
33

4-
54
try:
65
from importlib.metadata import version, PackageNotFoundError
76
except ImportError: # For Python <3.8
@@ -81,7 +80,7 @@
8180
"set_hloc",
8281
"search_variable",
8382
"check_convergence",
84-
"set_phonon_coefficients"
83+
"set_phonon_coefficients",
8584
],
8685
"func_bath": [
8786
"get_bath_dimension",
@@ -111,7 +110,7 @@
111110
"get_chi",
112111
"get_impurity_rdm",
113112
"get_dimp",
114-
"get_denmat"
113+
"get_denmat",
115114
],
116115
"func_bath_fit": ["chi2_fitgf"],
117116
}

src/edipack2py/func_aux_funx.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -364,44 +364,52 @@ def get_ed_mode(self):
364364
get_ed_mode_wrap.argtypes = None
365365
get_ed_mode_wrap.restype = ct.c_int
366366
return get_ed_mode_wrap()
367-
368-
367+
368+
369369
# set phonons displacement and coupling
370370
def set_phonon_coefficients(self, displacement=None, coupling=None):
371371
"""
372372
373373
This function sets new values for the phonon displacement field
374374
and the electron-phonon coupling matrix
375-
376-
:type displacement: float
375+
376+
:type displacement: float
377377
:param displacement: phonon displacement field
378-
379-
:type coupling: np.array(float)
380-
:param coupling: electron-phonon coupling matrix of shape ( :code:`Norb` ) or ( :code:`Norb`, :code:`Norb` )
378+
379+
:type coupling: np.array(complex)
380+
:param coupling: electron-phonon coupling matrix of shape ( :code:`Norb` ) or ( :code:`Norb`, :code:`Norb` )
381381
382382
"""
383383

384384
set_a_ph = self.library.ed_set_A_ph
385-
set_a_ph.argtypes = [np.ctypeslib.ndpointer(dtype=float, ndim=1, flags="F_CONTIGUOUS")]
385+
set_a_ph.argtypes = [
386+
np.ctypeslib.ndpointer(dtype=float, ndim=1, flags="F_CONTIGUOUS")
387+
]
386388
set_a_ph.restype = None
387-
389+
388390
set_g_ph = self.library.ed_set_G_ph
389-
set_g_ph.argtypes = [np.ctypeslib.ndpointer(dtype=float, ndim=2, flags="F_CONTIGUOUS")]
391+
set_g_ph.argtypes = [
392+
np.ctypeslib.ndpointer(dtype=complex, ndim=2, flags="F_CONTIGUOUS")
393+
]
390394
set_g_ph.restype = None
391-
395+
392396
aux_norb = ct.c_int.in_dll(self.library, "Norb").value
393-
394-
if displacement==None and coupling==None:
395-
raise RuntimeError("set_phonon_coefficients: provide at least either disp or coupling")
396-
397+
398+
if displacement == None and coupling == None:
399+
raise RuntimeError(
400+
"set_phonon_coefficients: provide at least either disp or coupling"
401+
)
402+
397403
if displacement != None:
398-
set_a_ph(np.array([displacement],order="F"))
399-
404+
set_a_ph(np.array([displacement], order="F"))
405+
400406
if coupling != None:
401407
if np.shape(copuling) == (aux_norb,):
402-
coupling = np.array(np.diag(coupling),order="F")
403-
elif np.shape(copuling) != (aux_norb,aux_norb):
404-
raise ValueError("set_phonon_coefficients: coupling shape is (Norb) or (Norb,Norb)")
408+
coupling = np.array(np.diag(coupling), order="F")
409+
elif np.shape(copuling) != (aux_norb, aux_norb):
410+
raise ValueError(
411+
"set_phonon_coefficients: coupling shape is (Norb) or (Norb,Norb)"
412+
)
405413
set_g_ph(coupling)
406-
414+
407415
return

src/edipack2py/func_bath.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,6 @@ def save_array_as_bath(self, bath):
631631

632632
# auxiliary functions to get/set bath structure. Only works for single-site.
633633
# User has to do a loop on sites
634-
635-
636634
def bath_inspect(self, bath=None, e=None, v=None, d=None, u=None, l=None):
637635
"""
638636
This function translates between the user-accessible continuous \

src/edipack2py/func_io.py

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,12 +1432,13 @@ def get_impurity_rdm(self, doprint=False):
14321432
rdm = np.ascontiguousarray(rdm)
14331433

14341434
return rdm
1435-
1436-
1435+
1436+
14371437
#######################
14381438
# DIMP #
14391439
#######################
14401440

1441+
14411442
def get_dimp(self, zeta=None, axis=None):
14421443
"""
14431444
@@ -1495,34 +1496,35 @@ def get_dimp(self, zeta=None, axis=None):
14951496
nfreq = np.shape(zeta)[0]
14961497

14971498
zeta = np.asfortranarray(zeta)
1498-
1499+
14991500
dimp = np.zeros([nfreq], dtype=complex, order="F")
15001501
ed_get_dimp(dimp, axisflag, zeta, nfreq, zetaflag)
1501-
1502+
15021503
dimp = np.ascontiguousarray(dimp)
1503-
1504+
15041505
return dimp
1505-
1506-
1506+
1507+
15071508
#######################
15081509
# 1BDM #
15091510
#######################
15101511

1512+
15111513
def get_denmat(self, ishape=4, doprint=False):
15121514
"""
1513-
1515+
15141516
This function returns the 1-body density matrix
1515-
1517+
15161518
:type ishape: int
15171519
:param ishape: the rank of the density matrix array. Possible values :code:`2,4` .
15181520
15191521
:type doprint: bool
15201522
:param doprint: flag to print the rdm.
1521-
1522-
:return: the 1-body density matrix of shape :code:`(Nspin,Nspin,Ns,Ns)` or
1523+
1524+
:return: the 1-body density matrix of shape :code:`(Nspin,Nspin,Ns,Ns)` or
15231525
:code:`(Nspin Ns,Nspin Ns)` where :code:`Ns` is the total number of levels per spin.
1524-
:rtype: np.array(dtype=complex)
1525-
1526+
:rtype: np.array(dtype=complex)
1527+
15261528
"""
15271529

15281530
ed_get_denmat_n2 = self.library.ed_get_denmat_n2
@@ -1531,7 +1533,7 @@ def get_denmat(self, ishape=4, doprint=False):
15311533
ct.c_int, # printflag
15321534
]
15331535
ed_get_denmat_n2.restype = None
1534-
1536+
15351537
ed_get_denmat_n4 = self.library.ed_get_denmat_n4
15361538
ed_get_denmat_n2.argtypes = [
15371539
np.ctypeslib.ndpointer(dtype=complex, ndim=4, flags="F_CONTIGUOUS"), # denmat
@@ -1540,33 +1542,32 @@ def get_denmat(self, ishape=4, doprint=False):
15401542
ed_get_denmat_n4.restype = None
15411543

15421544
doprint = int(doprint)
1543-
1545+
15441546
if self.Nineq != 0:
15451547
raise RuntimeError("get_denmat not implemented for inequivalent sites yet.")
1546-
1547-
aux_norb = ct.c_int.in_dll(self.library, "Norb").value
1548+
1549+
aux_norb = ct.c_int.in_dll(self.library, "Norb").value
15481550
aux_nspin = ct.c_int.in_dll(self.library, "Nspin").value
15491551
aux_nbath = ct.c_int.in_dll(self.library, "Nbath").value
1550-
1552+
15511553
bath_type = self.get_bath_type()
1552-
1554+
15531555
if bath_type == 1 or bath_type > 3:
15541556
Ns = (aux_nbath + 1) * aux_norb
15551557
elif bath_type == 2:
15561558
Ns = aux_nbath + aux_norb
15571559
else:
1558-
raise ValueError("get_denmat: wrong bath type")
1559-
1560+
raise ValueError("get_denmat: wrong bath type")
1561+
15601562
if ishape == 4:
1561-
denmat = np.zeros([aux_nspin,aux_nspin,Ns,Ns], dtype=complex, order="F")
1562-
ed_get_denmat_n4(denmat,doprint)
1563+
denmat = np.zeros([aux_nspin, aux_nspin, Ns, Ns], dtype=complex, order="F")
1564+
ed_get_denmat_n4(denmat, doprint)
15631565
elif ishape == 2:
1564-
denmat = np.zeros([aux_nspin*Ns,aux_nspin*Ns], dtype=complex, order="F")
1565-
ed_get_denmat_n2(denmat,doprint)
1566+
denmat = np.zeros([aux_nspin * Ns, aux_nspin * Ns], dtype=complex, order="F")
1567+
ed_get_denmat_n2(denmat, doprint)
15661568
else:
15671569
raise ValueError("get_denmat: wrong ishape")
15681570

1569-
15701571
denmat = np.ascontiguousarray(denmat)
1571-
1572+
15721573
return denmat

src/edipack2py/module_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pkgconfig
77
import warnings
88

9-
109
#############################################
1110
# Function that finds and loads the library #
1211
#############################################

0 commit comments

Comments
 (0)