@@ -31,9 +31,13 @@ def uniquify_path(path: str = None):
3131 return path
3232
3333
34- def load_from_w2dyn_file_and_update_config () -> tuple [GreensFunction , SelfEnergy , LocalFourPoint , LocalFourPoint ]:
34+ def load_from_w2dyn_file_and_update_config (
35+ combine_two_atoms_to_one_obj : bool = False ,
36+ ) -> tuple [GreensFunction , SelfEnergy , LocalFourPoint , LocalFourPoint ]:
3537 """
3638 Loads data from the w2dyn file and updates the config file.
39+ If combine_atoms_to_one_obj is True, we are doubling the orbital space and putting the data from the
40+ inequivalent atoms into the diagonal blocks after we average over them.
3741 """
3842 file = w2dyn_aux .W2dynFile (fname = str (os .path .join (config .dmft .input_path , config .dmft .fname_1p )))
3943
@@ -51,36 +55,106 @@ def load_from_w2dyn_file_and_update_config() -> tuple[GreensFunction, SelfEnergy
5155 config .lattice .interaction .vpp = file .get_vpp ()
5256
5357 config .sys .mu = file .get_mu ()
54- config .sys .n_bands = file .get_nd () + file .get_np ()
58+ config .sys .nd_bands = file .get_nd ()
59+ config .sys .np_bands = file .get_np ()
60+ config .sys .n_bands = config .sys .nd_bands + config .sys .np_bands
5561 config .sys .n = file .get_totdens ()
5662 config .sys .occ_dmft = 2 * np .mean (file .get_rho1 (), axis = (1 , 3 ))
5763
64+ if combine_two_atoms_to_one_obj :
65+ config .sys .n_bands *= 2
66+ config .sys .nd_bands *= 2
67+ config .sys .np_bands *= 2
68+ config .sys .n *= 2
69+
70+ config .sys .occ_dmft = np .zeros ((config .sys .n_bands , config .sys .n_bands ))
71+ rho_1_mean = 0.5 * (np .mean (file .get_rho1 (), axis = (1 , 3 )) + np .mean (file .get_rho1 (ineq = 2 ), axis = (1 , 3 )))
72+ config .sys .occ_dmft [0 :2 , 0 :2 ] = 2 * rho_1_mean
73+ config .sys .occ_dmft [2 :4 , 2 :4 ] = 2 * rho_1_mean
74+
5875 if config .sys .n == 0 :
5976 config .sys .n = 2 * np .sum (config .sys .occ_dmft )
6077
6178 file2 = w2dyn_aux .W2dynG4iwFile (fname = str (os .path .join (config .dmft .input_path , config .dmft .fname_2p )))
62- g2_dens = LocalFourPoint (file2 .read_g2_full_multiband (config .sys .n_bands , name = "dens" ), channel = SpinChannel .DENS )
63- g2_magn = LocalFourPoint (file2 .read_g2_full_multiband (config .sys .n_bands , name = "magn" ), channel = SpinChannel .MAGN )
79+ g2_dens = LocalFourPoint (
80+ file2 .read_g2_full_multiband (file .get_nd () + file .get_np (), name = "dens" ), channel = SpinChannel .DENS
81+ )
82+ g2_magn = LocalFourPoint (
83+ file2 .read_g2_full_multiband (file .get_nd () + file .get_np (), name = "magn" ), channel = SpinChannel .MAGN
84+ )
85+
86+ if combine_two_atoms_to_one_obj :
87+ g2_dens_2 = LocalFourPoint (
88+ file2 .read_g2_full_multiband (file .get_nd () + file .get_np (), ineq = 2 , name = "dens" ), channel = SpinChannel .DENS
89+ )
90+ g2_magn_2 = LocalFourPoint (
91+ file2 .read_g2_full_multiband (file .get_nd () + file .get_np (), ineq = 2 , name = "magn" ), channel = SpinChannel .MAGN
92+ )
93+
94+ def construct_large_g2 (g2_1 : LocalFourPoint , g2_2 : LocalFourPoint ) -> LocalFourPoint :
95+ g2_mean = 0.5 * (g2_1 .mat + g2_2 .mat )
96+ del g2_2
97+ g2_1 .mat = np .zeros ((4 , 4 , 4 , 4 , * g2_mean .shape [4 :]))
98+ g2_1 .mat [0 :2 , 0 :2 , 0 :2 , 0 :2 ] = g2_mean
99+ g2_1 .mat [2 :4 , 2 :4 , 2 :4 , 2 :4 ] = g2_mean
100+ del g2_mean
101+ return g2_1
102+
103+ g2_dens = construct_large_g2 (g2_dens , g2_dens_2 )
104+ g2_magn = construct_large_g2 (g2_magn , g2_magn_2 )
105+
64106 file2 .close ()
65107
66108 update_frequency_boxes (g2_dens .niw , g2_dens .niv )
67109
68110 def extend_orbital (arr : np .ndarray ) -> np .ndarray :
69- return np .einsum ("i...,ij->ij..." , arr , np .eye (config . sys . n_bands ))
111+ return np .einsum ("i...,ij->ij..." , arr , np .eye (arr . shape [ 0 ] ))
70112
71113 giw_spin_mean = np .mean (file .get_giw (), axis = 1 ) # [band,spin,niv]
72114 niv_dmft = giw_spin_mean .shape [- 1 ] // 2
73115 niv_cut = config .box .niw_core + config .box .niv_full + 10
74116 giw_spin_mean = giw_spin_mean [..., niv_dmft - niv_cut : niv_dmft + niv_cut ]
75117 g_dmft = GreensFunction (extend_orbital (giw_spin_mean ))
76118
119+ if combine_two_atoms_to_one_obj :
120+ giw_spin_mean_2 = np .mean (file .get_giw (ineq = 2 ), axis = 1 )[..., niv_dmft - niv_cut : niv_dmft + niv_cut ]
121+ giw_spin_mean = 0.5 * (giw_spin_mean + giw_spin_mean_2 )
122+ del giw_spin_mean_2
123+ giw_spin_mean_large = np .zeros ((2 * giw_spin_mean .shape [0 ], * giw_spin_mean .shape [1 :]))
124+ giw_spin_mean_large [0 :2 ] = giw_spin_mean
125+ giw_spin_mean_large [2 :4 ] = giw_spin_mean
126+ g_dmft = GreensFunction (extend_orbital (giw_spin_mean_large ))
127+ del giw_spin_mean_large
128+
77129 siw_spin_mean = np .mean (file .get_siw (), axis = 1 ) # [band,spin,niv]
78130 siw_spin_mean = extend_orbital (siw_spin_mean )[None , None , None , ...]
79131 siw_dc_spin_mean = np .mean (file .get_dc (), axis = - 1 ) # [band,spin]
80132 siw_dc_spin_mean = extend_orbital (siw_dc_spin_mean )[None , None , None , ..., None ]
81133 siw_spin_mean = siw_spin_mean [..., niv_dmft - niv_cut : niv_dmft + niv_cut ]
82134 sigma_dmft = SelfEnergy (siw_spin_mean , estimate_niv_core = True ) + siw_dc_spin_mean
83135
136+ if combine_two_atoms_to_one_obj :
137+ siw_spin_mean_2 = np .mean (file .get_siw (ineq = 2 ), axis = 1 )
138+ siw_spin_mean_2 = extend_orbital (siw_spin_mean_2 )[None , None , None , ...]
139+ siw_dc_spin_mean_2 = np .mean (file .get_dc (ineq = 2 ), axis = - 1 )
140+ siw_dc_spin_mean_2 = extend_orbital (siw_dc_spin_mean_2 )[None , None , None , ..., None ]
141+ siw_spin_mean_2 = siw_spin_mean_2 [..., niv_dmft - niv_cut : niv_dmft + niv_cut ]
142+ siw_spin_mean = 0.5 * (siw_spin_mean + siw_spin_mean_2 )
143+ del siw_spin_mean_2
144+ siw_dc_spin_mean = 0.5 * (siw_dc_spin_mean + siw_dc_spin_mean_2 )
145+ del siw_dc_spin_mean_2
146+
147+ siw_spin_mean_large = np .zeros (
148+ (1 , 1 , 1 , 2 * siw_spin_mean .shape [3 ], 2 * siw_spin_mean .shape [3 ], siw_spin_mean .shape [- 1 ])
149+ )
150+ siw_spin_mean_large [:, :, :, 0 :2 , 0 :2 , ...] = siw_spin_mean
151+ siw_spin_mean_large [:, :, :, 2 :4 , 2 :4 , ...] = siw_spin_mean
152+ siw_dc_spin_mean_large = np .zeros_like (siw_spin_mean_large )
153+ siw_dc_spin_mean_large [:, :, :, 0 :2 , 0 :2 , ...] = siw_dc_spin_mean
154+ siw_dc_spin_mean_large [:, :, :, 2 :4 , 2 :4 , ...] = siw_dc_spin_mean
155+ sigma_dmft = SelfEnergy (siw_spin_mean_large , estimate_niv_core = True ) + siw_dc_spin_mean_large
156+ del siw_spin_mean_large , siw_dc_spin_mean_large
157+
84158 del giw_spin_mean , siw_spin_mean , siw_dc_spin_mean
85159
86160 file .close ()
@@ -198,11 +272,17 @@ def set_hamiltonian(er_type: str, er_input: str | list, int_type: str, int_input
198272 if int_type == "one_band_from_dmft" or int_type == "" or int_type is None :
199273 return ham .single_band_interaction (config .lattice .interaction .udd )
200274 elif int_type == "kanamori_from_dmft" :
201- return ham .kanamori_interaction (
202- config .sys .n_bands ,
275+ return ham .kanamori_interaction_dp (
276+ config .sys .nd_bands ,
277+ config .sys .np_bands ,
203278 config .lattice .interaction .udd ,
279+ config .lattice .interaction .upp ,
280+ config .lattice .interaction .udp ,
204281 config .lattice .interaction .jdd ,
282+ config .lattice .interaction .jpp ,
283+ config .lattice .interaction .jdp ,
205284 config .lattice .interaction .vdd ,
285+ config .lattice .interaction .vpp ,
206286 )
207287 elif int_type == "custom" :
208288 if not isinstance (int_input , str ):
0 commit comments