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

From: yjcoshc_at_gmail.com
Date: Sat Dec 15 2018 - 19:33:28 CST

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
> <mailto: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
> <mailto: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 <mailto: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
>> <mailto:yjcoshc_at_gmail.com>> wrote:
>> >
>> > Haochuan
>>
>

This archive was generated by hypermail 2.1.6 : Tue Dec 31 2019 - 23:20:24 CST