Re: How to add a C code to NAMD properly?

From: Giacomo Fiorin (giacomo.fiorin_at_gmail.com)
Date: Wed Dec 19 2018 - 13:45:21 CST

Hi Faramarz, please see the questions asked to you earlier, and considering
answering them. You have at your disposal tclForces, tclBC and Colvars,
which can communicate to Tcl the following:
1) Atomic coordinates all gathered on the first processor core (i.e. serial
processing).
2) Atomic coordinates distributed on all processor cores (i.e. parallel
processing).
3) Functions of atomic coordinates gathered on the first processor core
(i.e. serial processing).

It seems to me that you have a variety of choices. The first step should
be identifying what looks best suitable for your problem, and read the
corresponding documentation.

Giacomo

On Tue, Dec 18, 2018 at 10:37 AM Faramarz Joodaki <fjoodaki_at_my.uri.edu>
wrote:

> Hi Fiorin,
>
> Thank you for your response! Actually, I had seen this link but I could
> not figure it out my problem on the basis of this link.
>
> Best Regards,
> Faramarz
>
> On Sun, Dec 16, 2018 at 11:37 PM Giacomo Fiorin <giacomo.fiorin_at_gmail.com>
> wrote:
>
>> Hello Faramarz, the pertinent options are described here:
>>
>> https://colvars.github.io/colvars-refman-namd/colvars-refman-namd.html#colvar|scriptedFunction
>>
>> On Sun, Dec 16, 2018 at 1:00 PM Faramarz Joodaki <fjoodaki_at_my.uri.edu>
>> wrote:
>>
>>> Hi everyone!
>>>
>>> According to Haichuan's guidance, I am trying to do some runtime
>>> calculations over a MD simulation by using Colvars. I would like to pass
>>> two parameters of Colvars to a function in the NAMD configuration file to
>>> apply my calculation on them. For example, the function in the NAMD
>>> configuration file can be:
>>>
>>> namespace eval funca { }
>>> proc calc_funca {arg1 arg2} {...}
>>>
>>> - arg1 can be Cartesian coordinate
>>> - arg2 can be a distance
>>>
>>> My question is how can I define these two variables in colvars at the
>>> same time and pass them to a function in the NAMD configuration file?
>>>
>>> Best Regards,
>>> Faramarz
>>>
>>> On Sun, Dec 16, 2018 at 12:50 PM Faramarz Joodaki <fjoodaki_at_my.uri.edu>
>>> wrote:
>>>
>>>> Dear Haochuan,
>>>>
>>>> Thank you for your guidance!
>>>>
>>>> Best Regards,
>>>> Faramarz
>>>>
>>>> On Sat, Dec 15, 2018 at 8:33 PM <yjcoshc_at_gmail.com> wrote:
>>>>
>>>>> Dear Faramarz,
>>>>>
>>>>> Please copy the email to the NAMD mailing list. This may give hints
>>>>> for other people who have the same question.
>>>>>
>>>>> As for your question, I am not very sure whether following code works:
>>>>>
>>>>> proc calc_funca {args} {
>>>>>
>>>>> set cartesian [lindex $args 0]
>>>>>
>>>>> set distance [lindex $args 1]
>>>>>
>>>>> }
>>>>>
>>>>> It may require some trying and debugging, but basically you can use
>>>>> puts to output the args to stdout and see the format of arguments from NAMD
>>>>> log.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Haochuan Chen
>>>>>
>>>>> 在 2018年12月15日 09:05, Faramarz Joodaki 写道:
>>>>>
>>>>> Dear Haochuan,
>>>>>
>>>>> Thanks again for your help! I have another question. I would be so
>>>>> grateful if you could guide me with this matter. How can I pass two or more
>>>>> parameters from colvars to the function in NAMD configuration file. For
>>>>> example:
>>>>>
>>>>> namespace eval funca { }
>>>>> proc calc_funca {arg1 arg2} {...}
>>>>>
>>>>>
>>>>> - arg1 can be cartesian coordinate
>>>>> - arg2 can be a distance
>>>>>
>>>>>
>>>>> Best Regards,
>>>>> Faramarz
>>>>>
>>>>> On Sat, Dec 8, 2018 at 1:28 PM Faramarz Joodaki <fjoodaki_at_my.uri.edu>
>>>>> wrote:
>>>>>
>>>>>> Dear Haochuan,
>>>>>>
>>>>>> Thank you very much for your complete explanation! So it seems that I
>>>>>> need to use TCL syntax for this kind of scripting.
>>>>>>
>>>>>> Best Regards,
>>>>>> Faramarz
>>>>>>
>>>>>> On Sat, Dec 8, 2018 at 6:55 AM <yjcoshc_at_gmail.com> wrote:
>>>>>>
>>>>>>> Hi Faramarz,
>>>>>>>
>>>>>>> In the NAMD configuration you can enable colvars and source this TCL
>>>>>>> script:
>>>>>>>
>>>>>>> namespace eval funca { }
>>>>>>> proc calc_funca {args} {
>>>>>>> puts $args
>>>>>>> set x0 [lindex [lindex $args 0] 0]
>>>>>>> set y0 [lindex [lindex $args 0] 1]
>>>>>>> set z0 [lindex [lindex $args 0] 2]
>>>>>>> return [expr $x0 + $y0 + $z0]
>>>>>>> }
>>>>>>>
>>>>>>> In the colvars file:
>>>>>>>
>>>>>>> colvar {
>>>>>>> name a
>>>>>>> scriptedFunction funca
>>>>>>>
>>>>>>> cartesian {
>>>>>>> atoms {atomNumbers {5}}
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> Then the x, y and z coordinates of the atom 5 will be added up and
>>>>>>> outputted to the colvars trajectory file. A more comprehensive example is
>>>>>>> in
>>>>>>> https://github.com/Colvars/colvars/blob/master/colvartools/pathCV.tcl
>>>>>>>
>>>>>>> Regards,
>>>>>>>
>>>>>>> Haochuan Chen
>>>>>>>
>>>>>>> 在 2018年12月08日 10:56, Faramarz Joodaki 写道:
>>>>>>>
>>>>>>> Dear Haochuan,
>>>>>>>
>>>>>>> Thank you again for your great guidance! Since I am new in colvars
>>>>>>> and scriptedFunction. I would be so grateful if you could give me an
>>>>>>> example about this kind of scripting. For example, if we assume x, y, and z
>>>>>>> are atom coordinates, how can we write x+y+z code in this kind of scripting?
>>>>>>>
>>>>>>> Best Regards,
>>>>>>> Faramarz
>>>>>>>
>>>>>>> On Wed, Dec 5, 2018 at 8:51 PM Faramarz Joodaki <fjoodaki_at_my.uri.edu>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Dear Haochuan,
>>>>>>>>
>>>>>>>> Thank you for your guidance! I will try your method and if I have
>>>>>>>> any questions, I will ask you about that.
>>>>>>>>
>>>>>>>> Best Regards,
>>>>>>>> Faramarz
>>>>>>>>
>>>>>>>> > On Dec 5, 2018, at 8:45 PM, yjcoshc <yjcoshc_at_gmail.com> wrote:
>>>>>>>> >
>>>>>>>> > Haochuan
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>
>> --
>> Giacomo Fiorin
>> Associate Professor of Research, Temple University, Philadelphia, PA
>> Contractor, National Institutes of Health, Bethesda, MD
>> http://goo.gl/Q3TBQU
>> https://github.com/giacomofiorin
>>
>

-- 
Giacomo Fiorin
Associate Professor of Research, Temple University, Philadelphia, PA
Contractor, National Institutes of Health, Bethesda, MD
http://goo.gl/Q3TBQU
https://github.com/giacomofiorin

This archive was generated by hypermail 2.1.6 : Wed Dec 11 2019 - 23:20:29 CST