예제 #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
예제 #2
0
def test_cc_uhf_raise2():
    psi4.geometry("""
    0 1
    O
    H 1 1.0
    H 1 1.0 2 104.5
    """)

    psi4.set_options({"reference": "uhf"})
    with pytest.raises(psi4.ValidationError) as e:
        psi4.properties("ccsd/sto-3g", properties=['polarizability'])

    assert "Non-RHF CC response properties are not implemented." in str(e.value)
예제 #3
0
def test_pe_adc1():
    """LR-PE-ADC(1)/sto-3g formaldehyde in presence of 6 water molecules
    cross-reference against PE-CIS from Psi4 itself"""
    mol = psi4.geometry(__geoms['formaldehyde'])
    potfile = _dump_potential('pna_6w')
    psi4.set_options({
        'basis': 'sto-3g',
        'pe': True,
        'scf_type': 'pk',
        'pe__potfile': potfile,
        'roots_per_irrep': [5],
        'qc_module': 'adcc',
        'tdscf_states': 5,
        'tdscf_tda': True,
    })

    _, wfn_tdhf = psi4.energy('td-hf', return_wfn=True)
    _, wfn_adc = psi4.properties('adc(1)',
                                 properties=["oscillator_strength", "dipole"],
                                 environment='linear_response',
                                 return_wfn=True)

    for i in range(5):
        assert compare_values(
            wfn_tdhf.variable(f'TD-HF ROOT 0 -> ROOT {i+1} EXCITATION ENERGY'),
            wfn_adc.variable(f'ADC ROOT 0 -> ROOT {i+1} EXCITATION ENERGY'), 5,
            f"PE-ADC(1) Excitation Energy Root {i+1}")
예제 #4
0
def test_dipole(inp):
    h2o = psi4.geometry("""
        O
        H 1 1.0
        H 1 1.0 2 101.5
    """)

    psi4.set_options({
        'perturb_h': True,
        'perturb_with': 'dipole',
        'basis': 'cc-pvdz'
    })
    psi4.set_options(inp['options'])
    energies = dict()
    for l in [1, -1, 2, -2]:
        psi4.set_options({'perturb_dipole': [0, 0, l * perturbation_strength]})
        energies[l] = psi4.energy(inp['name'])
    findif_dipole = [
        0, 0,
        (8 * energies[1] - 8 * energies[-1] - energies[2] + energies[-2]) /
        (12 * perturbation_strength)
    ]

    psi4.set_options({'perturb_h': False})
    wfn = psi4.properties(inp['name'], properties=['dipole'],
                          return_wfn=True)[1]
    analytic_dipole = wfn.variable(inp['varname'] + " DIPOLE")

    assert compare_values(findif_dipole, analytic_dipole, 5,
                          "findif vs. analytic dipole")
예제 #5
0
def test_pe_adc2():
    """PE-ADC(2)/cc-pvdz formaldehyde in presence of 6 water molecules
    including ptSS/ptLR corrections for excitation energies
    Reference data from Q-Chem calculation"""
    mol = psi4.geometry(__geoms['formaldehyde'])
    potfile = _dump_potential('fa_6w')
    psi4.set_options({
        'basis': 'cc-pvdz',
        'pe': True,
        'scf_type': 'pk',
        'pe__potfile': potfile,
        'roots_per_irrep': [5],
        'qc_module': 'adcc',
    })
    _, wfn = psi4.properties('adc(2)', properties=["oscillator_strength", "dipole"],
                             environment=True, return_wfn=True)
    energies_uncorrected = [0.15963251547743104, 0.3125861355885466, 0.36222631191059046,
                            0.37972031238708653, 0.4118959244399415]
    pe_ptlr_correction = [-2.9325959339722013e-05, -0.0002702545175242051,
                          -9.683446473705203e-05, -0.0001339512804427152,
                          -0.00270463988662346]
    pe_ptss_correction =  [-0.0005980584740534286, -0.00275711791912612,
                           -0.0008560754671915091, -0.0017443433408762471,
                           -0.0005800145567153289]
    ref_energies = np.array(energies_uncorrected)
    ref_energies += np.array(pe_ptlr_correction) + np.array(pe_ptss_correction)
    
    for i in range(5):
        en = wfn.variable(f"ADC(2) ROOT 0 -> ROOT {i+1} EXCITATION ENERGY")
        assert compare_values(en, ref_energies[i], 5, f"pt-PE-ADC(2) Excitation Energy Root {i+1}")
예제 #6
0
def test_cppe_scf_alpha():
    """Tests the PE-SCF ground state energies and static dipole polarizability"""
    alpha_diag = [36.14995, 35.10354, 78.45963]
    ref_pe_energy = -0.03424830892844
    ref_scf_energy = -482.9411084900

    mol = psi4.geometry(__geoms['pna'])
    potfile = _dump_potential('pna_6w')

    psi4.set_options({
        'basis': 'sto-3g',
        'pe': True,
        'e_convergence': 10,
        'd_convergence': 10,
        'scf_type': 'pk',
        'pe__potfile': potfile,
    })
    scf_energy, wfn = psi4.properties("SCF",
                                      properties=["DIPOLE_POLARIZABILITIES"],
                                      return_wfn=True)
    assert compare_values(ref_pe_energy, wfn.variable("PE ENERGY"), 6,
                          "PE Energy contribution")
    assert compare_values(ref_scf_energy, scf_energy, 6, "Total PE-SCF Energy")
    alpha_ref = [
        psi4.core.variable(f'DIPOLE POLARIZABILITY {cc}')
        for cc in ['XX', 'YY', 'ZZ']
    ]
    assert compare_arrays(alpha_diag, alpha_ref, 4, 'PE DIPOLE POLARIZABILITY')
예제 #7
0
    def _compute_monomers(self):
        "Compute monomer wavefunctions in aggregate-centred basis set"
        self.nmo_t = 0
        ofm_n = 0
        ofb_n = 0
        for n in range(self.aggregate.nfragments()):
            id_m = [n + 1]
            if self.acbs is True:
                id_g = list(range(1, self.aggregate.nfragments() + 1))
                id_g.pop(n)
                current_molecule = self.aggregate.extract_subsets(id_m, id_g)
            else:
                current_molecule = self.aggregate.extract_subsets(id_m)

            c_ene, c_wfn = psi4.properties(
                self.method,
                molecule=current_molecule,
                return_wfn=True,
                properties=['DIPOLE', 'NO_OCCUPATIONS'],
                **self.kwargs)

            if self.method.lower().startswith('cc') and self.cc_relax is True:
                psi4.core.set_global_option("DERTYPE", "FIRST")
                psi4.core.set_global_option("WFN", self.method.upper())
                psi4.core.ccdensity(c_wfn)

            D = c_wfn.Da().to_array(dense=True)
            N, C = self.natural_orbitals(D,
                                         S=c_wfn.S().to_array(dense=True),
                                         C=c_wfn.Ca_subset(
                                             "AO", "ALL").to_array(dense=True),
                                         orthogonalize_mo=True,
                                         order='descending',
                                         no_cutoff=0.0,
                                         return_ao_orthogonal=False,
                                         ignore_large_n=False,
                                         renormalize=False,
                                         n_eps=self.n_eps)
            if self.verbose is True:
                print("Sum of natural orbital occupations for n(%d)= %13.6f" %
                      (n, N.sum()))

            self.data['wfn'].append(c_wfn)
            self.data['ene'].append(c_ene)
            self.data['odm'].append(D)
            self.data['non'].append(N)
            self.data['noc'].append(C)

            self.data['nmo'].append(C.shape[1])
            self.nmo_t += self.data['nmo'][n]
            self.data['nbf'].append(c_wfn.basisset().nbf())
            self.data['ofm'].append(ofm_n)
            self.data['ofb'].append(ofb_n)
            ofm_n += self.data['nmo'][n]
            if self.acbs is False:
                ofb_n += self.data['nbf'][n]

            psi4.core.clean()
        return
예제 #8
0
def test_H2O_density_molden(inp_h2o_density, datadir):
    mol = psi4.geometry("""
            0 1
            O
            H   1   0.951342
            H   1   0.951342   2   112.505645
            """)
    psi4.set_options({'basis': 'dz', 'scf_type': 'pk', 'r_convergence': 12})
    molden_file = f"{inp_h2o_density['name']}.molden"
    ref = datadir.join(f"{inp_h2o_density['name']}.ref")
    e, wfn = psi4.properties(inp_h2o_density['energy'],
                             return_wfn=True,
                             molecule=mol)
    wfn.write_molden(molden_file,
                     do_virtual=inp_h2o_density['do_virtual'],
                     use_natural=inp_h2o_density['use_natural'])
    assert compare_moldenfiles(ref, molden_file)
예제 #9
0
    def compute_full_QM(self):
        "Compute full QM interaction energy"
        assert self.monomers_computed is True

        self.aggregate.activate_all_fragments()
        c_ene, c_wfn = psi4.properties(self.method,
                                       molecule=self.aggregate,
                                       return_wfn=True,
                                       properties=["DIPOLE", "NO_OCCUPATIONS"],
                                       **self.kwargs)
        if self.method.lower().startswith('cc') and self.cc_relax is True:
            psi4.core.set_global_option("DERTYPE", "FIRST")
            psi4.core.set_global_option("WFN", self.method.upper())
            psi4.core.ccdensity(c_wfn)

        D = c_wfn.Da().to_array(dense=True)
        S = c_wfn.S().to_array(dense=True)
        C_hf = c_wfn.Ca_subset("AO", "ALL").to_array(dense=True)
        N, C = self.natural_orbitals(D,
                                     S=S,
                                     C=C_hf,
                                     orthogonalize_mo=True,
                                     order='descending',
                                     no_cutoff=0.0,
                                     return_ao_orthogonal=False,
                                     ignore_large_n=False,
                                     renormalize=False,
                                     n_eps=self.n_eps)
        if self.verbose is True:
            print("Sum of natural orbital occupations for nqm= %13.6f" %
                  N.sum())
        self.matrix["dqm"] = D
        self.matrix["nqm"] = N
        self.matrix["cqm"] = C
        self.matrix["sqm"] = S
        self.matrix["chf"] = C_hf

        e_fqm_t = c_ene
        for i in range(self.aggregate.nfragments()):
            e_fqm_t -= self.data["ene"][i]
        self.vars["e_fqm_t"] = e_fqm_t

        self.energy_full_QM_computed = True
        return
예제 #10
0
def test_psi4_scfproperty():
    """scf-property"""
    #! UFH and B3LYP cc-pVQZ properties for the CH2 molecule.

    ref_hf_di_au = np.array([0.0, 0.0, 0.22531665104559076])
    ref_hf_quad_au = np.array([[-5.69804565317, 0.0, 0.0],
                               [0.0, -4.53353128969, 0.0],
                               [0.0, 0.0, -5.25978856037]])
    ref_b3lyp_di_au = np.array([0.0, 0.0, 0.252480541747])
    ref_b3lyp_quad_au = np.array([[-5.66266837697, 0.0, 0.0],
                                  [0.0, -4.46523692003, 0.0],
                                  [0.0, 0.0, -5.22054902407]])

    with open('grid.dat', 'w') as handle:
        handle.write("""\
0.0  0.0  0.0
1.1  1.3  1.4
""")

    ch2 = psi4.geometry("""
        0 3
        c
        h 1 b1
        h 1 b1 2 a1

        b1 = 1.0
        a1 = 125.0
    """)

    # Get a reasonable guess, to save some iterations
    psi4.set_options({
        "scf_type": "pk",
        "basis": "6-31G**",
        "e_convergence": 8,
        "docc": [2, 0, 0, 1],
        "socc": [1, 0, 1, 0],
        "reference": "uhf"
    })

    ch2.update_geometry()
    assert psi4.compare_values(6.6484189450, ch2.nuclear_repulsion_energy(), 9,
                               "Nuclear repulsion energy")

    props = [
        'DIPOLE', 'QUADRUPOLE', 'MULLIKEN_CHARGES', 'LOWDIN_CHARGES',
        'WIBERG_LOWDIN_INDICES', 'MAYER_INDICES', 'MAYER_INDICES',
        'MO_EXTENTS', 'GRID_FIELD', 'GRID_ESP', 'ESP_AT_NUCLEI',
        'MULTIPOLE(5)', 'NO_OCCUPATIONS'
    ]

    psi4.properties('scf', properties=props)

    assert psi4.compare_values(-38.91591819679808,
                               psi4.variable("CURRENT ENERGY"), 6,
                               "SCF energy")
    assert psi4.compare_values(ref_hf_di_au, psi4.variable('SCF DIPOLE'), 4,
                               "SCF DIPOLE")
    assert psi4.compare_values(ref_hf_quad_au, psi4.variable('SCF QUADRUPOLE'),
                               4, "SCF QUADRUPOLE")

    psi4.properties('B3LYP', properties=props)

    assert psi4.compare_values(psi4.variable('CURRENT ENERGY'),
                               -39.14134740550916, 6, "B3LYP energy")
    assert psi4.compare_values(ref_b3lyp_di_au, psi4.variable('B3LYP DIPOLE'),
                               4, "B3LYP DIPOLE")
    assert psi4.compare_values(ref_b3lyp_quad_au,
                               psi4.variable('B3LYP QUADRUPOLE'), 4,
                               "B3LYP QUADRUPOLE")
예제 #11
0
def run(input_json):
    # detect custom psi4, if we can
    psiapi_path = os.environ.get('PSIAPI_PATH')
    if psiapi_path:
        sys.path.insert(1, psiapi_path)

    import psi4

    mol_json = input_json.pop('molecule')
    mc_json = input_json.pop('modelchem')
    output_json = {}
    output_json['raw_output'] = {}
    output_json['success'] = False
    output_json['output'] = {}

    # set some psi4 global stuff
    # Scratch files
    scr_path = os.environ.get("WORK")
    psi4_io = psi4.core.IOManager.shared_object()
    psi4_io.set_default_path(scr_path)

    # raw output file
    outfile_path = Path('output.dat')
    psi4.core.set_output_file(str(outfile_path), False)

    # node (or configured) memory and cores (after setting output file so the changes are registered there?)
    psi4.set_memory(str(cpu_info.memory()) + " MB")
    psi4.set_num_threads(cpu_info.ncore())

    # set the basis
    basis = mc_json.get('basis')
    psi4.core.set_global_option('basis', basis)

    # set any other options
    for k, v in mc_json.get('program_options', {}).items():
        psi4.core.set_global_option(k, v)

    try:
        # create the molecule
        psi_mol = psi4.geometry(vicMol(mol_json, dtype='json').to_string())
        # extract name
        method = mc_json.get('method')
        driver = mc_json.get('driver')
        if driver == 'gradient':
            ret, wfn = psi4.gradient(method, return_wfn=True, molecule =psi_mol)
        elif driver == 'hessian':
            ret, wfn = psi4.hessian(method, return_wfn = True, molecule = psi_mol)
        elif driver == 'rotation':
            ret, wfn = psi4.properties(method, return_wfn = True, molecule = psi_mol, properties=['rotation'])
        else:
            raise RuntimeError("invalid driver {}: Validation should have caught this".format(driver))

        grad = wfn.gradient()
        hess = wfn.hessian()
        rotations = extract_rotations(psi4.core.get_variables())
        if hess:
            output_json['output']['hessian'] = util.pack_json_field(hess.to_array())
        if grad:
            output_json['output']['gradient'] = util.pack_json_field(grad.to_array())
        if rotations:
            output_json['output']['rotations'] = rotations
        output_json['output']['all_variables'] = psi4.core.get_variables()
        output_json['success'] = True
        output_json['raw_output']['outfile'] = outfile_path.read_text()
        return output_json
    except Exception as e:
        output_json['success'] = False
        output_json['raw_output']['error'] = "\n".join(traceback.format_exception(*sys.exc_info()))
        return output_json
예제 #12
0
파일: optrot.py 프로젝트: rdcunha/ccsd_lpno
psi4.set_memory('2 GB')
psi4.core.set_output_file('optrot.dat', False)
np.set_printoptions(precision=12,
                    threshold=np.inf,
                    linewidth=200,
                    suppress=True)

# Set Psi4 options
geom = ccsd_lpno.mollib.mollib["{}".format(args.m)]
mol = psi4.geometry(geom)

psi4.set_options({
    'basis': 'aug-cc-pvdz',
    'scf_type': 'pk',
    'freeze_core': 'false',
    'e_convergence': 1e-12,
    'd_convergence': 1e-12,
    'save_jk': 'true'
})
psi4.set_options({'omega': [589, 'nm'], 'gauge': 'both'})
psi4.properties('ccsd', properties=['rotation', 'polarizability'])

print("Correlation energy: {}".format(
    psi4.core.variable("CCSD CORRELATION ENERGY")))
print("Optical rotation (LG): {}".format(
    psi4.core.variable("CCSD SPECIFIC ROTATION (LEN) @ 589NM")))
print("Optical rotation (MVG): {}".format(
    psi4.core.variable("CCSD SPECIFIC ROTATION (MVG) @ 589NM")))
print("Polarizability: {}".format(
    psi4.core.variable("CCSD DIPOLE POLARIZABILITY @ 589NM")))
예제 #13
0
def test_psi4_scfproperty():
    """scf-property"""
    #! UFH and B3LYP cc-pVQZ properties for the CH2 molecule.

    with open('grid.dat', 'w') as handle:
        handle.write("""\
0.0  0.0  0.0
1.1  1.3  1.4
""")

    ch2 = psi4.geometry("""
        0 3
        c
        h 1 b1
        h 1 b1 2 a1

        b1 = 1.0
        a1 = 125.0
    """)

    # Get a reasonable guess, to save some iterations
    psi4.set_options({
        "scf_type": "pk",
        "basis": "6-31G**",
        "e_convergence": 8,
        "docc": [2, 0, 0, 1],
        "socc": [1, 0, 1, 0],
        "reference": "uhf"})

    ch2.update_geometry()
    assert psi4.compare_values(6.648418918908746, ch2.nuclear_repulsion_energy(), 9, "Nuclear repulsion energy")

    props = ['DIPOLE', 'QUADRUPOLE', 'MULLIKEN_CHARGES', 'LOWDIN_CHARGES',
             'WIBERG_LOWDIN_INDICES', 'MAYER_INDICES', 'MAYER_INDICES',
             'MO_EXTENTS', 'GRID_FIELD', 'GRID_ESP', 'ESP_AT_NUCLEI',
             'MULTIPOLE(5)', 'NO_OCCUPATIONS']

    psi4.properties('scf', properties=props)

    assert psi4.compare_values(psi4.get_variable("CURRENT ENERGY"), -38.91591819679808, 6, "SCF energy")
    assert psi4.compare_values(psi4.get_variable('SCF DIPOLE X'), 0.000000000000, 4, "SCF DIPOLE X")
    assert psi4.compare_values(psi4.get_variable('SCF DIPOLE Y'), 0.000000000000, 4, "SCF DIPOLE Y")
    assert psi4.compare_values(psi4.get_variable('SCF DIPOLE Z'), 0.572697798348, 4, "SCF DIPOLE Z")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE XX'), -7.664066833060, 4, "SCF QUADRUPOLE XX")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE YY'), -6.097755074075, 4, "SCF QUADRUPOLE YY")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE ZZ'), -7.074596012050, 4, "SCF QUADRUPOLE ZZ")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE XY'), 0.000000000000, 4, "SCF QUADRUPOLE XY")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE XZ'), 0.000000000000, 4, "SCF QUADRUPOLE XZ")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE YZ'), 0.000000000000, 4, "SCF QUADRUPOLE YZ")

    psi4.properties('B3LYP', properties=props)

    assert psi4.compare_values(psi4.get_variable('CURRENT ENERGY'), -39.14134740550916, 6, "B3LYP energy")
    assert psi4.compare_values(psi4.get_variable('B3LYP DIPOLE X'), 0.000000000000, 4, "B3LYP DIPOLE X")
    assert psi4.compare_values(psi4.get_variable('B3LYP DIPOLE Y'), -0.000000000000, 4, "B3LYP DIPOLE Y")
    assert psi4.compare_values(psi4.get_variable('B3LYP DIPOLE Z'), 0.641741521158, 4, "B3LYP DIPOLE Z")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE XX'), -7.616483183211, 4, "B3LYP QUADRUPOLE XX")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE YY'), -6.005896804551, 4, "B3LYP QUADRUPOLE YY")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE ZZ'), -7.021817489904, 4, "B3LYP QUADRUPOLE ZZ")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE XY'), 0.000000000000, 4, "B3LYP QUADRUPOLE XY")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE XZ'), 0.000000000000, 4, "B3LYP QUADRUPOLE XZ")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE YZ'), -0.000000000000, 4, "B3LYP QUADRUPOLE YZ")
예제 #14
0
"""
)


nroots = 3

psi4.set_options(
    {
        "basis": "6-31G*",
        "freeze_core": "true",
        "roots_per_irrep": [nroots],
        "pe": "true",
        "puream": "true",
        "ints_tolerance": 2.5e-11,
    }
)

psi4.set_module_options("pe", {"potfile": "nilered_in_water.pot", "maxiter": 200})

psi4.set_module_options("ccenergy", {"cachelevel": 0})

psi4.set_module_options("cclambda", {"r_convergence": 1e-3, "cachelevel": 0})
psi4.set_module_options(
    "cceom", {"cachelevel": 0, "r_convergence": 1e-3, "e_convergence": 1e-5}
)

cce, ccwfn = psi4.properties(
    "eom-cc2", properties=["dipole"], return_wfn=True, molecule=mol
)
ptss = compute_ptss_corrections(ccwfn, nroots)
예제 #15
0
      (cart[0], cart[1], cart[2]))

for a in range(0, 3):
    print(" %s %20.10lf %20.10lf %20.10lf\n" %
          (cart[a], polar_AB[3 * a + 0], polar_AB[3 * a + 1],
           polar_AB[3 * a + 2]))

# Isotropic polarizability
trace = polar_AB[0] + polar_AB[4] + polar_AB[8]
Isotropic_polar = trace / 3.0

print(
    " Isotropic CCSD Dipole Polarizability @ %d nm (Length Gauge): %20.10lf a.u."
    % (omega_nm, Isotropic_polar))

# Comaprison with PSI4 (if you have near to latest version of psi4)
psi4.set_options({'d_convergence': 1e-10})
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(
    Isotropic_polar, psi4.variable("CCSD DIPOLE POLARIZABILITY @ 589NM"), 6,
    "CCSD Isotropic Dipole Polarizability @ 589 nm (Length Gauge)")  #TEST

#psi4.compare_values(
#    Isotropic_polar, 8.5698293248, 6,
#    "CCSD Isotropic Dipole Polarizability @ 589 nm (Length Gauge)")  # TEST

# Optical rotation
예제 #16
0
def test_psi4_scfproperty():
    """scf-property"""
    #! UFH and B3LYP cc-pVQZ properties for the CH2 molecule.

    with open('grid.dat', 'w') as handle:
        handle.write("""\
0.0  0.0  0.0
1.1  1.3  1.4
""")

    ch2 = psi4.geometry("""
        0 3
        c
        h 1 b1
        h 1 b1 2 a1

        b1 = 1.0
        a1 = 125.0
    """)

    # Get a reasonable guess, to save some iterations
    psi4.set_options({
        "scf_type": "pk",
        "basis": "6-31G**",
        "e_convergence": 8,
        "docc": [2, 0, 0, 1],
        "socc": [1, 0, 1, 0],
        "reference": "uhf"
    })

    ch2.update_geometry()
    assert psi4.compare_values(6.6484189450, ch2.nuclear_repulsion_energy(), 9,
                               "Nuclear repulsion energy")

    props = [
        'DIPOLE', 'QUADRUPOLE', 'MULLIKEN_CHARGES', 'LOWDIN_CHARGES',
        'WIBERG_LOWDIN_INDICES', 'MAYER_INDICES', 'MAYER_INDICES',
        'MO_EXTENTS', 'GRID_FIELD', 'GRID_ESP', 'ESP_AT_NUCLEI',
        'MULTIPOLE(5)', 'NO_OCCUPATIONS'
    ]

    psi4.properties('scf', properties=props)

    assert psi4.compare_values(psi4.get_variable("CURRENT ENERGY"),
                               -38.91591819679808, 6, "SCF energy")
    assert psi4.compare_values(psi4.get_variable('SCF DIPOLE X'),
                               0.000000000000, 4, "SCF DIPOLE X")
    assert psi4.compare_values(psi4.get_variable('SCF DIPOLE Y'),
                               0.000000000000, 4, "SCF DIPOLE Y")
    assert psi4.compare_values(psi4.get_variable('SCF DIPOLE Z'),
                               0.572697798348, 4, "SCF DIPOLE Z")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE XX'),
                               -7.664066833060, 4, "SCF QUADRUPOLE XX")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE YY'),
                               -6.097755074075, 4, "SCF QUADRUPOLE YY")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE ZZ'),
                               -7.074596012050, 4, "SCF QUADRUPOLE ZZ")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE XY'),
                               0.000000000000, 4, "SCF QUADRUPOLE XY")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE XZ'),
                               0.000000000000, 4, "SCF QUADRUPOLE XZ")
    assert psi4.compare_values(psi4.get_variable('SCF QUADRUPOLE YZ'),
                               0.000000000000, 4, "SCF QUADRUPOLE YZ")

    psi4.properties('B3LYP', properties=props)

    assert psi4.compare_values(psi4.get_variable('CURRENT ENERGY'),
                               -39.14134740550916, 6, "B3LYP energy")
    assert psi4.compare_values(psi4.get_variable('B3LYP DIPOLE X'),
                               0.000000000000, 4, "B3LYP DIPOLE X")
    assert psi4.compare_values(psi4.get_variable('B3LYP DIPOLE Y'),
                               -0.000000000000, 4, "B3LYP DIPOLE Y")
    assert psi4.compare_values(psi4.get_variable('B3LYP DIPOLE Z'),
                               0.641741521158, 4, "B3LYP DIPOLE Z")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE XX'),
                               -7.616483183211, 4, "B3LYP QUADRUPOLE XX")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE YY'),
                               -6.005896804551, 4, "B3LYP QUADRUPOLE YY")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE ZZ'),
                               -7.021817489904, 4, "B3LYP QUADRUPOLE ZZ")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE XY'),
                               0.000000000000, 4, "B3LYP QUADRUPOLE XY")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE XZ'),
                               0.000000000000, 4, "B3LYP QUADRUPOLE XZ")
    assert psi4.compare_values(psi4.get_variable('B3LYP QUADRUPOLE YZ'),
                               -0.000000000000, 4, "B3LYP QUADRUPOLE YZ")
예제 #17
0
H 1 1.1 2 104
symmetry c1
""")

opt_dict = {
    "basis": "sto-3g",
    "reference": "RHF",
    "print_MOs": "True",
    "mp2_type": "conv",
    "scf_type": "pk",
    "roots_per_irrep": [40],
    "e_convergence": 1e-14,
    "r_convergence": 1e-14
}
psi4.set_options(opt_dict)
psi4.properties('ccsd', properties=['dipole', 'analyze'])
#psi4.properties('cc2', properties=['dipole','analyze'])

#Start parameters
#w0 frequency of the oscillation
#A = 0.005#the amplitude of the electric field
#t0 = 0.0000 #the start time
#dt = 0.0001 #time step
#precs = 15 #precision of the t1, t2, l1, l2 amplitudes

mol = CC_Calculator(psi4, w0=0.968635, A=0.005, t0=0.0, dt=0.0001, precs=15)
#Time-dependent CC2 calculation
#mol.TDCC(timeout, 'CC2')
#Time-dependent CCSD calculation
mol.TDCC(timeout, 'CCSD')
예제 #18
0
""")

mol.fix_com(True)
mol.fix_orientation(True)

psi4.core.set_num_threads(NUMTHREADS)
psi4.set_options({'basis': 'cc-pvdz'})
psi4.set_options({'maxiter': 500})
psi4.set_options({'cachelevel': CCCACHELEVEL})
psi4.set_options({'freeze_core': 'true'})
psi4.set_options({'reference': 'rhf'})

# --- HF calculation --- #
E, wf = psi4.energy('scf', molecule=mol, return_wfn=True)

# save the some matrixes
numpy.save("D-HF", wf.Da().to_array(False, True))
numpy.save("F-HF", wf.Fa().to_array(False, True))
numpy.save("C-HF", wf.Ca().to_array(False, True))
numpy.save("H-HF", wf.H().to_array(False, True))
numpy.save("e-HF", wf.epsilon_a().to_array(False, True))

props, ccwf = psi4.properties('CCSD',
                              molecule=mol,
                              properties=['MULLIKEN_CHARGES'],
                              return_wfn=True,
                              ref_wfn=wf)

# save the some matrixes
numpy.save("D-CCSD", ccwf.Da().to_array(False, True))
예제 #19
0
def test_cc_polaroptrot():
    # cc29 + polarizabilities + tensors
    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
        noreorient
        """)

    mw = sum([mol.mass(i) for i in range(0, 4)])
    c = psi4.constants.c
    h = psi4.constants.h
    h2j = psi4.constants.hartree2J
    Na = psi4.constants.na
    me = psi4.constants.me
    hbar = psi4.constants.hbar
    prefactor = -72E6 * hbar**2 * Na / c**2 / me**2 / mw / 3.0
    au_589 = c * h * 1E9 / h2j / 589
    au_355 = c * h * 1E9 / h2j / 355

    psi4.set_options({"basis": "cc-pVDZ"})
    omega = [589, 355, 'nm']
    psi4.set_options({
        'gauge': 'both',
        'omega': omega,
        'freeze_core': True,
        'r_convergence': 10
    })

    e, wfn = psi4.properties('CCSD',
                             properties=["polarizability", "rotation"],
                             return_wfn=True)

    pol_589 = 8.92296  #TEST
    pol_355 = 9.16134  #TEST
    rotlen_589 = -76.93388  #TEST
    rotvel_589 = 850.24712  #TEST
    rotmvg_589 = -179.08820  #TEST
    rotlen_355 = -214.73273  #TEST
    rotvel_355 = 384.88786  #TEST
    rotmvg_355 = -644.44746  #TEST

    polr_589 = np.trace(
        wfn.variable("CCSD DIPOLE POLARIZABILITY TENSOR @ 589NM").to_array()
    ) / 3.0  #RESULT
    polr_355 = np.trace(
        wfn.variable("CCSD DIPOLE POLARIZABILITY TENSOR @ 355NM").to_array()
    ) / 3.0  #RESULT
    rotlenr_589 = np.trace(
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (LEN) @ 589NM").to_array()
    ) * prefactor * au_589  #RESULT
    rotvelr_589 = np.trace(
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (VEL) @ 589NM").to_array()
    ) * prefactor  #RESULT
    rotmvgr_589 = np.trace(
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (MVG) @ 589NM").to_array()
    ) * prefactor  #RESULT
    rotlenr_355 = np.trace(
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (LEN) @ 355NM").to_array()
    ) * prefactor * au_355  #RESULT
    rotvelr_355 = np.trace(
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (VEL) @ 355NM").to_array()
    ) * prefactor  #RESULT
    rotmvgr_355 = np.trace(
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (MVG) @ 355NM").to_array()
    ) * prefactor  #RESULT

    polt_589 = np.array([[5.44184081e+00, -8.30270852e-01, 9.39878004e-14],
                         [-8.30270852e-01, 1.27518991e+01, -6.94720506e-14],
                         [9.39878004e-14, -6.94720506e-14,
                          8.57516214e+00]])  #TEST
    polt_355 = np.array([[5.57913165e+00, -8.66951957e-01, 1.02575190e-13],
                         [-8.66951957e-01, 1.31256109e+01, -7.71806997e-14],
                         [1.02575190e-13, -7.71806997e-14,
                          8.77928702e+00]])  #TEST
    rottvel_0 = np.array([[3.63702792e-01, -3.62754886e-01, -3.37227243e-14],
                          [-1.16320923e-01, 1.20784891e-02, 1.76483272e-14],
                          [1.90062651e-14, -2.33369227e-15,
                           -3.92022202e-01]])  #TEST
    rottlen_589 = np.array([[1.41679366e-01, -7.07140738e-02, -2.26060131e-14],
                            [-2.72710108e-01, 1.28928522e-03, 1.01578936e-14],
                            [3.74236371e-14, 3.88522300e-15,
                             -1.27276912e-01]])  #TEST
    rottvel_589 = np.array([[3.75624000e-01, -3.74245928e-01, -3.61489832e-14],
                            [-1.39409385e-01, 1.26867931e-02, 1.94630079e-14],
                            [2.33993608e-14, -1.61361648e-15,
                             -4.01726048e-01]])  #TEST
    rottmvg_589 = np.array([[1.19212077e-02, -1.14910412e-02, -2.42625886e-15],
                            [-2.30884623e-02, 6.08303937e-04, 1.81468070e-15],
                            [4.39309571e-15, 7.20075789e-16,
                             -9.70384612e-03]])  #TEST

    assert psi4.compare_values(pol_589, polr_589, 3,
                               "CCSD polarizability @ 589nm")  #TEST
    assert psi4.compare_values(pol_355, polr_355, 3,
                               "CCSD polarizability @ 355nm")  #TEST
    assert psi4.compare_values(rotlen_589, rotlenr_589, 3,
                               "CCSD rotation @ 589nm in length gauge")  #TEST
    assert psi4.compare_values(
        rotvel_589, rotvelr_589, 3,
        "CCSD rotation @ 589nm in velocity gauge")  #TEST
    assert psi4.compare_values(
        rotmvg_589, rotmvgr_589, 3,
        "CCSD rotation @ 589nm in modified velocity gauge")  #TEST
    assert psi4.compare_values(rotlen_355, rotlenr_355, 3,
                               "CCSD rotation @ 355nm in length gauge")  #TEST
    assert psi4.compare_values(
        rotvel_355, rotvelr_355, 3,
        "CCSD rotation @ 355nm in velocity gauge")  #TEST
    assert psi4.compare_values(
        rotmvg_355, rotmvgr_355, 3,
        "CCSD rotation @ 355nm in modified velocity gauge")  #TEST

    assert psi4.compare_values(
        polt_589, wfn.variable("CCSD DIPOLE POLARIZABILITY TENSOR @ 589NM"), 3,
        "CCSD polarizability tensor @ 589nm")  #TEST
    assert psi4.compare_values(
        polt_355, wfn.variable("CCSD DIPOLE POLARIZABILITY TENSOR @ 355NM"), 3,
        "CCSD polarizability tensor @ 355nm")  #TEST
    assert psi4.compare_arrays(
        rottvel_0, wfn.variable("CCSD OPTICAL ROTATION TENSOR (VEL) @ 0NM"), 3,
        "CCSD optrot tensor @ 0NM in velocity guage")  #TEST
    assert psi4.compare_arrays(
        rottlen_589,
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (LEN) @ 589NM"), 3,
        "CCSD optrot tensor @ 589NM in length guage")  #TEST
    assert psi4.compare_arrays(
        rottvel_589,
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (VEL) @ 589NM"), 3,
        "CCSD optrot tensor @ 589NM in velocity guage")  #TEST
    assert psi4.compare_arrays(
        rottmvg_589,
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (MVG) @ 589NM"), 3,
        "CCSD optrot tensor @ 589NM in modified velocity guage")  #TEST
예제 #20
0
def test_cc_roa():
    # three tensors for ROA (polar, optrot, and dip-quad)
    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
        noreorient
        """)

    psi4.set_options({"basis": "cc-pVDZ"})
    omega = [589, 'nm']
    psi4.set_options({
        'gauge': 'both',
        'omega': omega,
        'freeze_core': True,
        'r_convergence': 10
    })

    e, wfn = psi4.properties('CCSD',
                             properties=["roa_tensor"],
                             return_wfn=True)

    polt_589 = np.array([[5.44184081e+00, -8.30270852e-01, 9.39878004e-14],
                         [-8.30270852e-01, 1.27518991e+01, -6.94720506e-14],
                         [9.39878004e-14, -6.94720506e-14, 8.57516214e+00]])
    rottvel_0 = np.array([[3.63702792e-01, -3.62754886e-01, -3.37227243e-14],
                          [-1.16320923e-01, 1.20784891e-02, 1.76483272e-14],
                          [1.90062651e-14, -2.33369227e-15, -3.92022202e-01]])
    rottlen_589 = np.array([[1.41679366e-01, -7.07140738e-02, -2.26060131e-14],
                            [-2.72710108e-01, 1.28928522e-03, 1.01578936e-14],
                            [3.74236371e-14, 3.88522300e-15, -1.27276912e-01]])
    rottvel_589 = np.array([[3.75624000e-01, -3.74245928e-01, -3.61489832e-14],
                            [-1.39409385e-01, 1.26867931e-02, 1.94630079e-14],
                            [2.33993608e-14, -1.61361648e-15,
                             -4.01726048e-01]])
    rottmvg_589 = np.array([[1.19212077e-02, -1.14910412e-02, -2.42625886e-15],
                            [-2.30884623e-02, 6.08303937e-04, 1.81468070e-15],
                            [4.39309571e-15, 7.20075789e-16, -9.70384612e-03]])
    quad0 = np.array([[[-2.52229282e-14, -4.33846468e-13, 3.90176525e+00],
                       [-4.33846468e-13, -6.81906994e-15, -5.83659009e+00],
                       [3.90176525e+00, -5.83659009e+00, 3.18177152e-14]],
                      [[1.20834634e-13, 6.99638702e-14, -2.37995874e+00],
                       [6.99638702e-14, -1.17603861e-13, 6.85651590e+00],
                       [-2.37995874e+00, 6.85651590e+00, -3.99609068e-15]],
                      [[-4.55024365e+00, -5.30335671e+00, 1.65990108e-13],
                       [-5.30335671e+00, -1.35415335e+00, -8.75522529e-13],
                       [1.65990108e-13, -8.75522529e-13, 5.90439700e+00]]])

    assert psi4.compare_values(
        polt_589, wfn.variable("CCSD DIPOLE POLARIZABILITY TENSOR @ 589NM"), 3,
        "CCSD polarizability tensor @ 589nm")  #TEST
    assert psi4.compare_arrays(
        rottvel_0, wfn.variable("CCSD OPTICAL ROTATION TENSOR (VEL) @ 0NM"), 3,
        "CCSD optrot tensor @ 0NM in velocity guage")  #TEST
    assert psi4.compare_arrays(
        rottlen_589,
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (LEN) @ 589NM"), 3,
        "CCSD optrot tensor @ 589NM in length guage")  #TEST
    assert psi4.compare_arrays(
        rottvel_589,
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (VEL) @ 589NM"), 3,
        "CCSD optrot tensor @ 589NM in velocity guage")  #TEST
    assert psi4.compare_arrays(
        rottmvg_589,
        wfn.variable("CCSD OPTICAL ROTATION TENSOR (MVG) @ 589NM"), 3,
        "CCSD optrot tensor @ 589NM in modified velocity guage")  #TEST
    assert psi4.compare_values(
        quad0, wfn.variable("CCSD QUADRUPOLE POLARIZABILITY TENSOR @ 589NM"),
        3, "CCSD quadrupole tensor @ 589nm")  #TEST
예제 #21
0
파일: input.py 프로젝트: yramis/rtcc
# Run this with:
#   python input.py
# Make sure helper files are in the same directory
# Everything should work as intended if downloaded from github.com/yramis/rtcc
#   If not, feel free to write me a strongly worded email for not keepting this repo up to date.

import psi4
from helper_tdcc import rtcc
from opt_einsum import contract
import numpy as np

mol = psi4.geometry("""
Li
H 1 1
symmetry c1
""")

psi4.set_options({'basis': 'sto-3g'})
psi4.set_options({'reference': 'rhf'})

rtcc()

psi4.set_module_options('SCF', {'SCF_TYPE': 'PK'})
psi4.set_module_options('SCF', {'E_CONVERGENCE': 1e-14})
psi4.set_module_options('SCF', {'D_CONVERGENCE': 1e-14})
psi4.set_module_options('CCENERGY', {'E_CONVERGENCE': 1e-16})
psi4.set_module_options('CCLAMBDA', {'R_CONVERGENCE': 1e-16})

e_ccsd = psi4.properties('ccsd', 'dipole')
예제 #22
0
def test_adcc_reference_data(case):
    conf = case["config"]
    psi4.core.clean()
    psi4.set_options({
        'reference': conf['reference'],
        'basis': conf['basis'],
        'guess': 'core',
        'scf_type': 'pk',
        'roots_per_irrep': [conf['n_states']],
        'kind': conf['kind'],
        'num_core_orbitals': conf['core_orbitals'],
        'freeze_core': conf['frozen_core'],
        'num_frozen_uocc': conf['frozen_virtual'],
        'e_convergence': 1e-10,
        'd_convergence': 1e-8,
        'gauge': conf['gauge'],
        'adc__r_convergence': 1e-8,
    })
    mol = psi4.core.Molecule.from_string(conf['molstring'])

    props = [
        'TRANSITION_DIPOLE', 'DIPOLE', 'OSCILLATOR_STRENGTH',
        'ROTATIONAL_STRENGTH'
    ]
    en_adc, wfn = psi4.properties(conf['method'],
                                  properties=props,
                                  return_wfn=True,
                                  molecule=mol)

    np.testing.assert_allclose(en_adc, case['energy_gs'], atol=1e-7)
    np.testing.assert_allclose(wfn.variable("CURRENT ENERGY"),
                               case['energy_gs'],
                               atol=1e-7)

    method = conf['method'].upper()
    for i in range(conf['n_states']):
        root_index = i + 1
        prop_access_patterns = {
            'excitation_energy': ([
                f"{method} ROOT 0 -> ROOT {root_index} EXCITATION ENERGY",
                f"{method} ROOT 0 (IN A) -> ROOT {root_index} (IN A) EXCITATION ENERGY",
                f"{method} ROOT 0 (A) -> ROOT {root_index} (A) EXCITATION ENERGY",
                f"{method} ROOT 0 -> ROOT {root_index} EXCITATION ENERGY - A TRANSITION",
                f"ADC ROOT 0 -> ROOT {root_index} EXCITATION ENERGY",
                f"ADC ROOT 0 (IN A) -> ROOT {root_index} (IN A) EXCITATION ENERGY",
                f"ADC ROOT 0 (A) -> ROOT {root_index} (A) EXCITATION ENERGY",
                f"ADC ROOT 0 -> ROOT {root_index} EXCITATION ENERGY - A TRANSITION",
            ], 1e-6),
            'oscillator_strength': ([
                f"{method} ROOT 0 (IN A) -> ROOT {root_index} (IN A) OSCILLATOR STRENGTH (LEN)",
                f"{method} ROOT 0 (A) -> ROOT {root_index} (A) OSCILLATOR STRENGTH (LEN)",
                f"{method} ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (LEN)",
                f"{method} ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (LEN) - A TRANSITION",
                f"ADC ROOT 0 (IN A) -> ROOT {root_index} (IN A) OSCILLATOR STRENGTH (LEN)",
                f"ADC ROOT 0 (A) -> ROOT {root_index} (A) OSCILLATOR STRENGTH (LEN)",
                f"ADC ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (LEN)",
                f"ADC ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (LEN) - A TRANSITION",
            ], 1e-5),
            'oscillator_strength_velocity': ([
                f"{method} ROOT 0 (IN A) -> ROOT {root_index} (IN A) OSCILLATOR STRENGTH (VEL)",
                f"{method} ROOT 0 (A) -> ROOT {root_index} (A) OSCILLATOR STRENGTH (VEL)",
                f"{method} ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (VEL)",
                f"{method} ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (VEL) - A TRANSITION",
                f"ADC ROOT 0 (IN A) -> ROOT {root_index} (IN A) OSCILLATOR STRENGTH (VEL)",
                f"ADC ROOT 0 (A) -> ROOT {root_index} (A) OSCILLATOR STRENGTH (VEL)",
                f"ADC ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (VEL)",
                f"ADC ROOT 0 -> ROOT {root_index} OSCILLATOR STRENGTH (VEL) - A TRANSITION",
            ], 1e-5),
            'rotatory_strength': ([
                f"{method} ROOT 0 (IN A) -> ROOT {root_index} (IN A) ROTATORY STRENGTH (VEL)",
                f"{method} ROOT 0 (A) -> ROOT {root_index} (A) ROTATORY STRENGTH (VEL)",
                f"{method} ROOT 0 -> ROOT {root_index} ROTATORY STRENGTH (VEL)",
                f"{method} ROOT 0 -> ROOT {root_index} ROTATORY STRENGTH (VEL) - A TRANSITION",
                f"ADC ROOT 0 (IN A) -> ROOT {root_index} (IN A) ROTATORY STRENGTH (VEL)",
                f"ADC ROOT 0 (A) -> ROOT {root_index} (A) ROTATORY STRENGTH (VEL)",
                f"ADC ROOT 0 -> ROOT {root_index} ROTATORY STRENGTH (VEL)",
                f"ADC ROOT 0 -> ROOT {root_index} ROTATORY STRENGTH (VEL) - A TRANSITION",
            ], 1e-5),
            'state_dipole_moment': ([
                f"{method} ROOT {root_index} (IN A) DIPOLE MOMENT",
                f"{method} ROOT {root_index} (A) DIPOLE MOMENT",
                f"{method} ROOT {root_index} DIPOLE MOMENT",
                f"{method} ROOT {root_index} DIPOLE MOMENT - A TRANSITION",
                f"ADC ROOT {root_index} (IN A) DIPOLE MOMENT",
                f"ADC ROOT {root_index} (A) DIPOLE MOMENT",
                f"ADC ROOT {root_index} DIPOLE MOMENT",
                f"ADC ROOT {root_index} DIPOLE MOMENT - A TRANSITION",
            ], 5e-3),
        }
        for propname, (vars, atol) in prop_access_patterns.items():
            # Psi lets us select only one gauge, so skip length gauge oscillator strength
            # in case we have selected velocity gauge and vice versa
            if propname == "oscillator_strength" and conf['gauge'] == "velocity" or \
                propname == "oscillator_strength_velocity" and conf['gauge'] == "length":
                continue
            for v in vars:
                ret = wfn.variable(v)
                if isinstance(ret, psi4.core.Matrix):
                    ret = ret.np.flatten()
                np.testing.assert_allclose(
                    ret,
                    case[propname][i],
                    atol=atol,
                    err_msg=f"Result for {v} incorrect.")
예제 #23
0
파일: input.py 프로젝트: xinxing02/psi4
S 2 1.00
        12.2874690000           0.4448700000
         4.7568050000           0.2431720000
S 1 1.00
         1.0042710000           1.0000000000
S 1 1.00
         0.3006860000           1.0000000000
S 1 1.00
         0.0900300000           1.0000000000
P 4 1.00
        34.8564630000           0.0156480000
         7.8431310000           0.0981970000
         2.3062490000           0.3077680000
         0.7231640000           0.4924700000
P 1 1.00
         0.2148820000           1.0000000000
P 1 1.00
         0.0638500000           1.0000000000
D 2 1.00
         2.3062000000           0.2027000000
         0.7232000000           0.5791000000
D 2 1.00
         0.2149000000           0.7854500000
         0.0639000000           0.5338700000
****
""")

ccsd_e, wfn = psi4.properties('ccsd',properties=['dipole'],return_wfn=True)
psi4.oeprop(wfn,"DIPOLE", "QUADRUPOLE", title="(OEPROP)CC")
psi4.core.print_variables()
예제 #24
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