lammps / lammps

Public development project of the LAMMPS MD software package
https://www.lammps.org
GNU General Public License v2.0
2.23k stars 1.71k forks source link

[BUG] fix modify energy has no effect on fix orient/eco #2537

Closed 1314DA closed 3 years ago

1314DA commented 3 years ago

Summary

Grain growth can be studied by modifying the per atom potential energy of differently oriented grains using the fix orient/eco. The energy change cannot be include in the thermodynamic output as expected from the fix_modify energy as described in the documentation.

LAMMPS Version and Platform

Expected Behavior

The fix orient/eco adds or substracts potential energy to crystalline grains provided the cyrstallographic orientation. This can initiate grain growth based on a gradient in potential energy if differently oriented grains are present in a simulation cell. Per default, the energy contribution of the fix should not be included in the potential energy that is output to thermo or per-atom potential energy. According to the documentation this behavior can be changed using the fix_modify energy. The new potential energy should then be the sum of the normal pair potential contribution and the contribution from the fix orient/eco.

We have applied this fix to simple examples such as Cu (see files attached) but also systems that show less mobile grain boundaries. In the latter case larger driving forces can be applied and the below described problem becomes more obvious. To make statements about the potential energy we have used careful post-processing that includes temporal and spatial averaging of per atom energies to track the excess provided by the fix.

Actual Behavior

The grains are properly recognized by the fix (can be seen by the fix orient eco output) and grain growth works (see dump). However, the per-atom potential energy does not change if the fix_modify energy is set to either yes or no.

Steps to Reproduce

The files attached can be run with LAMMPS and produce the described output. Comment/uncomment the line regarding the fix_modify energy to observe the problem. Per atom energies can be temperorally and spatially averaged for the grains using some post-processing tool. We used Ovito (ovito.org)

Further Information, Files, and Links

Cu_u6.txt equilibrated_300K.txt grain.txt input.txt

akohlmey commented 3 years ago

fix_modify energy yes generally only applies to the global potential (and thus total) energy. The addition to the per-atom potential energy has so far only been implemented by fix cmap.

1314DA commented 3 years ago

I again looked at the cumulated energies in the thermodynamic output. It confirms your statement, that the thermo output TotEngand PotEng are correctly ignoring/including the fix orient/eco energy contribution when the fix_modify energy is set to no/yes. Therefore, only the per atom potential energies are treated inconsistently, since the sum of all per atom potential energies does not match the thermo PotEng in the thermodynamic output.

For illustration I added a plot where the behavior is shown in the right part of the figure. The solid line drops because the energetically favorable grain grows. However, the cumulated energy from per atom potential energies does not follow.

compare_thermo_and_cumulated_pe.pdf

akohlmey commented 3 years ago

I again looked at the cumulated energies in the thermodynamic output. It confirms your statement, that the thermo output TotEngand PotEng are correctly ignoring/including the fix orient/eco energy contribution when the fix_modify energy is set to no/yes. Therefore, only the per atom potential energies are treated inconsistently, since the sum of all per atom potential energies does not match the thermo PotEng in the thermodynamic output.

Let me rephrase, it is currently not expected for this fix (and all others) that the per-atom energy is changed with fix_modify <fix-ID> energy yes. The exception to this is fix cmap, which is the only fix that adds energy to the per-atom potential energy. If there is anything at fault, it is the documentation not stating this more clearly. This will be rectified with the changes requested in issue #2528.

For illustration I added a plot where the behavior is shown in the right part of the figure. The solid line drops because the energetically favorable grain grows. However, the cumulated energy from per atom potential energies does not follow.

there is no need to further demonstrate this since I see it clearly in the source code.

sjplimp commented 3 years ago

I want to clarify what the problem was here. The fix was missing a flag that would sum its global energy to the global potential energy. There was no peratom energy computed by the fix or documented that it would be accessible for output. A new PR #2560 should fix the former issue for global energy. As Axel said this fix does not compute peratom energy, nor do its sister fixes: orient/fcc or bcc.