diff --git a/python/edi2py.py b/python/edi2py.py index d2052d88..0e83d826 100644 --- a/python/edi2py.py +++ b/python/edi2py.py @@ -113,7 +113,8 @@ def setter(self, new_value): #bath import func_bath global_env.get_bath_dimension = types.MethodType(func_bath.get_bath_dimension, global_env) -global_env.set_Hreplica = types.MethodType(func_bath.set_Hreplica, global_env) +global_env.set_hreplica = types.MethodType(func_bath.set_hreplica, global_env) +global_env.set_hgeneral = types.MethodType(func_bath.set_hgeneral, global_env) global_env.break_symmetry_bath = types.MethodType(func_bath.break_symmetry_bath, global_env) global_env.spin_symmetrize_bath = types.MethodType(func_bath.spin_symmetrize_bath, global_env) global_env.orb_symmetrize_bath = types.MethodType(func_bath.orb_symmetrize_bath, global_env) diff --git a/python/func_bath.py b/python/func_bath.py index a6bc083f..95606f0d 100644 --- a/python/func_bath.py +++ b/python/func_bath.py @@ -11,8 +11,7 @@ def get_bath_dimension(self): return get_bath_dimension_wrap() #init_hreplica - -def set_Hreplica(self,hvec,lambdavec): +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'), @@ -58,7 +57,7 @@ def set_Hreplica(self,hvec,lambdavec): 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): + elif(len(dim_lambdavec)==3): init_hreplica_symmetries_lattice_d5(hvec,dim_hvec,lambdavec,dim_lambdavec) else: raise ValueError('Shape(lambdavec) != 2 or 3 in set_Hreplica') @@ -66,6 +65,61 @@ def set_Hreplica(self,hvec,lambdavec): raise ValueError('Shape(Hvec) != 3 or 5 in set_Hreplica') return ; +#init_hgeneral +def set_hgeneral(self,hvec,lambdavec): + init_hgeneral_symmetries_d5 = self.library.init_Hgeneral_symmetries_d5 + init_hgeneral_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_hgeneral_symmetries_d5.restype = None + + init_hgeneral_symmetries_d3 = self.library.init_Hgeneral_symmetries_d3 + init_hgeneral_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_hgeneral_symmetries_d3.restype = None + + init_hgeneral_symmetries_lattice_d5 = self.library.init_Hgeneral_symmetries_lattice_d5 + init_hgeneral_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_hgeneral_symmetries_lattice_d5.restype = None + + init_hgeneral_symmetries_lattice_d3 = self.library.init_Hgeneral_symmetries_lattice_d3 + init_hgeneral_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_hgeneral_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_hgeneral_symmetries_d3(hvec,dim_hvec,lambdavec,dim_lambdavec) + elif(len(Ddim_lambdavec)==3): + init_hgeneral_symmetries_lattice_d3(hvec,dim_hvec,lambdavec,dim_lambdavec) + else: + raise ValueError('Shape(lambdavec) != 2 or 3 in set_Hgeneral') + elif(len(dim_hvec) == 5): + if(len(dim_lambdavec)==2): + init_hgeneral_symmetries_d5(hvec,dim_hvec,lambdavec,dim_lambdavec) + elif(len(dim_lambdavec)==3): + init_hgeneral_symmetries_lattice_d5(hvec,dim_hvec,lambdavec,dim_lambdavec) + else: + raise ValueError('Shape(lambdavec) != 2 or 3 in set_Hgeneral') + else: + raise ValueError('Shape(Hvec) != 3 or 5 in set_Hgeneral') + return ; + #break_symmetry_bath def break_symmetry_bath(self, bath, field, sign, save=True): break_symmetry_bath_site = self.library.break_symmetry_bath_site diff --git a/src/edi2py/edi2py_bath.f90 b/src/edi2py/edi2py_bath.f90 index 586fbd05..c5daa55e 100644 --- a/src/edi2py/edi2py_bath.f90 +++ b/src/edi2py/edi2py_bath.f90 @@ -33,6 +33,36 @@ subroutine init_Hreplica_symmetries_lattice_d3_c(Hvec,d_hvec,lambdavec,d_lambdav end subroutine init_Hreplica_symmetries_lattice_d3_c +!H_general SETUP +subroutine init_Hgeneral_symmetries_d5_c(Hvec,d_hvec,lambdavec,d_lambdavec) bind(c, name='init_Hgeneral_symmetries_d5') + integer(c_int64_t) :: d_hvec(5), d_lambdavec(2) + complex(c_double_complex),dimension(d_hvec(1),d_hvec(2),d_hvec(3),d_hvec(4),d_hvec(5)) :: Hvec + real(c_double),dimension(d_lambdavec(1),d_lambdavec(2)) :: lambdavec + call ed_set_Hgeneral(Hvec,lambdavec) +end subroutine init_Hgeneral_symmetries_d5_c + +subroutine init_Hgeneral_symmetries_d3_c(Hvec,d_hvec,lambdavec,d_lambdavec) bind(c, name='init_Hgeneral_symmetries_d3') + integer(c_int64_t) :: d_hvec(3), d_lambdavec(2) + complex(c_double_complex),dimension(d_hvec(1),d_hvec(2),d_hvec(3)) :: Hvec + real(c_double),dimension(d_lambdavec(1),d_lambdavec(2)) :: lambdavec + call ed_set_Hgeneral(Hvec,lambdavec) +end subroutine init_Hgeneral_symmetries_d3_c + +subroutine init_Hgeneral_symmetries_lattice_d5_c(Hvec,d_hvec,lambdavec,d_lambdavec) bind(c, name='init_Hgeneral_symmetries_lattice_d5') + integer(c_int64_t) :: d_hvec(5), d_lambdavec(3) + complex(c_double_complex),dimension(d_hvec(1),d_hvec(2),d_hvec(3),d_hvec(4),d_hvec(5)) :: Hvec + real(c_double),dimension(d_lambdavec(1),d_lambdavec(2),d_lambdavec(3)) :: lambdavec + call ed_set_Hgeneral(Hvec,lambdavec) +end subroutine init_Hgeneral_symmetries_lattice_d5_c + +subroutine init_Hgeneral_symmetries_lattice_d3_c(Hvec,d_hvec,lambdavec,d_lambdavec) bind(c, name='init_Hgeneral_symmetries_lattice_d3') + integer(c_int64_t) :: d_hvec(3), d_lambdavec(3) + complex(c_double_complex),dimension(d_hvec(1),d_hvec(2),d_hvec(3)) :: Hvec + real(c_double),dimension(d_lambdavec(1),d_lambdavec(2),d_lambdavec(3)) :: lambdavec + call ed_set_Hgeneral(Hvec,lambdavec) +end subroutine init_Hgeneral_symmetries_lattice_d3_c + + !BREAK_SYMMETRY_BATH subroutine break_symmetry_bath_site_c(bath,dim_bath,field,sgn,sav) bind(c, name='break_symmetry_bath_site')