#include #include #include "xyz.hpp" namespace mort { void write_amber_xyz( ostream& os, const molecule_t& mol ) { string molname; os << ( mol.get_s(NAME, molname) ? molname : "untitled" ) << std::endl; os << format( "%6d" ) % mol.natom() << std::endl; double box[3]; memset( box, 0, 3*sizeof(double) ); int solute = 0; bool hasbox = mol.get_i(SOLUTE,solute) && (solute==BOX); if( hasbox ) { numvec b = mol.get_v(BOX); box[0] = b[0]; box[1] = b[1]; box[2] = b[2]; } atomiter_t atom = mol.atom_begin(); for( ; atom != mol.atom_end(); ++atom ) { numvec pos = atom->get_v(POSITION); pos[0] += box[0]*0.5; pos[1] += box[1]*0.5; pos[2] += box[2]*0.5; os << format( "%12.7f" ) % pos[0]; os << format( "%12.7f" ) % pos[1]; os << format( "%12.7f" ) % pos[2]; if( atom->absid() % 2 == 1 ) { os <get_v(POSITION); os << format( "%6d" ) % atom->get_i(ID) << " "; os << format( "%-3s" ) % atom->get_s(SYMBOL) << " "; os << format( "%11.6f" ) % pos[0] << " "; os << format( "%11.6f" ) % pos[1] << " "; os << format( "%11.6f" ) % pos[2] << " "; os << format( "%5s" ) % atom->get_s(POLTYPE) << " "; atomiter_t nbr = atom->atom_begin(); for( ; nbr != atom->atom_end(); ++nbr ) { os << format( "%5d" ) % nbr->get_i(ID) << " "; } os << std::endl; } } }