Skip to content

Commit 43d7366

Browse files
committed
cleanups in examples
1 parent 0c93670 commit 43d7366

File tree

3 files changed

+23
-35
lines changed

3 files changed

+23
-35
lines changed

examples/29-polarizability.py

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

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

2020
import pyscf
21-
from gpu4pyscf.dft import rks
2221
from gpu4pyscf.properties import polarizability
2322

2423
atom = '''
@@ -29,10 +28,9 @@
2928

3029
bas='631g'
3130

32-
mol = pyscf.M(atom=atom, basis=bas, max_memory=32000)
33-
mol.build()
31+
mol = pyscf.M(atom=atom, basis=bas)
3432

35-
mf = rks.RKS(mol, xc='b3lyp')
33+
mf = mol.RKS(xc='b3lyp').to_gpu()
3634
e_gpu = mf.kernel() # -76.3849465432042
3735
polar_gpu = polarizability.eval_polarizability(mf)
3836
print('------------------- Polarizability -----------------------------')
@@ -41,4 +39,4 @@
4139
[[ 6.96413065e+00 9.60315894e-18 -2.25792304e-13]
4240
[ 9.60315894e-18 1.48264155e+00 -6.84920815e-15]
4341
[-2.25792304e-13 -6.84920815e-15 4.81230498e+00]]
44-
"""
42+
"""

examples/30-nmr.py

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

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

2021
import pyscf
21-
from gpu4pyscf.dft import rks
2222
from gpu4pyscf.properties import shielding
2323

2424
atom = '''
@@ -29,10 +29,9 @@
2929

3030
bas='631g'
3131

32-
mol = pyscf.M(atom=atom, basis=bas, max_memory=32000)
33-
mol.build()
32+
mol = pyscf.M(atom=atom, basis=bas)
3433

35-
mf = rks.RKS(mol, xc='b3lyp')
34+
mf = mol.RKS(xc='b3lyp').to_gpu()
3635
e_gpu = mf.kernel() # -76.3849465432042
3736
msc_d, msc_p = shielding.eval_shielding(mf)
3837
msc = (msc_d + msc_p).get()
@@ -43,4 +42,4 @@
4342
Isotropic NMR shielding constant for 0-th atom is 318.1915
4443
Isotropic NMR shielding constant for 1-th atom is 33.0777
4544
Isotropic NMR shielding constant for 2-th atom is 33.0777
46-
"""
45+
"""

examples/31-ir_intensity.py

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
'''
2-
Author: puzhichen.996 [email protected]
3-
Date: 2025-04-23 00:43:36
4-
LastEditors: puzhichen.996 [email protected]
5-
LastEditTime: 2025-04-23 00:43:07
6-
FilePath: /playground/root/gpu4pysc/gpu4pyscf/examples/31-ir_intensity.py
7-
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
8-
'''
91
#!/usr/bin/env python
102
# Copyright 2021-2025 The PySCF Developers. All Rights Reserved.
113
#
@@ -21,9 +13,9 @@
2113
# See the License for the specific language governing permissions and
2214
# limitations under the License.
2315

24-
###################################
25-
# Example of IR intensity
26-
###################################
16+
'''
17+
IR intensity
18+
'''
2719

2820
import pyscf
2921
from gpu4pyscf.dft import rks
@@ -37,19 +29,18 @@
3729

3830
bas='631g'
3931

40-
mol = pyscf.M(atom=atom, basis=bas, max_memory=32000)
41-
mol.build()
32+
mol = pyscf.M(atom=atom, basis=bas)
4233

43-
mf = rks.RKS(mol, xc='b3lyp')
34+
mf = mol.RKS(xc='b3lyp').to_gpu()
4435
e_gpu = mf.kernel() # -76.3849465432042
4536

4637
h = mf.Hessian()
4738
freq, intensity = ir.eval_ir_freq_intensity(mf, h)
4839
print('------------------- IR frequncy and intensity -----------------------------')
4940
for i in range(freq.shape[0]):
50-
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)
5146
"""
52-
IR frequency|intensity for 0-th mode is 1613.0866|62.3982
53-
IR frequency|intensity for 1-th mode is 3874.9540|3.7823
54-
IR frequency|intensity for 2-th mode is 4006.0173|5.0603
55-
"""

0 commit comments

Comments
 (0)