-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help wanted: How to reference the Q6 and it's derivatives defined in Plumed? #715
Comments
@tuoping it is not clear what you want to do. Do you want to call these functions from a C/C++ program?
|
Thank you for your kind reply. I do want to call the functions from a C++ program. And I found that every function requires a ActionOption parameter as input, which makes it hard to use. Do you think it's possible or usefull to detach Action related parts in these functions, so that these functions can be called independently? |
You are right. In some cases we have tools that can be used easily from outside PLUMED (e.g. RMSD), but most CVs are deeply integrated in our framework and difficult to use as standalone. I would suggest that you create a I recommend to use the master branch since there the C++ interface implements type checks (#653) and so it is much less likely to make mistakes. There is one specific tricky point, namely the Given the fact that variables such as Q6 are very expensive, I don't expect a significant overhead with respect to a hypothetical direct use of the Q6 class. |
This is very helpfull. Thank you so much. |
@tuoping please let us know if you succeeded (we are always interested in feedbacks from people using PLUMED differently from what we expected) |
Hello, @GiovanniBussi. Thank you for your help earlier this year. I managed to use MultiColvar, Q6 to be specific, by void PlumedMain::justCalculate() {
...
multicolvar::MultiColvarBase* amc=dynamic_cast<multicolvar::MultiColvarBase*>(p);
if(amc){
// log<<"> getNumberOfVessels(): "<<amc->getNumberOfVessels()<<"\n";
// log<<"> nactive_tasks: "<<amc->getCurrentNumberOfActiveTasks()<<"\n";
vesselbase::StoreDataVessel* mystash = amc->buildDataStashes( NULL );
NumberOfTasks=amc->getFullNumberOfTasks();
NumberOfQuantities=amc->getNumberOfQuantities();
int NumberOfStoredValues=mystash->getNumberOfStoredValues();
// std::vector<double> myvalues( NumberOfQuantities );
myvalues.resize(NumberOfTasks);
log<<">> getNumberOfQuantities(): "<<amc->getNumberOfQuantities()<<"\n";
log<<">> getNumberOfStoredValues(): "<<NumberOfStoredValues<<"\n";
for(unsigned i=0; i<mystash->getNumberOfStoredValues();++i){
myvalues[i].resize(NumberOfQuantities);
mystash->retrieveSequentialValue(i, false, myvalues[i] );
}
NumberOfDerivatives=amc->getNumberOfDerivatives();
MultiValue val_k( amc->getNumberOfQuantities(), amc->getNumberOfDerivatives() ); val_k.clearAll();
myder.resize(NumberOfStoredValues);
for(unsigned k=0; k<NumberOfStoredValues; ++k) {
stash->retrieveDerivatives( k, false, val_k );
myder[k].resize(NumberOfQuantities);
for(unsigned i=0; i<NumberOfQuantities; ++i){
myder[k][i].resize(NumberOfDerivatives);
for(unsigned j=0; j<NumberOfDerivatives; ++j) myder[k][i][j]=val_k.getDerivative(i,j);
}
}
}else log<<"*** No ActionWithVessel ***\n";
...
} Of course, several new void PlumedMain::cmd(const std::string & word,const TypesafePtr & val) {
...
case cmd_getNumberOfTasks:
CHECK_INIT(initialized,word);
CHECK_NOTNULL(val,word);
*val.get<int*>()=getNumberOfTasks();
break;
case cmd_getNumberOfQuantities:
CHECK_INIT(initialized,word);
CHECK_NOTNULL(val,word);
*val.get<int*>()=getNumberOfQuantities();
break;
case cmd_getMultiColvars:
CHECK_INIT(initialized,word);
plumed_assert(nw==2);
CHECK_NOTNULL(val,word);
int itask; Tools::convertNoexcept(words[1], itask);
*( val.template get<const double**>())=&myvalues[itask][0];
break
case cmd_getDerivativeOfMCV:
CHECK_INIT(initialized,word);
plumed_assert(nw==3);
CHECK_NOTNULL(val,word);
getDerivativesOfMCV(val, words[1], words[2]);
break;
...
} where void PlumedMain::getDerivativesOfMCV(const TypesafePtr& val, const std::string& word1, const std::string& word2){
int itask;
int jtask;
Tools::convertNoexcept(word1, itask);
Tools::convertNoexcept(word2, jtask);
auto vval=val.template get<const double**>();
if(!myder.empty()){
*vval=&myder[itask][jtask][0];
}else *vval=NULL;
} When calling Plumed from LAMMPS, fix_plumed.cpp to be specific, I changed |
Hello. I want to use the Q6 defined in Plumed. But failed to find it in wrapper. I have two questions. 1. Is it compiled in libplumed.so or libplumedkernel.so? If it is, how do I reference it? If it is not, is it possible for me to include it in the compiled static lib? Or is there a way for me to use it directly?
Thank you sincerely.
The text was updated successfully, but these errors were encountered: