3
3
# 2. optking still has a module level parameters and history,
4
4
# that could be eliminated, so not yet multi-object safe.
5
5
# 3. Have not yet restarted from json or disk, but should be close to working.
6
- import psi4
7
6
import optking
8
7
import pytest
9
8
10
9
11
10
def test_step_by_step ():
12
-
11
+ import psi4
13
12
h2o = psi4 .geometry (
14
13
"""
15
14
O
@@ -63,22 +62,19 @@ def test_step_by_step():
63
62
64
63
65
64
def test_lj_external_gradient ():
66
- h2o = psi4 .geometry (
65
+ import qcelemental as qcel
66
+ import numpy as np
67
+
68
+ h2o = qcel .models .Molecule .from_data (
69
+ """
70
+ O 0.00000000 0.00000000 -0.12947689
71
+ H 0.00000000 -1.49418674 1.02744610
72
+ H 0.00000000 1.49418674 1.02744610
67
73
"""
68
- O
69
- H 1 1.0
70
- H 1 1.0 2 104.5
71
- """
72
74
)
73
75
74
- psi4 .core .clean_options ()
75
- psi4_options = {
76
- "basis" : "sto-3g" ,
77
- }
78
76
optking_options = {"g_convergence" : "gau_verytight" , "intrafrag_hess" : "SIMPLE" }
79
77
80
- psi4 .set_options (psi4_options )
81
-
82
78
opt = optking .CustomHelper (h2o , optking_options )
83
79
84
80
for step in range (30 ):
@@ -103,11 +99,14 @@ def test_lj_external_gradient():
103
99
assert conv is True
104
100
E = json_output ["energies" ][- 1 ] # TEST
105
101
RefEnergy = - 0.03 # - epsilon * 3, where -epsilon is depth of each Vij well
106
- assert psi4 . compare_values (RefEnergy , E , 6 , "L-J Energy upon optimization" )
102
+ assert np . isclose (RefEnergy , E , rtol = 1e-05 , atol = 1e-6 )
107
103
108
104
109
105
# Demonstrate a complete export/import of OptHelper object
110
106
def test_stepwise_export ():
107
+ import psi4
108
+ import pprint
109
+
111
110
h2o = psi4 .geometry (
112
111
"""
113
112
O
@@ -129,8 +128,6 @@ def test_stepwise_export():
129
128
opt = optking .CustomHelper (h2o )
130
129
optSaved = opt .to_dict ()
131
130
132
- import pprint
133
-
134
131
pp = pprint .PrettyPrinter (indent = 2 )
135
132
pp .pprint (optSaved )
136
133
0 commit comments