--- trunk/mdtools/md_code/Verlet.cpp 2002/07/09 18:40:59 11 +++ trunk/mdtools/md_code/Verlet.cpp 2003/01/27 21:28:19 249 @@ -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; @@ -123,89 +124,6 @@ Verlet::~Verlet(){ } - -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 */ @@ -224,6 +142,8 @@ void Verlet::integrate( void ){ double *Fy = new double[c_natoms]; double *Fz = new double[c_natoms]; + int time; + double dt = entry_plug->dt; double runTime = entry_plug->run_time; double sampleTime = entry_plug->sampleTime; @@ -243,20 +163,15 @@ 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(); - 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 ); + if( c_is_constrained ){ for(i = 0; i < n_loops; i++){ @@ -297,16 +212,8 @@ void Verlet::integrate( void ){ // calculate the forces - for(j = 0; j < c_natoms; j++){ - c_atoms[j]->zeroForces(); - } + myFF->doForces(); - 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; jset_vz(Vz[j]); } + time = i + 1; + if( entry_plug->setTemp ){ - if( !(i % vel_n) ) tStats->velocitize(); + if( !(time % vel_n) ) tStats->velocitize(); } - if( !(i % sample_n) ) dump_out->writeDump( i * dt ); - if( !(i % status_n) ) e_out->writeStat( i * dt ); - + if( !(time % sample_n) ) dump_out->writeDump( time * dt ); + if( !(time % status_n) ) e_out->writeStat( time * dt ); } } else{ @@ -356,25 +264,19 @@ 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(); // complete the verlet move move_b( dt ); + time = i + 1; + if( entry_plug->setTemp ){ - if( !(i % vel_n) ) tStats->velocitize(); + if( !(time % vel_n) ) tStats->velocitize(); } - if( !(i % sample_n) ) dump_out->writeDump( i * dt ); - if( !(i % status_n) ) e_out->writeStat( i * dt ); + if( !(time % sample_n) ) dump_out->writeDump( time * dt ); + if( !(time % status_n) ) e_out->writeStat( time * dt ); } } @@ -427,7 +329,6 @@ void Verlet::move_b( double dt ){ const double e_convert = 4.184e-4; // converts kcal/mol -> amu*A^2/fs^2 double vx, vy, vz; - double v_sqr; int mb; double h_dt = 0.5 * dt;