--- trunk/mdtools/md_code/Verlet.cpp 2002/09/24 22:10:55 117 +++ trunk/mdtools/md_code/Verlet.cpp 2003/02/03 21:15:59 261 @@ -30,16 +30,17 @@ Verlet::Verlet( SimInfo &info ){ } -Verlet::Verlet( SimInfo &info ){ +Verlet::Verlet( SimInfo &info, ForceFields* the_ff ){ // get what information we need from the SimInfo object entry_plug = &info; + myFF = the_ff; + c_natoms = info.n_atoms; c_atoms = info.atoms; c_sr_interactions = info.sr_interactions; - longRange = info.longRange; c_n_SRI = info.n_SRI; c_is_constrained = 0; c_box_x = info.box_x; @@ -120,96 +121,14 @@ Verlet::~Verlet(){ delete[] c_mass; c_mass = 0; -} - - - -void Verlet::integrate_b( double time_length, double dt, - int n_bond_0, int n_bond_f, - int n_bend_0, int n_bend_f, - int n_torsion_0, int n_torsion_f, - bool do_bonds, bool do_bends, bool do_torsions, - bool do_LRI ){ - -// double percent_tolerance = 0.001; -// int max_iterations = 10000; - - int i, j; /* loop counters */ - double n_loops = time_length / dt; - - // the first time integrate is called, the forces need to be initialized - - if(is_first){ - is_first = 0; - - for(i = 0; i < c_natoms; i++){ - c_atoms[i]->zeroForces(); - } - - if( do_bonds ){ - for(i = n_bond_0; i <= n_bond_f; i++){ - c_sr_interactions[i]->calc_forces(); - } - } - - if( do_bends ){ - for(i = n_bend_0; i <= n_bend_f; i++){ - c_sr_interactions[i]->calc_forces(); - } - } - - if( do_torsions ){ - for(i = n_torsion_0; i <= n_torsion_f; i++){ - c_sr_interactions[i]->calc_forces(); - } - } - - if( do_LRI ) longRange->calc_forces(); - } - - for(i = 0; i < n_loops; i++){ - - move_a( dt ); - - // calculate the forces - - for(j = 0; j < c_natoms; j++){ - c_atoms[j]->zeroForces(); - } - - - if( do_bonds ){ - for(i = n_bond_0; i <= n_bond_f; i++){ - c_sr_interactions[i]->calc_forces(); - } - } - - if( do_bends ){ - for(i = n_bend_0; i <= n_bend_f; i++){ - c_sr_interactions[i]->calc_forces(); - } - } - - if( do_torsions ){ - for(i = n_torsion_0; i <= n_torsion_f; i++){ - c_sr_interactions[i]->calc_forces(); - } - } - - if( do_LRI ) longRange->calc_forces(); - - - // complete the verlet move - - move_b( dt ); - } } void Verlet::integrate( void ){ int i, j; /* loop counters */ - + int calcPot; + double kE; double *Rx = new double[c_natoms]; @@ -245,23 +164,18 @@ void Verlet::integrate( void ){ // the first time integrate is called, the forces need to be initialized - for(i = 0; i < c_natoms; i++){ - c_atoms[i]->zeroForces(); - } + myFF->doForces(1); - for(i = 0; i < c_n_SRI; i++){ - c_sr_interactions[i]->calc_forces(); - } - - longRange->calc_forces(); - if( entry_plug->setTemp ){ tStats->velocitize(); } dump_out->writeDump( 0.0 ); + e_out->writeStat( 0.0 ); + calcPot = 0; + if( c_is_constrained ){ for(i = 0; i < n_loops; i++){ @@ -302,16 +216,8 @@ void Verlet::integrate( void ){ // calculate the forces - for(j = 0; j < c_natoms; j++){ - c_atoms[j]->zeroForces(); - } + myFF->doForces(calcPot); - for(j = 0; j < c_n_SRI; j++){ - c_sr_interactions[j]->calc_forces(); - } - - longRange->calc_forces(); - // finish the constrain move ( same as above. ) for( j=0; jvelocitize(); } if( !(time % sample_n) ) dump_out->writeDump( time * dt ); - if( !(time % status_n) ) e_out->writeStat( time * dt ); + if( !((time+1) % status_n) ) calcPot = 1; + if( !(time % status_n) ){ e_out->writeStat( time * dt ); calcPot = 0; } } } else{ @@ -362,15 +269,7 @@ void Verlet::integrate( void ){ // calculate the forces - for(j = 0; j < c_natoms; j++){ - c_atoms[j]->zeroForces(); - } - - for(j = 0; j < c_n_SRI; j++){ - c_sr_interactions[j]->calc_forces(); - } - - longRange->calc_forces(); + myFF->doForces(calcPot); // complete the verlet move @@ -381,8 +280,9 @@ void Verlet::integrate( void ){ if( entry_plug->setTemp ){ if( !(time % vel_n) ) tStats->velocitize(); } - if( !(time % sample_n) ) dump_out->writeDump( time * dt ); - if( !(time % status_n) ) e_out->writeStat( time * dt ); + if( !(time % sample_n) ) dump_out->writeDump( time * dt ); + if( !((time+1) % status_n) ) calcPot = 1; + if( !(time % status_n) ){ e_out->writeStat( time * dt ); calcPot = 0; } } }