void cells_update_ghosts() { switch (cell_structure.type) { /* methods using skin rsp. rebuild_verletlist */ case CELL_STRUCTURE_DOMDEC: if(dd.use_vList) { if (rebuild_verletlist == 1) /* Communication step: number of ghosts and ghost information */ cells_resort_particles(CELL_NEIGHBOR_EXCHANGE); else /* Communication step: ghost information */ ghost_communicator(&cell_structure.update_ghost_pos_comm); } else cells_resort_particles(CELL_NEIGHBOR_EXCHANGE); break; /* layered has a skin only in z in principle, but probably we can live very well with the standard skin */ case CELL_STRUCTURE_LAYERED: if (rebuild_verletlist == 1) /* Communication step: number of ghosts and ghost information */ cells_resort_particles(CELL_NEIGHBOR_EXCHANGE); else /* Communication step: ghost information */ ghost_communicator(&cell_structure.update_ghost_pos_comm); break; case CELL_STRUCTURE_NSQUARE: /* the particles probably are still balanced... */ ghost_communicator(&cell_structure.update_ghost_pos_comm); } }
void local_sort_particles() { CELL_TRACE(fprintf(stderr, "%d: entering local_sort_particles\n", this_node)); /* first distribute strictly on nodes */ cells_resort_particles(CELL_GLOBAL_EXCHANGE); CELL_TRACE(fprintf(stderr, "%d: sorting local cells\n", this_node)); /* now sort the local cells */ for (int c = 0; c < local_cells.n; c++) { Cell *cell = local_cells.cell[c]; Particle *p = cell->part; int np = cell->n; #ifdef CELL_DEBUG for (int id = 0; id < np; ++id) { Cell *tgt_cell = cell_structure.position_to_cell(p[id].r.p); if (tgt_cell != cell) { fprintf(stderr, "%d: particle %d at position %lf %lf %lf is not in its expected cell. Have %ld, expected %ld\n", this_node, p[id].p.identity, p[id].r.p[0], p[id].r.p[1], p[id].r.p[2], (cell - cells)/sizeof(Cell*), (tgt_cell - cells) /sizeof(Cell*)); } } #endif qsort(p, np, sizeof(Particle), compare_particles); update_local_particles(cell); } CELL_TRACE(dump_particle_ordering()); CELL_TRACE(fprintf(stderr, "%d: leaving local_sort_particles\n", this_node)); }
/* monte carlo step of ghmc - evaluation stage */ void ghmc_mc() { INTEG_TRACE(fprintf(stderr,"%d: ghmc_mc:\n",this_node)); double boltzmann; int ekin_update_flag = 0; hamiltonian_calc(ekin_update_flag); //make MC decision only on the master if (this_node==0) { ghmcdata.att++; //metropolis algorithm boltzmann = ghmcdata.hmlt_new - ghmcdata.hmlt_old; if (boltzmann < 0) boltzmann = 1.0; else if (boltzmann > 30) boltzmann = 0.0; else boltzmann = exp(-beta*boltzmann); //fprintf(stderr,"old hamiltonian : %f, new hamiltonian: % f, boltzmann factor: %f\n",ghmcdata.hmlt_old,ghmcdata.hmlt_new,boltzmann); if ( d_random() < boltzmann) { ghmcdata.acc++; ghmc_mc_res = GHMC_MOVE_ACCEPT; } else { ghmc_mc_res = GHMC_MOVE_REJECT; } } //let all nodes know about the MC decision result mpi_bcast_parameter(FIELD_GHMC_RES); if (ghmc_mc_res == GHMC_MOVE_ACCEPT) { save_last_state(); //fprintf(stderr,"%d: mc move accepted\n",this_node); } else { load_last_state(); //fprintf(stderr,"%d: mc move rejected\n",this_node); //if the move is rejected we might need to resort particles according to the loaded configurations cells_resort_particles(CELL_GLOBAL_EXCHANGE); invalidate_obs(); if (ghmc_mflip == GHMC_MFLIP_ON) { momentum_flip(); } else if (ghmc_mflip == GHMC_MFLIP_RAND) { if (d_random() < 0.5) momentum_flip(); } } //fprintf(stderr,"%d: temp after mc: %f\n",this_node,calc_local_temp()); }
void cells_update_ghosts() { /* if dd.use_vList is set, it so far means we want EXACT sorting of the particles.*/ if (dd.use_vList == 0) resort_particles = 1; if (resort_particles) { #ifdef LEES_EDWARDS /* Communication step: number of ghosts and ghost information */ cells_resort_particles(CELL_GLOBAL_EXCHANGE); #else /* Communication step: number of ghosts and ghost information */ cells_resort_particles(CELL_NEIGHBOR_EXCHANGE); #endif } else /* Communication step: ghost information */ ghost_communicator(&cell_structure.update_ghost_pos_comm); }
void on_observable_calc() { /* Prepare particle structure: Communication step: number of ghosts and ghost information */ if(resort_particles) { cells_resort_particles(CELL_GLOBAL_EXCHANGE); resort_particles = 0; } #ifdef ELECTROSTATICS if(reinit_electrostatics) { EVENT_TRACE(fprintf(stderr, "%d: reinit_electrostatics\n", this_node)); switch (coulomb.method) { #ifdef ELP3M case COULOMB_ELC_P3M: case COULOMB_P3M: P3M_count_charged_particles(); break; #endif case COULOMB_EWALD: EWALD_count_charged_particles(); break; case COULOMB_MAGGS: maggs_init(); break; default: break; } reinit_electrostatics = 0; } #endif /*ifdef ELECTROSTATICS */ #ifdef MAGNETOSTATICS if(reinit_magnetostatics) { EVENT_TRACE(fprintf(stderr, "%d: reinit_magnetostatics\n", this_node)); switch (coulomb.Dmethod) { #ifdef ELP3M case DIPOLAR_MDLC_P3M: case DIPOLAR_P3M: P3M_count_magnetic_particles(); break; #endif default: break; } reinit_magnetostatics = 0; } #endif /*ifdef ELECTROSTATICS */ }
int tclcommand_load_state(ClientData data, Tcl_Interp *interp, int argc, char **argv) { #ifdef GHMC Tcl_ResetResult(interp); /* load last saved system state */ load_last_state(); cells_resort_particles(CELL_GLOBAL_EXCHANGE); invalidate_obs(); return TCL_OK; #else INTEG_TRACE(fprintf(stderr,"%d: call to ghmc but not compiled in!\n",this_node)); return tclcommand_ghmc_print_usage(interp); #endif }