/*************************************************************************** mdx_mod.cpp - description ------------------- begin : Tue Nov 30 17:01:41 2004 copyright : (C) 2002 by Cavalli Andrea email : cavalli@bioc.unizh.ch **************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include #include #include #include #include #include #define ALMTOSTRING(s) \ template<> \ inline string to_string(const s & ){ \ return "<" #s ">"; \ } ALMTOSTRING(ConstraintCollection); ALMTOSTRING(MonitorSet); ALMTOSTRING(RMSDMonitor); ALMTOSTRING(RGYRMonitor); //ALMTOSTRING(NameSecection); typedef MDXImpl > * (MDX::*mdx_factory)(const Molecules & molecules, const MDXOptions & options, const MDB & mdb); #if (__GNUC__ >= 3) template<> #endif map::mdx_factory > MDX::factory #if (__GNUC__ >= 3) = map::mdx_factory >(); #endif ; template<> inline string to_string(const Molecules & molecules){ return ""; } template<> inline string to_string(const XMolecules & molecules){ return ""; } template<> inline string to_string(const MDB & mdb){ return ""; } template<> inline string to_string(const MDX &){ return ""; } MDXOptions c19_mdx_options(){ return MDXOptions(MDXOptions::C19); } MDXOptions c22_mdx_options(){ return MDXOptions(MDXOptions::C22); } MDXOptions c19_mdx_defaults(int FF, int algo){ MDXOptions opts; if(FF==MDXOptions::EEF1){ opts.elec = MDXOptions::RDIE; opts. elec_cutoff = MDXOptions::SWITCH; opts.vdw = MDXOptions::LJ; opts.vdw_cutoff = MDXOptions::SWITCH; opts.eps = 1.0; opts.solv = MDXOptions::EEF1; opts.cut_on = 7.0; opts.cut_off = 9.0; opts.cut_nb = 10.0; } else if(FF!=MDXOptions::SASA) opts.solv = MDXOptions::NONE; if(algo==MDXOptions::LANGEVIN){ opts.algorithm = MDXOptions::LANGEVIN; } else opts.algorithm = MDXOptions::BERENDSEN; return opts; } template DynaType const_mdx(ConstraintCollection & cc){ return DynaType(cc); } void check_xconst(ConstraintCollection & cc, XMolecules & xmols, double dx, int steps){ vector xconst; xconst = cc.xconstraints(); int size = xmols.size(); int asize= xmols[0].atom_size(); Coor **coor, **coor_buffer,**ff; coor = new Coor * [size]; coor_buffer = new Coor *[size]; ff = new Coor* [size]; for(int rep = 0;rep(xmols[rep]); coor_buffer[rep] = new Coor(xmols[rep]); ff[rep] = new Coor; ff[rep]->resize(asize); ff[rep]->clear(); } double W = 0; double Ene = 0; double tmp_ene = 0; for(int i=0;ienergy_force(coor,ff,size); } cout<<"Initial energy "<assign(*coor[rep]); ff[rep]->clear(); for(int j = 0;j::DIM*j; coor[rep]->coor[pos] += dx*(drand48()-0.5); coor[rep]->coor[pos+1] += dx*(drand48()-0.5); coor[rep]->coor[pos+2] += dx*(drand48()-0.5); } } tmp_ene = 0; for(int i=0;ienergy_force(coor,ff,size); } cout<<"Current energy "<::DIM*j; W += (coor[rep]->coor[pos]-coor_buffer[rep]->coor[pos])*ff[rep]->coor[pos]; pos = pos + 1; W += (coor[rep]->coor[pos]-coor_buffer[rep]->coor[pos])*ff[rep]->coor[pos]; pos = pos + 1; W += (coor[rep]->coor[pos]-coor_buffer[rep]->coor[pos])*ff[rep]->coor[pos]; } } cout<<"Current energy difference "<::NONE); mod.def_const("BONDH",(int)Shake::BONDH); mod.def_const("BONDALL",(int)Shake::BONDALL); REGISTER_MDXC19_OPTIONS(double); Class >(mod.self(),"mdx") .def_method("run",&MDX::run) .def_method("cont",&MDX::cont) .def_method("run_from_mol",&MDX::run_from_mol) .def_method("restart",&MDX::restart) .def_method("set_monitors",&MDX::set_monitors) .def_method("clear_monitors",&MDX::clear_monitors); mod .def_const("C19",(int)MDXOptions::C19) .def_const("C22",(int)MDXOptions::C22) .def_const("NONE",(int)MDXOptions::NONE) .def_const("SASA",(int)MDXOptions::SASA) .def_const("EEF1",(int)MDXOptions::EEF1) .def_const("BERENDSEN",(int)MDXOptions::BERENDSEN) .def_const("LANGEVIN",(int)MDXOptions::LANGEVIN) .def_const("BERE",(int)MDXOptions::BERENDSEN) .def_const("LANG",(int)MDXOptions::LANGEVIN) .def_const("MDX",(int)MDXOptions::MDX) .def_const("REMD",(int)MDXOptions::REMD) ; mod.def_function("const_mdx","Run a constrained MDX simulation", const_mdx >); Class >(mod.self(),"monitor_set") .def_method("size",&MonitorSet::size) .def_method("clear",&MonitorSet::clear) .def_method("add_rmsd",&MonitorSet::add_monitor >) ; Class,ArgList2 >(mod.self(), "rmsd"); mod .def_function("c19_options","Return options with right defaults",c19_mdx_options) .def_function("c22_options","Return options with right defaults",c22_mdx_options) .def_function("c19_defaults","Return options with right defaults",c19_mdx_defaults) .def_function("check_xconst","Check that MDX constraints work",check_xconst); } }