-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minimal version to make the driver in the test folder work.
- Loading branch information
Showing
15 changed files
with
976 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
from ctypes import * | ||
import numpy as np | ||
import os,sys | ||
import types | ||
|
||
#set_hloc | ||
|
||
def set_hloc(self,hloc=None,Nlat=None): | ||
ed_set_Hloc_single_N2 = self.library.ed_set_Hloc_single_N2 | ||
ed_set_Hloc_single_N2.argtypes = [np.ctypeslib.ndpointer(dtype=complex,ndim=2, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS')] | ||
ed_set_Hloc_single_N2.restype = None | ||
|
||
ed_set_Hloc_single_N4 = self.library.ed_set_Hloc_single_N4 | ||
ed_set_Hloc_single_N4.argtypes = [np.ctypeslib.ndpointer(dtype=complex,ndim=4, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS')] | ||
ed_set_Hloc_single_N4.restype = None | ||
|
||
ed_set_Hloc_lattice_N2 = self.library.ed_set_Hloc_lattice_N2 | ||
ed_set_Hloc_lattice_N2.argtypes = [np.ctypeslib.ndpointer(dtype=complex,ndim=2, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
ed_set_Hloc_lattice_N2.restype = None | ||
|
||
ed_set_Hloc_lattice_N3 = self.library.ed_set_Hloc_lattice_N3 | ||
ed_set_Hloc_lattice_N3.argtypes = [np.ctypeslib.ndpointer(dtype=complex,ndim=3, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
ed_set_Hloc_lattice_N3.restype = None | ||
|
||
ed_set_Hloc_lattice_N5 = self.library.ed_set_Hloc_lattice_N5 | ||
ed_set_Hloc_lattice_N5.argtypes = [np.ctypeslib.ndpointer(dtype=complex,ndim=5, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
ed_set_Hloc_lattice_N5.restype = None | ||
dim_hloc = np.asarray(np.shape(hloc),dtype=np.int64,order="F") | ||
if(Nlat is not None): | ||
if len(dim_hloc) == 2: | ||
ed_set_Hloc_lattice_N2(hloc,dim_hloc,Nlat) | ||
elif len(dim_hloc) == 3: | ||
ed_set_Hloc_lattice_N3(hloc,dim_hloc,Nlat) | ||
elif len(dim_hloc) == 5: | ||
ed_set_Hloc_lattice_N5(hloc,dim_hloc,Nlat) | ||
else: | ||
raise ValueError ("ed_set_Hloc_lattice: dimension must be 2,3 or 5") | ||
else: | ||
if len(dim_hloc) == 2: | ||
ed_set_Hloc_single_N2(hloc,dim_hloc) | ||
elif len(dim_hloc) == 4: | ||
ed_set_Hloc_single_N4(hloc,dim_hloc) | ||
else: | ||
raise ValueError ("ed_set_Hloc_site: dimension must be 2 or 4") | ||
return ; | ||
|
||
|
||
#search_variable | ||
def search_variable(self,var,ntmp,converged): | ||
search_variable_wrap = self.library.search_variable | ||
search_variable_wrap.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=int,ndim=1, flags='F_CONTIGUOUS')] | ||
search_variable_wrap.restype = None | ||
var = np.asarray([var]) | ||
ntmp = np.asarray([ntmp]) | ||
converged = np.asarray([converged]) | ||
conv_int=int(converged) | ||
search_variable_wrap(var,ntmp,converged) | ||
if conv_int[0]==0: | ||
converged=False | ||
else: | ||
converged=True | ||
return err[0],conv_bool | ||
|
||
#check_convergence | ||
def check_convergence(self,func,threshold,N1,N2): | ||
check_convergence_wrap = self.library.check_convergence | ||
check_convergence_wrap.argtypes = [np.ctypeslib.ndpointer(dtype=complex,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int, | ||
c_double, | ||
c_int, | ||
c_int, | ||
np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=int,ndim=1, flags='F_CONTIGUOUS')] | ||
check_convergence_wrap.restype = None | ||
err=np.asarray([1.0]) | ||
converged=np.asarray([0]) | ||
dim_func=np.shape(func) | ||
check_convergence_wrap(func,dim_func[0],threshold,N1,N2,err,converged) | ||
if converged[0]==0: | ||
conv_bool=False | ||
else: | ||
conv_bool=True | ||
return err[0],conv_bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
from ctypes import * | ||
import numpy as np | ||
import os,sys | ||
import types | ||
|
||
#get_bath_dimension | ||
def get_bath_dimension(self): | ||
get_bath_dimension_wrap = self.library.get_bath_dimension | ||
get_bath_dimension_wrap.argtypes = None | ||
get_bath_dimension_wrap.restype = c_int | ||
return get_bath_dimension_wrap() | ||
|
||
#init_hreplica | ||
|
||
def set_Hreplica(self,hvec,lambdavec): | ||
init_hreplica_symmetries_d5 = self.library.init_Hreplica_symmetries_d5 | ||
init_hreplica_symmetries_d5.argtypes =[np.ctypeslib.ndpointer(dtype=complex,ndim=5, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=float,ndim=2, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS')] | ||
init_hreplica_symmetries_d5.restype = None | ||
|
||
init_hreplica_symmetries_d3 = self.library.init_Hreplica_symmetries_d3 | ||
init_hreplica_symmetries_d3.argtypes =[np.ctypeslib.ndpointer(dtype=complex,ndim=3, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=float,ndim=2, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS')] | ||
init_hreplica_symmetries_d3.restype = None | ||
|
||
init_hreplica_symmetries_lattice_d5 = self.library.init_Hreplica_symmetries_lattice_d5 | ||
init_hreplica_symmetries_lattice_d5.argtypes =[np.ctypeslib.ndpointer(dtype=complex,ndim=5, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=float,ndim=3, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS')] | ||
init_hreplica_symmetries_lattice_d5.restype = None | ||
|
||
init_hreplica_symmetries_lattice_d3 = self.library.init_Hreplica_symmetries_lattice_d3 | ||
init_hreplica_symmetries_lattice_d3.argtypes =[np.ctypeslib.ndpointer(dtype=complex,ndim=3, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=float,ndim=3, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS')] | ||
init_hreplica_symmetries_lattice_d3.restype = None | ||
|
||
|
||
aux_norb=c_int.in_dll(self.library, "Norb").value | ||
aux_nspin=c_int.in_dll(self.library, "Nspin").value | ||
dim_hvec = np.asarray(np.shape(hvec),dtype=np.int64,order="F") | ||
dim_lambdavec = np.asarray(np.shape(lambdavec),dtype=np.int64,order="F") | ||
|
||
|
||
if(len(dim_hvec) == 3): | ||
if(len(dim_lambdavec)==2): | ||
init_hreplica_symmetries_d3(hvec,dim_hvec,lambdavec,dim_lambdavec) | ||
elif(len(Ddim_lambdavec)==3): | ||
init_hreplica_symmetries_lattice_d3(hvec,dim_hvec,lambdavec,dim_lambdavec) | ||
else: | ||
raise ValueError('Shape(lambdavec) != 2 or 3 in set_Hreplica') | ||
elif(len(dim_hvec) == 5): | ||
if(len(dim_lambdavec)==2): | ||
init_hreplica_symmetries_d5(hvec,dim_hvec,lambdavec,dim_lambdavec) | ||
elif(len(Ddim_lambdavec)==3): | ||
init_hreplica_symmetries_lattice_d5(hvec,dim_hvec,lambdavec,dim_lambdavec) | ||
else: | ||
raise ValueError('Shape(lambdavec) != 2 or 3 in set_Hreplica') | ||
else: | ||
raise ValueError('Shape(Hvec) != 3 or 5 in set_Hreplica') | ||
return ; | ||
|
||
#break_symmetry_bath | ||
def break_symmetry_bath(self, bath, field, sign, save=True): | ||
break_symmetry_bath_site = self.library.break_symmetry_bath_site | ||
break_symmetry_bath_site.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_double, | ||
c_double, | ||
c_int] | ||
break_symmetry_bath_site.restype = None | ||
|
||
break_symmetry_bath_ineq = self.library.break_symmetry_bath_ineq | ||
break_symmetry_bath_ineq.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_double, | ||
c_double, | ||
c_int] | ||
break_symmetry_bath_ineq.restype = None | ||
|
||
if save: | ||
save_int=1 | ||
else: | ||
save_int=0 | ||
bath_shape = np.asarray(np.shape(bath),dtype=np.int64,order="F") | ||
if (len(bath_shape)) == 1: | ||
break_symmetry_bath_site(bath,bath_shape,field,float(sign),save_int) | ||
else: | ||
break_symmetry_bath_ineq(bath,bath_shape,field,float(sign),save_int) | ||
return bath | ||
|
||
#spin_symmetrize_bath | ||
|
||
def spin_symmetrize_bath(self, bath, save=True): | ||
spin_symmetrize_bath_site = self.library.spin_symmetrize_bath_site | ||
spin_symmetrize_bath_site.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
spin_symmetrize_bath_site.restypes = None | ||
|
||
spin_symmetrize_bath_ineq = self.library.spin_symmetrize_bath_ineq | ||
spin_symmetrize_bath_ineq.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
spin_symmetrize_bath_ineq.restypes = None | ||
if save: | ||
save_int=1 | ||
else: | ||
save_int=0 | ||
bath_shape = np.asarray(np.shape(bath),dtype=np.int64,order="F") | ||
if (len(bath_shape)) == 1: | ||
spin_symmetrize_bath_site(bath,bath_shape,save_int) | ||
else: | ||
spin_symmetrize_bath_ineq(bath,bath_shape,save_int) | ||
return bath | ||
|
||
#orb_symmetrize_bath | ||
def orb_symmetrize_bath(self, bath, save=True): | ||
orb_symmetrize_bath_site = self.library.orb_symmetrize_bath_site | ||
orb_symmetrize_bath_site.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
orb_symmetrize_bath_site.restypes = None | ||
|
||
orb_symmetrize_bath_ineq = self.library.orb_symmetrize_bath_ineq | ||
orb_symmetrize_bath_ineq.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
orb_symmetrize_bath_ineq.restypes = None | ||
|
||
if save: | ||
save_int=1 | ||
else: | ||
save_int=0 | ||
bath_shape = np.asarray(np.shape(bath),dtype=np.int64,order="F") | ||
if (len(bath_shape)) == 1: | ||
orb_symmetrize_bath_site(bath,bath_shape,save_int) | ||
else: | ||
orb_symmetrize_bath_ineq(bath,bath_shape,save_int) | ||
return bath | ||
|
||
#orb_equality_bath | ||
|
||
def orb_equality_bath(self, bath, indx, save=True): | ||
orb_equality_bath_site = self.library.orb_equality_bath_site | ||
orb_equality_bath_site.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int, | ||
c_int] | ||
orb_equality_bath_site.restypes = None | ||
|
||
orb_equality_bath_ineq = self.library.orb_equality_bath_ineq | ||
orb_equality_bath_ineq.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int, | ||
c_int] | ||
orb_equality_bath_ineq.restypes = None | ||
aux_norb=c_int.in_dll(self.library, "Norb").value | ||
if save: | ||
save_int=1 | ||
else: | ||
save_int=0 | ||
bath_shape = np.asarray(np.shape(bath),dtype=np.int64,order="F") | ||
if (indx < 0) or (indx >= aux_norb): | ||
raise ValueError("orb_equality_bath: orbital index should be in [0,Norb]") | ||
else: | ||
indx = indx + 1 #python to fortran convention | ||
if (len(bath_shape)) == 1: | ||
orb_equality_bath_site(bath,bath_shape,indx,save_int) | ||
else: | ||
orb_equality_bath_ineq(bath,bath_shape,indx,save_int) | ||
return bath | ||
|
||
|
||
#ph_symmetrize_bath | ||
def ph_symmetrize_bath(self, bath, save): | ||
ph_symmetrize_bath_site = self.library.ph_symmetrize_bath_site | ||
ph_symmetrize_bath_site.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
ph_symmetrize_bath_site.restypes = None | ||
|
||
ph_symmetrize_bath_ineq = self.library.ph_symmetrize_bath_ineq | ||
ph_symmetrize_bath_ineq.argtypes = [np.ctypeslib.ndpointer(dtype=float,ndim=1, flags='F_CONTIGUOUS'), | ||
np.ctypeslib.ndpointer(dtype=np.int64,ndim=1, flags='F_CONTIGUOUS'), | ||
c_int] | ||
ph_symmetrize_bath_ineq.restypes = None | ||
if save: | ||
save_int=1 | ||
else: | ||
save_int=0 | ||
bath_shape = np.asarray(np.shape(bath),dtype=np.int64,order="F") | ||
if (len(bath_shape)) == 1: | ||
ph_symmetrize_bath_site(bath,bath_shape,save_int) | ||
else: | ||
ph_symmetrize_bath_ineq(bath,bath_shape,save_int) | ||
return bath | ||
|
Oops, something went wrong.