Re: colvars: How to implement a collective variable of vector type?

From: yjcoshc (yjcoshc_at_gmail.com)
Date: Wed Mar 14 2018 - 04:13:19 CDT

Hi Giacomo,

I have followed the steps decribed in
http://colvars.github.io/doxygen/html/classcolvar_1_1cvc.html. However
the object file isn't compiled when compiling NAMD and then it gives me
"undefined reference" error during linking. Should I modify the
Make.depend or some other Makefile manually?

Thanks,

Haochuan Chen

在 2018年03月13日 22:07, Giacomo Fiorin 写道:
> Hi Haochuan,
>
> 1. The "atom" class only has a single field "grad" for the gradients
> of a scalar variable.  There is no general mechanism for storing
> gradients of vector variables (I'm working on that very slowly and
> sporadically).  I would recommend allocating inside your new class
> several STL vectors of 3D vectors (cvm::rvector), and storing their
> pointers in a container of your choosing.  This is what is done for
> the quaternion variable, in the cvm::rotation class.  This will be
> easier to port to the new general mechanism that will some time see
> the light of day.
>
> The implicit gradients flag tells the rest of the code about this
> limitation, which affects for example computing the gradients of the
> rotational fit.  If your new variable is rotationally invariant (like
> e.g. the angle between 3 COMs), you won't have to worry about that.
>
> 2. Yes, the applied force should have the same type as the variable. 
> In apply_force(), you should have a loop that projects a vector force
> onto the atomic gradients that you are maintaining (step 1).
>
> Giacomo
>
>
>
>
>
> On Tue, Mar 13, 2018 at 4:12 AM, yjcoshc <yjcoshc_at_gmail.com
> <mailto:yjcoshc_at_gmail.com>> wrote:
>
> Hi Giacomo,
>
> Thanks for your reply! My collective variable is a 3D vector like
> (k0,k1,k2) and I know how to calculate (dk0/dri,dk1/dri,dk2/dri)
> where ri is the Cartesian coordinate of i-th COM. Now I encounter
> some other problems:
>
> 1. What is implicit gradients? It looks all vector or quaternion
> based colvars use enable(f_cvc_implicit_gradient) and have empty
> calc_gradients(). How do I choose which features in features_cvc
> enum to be enabled? Should I use some additional member variable
> to store the gradients other than atom_group->grad?
>
> 2. What is the type of the force inapply_force(colvarvalue const
> &force) ? Is the force a 3D vector like (f0,f1,f2) or just any
> type defined in theType enum?
>
> Haochuan chen
>
>
> 在 2018年03月12日 20:13, Giacomo Fiorin 写道:
>> Hi Haochuan, yes, that's because not finding the keyword "groupN"
>> is considered an error, and it normally would be.
>>
>> You could either:
>> (1) Add a keyword to set the number of groups in the
>> configuration (numGroups?).
>> (2) Use the lower-level parsing function
>> colvarparse::key_lookup() to test whether the keyword "groupN" is
>> used before attempting to parse it.  You probably don't need to
>> call key_lookup() with more than two arguments, if you only use
>> it to test the availability of the keyword.
>>
>> Regarding using scriptedFunction in Tcl, yes, a vector is
>> represented by a Tcl list.
>>
>> Giacomo
>>
>> On Mon, Mar 12, 2018 at 6:01 AM, yjcoshc <yjcoshc_at_gmail.com
>> <mailto:yjcoshc_at_gmail.com>> wrote:
>>
>> Hi Giacomo,
>>
>> Is there any way to parse unlimited atom groups
>> (group1,...,groupN)? I decide to write a loop checking groupN
>> by cvc::parse_group and break the loop when cvc::parse_group
>> return NULL, but cvc::parse_group seems raising an error when
>> groupN is not defined.
>>
>> Haochuan Chen
>>
>>
>> 在 2018年03月11日 20:05, Giacomo Fiorin 写道:
>>> Hi Haochuan, you need to derive a new class from the
>>> colvar::cvc, whose structure is described here.
>>> http://colvars.github.io/doxygen/html/classcolvar_1_1cvc.html#details
>>> <http://colvars.github.io/doxygen/html/classcolvar_1_1cvc.html#details>
>>> The rest of the webpage shows you also the current
>>> inheritance structure (what classes are derived from what).
>>>
>>> Among the variables that have vector values, a good example
>>> to take a look at could be distance_pairs.  Presumably you
>>> only need to wrap your C++ code in the correct functions,
>>> and add the calls that read coordinates or send forces.
>>>
>>> See also:
>>> http://colvars.github.io/doxygen/html/index.html
>>> <http://colvars.github.io/doxygen/html/index.html>
>>> for documentation on the other classes.
>>>
>>> Giacomo
>>>
>>> On Sat, Mar 10, 2018 at 4:27 AM, yjcoshc <yjcoshc_at_gmail.com
>>> <mailto:yjcoshc_at_gmail.com>> wrote:
>>>
>>> Hello,
>>>
>>> I want to implement a vector collective variable in NAMD
>>> through the colvars module. It can calculate the least
>>> square fitted plane among multiple atomgroups and return
>>> the normal vector of the plane. The example pathCV
>>> script in colvartools folder seems scalar type only. Any
>>> suggestion of implementing a vector type one? I have
>>> finished a sample C++ code to calculate this. How do I
>>> incorporate it in colvars?
>>>
>>> Thanks,
>>>
>>> Haochuan Chen
>>>
>>>
>>>
>>>
>>> --
>>> 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
>>> <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 <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 <https://github.com/giacomofiorin>

This archive was generated by hypermail 2.1.6 : Sun Dec 08 2019 - 23:19:40 CST