Free Energy - ProkopHapala/FireCore GitHub Wiki
Function Overview
double compute_Free_energy(double l1, double l2, DistConstr *dc)
Description
This function computes the free energy difference (deltaF
) between bounded and unbounded states defined by constrain distances (l1
and l2
) through a sequence of molecular dynamics simulations. The simulations are run with a distance constraint applied, and the free energy change is estimated using the Jarzynski equation, which relates work done on the system to changes in free energy.
Parameters
l1
: The initial distance for the simulation.
l2
: The final distance for the simulation.
dc
: A pointer to a DistConstr object that represents the distance constraint. The constraint is updated during the simulation to gradually increase the distance between l1 and l2.
Detailed Explanation
- Initialization:
The function first sets up some essential parameters and run system equilibration to stabilize temperature movements.
- Distance and Free Energy Calculation:
The range of distances between l1
and l2
is divided into nbStep equal increments (d = (l2 - l1) / nbStep
).
For each step i
, the distance constraint (dc
) is updated by incrementing it by d
.
Molecular dynamics simulations are performed at each distance by calling run_omp
, which stores the computed forces (Forces
) and energies (Es
).
Q: Which force is the right force? Is it necessery to have zero force in the initial position?
- Partition Function Calculation:
The partition function is computed by summing the Boltzmann factors for all forces (Forces[j]
) over the nMDSteps, i.e. averaging. The formula used is:
$$ Z_i=\frac{1}{N}\sum_{j=1}^N \exp{\left( \frac{-F_j d}{k_B T}\right) } $$
where:
$F_j$: Force (Force[j]
) at MD step j.
$T$: Temperature.
$k_B$: Boltzmann constant.
Q: How to compute local work? Force difference (or total force) times distance difference $W=\int{l_1}^{l_2}F(x) , dx$_
- Free Energy Calculation using the Jarzynski Equation:
The free energy change is computed incrementally using the Jarzynski equation:
$$ \Delta F^i = -k_BT \ln(Z_i) $$
The equation converts the partition function into the free energy difference for the current distance step.