@@ -82,6 +82,23 @@ def __init__(self,
8282 self .e_tot = NotImplemented
8383 self .eng_tot = self .eng_nc = self .eng_pt2 = self .eng_nuc = self .eng_os = self .eng_ss = NotImplemented
8484
85+ def _init_common (self ):
86+ """Shared initialization after subclass creates mf_s / mf_n."""
87+ mf_s = self .mf_s
88+ mol = self .mol
89+ if not hasattr (self , 'grids' ) or self .grids is None :
90+ self .grids = getattr (mf_s , 'grids' , dft .Grids (mol ))
91+ if not hasattr (self , 'grids_cpks' ) or self .grids_cpks is None :
92+ self .grids_cpks = self .grids
93+ self .mf_s .grids = self .grids
94+ self .ni = getattr (mf_s , '_numint' , dft .numint .NumInt ())
95+ self .cx = self .ni .hybrid_coeff (self .xc )
96+ self .cx_n = self .ni .hybrid_coeff (self .xc_n )
97+ self .df_jk = mf_s .with_df
98+ self .df_ri = df .DF (mol , self .auxbasis_ri ) if not self .same_aux else self .df_jk
99+ if self ._scf is not None and self ._scf .e_tot != 0 :
100+ self .run_scf ()
101+
85102 @property
86103 def base (self ):
87104 return self
@@ -163,47 +180,8 @@ def build(self):
163180 self .mf_s .grids = self .mf_n .grids = self .grids
164181 if self .df_jk .auxmol is None :
165182 self .df_jk .build ()
166- self .aux_jk = self .df_jk .auxmol
167183 if self .df_ri .auxmol is None :
168184 self .df_ri .build ()
169- self .aux_ri = self .df_ri .auxmol
170-
171- def set_frozen (self , method = 'auto' ):
172- if method != 'auto' :
173- raise NotImplementedError ("Only method='auto' is supported." )
174- return _ccsd_set_frozen (self )
175-
176- def dump_intermediates (self , dir_path = "scratch" ):
177- os .makedirs (dir_path , exist_ok = True )
178- tensors = self .tensors
179- h5_path = dir_path + "/tensors.h5"
180- dat_path = dir_path + "/tensors.dat"
181- tensors .dump (h5_path , dat_path )
182- att_path = dir_path + "/attributes.dat"
183- dct = {
184- "mo_coeff" : self .mo_coeff ,
185- "mo_energy" : self .mo_energy ,
186- "D" : self .D ,
187- "mo_occ" : self .mo_occ ,
188- "mf_s_e_tot" : self .mf_s .e_tot ,
189- }
190- with open (att_path , "wb" ) as f :
191- pickle .dump (dct , f )
192-
193- def load_intermediates (self , dir_path = "scratch" , rerun_scf = False ):
194- h5_path = dir_path + "/tensors.h5"
195- dat_path = dir_path + "/tensors.dat"
196- self .tensors = HybridDict .pick (h5_path , dat_path )
197- att_path = dir_path + "/attributes.dat"
198- with open (att_path , "rb" ) as f :
199- dct = pickle .load (f )
200- self .mf_s .mo_coeff = dct ["mo_coeff" ]
201- self .mf_s .mo_energy = dct ["mo_energy" ]
202- self .mf_s .mo_occ = dct ["mo_occ" ]
203- self .mf_s .e_tot = dct ["mf_s_e_tot" ]
204- if rerun_scf :
205- self .mf_s .kernel (dm = self .mf_s .make_rdm1 ())
206- self .run_scf ()
207185 return self
208186
209187
0 commit comments