question regarding source code modification.

Hello! LAMMPS users,

I have a question about source code modification.

I tried modifying ‘ tersoff.cpp ’ and ‘ tersoff.h ‘ for my research,

(for example, adding a function related to ‘eta’ which relates to repulsive bond-order in Tersoff potential)

but after compiling it to an executable file and testing it,

I found that there are some kind of error in potential energy and virial pressure calculations.

Step KinEng PotEng compute_temp compute_virial Volume Density MSDfirst
25001 624.58544 0 4836.8401 0 20012.876 2.330353 118834.03
25100 643.91117 0 4986.5001 0 20012.876 2.330353 120259.66
25200 669.19833 0 5182.3259 0 20012.876 2.330353 121740.52
25300 654.37363 0 5067.5223 0 20012.876 2.330353 123235.68
25400 643.78005 0 4985.4847 0 20012.876 2.330353 124720.79
25500 643.9345 0 4986.6808 0 20012.876 2.330353 126210.34
25600 647.89696 0 5017.3664 0 20012.876 2.330353 127711.36
25700 651.2926 0 5043.6625 0 20012.876 2.330353 129226.24
25800 644.05136 0 4987.5857 0 20012.876 2.330353 130748.86
25900 630.08448 0 4879.4251 0 20012.876 2.330353 132265.52

like that,

For now, I’m guessing that the problem is related to a function like < ev_tally , v_tally3 >

Is there any instructive advice or short comment about these function?

I will keep trying to find a solution but it is hard to me to understand upper hierarchy function.

Jo You-hwan
mangoman@…5003…

Hello! LAMMPS users,

I have a question about source code modification.

I tried modifying ‘ tersoff.cpp ' and ‘ tersoff.h ‘ for my research,

(for example, adding a function related to ‘eta’ which relates to repulsive
bond-order in Tersoff potential)

but after compiling it to an executable file and testing it,

I found that there are some kind of error in potential energy and virial
pressure calculations.

Step KinEng PotEng compute_temp compute_virial Volume Density MSDfirst
   25001 624.58544 0 4836.8401 0 20012.876
2.330353 118834.03
   25100 643.91117 0 4986.5001 0 20012.876
2.330353 120259.66
   25200 669.19833 0 5182.3259 0 20012.876
2.330353 121740.52
   25300 654.37363 0 5067.5223 0 20012.876
2.330353 123235.68
   25400 643.78005 0 4985.4847 0 20012.876
2.330353 124720.79
   25500 643.9345 0 4986.6808 0 20012.876
2.330353 126210.34
   25600 647.89696 0 5017.3664 0 20012.876
2.330353 127711.36
   25700 651.2926 0 5043.6625 0 20012.876
2.330353 129226.24
   25800 644.05136 0 4987.5857 0 20012.876
2.330353 130748.86
   25900 630.08448 0 4879.4251 0 20012.876
2.330353 132265.52

like that,

For now, I’m guessing that the problem is related to a function like <
ev_tally , v_tally3 >

Is there any instructive advice or short comment about these function?

there *is* a comment in the source code (file pair.cpp):

/* ----------------------------------------------------------------------
   tally eng_vdwl and virial into global and per-atom accumulators
   need i < nlocal test since called by bond_quartic and dihedral_charmm
------------------------------------------------------------------------- */

so, this function takes the contributions to energy and virial and
adds them to the corresponding accumulator variables, if requested.

in general, in LAMMPS it is not advisable to modify source directly
for the purpose you are describing. you are destroying your reference
through this. the better approach is to create a derived class (there
are a few already) and then only modify/override the methods that are
relevant to your model/modification.

axel.

You don’t need to “guess”. What we do usually is to comment out all energy/force/virial terms and turning then back one-by-one then compare the thermodynamic properties. Things you can compare are pe and the sum of “compute pe/atom”, as well as press and the sum of “compute stress/atom”, etc.

Ray