I want to use lammps to calculate the constant volume heat capacity(Cv) of Ag nanoparticles during the heating process, so I heated the particles in the NVT ensemble, outputting temperature and total energy. Finally, I used the formula (dE/dT) (N, V) to solve for the constant volume heat capacity, but I was surprised to find that the heat capacity had a negative value. What does a negative heat capacity represent in lammps? How to avoid or handle it?
I have read other posts about calculating heat capacity and tried to use Cv * (kB * T ^ 2)=<E ^ 2>-^ 2 to calculate heat capacity. However, as mentioned in other posts, the results not only have poor stability, but also have negative values for heat capacity.
I don’t think it’s a data processing issue, because when I checked the data output from Lammps, I found that during the simulated heating process, there was a situation where a higher temperature corresponds to a relatively low energy. This will cause the derivative to be negative (maybe).
Code for my heating and output section:
velocity all create 300 7892 rot yes dist gaussian
fix 1 all nvt temp 300 300 $(100.0*dt)
run 10000
unfix 1
reset_timestep 0
thermo 10000
thermo_style custom step temp pe etotal press vol
fix 1 all nvt temp 300 1500 $(100.0*dt)
run 2000000
This raises many doubts about your analysis procedure. The variance of energy cannot be negative*, no matter how it has fluctuated over your trajectory, so if you get a negative heat capacity from that then there is definitely something wrong with your numerical processing.
Please describe the exact steps used to process the information from your LAMMPS log file into your calculated heat capacity (and even then, there is no guarantee that correcting your numerical procedure will correct other possible problems, such as possible unsuitability of your force field – which you do not describe – or calculating an equilibrium property from such a short non-equilibrium run).
*For a large enough dataset of entirely identical numbers, naive implementations might return a small negative number rather than zero due to floating point subtraction error.
Thank you for your suggestion. I will carefully consider the issue you mentioned. But let’s temporarily ignore the analysis procedure issue and only look at the lammps output file.During the heating process, a higher temperature corresponds to a lower total energy(compared to several surrounding temperatures). How do you view this problem?
As @srtee stated it is impossible to help you without the exact procedure you used for computation.
Also the naive numerical computation of the standard deviation/variance is known to give wrong negative results. This is the most probable source for your result.
See this blog post for an example of the issue and this one for an example of a one-pass algorithm that gives the correct result.
Is this the part you are using to calculate the heat capacity? For you to calculate the heat capacity, be it within the formalism of classical thermodynamics (related to the dU/dT as you mentioned) or the statistical thermodynamics one (the one related to <E ^2> as you mentioned), you need to have equilibrated your system beforehand.
For example, if you are to approximate the dU/dT derivative with a (U_final - U_initial)/(T_final - T_initial), you need to have the thermodynamic value of U for the given thermodynamic state, not instantaneous ones. This means that you need to first equilibrate your system at the given corresponding temperature and volume, have a representative amount of microstates and average the value of U to get U_final and U_initial. You cannot get isolated values on the flight like you seem to be doing since these values are quite different than the rightful U_final and U_initial as your system’s instantaneous properties are free to fluctuate.
EDIT: in case it was not clear from my writing, you would need to do this for two thermodynamic states: (T_initial,V) to get U_initial and then (T_final,V) to get U_final.
I will give this a go, hopefully I am not too rusty in my thermodynamics ^^
So, heat capacity should be the amount of heat you need to provide to your system, at a given thermodynamic state, in order to increase its temperature by 1 degree (of whatever unit you are using to measure temperature). The meaning of temperature in the atomistic-ish scale is related to the average kinetic energy the structural units (e.g. atoms) in your system have. The total internal energy of your system corresponds to E_kinetic + E_potential (+ E_radiation, but this one only occurs in specific scenarios).
A negative heat capacity (in LAMMPS or in whatever place of the planet) would then mean that, at the given thermodynamic state your system is, you actually do not need to provide any energy to increase the temperature of your system. This could happen if the E_potential of the new thermodynamic state is such that it decreases to the point where it is not only compensating the amoutn of energy you would need to provide to increase the overall E_kinetic but it goes beyond that, to the point where a “release” of energy is observed.
EDIT: But make sure you are calculating things correctly (either via the dU/dT or the <E^2> approach as Germain and Shern suggested) since this is probably the issue there. I am just trying to explain one of your questions related to negative heat capacity, not saying that your calculation is correct or anything.
I don’t see how that is possible. The heat capacity you describe is a bulk material property, but nanoparticles are not bulk. For starters, the individual nanoparticles can expand and shrink.