prisms-center / CASMcode

First-principles statistical mechanical software for the study of multi-component crystalline solids
Other
105 stars 69 forks source link

Query regarding formation energy convergence with respect to the supercell in canonical MC calculations #338

Open pandeydhanshree opened 9 months ago

pandeydhanshree commented 9 months ago

Hello I am trying to perform canonical MC calculations with A,B and Va as the components of the alloy at a certain temperature (to begin with I took 5K). I have provided the compositions , say, "comp": [0.66666667, 0.22222222, 0.11111111] in my input file. I intended to compare the values of formation energy (EF) with respect to change in the supercell size. When my supercell size is such that there are in total 1728 atoms, the EF is -0.54165 eV(/unit cell?) Similarly, with supercell of 5832 atoms, the EF is -0.74025 eV/unitcell. Both the values are obtained at same temperature, with only difference in the supercell sizes. Does, this mean the formation energy is not converged with smaller supercells? Also, can we obtain the EF per unit atom (if the reported values are in per-unitcell). Just to let you know, my primitive cell is bcc. Looking forward to have any response in this direction. Thank you and best regards Dhanshree

xivh commented 9 months ago

It is possible that the energy is not converged. You could try a few different volumes and see if the energy is converging.

The energy is per unit cell, but you can add any CASM query to the measurements, for example

"measurements" : [
  { 
      "quantity" : "formation_energy_per_atom"
  }
]

Also keep in mind that the formation energy is not the free energy.

pandeydhanshree commented 9 months ago

Thank you so much. I will try with a few more supercells to check the energy convergence. Besides formation energy, we also find potential energy in the output file. Is that the free energy? For canonical ensemble, I am getting the same value for formation energy and the potential energy. In other words, how to obtain the free energies for canonical MC calculations? Can you comment something on this? Thank you again and best regards Dhanshree

xivh commented 9 months ago

The potential energy output by the Monte Carlo simulation is not integrated. For the canonical ensemble, it is equal to the formation energy. The Monte Carlo simulation is described in detail in this paper. Here is a derivation for the canonical free energy integration.

Canonical Monte Carlo Integration

The free energy in the canonical ensemble is the Helmholtz free energy, $F$. The Helmholtz free energy is defined as

F(T, V, N) = U - TS

where $U$ is the internal energy ("formation energy" from CASM Monte Carlo, calculated at each temperature). In order to calculate $F$ from the internal energy, we need an entropy. CASM does not give an entropy directly, but $F$ can be calculated by integrating from a reference point where entropy is known. The goal is to find

F(T, V, N) = F_0(T_0, V_0, N_0) + \int_{\text{ref}}^{\text{end}} dF

where $F_0$ is the free energy of a reference state with known entropy and the integration is performed along a path from the reference state to the end state. Two common reference states are a composition extreme, where the configurational entropy is 0, or a low temperature where CASM will calculate the low temperature expansion of the free energy. Let's consider the second case. The path starts at some composition and increases in temperature with the composition fixed.

The differential form of the Helmholtz free energy is

dF = dU - TdS - SdT = TdS - PdV + \mu dN - TdS - SdT = -pdV + \mu dN - SdT.

This differential still has $S$, which is a problem. Instead of $dF$, we use $d(\beta F)$ where $\beta = \frac{1}{k_BT}$:

d(\beta F) = \beta dF + F d\beta = \beta(-pdV + \mu dN - SdT) + (U - TS)(- \frac{1}{T}\beta)dT.

Note that $\frac{\partial \beta}{\partial T}= \frac{\partial}{\partial T}(\frac{1}{k_BT})= -\frac{1}{k_BT^2} = -\frac{1}T\beta$ and therefore $d\beta = (-\frac{1}T\beta) dT$. This will come up again for the integration step. Canceling terms and setting constant $V$ and $N$ due to the canonical ensemble results in

d(\beta F) = -\frac{U}{T}\beta dT = Ud\beta.

The integration is now possible:

F(T, V, N) = \frac{1}{\beta} (\beta F) = \frac{1}{\beta}\left[\beta_0 F_0 + \int_{\text{ref}}^{\text{end}} d(\beta F)\right] = \frac{1}{\beta} \left[\beta_0F_0 + \int_{\beta_0}^{\beta} Ud\beta\right].

In order to calculate this from the Monte Carlo data, change variables from $\beta$ to $T$ using the above expression for $d\beta$ and replace the integral with a sum:

F(T, V, N) = \frac{T}{T_0} F_0 - T \sum_{t=T_0}^T \frac{U(t)}{t^2}\Delta T

with temperature step size $\Delta T$ and formation energy per primitive cell $U(t)$ at each temperature $t$.

Because the canonical ensemble has a fixed volume, the integration must be performed with energies normalized to the primitive unit cell and not the number of atoms (this is important if there are vacancies). Also keep in mind that the derivative of $F$ is discontinuous at a first order phase transition, so the integration path should not pass through any phase transitions.

pandeydhanshree commented 9 months ago

Thanks a lot. I will go through the paper and free energy integration part. With regards Dhanshree

pandeydhanshree commented 7 months ago

Hello As mentioned above, I am trying to perform canonical MC calculations with A,B and vacancy (Va) as the components of the alloy at a certain temperature. So, my training DFT data contains structures like AB, BVa, AVa, and ABVa. Now I wish to see the formation energy trends at different temperatures for, let say, a: Pure AB system ("comp": [0.49, 0.51],) b: Low vacancy concentration ("comp": [0.49, 0.49, 0.02],) c: High vacancy concentration ("comp": [0.45454545, 0.45454545, 0.09090910],) The results I obtain (attached below) are not consistent with what we obtain from 0K cluster expansion/DFT energies (structures with vacancy have higher formation energy). Can you please have a look at the plots and let me know what is the issue. Thank you and best regards Dhanshree Casm-MC-results.pdf