is it possible to call a python function in PLUMED?
Dear developers,
I wonder whether we can call a Python function in PLUMED code? This python script may process on per-atom values, and then return per-atom values or scalar values. The scalar values will act as collective variables. And whether the calculated per-atom values can be transferred back to MD code?
Thank you in advance for your help?
Hi,
currently it is not possible. However, we are discussing about this.
I leave this issue open meanwhile so that when the discussion starts we can notify you.
Giovanni
Dear GiovanniBussi,
Thank you so much for your reply. I hope to see this implementation soon on the next patch of PLUMED. This functionality will extremely useful for who want to define their own CVs, as well do on-the-fly post-process.
Please let me know if you have already the testing-patch for this
Thank,
@thangckt this requires quite a bit of work, so unfortunately I am afraid it won't be implemented soon...
@GiovanniBussi Can you let a custom-variable be imported to PLUMED ? This custom-variable may be calculated from MD code (outside Plumed) on each MD-step, then be imported into PLUMED (like as PLUMED receive atomic trajectories?) I am using LAMMPS, and I think this can be an option in ''fix plumed..." command
Ex: fix pl all plumed all plumedfile ... outfile p.log ... input v_VarName where "v_VarName" is the custom variable calculated in MD code
This imported variable, then can be serve as CV. How do you think about this ?
Plumed interface allows this. The relevant cmd string is setExtraCV. Not much documentation but there is an example here:
https://github.com/plumed/plumed2/blob/master/regtest/basic/rt-make-extracv/main.cpp
However, you need to modify the LAMMPS to do so
Il giorno sab 3 ago 2019 alle 10:05 thangckt [email protected] ha scritto:
@GiovanniBussi https://github.com/GiovanniBussi Can you let a custom-variable be imported to PLUMED ? This custom-variable may be calculated from MD code (outside Plumed) on each MD-step, then be imported into PLUMED (like as PLUMED receive atomic trajectories?) I am using LAMMPS, and I think this can be an option in ''fix plumed..." command Ex: fix pl all plumed all plumedfile ... outfile p.log ... input v_VarName where "v_VarName" is the custom variable calculated in MD code
How do you think about this ?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/plumed/plumed2/issues/508?email_source=notifications&email_token=ABBNCXU35PSXNAE25XSKFHTQCU35TA5CNFSM4IIHYRR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3PJTEA#issuecomment-517904784, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBNCXXNLYNW5DWIMVJDGR3QCU35TANCNFSM4IIHYRRQ .
-- Sent from Gmail mobile
Dear GiovanniBussi ,
I am very glad to hear about that. But... can you have a little more detail explanation? Since I just play as an "end user" rather than a deveploper. Or can you tell me who is capable to modify the "fix plumed..." command in Lammps. May I ask for their help? Thank you so much.
The real question is how you want to compute the variable that you plan to feed to plumed.
You first wrote you want to use python, which I guess means you want to write a python script to compute the variable given the atomi coordinates. I think this is useful since it allows more flexibility to users that know how to code in Python and do not know hot to code in c++. This is something that will be available at some time in the (not near) future.
Now you say you want to pass the variable from LAMMPS, but you do not specify how you want to compute the variable. I think you should talk to someone that knows how to implement stuff in LAMMPS and provide more detail (which variable do you need? why do you want it to be implemented outside plumed?).
In case you know how to compute a variable (and its derivatives wrt atomic coordinates) inside LAMMPS, we can tell you how to pass it to PLUMED
Giovanni