Skip to content

Commit 638783d

Browse files
authored
Merge pull request #6 from sunqm/bytedance-feat/polarizability-example
Update Bytedance feat/polarizability example
2 parents 923567a + b1dbf7b commit 638783d

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

examples/29-polarizability.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
17-
###################################
18-
# Example of Polarizability
19-
###################################
16+
'''
17+
Static polarizability (unit Bohr^3)
18+
'''
2019

2120
import pyscf
22-
from gpu4pyscf.dft import rks
2321
from gpu4pyscf.properties import polarizability
2422

2523
atom = '''
@@ -28,9 +26,11 @@
2826
H 0.7570000000 0.0000000000 -0.4696000000
2927
'''
3028

31-
mol = pyscf.M(atom=atom, basis='631g', max_memory=32000)
29+
bas='631g'
3230

33-
mf = rks.RKS(mol, xc='b3lyp')
31+
mol = pyscf.M(atom=atom, basis=bas)
32+
33+
mf = mol.RKS(xc='b3lyp').to_gpu()
3434
e_gpu = mf.kernel() # -76.3849465432042
3535
polar_gpu = polarizability.eval_polarizability(mf)
3636
print('------------------- Polarizability -----------------------------')
@@ -39,4 +39,4 @@
3939
[[ 6.96413065e+00 9.60315894e-18 -2.25792304e-13]
4040
[ 9.60315894e-18 1.48264155e+00 -6.84920815e-15]
4141
[-2.25792304e-13 -6.84920815e-15 4.81230498e+00]]
42-
"""
42+
"""

examples/30-nmr.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
17-
###################################
18-
# Example of NMR shielding constant
19-
###################################
16+
'''
17+
NMR shielding constant. The unit is dimensionless, scaled by 10^6 to align to
18+
the PPM unit in chemical shifts.
19+
'''
2020

2121
import pyscf
22-
from gpu4pyscf.dft import rks
2322
from gpu4pyscf.properties import shielding
2423

2524
atom = '''
@@ -28,9 +27,11 @@
2827
H 0.7570000000 0.0000000000 -0.4696000000
2928
'''
3029

31-
mol = pyscf.M(atom=atom, basis='631g', max_memory=32000)
30+
bas='631g'
3231

33-
mf = rks.RKS(mol, xc='b3lyp')
32+
mol = pyscf.M(atom=atom, basis=bas)
33+
34+
mf = mol.RKS(xc='b3lyp').to_gpu()
3435
e_gpu = mf.kernel() # -76.3849465432042
3536
msc_d, msc_p = shielding.eval_shielding(mf)
3637
msc = (msc_d + msc_p).get()
@@ -41,4 +42,4 @@
4142
Isotropic NMR shielding constant for 0-th atom is 318.1915
4243
Isotropic NMR shielding constant for 1-th atom is 33.0777
4344
Isotropic NMR shielding constant for 2-th atom is 33.0777
44-
"""
45+
"""

examples/31-ir_intensity.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
17-
###################################
18-
# Example of IR intensity
19-
###################################
16+
'''
17+
IR intensity
18+
'''
2019

2120
import pyscf
2221
from gpu4pyscf.dft import rks
@@ -28,18 +27,20 @@
2827
H 0.7570000000 0.0000000000 -0.4696000000
2928
'''
3029

31-
mol = pyscf.M(atom=atom, basis='631g', max_memory=32000)
30+
bas='631g'
3231

33-
mf = rks.RKS(mol, xc='b3lyp')
32+
mol = pyscf.M(atom=atom, basis=bas)
33+
34+
mf = mol.RKS(xc='b3lyp').to_gpu()
3435
e_gpu = mf.kernel() # -76.3849465432042
3536

3637
h = mf.Hessian()
3738
freq, intensity = ir.eval_ir_freq_intensity(mf, h)
3839
print('------------------- IR frequncy and intensity -----------------------------')
3940
for i in range(freq.shape[0]):
40-
print(f"IR frequency|intensity for {i}-th mode is {freq[i]:.4f}|{intensity[i]:.4f}")
41+
print(f"IR frequency|intensity for {i}-th mode is {freq[i]:.4f} (cm^-1) |{intensity[i]:.4f} (km/mol)")
42+
"""
43+
IR frequency|intensity for 0-th mode is 1613.0866 (cm^-1) |62.3982 (km/mol)
44+
IR frequency|intensity for 1-th mode is 3874.9540 (cm^-1) |3.7823 (km/mol)
45+
IR frequency|intensity for 2-th mode is 4006.0173 (cm^-1) |5.0603 (km/mol)
4146
"""
42-
IR frequency|intensity for 0-th mode is 1613.0866|62.3982
43-
IR frequency|intensity for 1-th mode is 3874.9540|3.7823
44-
IR frequency|intensity for 2-th mode is 4006.0173|5.0603
45-
"""

0 commit comments

Comments
 (0)