Skip to content

Commit

Permalink
small updates in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenhaute committed Nov 21, 2023
1 parent feac929 commit f06a742
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
31 changes: 15 additions & 16 deletions examples/alanine_nwchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@
from psiflow.learning import SequentialLearning
from psiflow.metrics import Metrics
from psiflow.models import NequIPConfig, NequIPModel
from psiflow.reference import NWChemReference
from psiflow.reference import PySCFReference
from psiflow.walkers import BiasedDynamicWalker, DynamicWalker, PlumedBias


def get_reference():
calculator_kwargs = {
"basis": {e: "3-21g" for e in ["H", "C", "O", "N"]},
"dft": {
"xc": "pw91lda",
"mult": 1,
"convergence": {
"energy": 1e-6,
"density": 1e-6,
"gradient": 1e-6,
},
#'disp': {'vdw': 3},
},
}
return NWChemReference(**calculator_kwargs)
routine = """
from pyscf import dft
mf = dft.RKS(molecule)
mf.xc = 'pbe,pbe'
energy = mf.kernel()
forces = -mf.nuc_grad_method().kernel()
"""
basis = "cc-pvtz"
spin = 0
return PySCFReference(routine, basis, spin)


def get_bias():
Expand Down Expand Up @@ -93,7 +91,7 @@ def main(path_output):

# this is mostly a toy script to test code paths rather
# than an actually working example
data = learning.run(
data = learning.run( # noqa: F841
model=model,
reference=reference,
walkers=walkers_md + walkers_mtd,
Expand All @@ -104,3 +102,4 @@ def main(path_output):
psiflow.load()
path_output = Path.cwd() / "output"
main(path_output)
psiflow.wait()
14 changes: 6 additions & 8 deletions examples/copper_emt.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import logging
from pathlib import Path

import numpy as np
import requests
from ase.build import bulk, make_supercell

import psiflow
from psiflow.committee import Committee
from psiflow.data import Dataset, FlowAtoms
from psiflow.learning import CommitteeLearning, SequentialLearning, load_learning
from psiflow.data import Dataset
from psiflow.learning import CommitteeLearning, SequentialLearning
from psiflow.metrics import Metrics
from psiflow.models import MACEConfig, MACEModel
from psiflow.reference import EMTReference
from psiflow.state import load_state
from psiflow.walkers import DynamicWalker, PlumedBias
from psiflow.walkers import DynamicWalker


def main(path_output):
Expand All @@ -22,7 +19,7 @@ def main(path_output):
path_committee = path_output / "learn_committee"
path_committee.mkdir(parents=True)

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

config = MACEConfig()
Expand Down Expand Up @@ -56,7 +53,7 @@ def main(path_output):
step=40,
start=0,
temperature=100,
temperature_threshold=300, # reset if T > T_0 + 300 K
max_excess_temperature=300, # reset if T > T_0 + 300 K
pressure=0,
)
data = learning.run(
Expand Down Expand Up @@ -90,3 +87,4 @@ def main(path_output):
psiflow.load()
path_output = Path.cwd() / "output" # stores learning results
main(path_output)
psiflow.wait()
7 changes: 3 additions & 4 deletions examples/mof_phase_transition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path

import numpy as np
import requests
from ase.io import read

Expand Down Expand Up @@ -100,10 +99,10 @@ def main(path_output):
step=50,
start=0,
temperature=300,
temperature_threshold=3, # reset if T > T_0 + 3 * sigma
max_excess_temperature=1000, # reset if T > T_0 + 1000
pressure=0,
)
data = learning.run(
data = learning.run( # noqa: F841
model=model,
reference=reference,
walkers=walkers,
Expand All @@ -126,4 +125,4 @@ def restart(path_output):
psiflow.load()
path_output = Path.cwd() / "output" # stores learning results
main(path_output)
# restart(path_output)
psiflow.wait()
2 changes: 1 addition & 1 deletion examples/perovskite_defect.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def main(path_output):
step=50,
start=0,
temperature=100,
temperature_threshold=300, # reset if T > T_0 + 300 K
max_excess_temperature=300, # reset if T > T_0 + 300 K
pressure=0,
)
metrics = Metrics("perovskite_defect", "psiflow_examples")
Expand Down
5 changes: 2 additions & 3 deletions examples/zeolite_reaction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pathlib import Path

import numpy as np
import requests
from ase.io import read

Expand Down Expand Up @@ -102,10 +101,10 @@ def main(path_output):
step=50,
start=0,
temperature=300,
temperature_threshold=3, # reset if T > T_0 + 3 * sigma
max_excess_temperature=1000, # reset if T > T_0 + 1000
pressure=0,
)
data = learning.run(
data = learning.run( # noqa: F841
model=model,
reference=reference,
walkers=walkers,
Expand Down

0 comments on commit f06a742

Please sign in to comment.