Skip to content

Commit 11eb457

Browse files
committed
last-part
1 parent 9b46ff2 commit 11eb457

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

examples/free-energy/free-energy.py

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def PES(x, y , z):
263263
# The initial configuration for this calculation should correspond to an
264264
# opitimized position. You can obtain this from the last frame of the geop trajectory.
265265

266-
ase.io.write('init_harm.xyz',geop_traj,format='extxyz')
266+
ase.io.write('init_harm.xyz',geop_traj[-1],format='extxyz')
267267

268268
# %%
269269
# The `bash` command for this would be
@@ -405,5 +405,63 @@ def quantum_harmonic_free_energy(Ws, T):
405405
# is the path-integral estimator for a positon dependent operator
406406
# for :math:`\hat{H}(\lambda)`.
407407

408+
# %%
409+
#
410+
# Step 3: Harmonic to anharmonic thermodynamic integration
411+
# --------------------------------------------------------
412+
#
413+
# A full quantum thermodynamic integration calculation requires
414+
# knowledge of the harmonic reference. Luckily we have just performed these
415+
# calculations!
416+
#
417+
418+
# %%
419+
# Classical Statistical Mechanics
420+
# -------------------------------
421+
#
422+
# Let's first compute the anharmonic free energy difference within the classical approximation.
423+
#
424+
# To create the input file for I-PI we need to defines a "mixed"
425+
# :math:`\lambda`-dependent Hamiltonian. Let's see the new most important parts.
426+
#
427+
# This i-PI calculation includes two "forcefield classes"
428+
#
429+
# .. code-block:: xml
430+
#
431+
# <!--> defines the anharmonic PES <-->
432+
# <ffsocket name='driver' mode='unix' matching='any' pbc='false'>
433+
# <address> f0 </address>
434+
# <latency> 1e-3 </latency>
435+
# </ffsocket>
436+
#
437+
# a standard socket
438+
#
439+
# and
440+
#
441+
# .. code-block:: xml
442+
#
443+
# <!--> defines the harmonic PES <-->
444+
# <ffdebye name='debye'>
445+
# <hessian shape='(3,3)' mode='file'> HESSIAN-FILE </hessian>
446+
# <x_reference mode='file'> X-REF-FILE <!--> relative path to a file containing the optimized positon vector <--> </x_reference>
447+
# <v_reference> V-REF <!--> the value of the PES at its local minimum <--> </v_reference>
448+
# </ffdebye>
449+
#
450+
# an intrinsic harmonic forcefield that builds the harmonic potential.
451+
# This requires :math:`q_0`, :math:`V(q_0)` and the full Hessian.
452+
# `HESSIAN-FILE` is `harm.phonons.hess` which is the file containing the
453+
# full hessian.
454+
# X-REF-FILE is a file with the optimized positon vector
455+
#
456+
457+
with open('ref.data','w') as xref:
458+
for pos in geop_traj[-1].positions:
459+
xref.write(f'{pos[0]} {pos[1]} {pos[2]} \n')
460+
461+
# V-REF can be obtained from the potential energy in `harm.out`
462+
463+
V-ref = np.readtxt('harm.out')
464+
print(V-ref)
465+
408466

409467

0 commit comments

Comments
 (0)