void force_calc() { espressoSystemInterface.update(); #ifdef LB_GPU #ifdef SHANCHEN if (lattice_switch & LATTICE_LB_GPU && this_node == 0) lattice_boltzmann_calc_shanchen_gpu(); #endif // SHANCHEN // transfer_momentum_gpu check makes sure the LB fluid doesn't get updated on integrate 0 // this_node==0 makes sure it is the master node where the gpu exists if (lattice_switch & LATTICE_LB_GPU && transfer_momentum_gpu && this_node==0 ) lb_calc_particle_lattice_ia_gpu(); #endif // LB_GPU #ifdef ELECTROSTATICS if (iccp3m_initialized && iccp3m_cfg.set_flag) iccp3m_iteration(); else #endif init_forces(); switch (cell_structure.type) { case CELL_STRUCTURE_LAYERED: layered_calculate_ia(); break; case CELL_STRUCTURE_DOMDEC: if(dd.use_vList) { if (rebuild_verletlist) build_verlet_lists_and_calc_verlet_ia(); else calculate_verlet_ia(); } else calc_link_cell(); break; case CELL_STRUCTURE_NSQUARE: nsq_calculate_ia(); } #ifdef VOLUME_FORCE double volume=0.; for (int i=0;i< MAX_OBJECTS_IN_FLUID;i++){ calc_volume(&volume,i); if (volume<1e-100) break; add_volume_force(volume,i); } #endif #ifdef AREA_FORCE_GLOBAL double area=0.; for (int i=0;i< MAX_OBJECTS_IN_FLUID;i++){ calc_area_global(&area,i); if (area<1e-100) break; add_area_global_force(area,i); } #endif calc_long_range_forces(); #ifdef LB if (lattice_switch & LATTICE_LB) calc_particle_lattice_ia() ; #endif #ifdef COMFORCE calc_comforce(); #endif #ifdef METADYNAMICS /* Metadynamics main function */ meta_perform(); #endif #if defined(LB_GPU) || (defined(ELECTROSTATICS) && defined(CUDA)) copy_forces_from_GPU(); #endif }
/** Calculate forces. * * A short list, what the function is doing: * <ol> * <li> Initialize forces with: \ref friction_thermo_langevin (ghost forces with zero). * <li> Calculate bonded interaction forces:<br> * Loop all local particles (not the ghosts). * <ul> * <li> FENE * <li> ANGLE (cos bend potential) * </ul> * <li> Calculate non-bonded short range interaction forces:<br> * Loop all \ref IA_Neighbor::vList "verlet lists" of all \ref #cells. * <ul> * <li> Lennard-Jones. * <li> Buckingham. * <li> Real space part: Coulomb. * <li> Ramp. * </ul> * <li> Calculate long range interaction forces:<br> Uses <a href=P3M_calc_kspace_forces> P3M_calc_kspace_forces </a> * </ol> */ inline void force_calc() { // Communication step: distribute ghost positions cells_update_ghosts(); // VIRTUAL_SITES pos (and vel for DPD) update for security reason !!! #ifdef VIRTUAL_SITES update_mol_vel_pos(); ghost_communicator(&cell_structure.update_ghost_pos_comm); #endif #if defined(VIRTUAL_SITES_RELATIVE) && defined(LB) // This is on a workaround stage: // When using virtual sites relative and LB at the same time, it is necessary // to reassemble the cell lists after all position updates, also of virtual // particles. if ((lattice_switch & LATTICE_LB) && cell_structure.type == CELL_STRUCTURE_DOMDEC && (!dd.use_vList) ) cells_update_ghosts(); #endif #ifdef COLLISION_DETECTION prepare_collision_queue(); #endif espressoSystemInterface.update(); // Compute the forces from the force objects for (ActorList::iterator actor = forceActors.begin(); actor != forceActors.end(); ++actor) (*actor)->computeForces(espressoSystemInterface); #ifdef LB_GPU #ifdef SHANCHEN if (lattice_switch & LATTICE_LB_GPU && this_node == 0) lattice_boltzmann_calc_shanchen_gpu(); #endif // SHANCHEN // transfer_momentum_gpu check makes sure the LB fluid doesn't get updated on integrate 0 // this_node==0 makes sure it is the master node where the gpu exists if (lattice_switch & LATTICE_LB_GPU && transfer_momentum_gpu && (this_node == 0) ) lb_calc_particle_lattice_ia_gpu(); #endif // LB_GPU #ifdef ELECTROSTATICS if (iccp3m_initialized && iccp3m_cfg.set_flag) iccp3m_iteration(); #endif init_forces(); switch (cell_structure.type) { case CELL_STRUCTURE_LAYERED: layered_calculate_ia(); break; case CELL_STRUCTURE_DOMDEC: if(dd.use_vList) { if (rebuild_verletlist) build_verlet_lists_and_calc_verlet_ia(); else calculate_verlet_ia(); } else calc_link_cell(); break; case CELL_STRUCTURE_NSQUARE: nsq_calculate_ia(); } #ifdef VOLUME_FORCE double volume=0.; for (int i=0;i< MAX_OBJECTS_IN_FLUID;i++){ calc_volume(&volume,i); if (volume<1e-100) break; add_volume_force(volume,i); } #endif #ifdef AREA_FORCE_GLOBAL double area=0.; for (int i=0;i< MAX_OBJECTS_IN_FLUID;i++){ calc_area_global(&area,i); if (area<1e-100) break; add_area_global_force(area,i); } #endif calc_long_range_forces(); #ifdef LB if (lattice_switch & LATTICE_LB) calc_particle_lattice_ia() ; #endif #ifdef COMFORCE calc_comforce(); #endif #ifdef METADYNAMICS /* Metadynamics main function */ meta_perform(); #endif #ifdef CUDA copy_forces_from_GPU(); #endif // VIRTUAL_SITES distribute forces #ifdef VIRTUAL_SITES ghost_communicator(&cell_structure.collect_ghost_force_comm); init_forces_ghosts(); distribute_mol_force(); #endif // Communication Step: ghost forces ghost_communicator(&cell_structure.collect_ghost_force_comm); // apply trap forces to trapped molecules #ifdef MOLFORCES calc_and_apply_mol_constraints(); #endif // should be pretty late, since it needs to zero out the total force #ifdef COMFIXED calc_comfixed(); #endif // mark that forces are now up-to-date recalc_forces = 0; #ifdef COLLISION_DETECTION handle_collisions(); #endif }