{"action":"opened","issue":{"url":"https://api.github.com/repos/lammps/lammps/issues/995","repository_url":"https://api.github.com/repos/lammps/lammps","labels_url":"https://api.github.com/repos/lammps/lammps/issues/995/labels{/name}","comments_url":"https://api.github.com/repos/lammps/lammps/issues/995/comments","events_url":"https://api.github.com/repos/lammps/lammps/issues/995/events","html_url":"https://github.com/lammps/lammps/issues/995","id":340386891,"node_id":"MDU6SXNzdWUzNDAzODY4OTE=","number":995,"title":"Tail corrections missing in gcmc insertions and deletions","user":{"login":"marshallmcdonnell","id":17032543,"node_id":"MDQ6VXNlcjE3MDMyNTQz","avatar_url":"https://avatars1.githubusercontent.com/u/17032543?v=4","gravatar_id":"","url":"https://api.github.com/users/marshallmcdonnell","html_url":"https://github.com/marshallmcdonnell","followers_url":"https://api.github.com/users/marshallmcdonnell/followers","following_url":"https://api.github.com/users/marshallmcdonnell/following{/other_user}","gists_url":"https://api.github.com/users/marshallmcdonnell/gists{/gist_id}","starred_url":"https://api.github.com/users/marshallmcdonnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marshallmcdonnell/subscriptions","organizations_url":"https://api.github.com/users/marshallmcdonnell/orgs","repos_url":"https://api.github.com/users/marshallmcdonnell/repos","events_url":"https://api.github.com/users/marshallmcdonnell/events{/privacy}","received_events_url":"https://api.github.com/users/marshallmcdonnell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-11T20:06:14Z","updated_at":"2018-07-11T20:06:14Z","closed_at":null,"author_association":"NONE","body":"## Summary\r\n\r\nIn `fix gcmc`, the tail corrections for the `full_energy` option do not appear to be included for insertions and deletions. This was previously discussed in the mailing list [here](http://lammps.sandia.gov/threads/msg67252.html). A key note in the discussion was the following:\r\n\r\n> User: Are they ( the tail corrections ) updated every time a particle is added/removed or calculated once\r\n> the simulation is initialized and constant since?\r\n\r\n>> @akohlmey: they are computed during the init-phase of a run or minimization, and\r\n- if i read the code correctly - not updated during fix gcmc. however,\r\nthe pair class also has a function Pair::reinit() that is currently\r\nused by fix adapt to update various precomputed constants including\r\nthe tail correction, when it changes potential parameters and it may\r\nbe possible to insert this into the fix gcmc workflow.\r\n\r\nTesting with debug lines inserted into `src/MC/fix_gcmc.cpp` to print out `force->pair->etail` confirm that the tail correction is not being up dated due to the change in density (insertions and deletions)using a modified version of `/examples/gcmc/in.gcmc.lj` (in the \"Steps to Reproduce\" section)\r\n\r\n## Type of Issue\r\n\r\nBug Report\r\n\r\n\r\n## LAMMPS Version\r\n\r\nVersion tested on: `LAMMPS (29 Jun 2018)`\r\n\r\nMachine: \r\n\r\n  * Ubuntu 17.10 artful \r\n  * gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0 \r\n  * Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (4-core)\r\n\r\n## Expected Behavior \r\n\r\nThe potential energy (PE) tail correction changes with density. Thus, the insertions [deletions] should include a (relatively) small PE tail correction for the energy difference U(N+1)- U(N) [U(N-1) - U(N)].\r\n\r\n## Actual Behavior\r\n\r\nThe `force->pair->etail` appears to stay constant with the insertion and deletion tests.\r\n\r\n\r\nThus, the `energy_full()` calls do not update the difference in the PE tail corrections (delta_etail) due to the change in density.\r\n\r\n## Steps to Reproduce\r\n\r\nI don't know exactly how to reproduce this in a simpler way than to go into `FixGCMC::attempt_atomic_insertion_full()` function and add the following at approximately [line 1672](https://github.com/lammps/lammps/blob/f2883318748b18e6620bf214d57b58c3f636494a/src/MC/fix_gcmc.cpp#L1672)\r\n\r\n```\r\ndouble tail_before;\r\ntail_before = force->pair->etail;\r\n```\r\n\r\nAnd the following to approximately [line 1703]\r\n(https://github.com/lammps/lammps/blob/f2883318748b18e6620bf214d57b58c3f636494a/src/MC/fix_gcmc.cpp#L1703) or really anywhere after `atom->avec->create_atom(ngcmc_type,coord);` on [line 1674](https://github.com/lammps/lammps/blob/f2883318748b18e6620bf214d57b58c3f636494a/src/MC/fix_gcmc.cpp#L1674)\r\n\r\n```\r\ndouble tail_after;\r\ntail_after = force->pair->etail;\r\n```\r\n\r\nThen print the results after the previous command:\r\n```\r\nprintf(\"tail before %f tail after %f\\n\", tail_before, tail_after);\r\n```\r\n\r\nThis is the input script used:\r\n\r\n```\r\nvariable        mu index -1.25\r\nvariable        temp index 2.0\r\nvariable        disp index 1.0\r\nvariable        lbox index 5.0\r\nunits           lj\r\natom_style      atomic\r\npair_style      lj/cut 3.0\r\npair_modify tail yes # turn of to avoid triggering full_energy\r\nlattice     sc 0.4\r\nregion      box block 0 ${lbox} 0 ${lbox} 0 ${lbox}\r\ncreate_box   1 box\r\ncreate_atoms 1 box\r\npair_coeff  * * 1.0 1.0\r\nmass        * 1.0\r\ngroup       gcmcgroup type 1\r\nfix             mygcmc gcmcgroup gcmc 1 2 0 1 29494 ${temp} ${mu} ${disp}\r\ncompute_modify  thermo_temp dynamic yes\r\nthermo_style    custom step temp pe press atoms density etail\r\nthermo_modify   norm no\r\nthermo          1\r\nrun            1\r\n```\r\n\r\nOutput shows that the `etail` does not change::\r\n```\r\ntail before -4845.920013 tail after -4845.920013\r\n```\r\n\r\nFrom Equation 5.6.8 and 5.6.9 of Frenkel and Smit _Understanding Molecular Simulation_ 2nd edition, I believe there is thus a missing factor of exp(beta*delta_etail) in the acceptance and rejection criteria checks.\r\n\r\n## Plan for Fix / Pull Request: \r\nInsert this into `fix gcmc` workflow:\r\n\r\n> `if (force->pair->tail_flag) \r\nforce->pair->reinit();` \r\n\r\nSpecifically, in the `_full` variants of the insertion and deletion functions (atomic and molecular).\r\n"}}
{"actor":{"display_login":"marshallmcdonnell"}}