Skip to content

Commit

Permalink
Add a test for ir intensity WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
puzhichen committed May 7, 2024
1 parent 8ffa5e0 commit bb955db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions gpu4pyscf/properties/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ def eval_ir_freq_intensity(mf, hessian_obj):
atom_charges = mf.mol.atom_charges()
mass = cupy.array([elements.MASSES[atom_charges[i]] for i in range(natm)])
intensity = cupy.zeros((3*natm))
hessian_mass = contract('ijkl,i,j->ijkl', hessian,
1/cupy.sqrt(mass), 1/cupy.sqrt(mass))

# hessian_mass = contract('ijkl,i,j->ijkl', hessian,
# 1/cupy.sqrt(mass), 1/cupy.sqrt(mass))
hessian_mass = contract('ijkl,i->ijkl', cupy.array(hessian), 1/cupy.sqrt(mass))
hessian_mass = contract('ijkl,j->ijkl', hessian_mass, 1/cupy.sqrt(mass))

TR = thermo._get_TR(mass.get(), mf.mol.atom_coords())
TRspace = []
TRspace.append(TR[:3])
Expand Down
11 changes: 8 additions & 3 deletions gpu4pyscf/properties/tests/test_ir_intensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ def run_dft_ir(xc):
def run_dft_df_if(xc):
mf = rks.RKS(mol, xc=xc).density_fit(auxbasis='def2-universal-jkfit')
mf.grids.level = grids_level
mf.conv_tol_cpscf = 1e-3
e_dft = mf.kernel()
h = mf.Hessian()
h.auxbasis_response = 2
polar = ir.eval_ir_freq_intensity(mf, h)
# h_debug = h.kernel()
# print(h_debug)
freq, intensity = ir.eval_ir_freq_intensity(mf, h)
return e_dft, freq, intensity


Expand Down Expand Up @@ -113,7 +116,8 @@ def test_rks_b3lyp(self):
qchem_polar = np.array([ [ 8.5899463, -0.0000000, -0.0000000],
[-0.0000000, 6.0162267, -0.0000000],
[-0.0000000, -0.0000000, 7.5683123]])
assert np.allclose(polar, qchem_polar)
print(freq, intensity)
# assert np.allclose(polar, qchem_polar)

def test_rks_b3lyp_df(self):
print('-------- RKS density fitting B3LYP -------------')
Expand All @@ -122,7 +126,8 @@ def test_rks_b3lyp_df(self):
qchem_polar = np.array([ [ 8.5902540, -0.0000000, -0.0000000],
[ 0.0000000, 6.0167648, -0.0000000],
[ -0.0000000, -0.0000000, 7.5688173]])
assert np.allclose(polar, qchem_polar)
print(freq, intensity)
# assert np.allclose(polar, qchem_polar)



Expand Down

0 comments on commit bb955db

Please sign in to comment.