def test_density_ccsd_h2o(): """H2O""" # Psi4 Setup psi4.set_memory('2 GB') psi4.core.set_output_file('output.dat', False) psi4.set_options({ 'basis': 'STO-3G', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'true', 'e_convergence': 1e-12, 'd_convergence': 1e-12, 'r_convergence': 1e-12, 'diis': 1 }) mol = psi4.geometry(moldict["H2O"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) maxiter = 75 e_conv = 1e-12 r_conv = 1e-12 ccsd = pycc.ccwfn(rhf_wfn) eccsd = ccsd.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(ccsd) cclambda = pycc.cclambda(ccsd, hbar) lccsd = cclambda.solve_lambda(e_conv, r_conv) epsi4 = -0.070616830152761 lpsi4 = -0.068826452648939 ccdensity = pycc.ccdensity(ccsd, cclambda) ecc_density = ccdensity.compute_energy() assert (abs(epsi4 - eccsd) < 1e-11) assert (abs(lpsi4 - lccsd) < 1e-11) assert (abs(epsi4 - ecc_density) < 1e-11) psi4.set_options({'basis': 'cc-pVDZ'}) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) ccsd = pycc.ccwfn(rhf_wfn) eccsd = ccsd.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(ccsd) cclambda = pycc.cclambda(ccsd, hbar) lccsd = cclambda.solve_lambda(e_conv, r_conv) epsi4 = -0.222029814166783 lpsi4 = -0.217838951550509 ccdensity = pycc.ccdensity(ccsd, cclambda) ecc_density = ccdensity.compute_energy() assert (abs(epsi4 - eccsd) < 1e-11) assert (abs(lpsi4 - lccsd) < 1e-11) assert (abs(epsi4 - ecc_density) < 1e-11)
def test_ccd_h2o(): # Psi4 Setup psi4.set_memory('2 GB') psi4.core.set_output_file('output.dat', False) psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-12, 'd_convergence': 1e-12, 'r_convergence': 1e-12, 'diis': 1}) mol = psi4.geometry(moldict["H2O"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) maxiter = 75 e_conv = 1e-12 r_conv = 1e-12 cc = pycc.ccwfn(rhf_wfn, model='CCD') ecc = cc.solve_cc(e_conv,r_conv,maxiter) epsi4 = -0.222559319034 # Checked against CFOUR assert (abs(epsi4 - ecc) < 1e-11) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lcc = cclambda.solve_lambda(e_conv, r_conv) lcc_cfour = -0.218758826700 assert (abs(lcc - lcc_cfour) < 1e-11) ccdensity = pycc.ccdensity(cc, cclambda) ecc = ccdensity.compute_energy() assert (abs(epsi4 - ecc) < 1e-11)
def test_lpno_ccsd(): """H2O LPNO-CCSD Test""" # Psi4 Setup psi4.set_memory('2 GB') psi4.core.set_output_file('output.dat', False) psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1}) mol = psi4.geometry(moldict["H2O"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) maxiter = 75 e_conv = 1e-12 r_conv = 1e-12 max_diis = 8 ccsd = pycc.ccwfn(rhf_wfn, local='LPNO', local_cutoff=1e-5) eccsd = ccsd.solve_cc(e_conv, r_conv, maxiter) hbar = pycc.cchbar(ccsd) cclambda = pycc.cclambda(ccsd, hbar) lccsd = cclambda.solve_lambda(e_conv, r_conv, maxiter, max_diis) epsi4 = -0.221156413159674 lpsi4 = -0.217144045119535 assert (abs(epsi4 - eccsd) < 1e-7) assert (abs(lpsi4 - lccsd) < 1e-7)
def test_cc2_h2o(): # Psi4 Setup psi4.set_memory('2 GB') psi4.core.set_output_file('output.dat', False) psi4.set_options({ 'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-12, 'd_convergence': 1e-12, 'r_convergence': 1e-12, 'diis': 1 }) mol = psi4.geometry(moldict["H2O"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) maxiter = 75 e_conv = 1e-12 r_conv = 1e-12 cc = pycc.ccwfn(rhf_wfn, model='CC2') ecc = cc.solve_cc(e_conv, r_conv, maxiter) epsi4 = -0.215857544656 assert (abs(epsi4 - ecc) < 1e-11) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lcc = cclambda.solve_lambda(e_conv, r_conv) lcc_psi4 = -0.215765740373555 assert (abs(lcc - lcc_psi4) < 1e-11)
def test_rtcc_he_cc_pvdz(): """He cc-pVDZ""" psi4.set_memory('2 GiB') psi4.core.set_output_file('output.dat', False) psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1}) mol = psi4.geometry(moldict["He"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) e_conv = 1e-13 r_conv = 1e-13 cc = pycc.ccwfn(rhf_wfn) ecc = cc.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # Sine squared pulse (a.u.) F_str = 1.0 omega = 2.87 tprime = 5.0 V = sine_square_laser(F_str, omega, tprime) # RT-CC Setup t0 = 0 tf = 1.0 h = 0.01 rtcc = pycc.rtcc(cc, cclambda, ccdensity, V) y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128') ODE = ode(rtcc.f).set_integrator('vode',atol=1e-13,rtol=1e-13) ODE.set_initial_value(y0, t0) t1, t2, l1, l2 = rtcc.extract_amps(y0) mu0_x, mu0_y, mu0_z = rtcc.dipole(t1, t2, l1, l2) ecc0 = rtcc.lagrangian(t0, t1, t2, l1, l2) mu_z_ref = 0.008400738202694 # a.u. while ODE.successful() and ODE.t < tf: y = ODE.integrate(ODE.t+h) t = ODE.t t1, t2, l1, l2 = rtcc.extract_amps(y) mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2) ecc = rtcc.lagrangian(t, t1, t2, l1, l2) print(mu_z) assert (abs(mu_z_ref - mu_z.real) < 1e-10)
def test_rtpao(datadir): """H2O RT-PAO""" psi4.set_memory('2 GiB') psi4.core.set_output_file('output.dat', False) psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1, 'local_convergence': 1.e-13}) mol = psi4.geometry(moldict["H2O"]+"\nnoreorient\nnocom") ref_dir = str(datadir.join(f"wfn.npy")) rhf_wfn = psi4.core.Wavefunction.from_file(ref_dir) maxiter = 75 e_conv = 1e-13 r_conv = 1e-13 max_diis = 8 cc = pycc.ccwfn(rhf_wfn, local='PAO', local_cutoff=1e-2) ecc = cc.solve_cc(e_conv, r_conv, maxiter, max_diis) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # Narrow Gaussian pulse F_str = 0.001 omega = 0 sigma = 0.01 center = 0.05 V = gaussian_laser(F_str, omega, sigma, center=center) # RT-CC Setup t0 = 0 tf = 0.5 h = 0.02 rtcc = pycc.rtcc(cc, cclambda, ccdensity, V) y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128') ODE = rk4(h) # Propagate ret = rtcc.propagate(ODE, y0, tf, ti=t0, ref=False) # check ref = {'ecc': (-84.21540972040579+2.9584453421137937e-16j), 'mu_x': (-4.987717148832141e-05-2.5885460555301484e-12j), 'mu_y': (-4.707786986481166e-05-1.5660290548026362e-11j), 'mu_z': (-0.0783037960868978-1.168135844689433e-11j)} for prop in ret['0.50']: assert (abs(ret['0.50'][prop] - ref[prop]) < 1e-8)
def test_rtpno(datadir): """H2O RT-LPNO""" psi4.set_memory('2 GiB') psi4.core.set_output_file('output.dat', False) psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1, 'local_convergence': 1.e-13}) mol = psi4.geometry(moldict["H2O"]+"\nnoreorient\nnocom") ref_dir = str(datadir.join(f"wfn.npy")) rhf_wfn = psi4.core.Wavefunction.from_file(ref_dir) maxiter = 75 e_conv = 1e-13 r_conv = 1e-13 max_diis = 8 cc = pycc.ccwfn(rhf_wfn, local='LPNO', local_cutoff=1e-5) ecc = cc.solve_cc(e_conv, r_conv, maxiter, max_diis) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # Narrow Gaussian pulse F_str = 0.001 omega = 0 sigma = 0.01 center = 0.05 V = gaussian_laser(F_str, omega, sigma, center=center) # RT-CC Setup t0 = 0 tf = 0.5 h = 0.02 rtcc = pycc.rtcc(cc, cclambda, ccdensity, V) y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128') ODE = rk4(h) # Propagate ret = rtcc.propagate(ODE, y0, tf, ti=t0, ref=False) # check ref = {'ecc': (-84.21331867940133+4.925945912792495e-17j), 'mu_x': (-5.106207671158796e-05+3.641896436116718e-12j), 'mu_y': (-5.001503722097678e-05-1.7436592314191415e-12j), 'mu_z': (-0.06905411053873889-9.328439713393588e-12j)} for prop in ret['0.50']: assert (abs(ret['0.50'][prop] - ref[prop]) < 1e-8)
def test_dipole_h2_2_cc_pvdz(): """He cc-pVDZ""" psi4.set_memory('2 GiB') psi4.core.set_output_file('output.dat', False) psi4.set_options({ 'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1 }) mol = psi4.geometry(moldict["(H2)_2"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) e_conv = 1e-13 r_conv = 1e-13 cc = pycc.ccwfn(rhf_wfn) ecc = cc.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # no laser rtcc = pycc.rtcc(cc, cclambda, ccdensity, None, magnetic=True) y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128') t1, t2, l1, l2 = rtcc.extract_amps(y0) ref = [0, 0, 0.005371586416860086] # au mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2) opdm = rtcc.ccdensity.compute_onepdm(t1, t2, l1, l2, withref=True) assert (abs(ref[0] - mu_x) < 1E-10) assert (abs(ref[1] - mu_y) < 1E-10) assert (abs(ref[2] - mu_z) < 1E-10) ref = [0, 0, -2.3037968376087573E-5] m_x, m_y, m_z = rtcc.dipole(t1, t2, l1, l2, magnetic=True) assert (abs(ref[0] * 1.0j - m_x) < 1E-10) assert (abs(ref[1] * 1.0j - m_y) < 1E-10) assert (abs(ref[2] * 1.0j - m_z) < 1E-10)
def test_rtcc_water_cc_pvdz(): """H2O cc-pVDZ""" psi4.set_memory('2 GiB') psi4.core.set_output_file('output.dat', False) psi4.set_options({ 'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1 }) mol = psi4.geometry(moldict["H2O"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) e_conv = 1e-13 r_conv = 1e-13 cc = pycc.ccwfn(rhf_wfn) ecc = cc.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # Gaussian pulse (a.u.) F_str = 0.01 omega = 0 sigma = 0.01 center = 0.05 V = gaussian_laser(F_str, omega, sigma, center) # RT-CC Setup t0 = 0 tf = 0.1 h = 0.01 t = t0 rtcc = pycc.rtcc(cc, cclambda, ccdensity, V) y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128') y = y0 ODE = rk4(h) t1, t2, l1, l2 = rtcc.extract_amps(y0) mu0_x, mu0_y, mu0_z = rtcc.dipole(t1, t2, l1, l2) ecc0 = rtcc.lagrangian(t0, t1, t2, l1, l2) # For saving data at each time step. """ dip_x = [] dip_y = [] dip_z = [] time_points = [] dip_x.append(mu0_x) dip_y.append(mu0_y) dip_z.append(mu0_z) time_points.append(t) """ while t < tf: y = ODE(rtcc.f, t, y) t += h t1, t2, l1, l2 = rtcc.extract_amps(y) mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2) ecc = rtcc.lagrangian(t, t1, t2, l1, l2) """ dip_x.append(mu_x) dip_y.append(mu_y) dip_z.append(mu_z) time_points.append(t) """ print(mu_z) mu_z_ref = -0.34894577 assert (abs(mu_z_ref - mu_z.real) < 1e-4)
def test_rtcc_water_cc_pvdz(): """H2O cc-pVDZ""" psi4.set_memory('2 GiB') psi4.core.set_output_file('output.dat', False) psi4.set_options({ 'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1 }) mol = psi4.geometry(moldict["H2O"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) e_conv = 1e-13 r_conv = 1e-13 cc = pycc.ccwfn(rhf_wfn) ecc = cc.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # Gaussian pulse (a.u.) F_str = 100 omega = 0 # The pulse is chosen to be thinner for less time steps with h_small(see below). sigma = 0.0001 center = 0.0005 V = gaussian_laser(F_str, omega, sigma, center) # Cutoff for the field to decide which step size is used e_field = 1e-7 # RT-CC Setup t0 = 0 tf = 0.1 h_small = 1e-5 h = 0.01 t = t0 rtcc = pycc.rtcc(cc, cclambda, ccdensity, V) y0 = rtcc.collect_amps(cc.t1, cc.t2, cclambda.l1, cclambda.l2).astype('complex128') y = y0 ODE1 = rk4(h_small) ODE2 = rk4(h) t1, t2, l1, l2 = rtcc.extract_amps(y0) mu0_x, mu0_y, mu0_z = rtcc.dipole(t1, t2, l1, l2) ecc0 = rtcc.lagrangian(t0, t1, t2, l1, l2) #mu_z_ref = 0.008400738202694 # a.u. # For saving data at each time step. """ dip_x = [] dip_y = [] dip_z = [] time_points = [] dip_x.append(mu0_x) dip_y.append(mu0_y) dip_z.append(mu0_z) time_points.append(t) """ while t < tf: # When the field is on if V(t) > e_field: y = ODE1(rtcc.f, t, y) h_i = h_small # When the field is off else: y = ODE2(rtcc.f, t, y) h_i = h t += h_i t1, t2, l1, l2 = rtcc.extract_amps(y) mu_x, mu_y, mu_z = rtcc.dipole(t1, t2, l1, l2) ecc = rtcc.lagrangian(t, t1, t2, l1, l2) """ dip_x.append(mu_x) dip_y.append(mu_y) dip_z.append(mu_z) time_points.append(t) """ print(mu_z) mu_z_ref = -0.34894577 assert (abs(mu_z_ref - mu_z.real) < 1e-1)
'freeze_core': 'false', 'e_convergence': 1e-8, 'd_convergence': 1e-8, 'r_convergence': 1e-8, 'diis': 8 }) mol = psi4.geometry(moldict["H2"]) if full: rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) else: rhf_wfn = psi4.core.Wavefunction.from_file('ref_wfn') e_conv = 1e-8 r_conv = 1e-8 cc = pycc.ccwfn(rhf_wfn) ecc = cc.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # narrow Gaussian pulse F_str = 0.001 sigma = 0.01 center = 0.05 V = gaussian_laser(F_str, 0, sigma, center=center) # RTCC # use tf = 5 to generate checkpoint file h = 0.1 ti = 0 if full:
def test_chk(datadir): # run cc psi4.set_memory('600MB') psi4.core.set_output_file('output.dat', False) psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-8, 'd_convergence': 1e-8, 'r_convergence': 1e-8, 'diis': 8}) mol = psi4.geometry(moldict["H2"]) # pull ref wfn, psi4 is picky about strings rhf_dir = str(datadir.join(f"ref_wfn.npy")) rhf_wfn = psi4.core.Wavefunction.from_file(rhf_dir) e_conv = 1e-8 r_conv = 1e-8 cc = pycc.ccwfn(rhf_wfn) ecc = cc.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # narrow Gaussian pulse F_str = 0.001 sigma = 0.01 center = 0.05 V = gaussian_laser(F_str, 0, sigma, center=center) # RTCC setup h = 0.1 tf = 10 rtcc = pycc.rtcc(cc,cclambda,ccdensity,V,magnetic=True,kick='z') # pull chk files for 0-5.1au chk_file = datadir.join(f"chk_5.pk") with open(chk_file,'rb') as cf: chk = pk.load(cf) # propagate to 10au ODE = rk2(h) y0 = chk['y'] ti = chk['time'] ofile = datadir.join(f"output.pk") tfile = datadir.join(f"t_out.pk") ret, ret_t = rtcc.propagate(ODE, y0, tf, ti=ti, ref=False, chk=True, tchk=1, ofile=ofile, tfile=tfile, k=2) # reference is "full" propagation (0-10au) refp_file = datadir.join(f"output_full.pk") with open(refp_file,'rb') as pf: ref_p = pk.load(pf) reft_file = datadir.join(f"t_out_full.pk") with open(reft_file,'rb') as ampf: ref_t = pk.load(ampf) # check properties pchk = ['ecc','mu_x','mu_y','mu_z','m_x','m_y','m_z'] for k in ref_p.keys(): for p in pchk: assert np.allclose(ret[k][p],ref_p[k][p]) # check amplitudes tchk = ['t1','t2','l1','l2'] for k in ref_t.keys(): for t in tchk: assert np.allclose(ret_t[k][t],ref_t[k][t])
def test_dipole_h2_2_field(): """H2 dimer""" psi4.set_memory('2 GiB') psi4.core.set_output_file('output.dat', False) psi4.set_options({ 'basis': '6-31G', 'scf_type': 'pk', 'mp2_type': 'conv', 'freeze_core': 'false', 'e_convergence': 1e-13, 'd_convergence': 1e-13, 'r_convergence': 1e-13, 'diis': 1 }) mol = psi4.geometry(moldict["(H2)_2"]) rhf_e, rhf_wfn = psi4.energy('SCF', return_wfn=True) e_conv = 1e-13 r_conv = 1e-13 cc = pycc.ccwfn(rhf_wfn) ecc = cc.solve_cc(e_conv, r_conv) hbar = pycc.cchbar(cc) cclambda = pycc.cclambda(cc, hbar) lecc = cclambda.solve_lambda(e_conv, r_conv) ccdensity = pycc.ccdensity(cc, cclambda) # narrow Gaussian pulse F_str = 0.01 sigma = 0.01 center = 0.05 V = gaussian_laser(F_str, 0, sigma, center=center) rtcc = pycc.rtcc(cc, cclambda, ccdensity, V, magnetic=True) mints = psi4.core.MintsHelper(cc.ref.basisset()) dipole_ints = mints.ao_dipole() m_ints = mints.ao_angular_momentum() C = np.asarray(cc.ref.Ca_subset("AO", "ACTIVE")) ref_mu = [] ref_m = [] for axis in range(3): ref_mu.append(C.T @ np.asarray(dipole_ints[axis]) @ C) ref_m.append(C.T @ (np.asarray(m_ints[axis]) * -0.5) @ C) assert np.allclose(ref_mu[axis], rtcc.mu[axis]) assert np.allclose(ref_m[axis] * 1.0j, rtcc.m[axis]) ref_mu_tot = sum(ref_mu) / np.sqrt(3.0) assert np.allclose(ref_mu_tot, rtcc.mu_tot) rtcc = pycc.rtcc(cc, cclambda, ccdensity, V, magnetic=True, kick="Y") mints = psi4.core.MintsHelper(cc.ref.basisset()) dipole_ints = mints.ao_dipole() m_ints = mints.ao_angular_momentum() C = np.asarray(cc.ref.Ca_subset("AO", "ACTIVE")) ref_mu = [] ref_m = [] for axis in range(3): ref_mu.append(C.T @ np.asarray(dipole_ints[axis]) @ C) ref_m.append(C.T @ (np.asarray(m_ints[axis]) * -0.5) @ C) assert np.allclose(ref_mu[axis], rtcc.mu[axis]) assert np.allclose(ref_m[axis] * 1.0j, rtcc.m[axis]) assert np.allclose(ref_mu[1], rtcc.mu_tot)