bool FormatTopology::save(string topfile, Space &spc) { std::set<string> done; std::ofstream f(topfile.c_str()); if (f) { f << "[ defaults ]\n" << ";nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ\n" << " 1 2 yes 1.0000 1.0000\n"; f << writeAtomTypes(spc); for (auto g : spc.groupList() ) { if ( done.find(g->name)==done.end() ) { f << writeMoleculeType(*g, spc); done.insert(g->name); } } f << "[ system ]\n" << "something" << endl; f << "[ molecules ]\n" << "prot " << spc.groupList().size() << endl; return true; } return false; }
bool FormatGRO::save(string file, Space &spc) { assert( abs(len*len*len-spc.geo->getVolume())<1e-6 && "Did you forget to pass box size to FormatGRO?" ); string name; int nres=1, natom=1; char buf[79]; double halflen=len/2; std::ostringstream o; o << "Generated by Faunus -- http://faunus.sourceforge.net" << std::endl << spc.p.size() << std::endl; for (auto g : spc.groupList()) { for (auto i : *g) { name=atom[ spc.p[i].id ].name; sprintf(buf, "%5d%5s%5s%5d%8.3f%8.3f%8.3f\n", nres,name.c_str(),name.c_str(),natom++, spc.p[i].x()/10+halflen, spc.p[i].y()/10+halflen, spc.p[i].z()/10+halflen ); o << buf; } nres++; } if (len>0) o << len << " " << len << " " << len << std::endl; return IO::writeFile(file, o.str()); }