Skip to content

Commit f06a742

Browse files
committed
small updates in examples
1 parent feac929 commit f06a742

5 files changed

+27
-32
lines changed

examples/alanine_nwchem.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@
77
from psiflow.learning import SequentialLearning
88
from psiflow.metrics import Metrics
99
from psiflow.models import NequIPConfig, NequIPModel
10-
from psiflow.reference import NWChemReference
10+
from psiflow.reference import PySCFReference
1111
from psiflow.walkers import BiasedDynamicWalker, DynamicWalker, PlumedBias
1212

1313

1414
def get_reference():
15-
calculator_kwargs = {
16-
"basis": {e: "3-21g" for e in ["H", "C", "O", "N"]},
17-
"dft": {
18-
"xc": "pw91lda",
19-
"mult": 1,
20-
"convergence": {
21-
"energy": 1e-6,
22-
"density": 1e-6,
23-
"gradient": 1e-6,
24-
},
25-
#'disp': {'vdw': 3},
26-
},
27-
}
28-
return NWChemReference(**calculator_kwargs)
15+
routine = """
16+
from pyscf import dft
17+
18+
mf = dft.RKS(molecule)
19+
mf.xc = 'pbe,pbe'
20+
21+
energy = mf.kernel()
22+
forces = -mf.nuc_grad_method().kernel()
23+
"""
24+
basis = "cc-pvtz"
25+
spin = 0
26+
return PySCFReference(routine, basis, spin)
2927

3028

3129
def get_bias():
@@ -93,7 +91,7 @@ def main(path_output):
9391

9492
# this is mostly a toy script to test code paths rather
9593
# than an actually working example
96-
data = learning.run(
94+
data = learning.run( # noqa: F841
9795
model=model,
9896
reference=reference,
9997
walkers=walkers_md + walkers_mtd,
@@ -104,3 +102,4 @@ def main(path_output):
104102
psiflow.load()
105103
path_output = Path.cwd() / "output"
106104
main(path_output)
105+
psiflow.wait()

examples/copper_emt.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
import logging
21
from pathlib import Path
32

43
import numpy as np
5-
import requests
64
from ase.build import bulk, make_supercell
75

86
import psiflow
97
from psiflow.committee import Committee
10-
from psiflow.data import Dataset, FlowAtoms
11-
from psiflow.learning import CommitteeLearning, SequentialLearning, load_learning
8+
from psiflow.data import Dataset
9+
from psiflow.learning import CommitteeLearning, SequentialLearning
1210
from psiflow.metrics import Metrics
1311
from psiflow.models import MACEConfig, MACEModel
1412
from psiflow.reference import EMTReference
15-
from psiflow.state import load_state
16-
from psiflow.walkers import DynamicWalker, PlumedBias
13+
from psiflow.walkers import DynamicWalker
1714

1815

1916
def main(path_output):
@@ -22,7 +19,7 @@ def main(path_output):
2219
path_committee = path_output / "learn_committee"
2320
path_committee.mkdir(parents=True)
2421

25-
reference = EMTReference() # CP2K; PBE-D3(BJ); TZVP
22+
reference = EMTReference()
2623
atoms = make_supercell(bulk("Cu", "fcc", a=3.6, cubic=True), 3 * np.eye(3))
2724

2825
config = MACEConfig()
@@ -56,7 +53,7 @@ def main(path_output):
5653
step=40,
5754
start=0,
5855
temperature=100,
59-
temperature_threshold=300, # reset if T > T_0 + 300 K
56+
max_excess_temperature=300, # reset if T > T_0 + 300 K
6057
pressure=0,
6158
)
6259
data = learning.run(
@@ -90,3 +87,4 @@ def main(path_output):
9087
psiflow.load()
9188
path_output = Path.cwd() / "output" # stores learning results
9289
main(path_output)
90+
psiflow.wait()

examples/mof_phase_transition.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22

3-
import numpy as np
43
import requests
54
from ase.io import read
65

@@ -100,10 +99,10 @@ def main(path_output):
10099
step=50,
101100
start=0,
102101
temperature=300,
103-
temperature_threshold=3, # reset if T > T_0 + 3 * sigma
102+
max_excess_temperature=1000, # reset if T > T_0 + 1000
104103
pressure=0,
105104
)
106-
data = learning.run(
105+
data = learning.run( # noqa: F841
107106
model=model,
108107
reference=reference,
109108
walkers=walkers,
@@ -126,4 +125,4 @@ def restart(path_output):
126125
psiflow.load()
127126
path_output = Path.cwd() / "output" # stores learning results
128127
main(path_output)
129-
# restart(path_output)
128+
psiflow.wait()

examples/perovskite_defect.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def main(path_output):
9797
step=50,
9898
start=0,
9999
temperature=100,
100-
temperature_threshold=300, # reset if T > T_0 + 300 K
100+
max_excess_temperature=300, # reset if T > T_0 + 300 K
101101
pressure=0,
102102
)
103103
metrics = Metrics("perovskite_defect", "psiflow_examples")

examples/zeolite_reaction.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22

3-
import numpy as np
43
import requests
54
from ase.io import read
65

@@ -102,10 +101,10 @@ def main(path_output):
102101
step=50,
103102
start=0,
104103
temperature=300,
105-
temperature_threshold=3, # reset if T > T_0 + 3 * sigma
104+
max_excess_temperature=1000, # reset if T > T_0 + 1000
106105
pressure=0,
107106
)
108-
data = learning.run(
107+
data = learning.run( # noqa: F841
109108
model=model,
110109
reference=reference,
111110
walkers=walkers,

0 commit comments

Comments
 (0)