Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenhaute committed Jul 20, 2024
1 parent cbbeed4 commit 6533ce5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions examples/iron_harmonic_fcc_bcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import psiflow
from psiflow.data import Dataset
from psiflow.free_energy import Integration, compute_harmonic
from psiflow.free_energy import Integration, compute_harmonic, harmonic_free_energy
from psiflow.geometry import Geometry
from psiflow.hamiltonians import Harmonic, MACEHamiltonian
from psiflow.sampling import optimize
Expand Down Expand Up @@ -39,8 +39,7 @@ def main():
integration = Integration(
harmonic,
temperatures=[temperature],
delta_hamiltonian=(scaling - 1)
* harmonic, # makes sampling distribution slightly broader
delta_hamiltonian=(scaling - 1) * harmonic,
delta_coefficients=np.linspace(0, 1, num=4, endpoint=True),
)
walkers = integration.create_walkers( # noqa: F841
Expand All @@ -51,15 +50,18 @@ def main():
integration.compute_gradients()

reduced_f = integration.along_delta(temperature=temperature).result()
f_harmonic = harmonic.compute_free_energy(
temperature=temperature, quantum=False
f_harmonic = harmonic_free_energy(
hessian,
temperature=temperature,
quantum=False,
)
simulated[name] = (f_harmonic.result() + reduced_f[-1]) / beta

# theoretical
harmonic = Harmonic(minimum, scaling * hessian.result())
f_harmonic_scaled = harmonic.compute_free_energy(
temperature=temperature, quantum=False
f_harmonic_scaled = harmonic_free_energy(
scaling * hessian.result(),
temperature=temperature,
quantum=False,
)
theoretical[name] = f_harmonic_scaled.result() / beta

Expand Down
4 changes: 2 additions & 2 deletions examples/water_cp2k_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import psiflow
from psiflow.data import Dataset
from psiflow.geometry import Geometry
from psiflow.reference import CP2K
from psiflow.reference import CP2K, evaluate


def main():
Expand Down Expand Up @@ -42,7 +42,7 @@ def main():
for i in range(50):
g = copy.deepcopy(geometry)
g.per_atom.positions += i * delta_x
states.append(cp2k.evaluate(g))
states.append(evaluate(g, cp2k))
data = Dataset(states)
energy = data.get("per_atom_energy").result()
forces = data.get("forces").result()
Expand Down

0 comments on commit 6533ce5

Please sign in to comment.