Beispiel #1
0
def test_optrot():
    psi4.core.clean()

    # Set memory
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('test_optrot_out.dat', False)
    np.set_printoptions(precision=12, threshold=np.inf, linewidth=200, suppress=True)

    # Set Psi4 options
    mol = psi4.geometry("""                                                 
     O     -0.028962160801    -0.694396279686    -0.049338350190                                                                  
     O      0.028962160801     0.694396279686    -0.049338350190                                                                  
     H      0.350498145881    -0.910645626300     0.783035421467                                                                  
     H     -0.350498145881     0.910645626300     0.783035421467                                                                  
    symmetry c1        
    """)

    psi4.set_options({'basis': 'cc-pVDZ', 'scf_type': 'pk',
                      'freeze_core': 'false', 'e_convergence': 1e-10,
                      'd_convergence': 1e-10, 'save_jk': 'true'})

    # Set for CCSD
    E_conv = 1e-10
    R_conv = 1e-10
    maxiter = 40
    compare_psi4 = False

    # Set for LPNO
    #local=True
    local=False
    pno_cut = 0.0

    # Set for polarizability calculation
    typ = 'polar'
    omega_nm = 589.0

    # Compute RHF energy with psi4
    psi4.set_module_options('SCF', {'E_CONVERGENCE': 1e-10})
    psi4.set_module_options('SCF', {'D_CONVERGENCE': 1e-10})
    e_scf, wfn = psi4.energy('SCF', return_wfn=True)
    print('SCF energy: {}\n'.format(e_scf))
    print('Nuclear repulsion energy: {}\n'.format(mol.nuclear_repulsion_energy()))

    # Create Helper_CCenergy object
    optrot_lg = ccsd_lpno.do_linresp(wfn, omega_nm, mol, method='optrot', gauge='length', e_conv=E_conv, r_conv=R_conv, localize=local, pno_cut=pno_cut) 
    optrot_mvg = ccsd_lpno.do_linresp(wfn, omega_nm, mol, method='optrot', gauge='velocity', e_conv=E_conv, r_conv=R_conv, localize=local, pno_cut=pno_cut) 

    # Comaprison with Psi4
    psi4.set_options({'e_convergence': 1e-10})
    psi4.set_options({'r_convergence': 1e-10})
    psi4.set_options({'omega': [589, 'nm'],
                      'gauge': 'both'})  
    psi4.properties('ccsd', properties=['rotation'], ref_wfn=wfn)
    psi4.compare_values(optrot_lg, psi4.core.variable("CCSD SPECIFIC ROTATION (LEN) @ 589NM"), \
     4, "CCSD SPECIFIC ROTATION (LENGTH GAUGE) 589 nm") #TEST
    psi4.compare_values(optrot_mvg, psi4.core.variable("CCSD SPECIFIC ROTATION (MVG) @ 589NM"), \
     4, "CCSD SPECIFIC ROTATION (MODIFIED VELOCITY GAUGE) 589 nm") #TEST
Beispiel #2
0
def test_polar():
    i = 0
    for cut in cutoffs:
        pno_cut = cut

        # Do the linear response calculation
        polar = ccsd_lpno.do_linresp(wfn,
                                     omega_nm,
                                     mol,
                                     method='polar',
                                     localize=localize,
                                     pert=pert,
                                     pno_cut=pno_cut)
        assert np.allclose(polar, polar_compare_list[i], atol=1e-4)
        print("Polarizability = {}".format(polar))
        i += 1
Beispiel #3
0
def test_or_mvg():
    i = 0
    for cut in cutoffs:
        pno_cut = cut

        # Do the linear response calculation
        optrot_mvg = ccsd_lpno.do_linresp(wfn,
                                          omega_nm,
                                          mol,
                                          method='optrot',
                                          gauge='velocity',
                                          localize=localize,
                                          pert=pert,
                                          pno_cut=pno_cut)
        print("Optical rotation(MVG) = {}".format(optrot_mvg))
        assert np.allclose(optrot_mvg, optrot_compare_list_mvg[i], atol=1e-4)
        i += 1
Beispiel #4
0
    print('SCF energy: {}\n'.format(e_scf))
    print('Nuclear repulsion energy: {}\n'.format(
        mol.nuclear_repulsion_energy()))

    no_vir = wfn.nmo() - wfn.doccpi()[0] - wfn.frzcpi()[0]
    # Set for LPNO
    localize = True
    #local=False
    pert = 'mu'
    pno_cut = cut

    # Do the linear response calculation
    optrot_lg = ccsd_lpno.do_linresp(wfn,
                                     omega_nm,
                                     mol,
                                     method='optrot',
                                     gauge='length',
                                     localize=localize,
                                     pert=pert,
                                     pno_cut=pno_cut)
    t0 = time.time()
    #optrot_mvg = ccsd_lpno.do_linresp(wfn, omega_nm, mol, method='optrot', gauge='velocity', localize=localize, pert=pert, pno_cut=pno_cut, e_cut=1e-4)
    t1 = time.time()
    print("Total time: {}".format(t1 - t0))
    optrot_lg_list['{}'.format(cut)] = optrot_lg
    #optrot_mvg_list['{}'.format(cut)] = optrot_mvg

#optrot_data = {}
#optrot_data['LG'] = optrot_lg_list
#optrot_data['MVG'] = optrot_mvg_list
#with open("{}".format(args.j), "w") as write_file:
#    json.dump(optrot_data, write_file, indent=4)
Beispiel #5
0
def test_polar():
    psi4.core.clean()

    # Set memory
    psi4.set_memory('2 GB')
    psi4.core.set_output_file('test_polar_out.dat', False)
    np.set_printoptions(precision=12,
                        threshold=np.inf,
                        linewidth=200,
                        suppress=True)

    # Set Psi4 options
    mol = psi4.geometry("""                                                 
    0 1
    O
    H 1 1.1
    H 1 1.1 2 104 
    noreorient
    symmetry c1
    """)

    psi4.set_options({
        'basis': 'cc-pVDZ',
        'scf_type': 'pk',
        'freeze_core': 'false',
        'e_convergence': 1e-10,
        'd_convergence': 1e-10,
        'save_jk': 'true'
    })

    # Set for CCSD
    E_conv = 1e-10
    R_conv = 1e-10
    maxiter = 40
    compare_psi4 = False

    # Set for LPNO
    #local=True
    local = False
    pno_cut = 0.0

    # Set for polarizability calculation
    typ = 'polar'
    omega_nm = 589.0

    # Compute RHF energy with psi4
    psi4.set_module_options('SCF', {'E_CONVERGENCE': 1e-10})
    psi4.set_module_options('SCF', {'D_CONVERGENCE': 1e-10})
    e_scf, wfn = psi4.energy('SCF', return_wfn=True)
    print('SCF energy: {}\n'.format(e_scf))
    print('Nuclear repulsion energy: {}\n'.format(
        mol.nuclear_repulsion_energy()))

    # Create Helper_CCenergy object
    polarizability = ccsd_lpno.do_linresp(wfn,
                                          omega_nm,
                                          mol,
                                          method='polar',
                                          e_conv=E_conv,
                                          r_conv=R_conv,
                                          localize=local,
                                          pno_cut=pno_cut)

    # Comaprison with Psi4
    psi4.set_options({'e_convergence': 1e-10})
    psi4.set_options({'r_convergence': 1e-10})
    psi4.set_options({'omega': [589, 'nm']})
    psi4.properties('ccsd', properties=['polarizability'])
    psi4.compare_values(
        polarizability,
        psi4.core.variable("CCSD DIPOLE POLARIZABILITY @ 589NM"), 6,
        "CCSD Isotropic Dipole Polarizability @ 589 nm (Length Gauge)")  #TEST