void grid_changed_n_nodes() { int per[3] = { 1, 1, 1 }; GRID_TRACE(fprintf(stderr,"%d: grid_changed_n_nodes:\n",this_node)); MPI_Comm_free(&comm_cart); MPI_Cart_create(MPI_COMM_WORLD, 3, node_grid, per, 0, &comm_cart); MPI_Comm_rank(comm_cart, &this_node); MPI_Cart_coords(comm_cart, this_node, 3, node_pos); calc_node_neighbors(this_node); #ifdef GRID_DEBUG fprintf(stderr,"%d: node_pos=(%d,%d,%d)\n",this_node,node_pos[0],node_pos[1],node_pos[2]); fprintf(stderr,"%d: node_neighbors=(%d,%d,%d,%d,%d,%d)\n",this_node, node_neighbors[0],node_neighbors[1],node_neighbors[2], node_neighbors[3],node_neighbors[4],node_neighbors[5]); fprintf(stderr,"%d: boundary=(%d,%d,%d,%d,%d,%d)\n",this_node, boundary[0],boundary[1],boundary[2],boundary[3],boundary[4],boundary[5]); #endif grid_changed_box_l(); }
void on_NpT_boxl_change(double scal1) { grid_changed_box_l(); #ifdef ELECTROSTATICS switch(coulomb.method) { #ifdef ELP3M case COULOMB_P3M: P3M_scaleby_box_l_charges(); integrate_vv_recalc_maxrange(); break; #endif case COULOMB_EWALD: EWALD_scaleby_box_l(); integrate_vv_recalc_maxrange(); break; default: break; } #endif #ifdef MAGNETOSTATICS switch(coulomb.Dmethod) { #ifdef ELP3M case DIPOLAR_P3M: P3M_scaleby_box_l_dipoles(); integrate_vv_recalc_maxrange(); break; #endif default: break; } #endif if(cell_structure.type==CELL_STRUCTURE_DOMDEC) dd_NpT_update_cell_grid(scal1); }
void on_parameter_change(int field) { EVENT_TRACE(fprintf(stderr, "%d: on_parameter_change %s\n", this_node, fields[field].name)); switch (field) { case FIELD_BOXL: grid_changed_box_l(); /* Electrostatics cutoffs mostly depend on the system size, therefore recalculate them. */ recalc_maximal_cutoff(); cells_on_geometry_change(0); break; case FIELD_MIN_GLOBAL_CUT: recalc_maximal_cutoff(); cells_on_geometry_change(0); break; case FIELD_SKIN: cells_on_geometry_change(0); case FIELD_PERIODIC: cells_on_geometry_change(CELL_FLAG_GRIDCHANGED); break; case FIELD_NODEGRID: grid_changed_n_nodes(); cells_on_geometry_change(CELL_FLAG_GRIDCHANGED); break; case FIELD_MINNUMCELLS: case FIELD_MAXNUMCELLS: cells_re_init(CELL_STRUCTURE_CURRENT); case FIELD_TEMPERATURE: on_temperature_change(); reinit_thermo = 1; break; case FIELD_TIMESTEP: #ifdef LB_GPU if(this_node == 0) { if (lattice_switch & LATTICE_LB_GPU) { lb_reinit_parameters_gpu(); } } #endif #ifdef LB if (lattice_switch & LATTICE_LB) { lb_reinit_parameters(); } #endif case FIELD_LANGEVIN_GAMMA: case FIELD_DPD_TGAMMA: case FIELD_DPD_GAMMA: case FIELD_NPTISO_G0: case FIELD_NPTISO_GV: case FIELD_NPTISO_PISTON: reinit_thermo = 1; break; #ifdef NPT case FIELD_INTEG_SWITCH: if (integ_switch != INTEG_METHOD_NPT_ISO) nptiso.invalidate_p_vel = 1; break; #endif case FIELD_THERMO_SWITCH: /* DPD needs ghost velocities, other thermostats not */ on_ghost_flags_change(); break; #ifdef LB case FIELD_LATTICE_SWITCH: /* LB needs ghost velocities */ on_ghost_flags_change(); break; #endif } }
void propagate_press_box_pos_and_rescale_npt() { #ifdef NPT if(integ_switch == INTEG_METHOD_NPT_ISO) { Cell *cell; Particle *p; int i, j, np, c; double scal[3]={0.,0.,0.}, L_new=0.0; /* finalize derivation of p_inst */ finalize_p_inst_npt(); /* adjust \ref nptiso_struct::nptiso.volume; prepare pos- and vel-rescaling */ if (this_node == 0) { nptiso.volume += nptiso.inv_piston*nptiso.p_diff*0.5*time_step; scal[2] = SQR(box_l[nptiso.non_const_dim])/pow(nptiso.volume,2.0/nptiso.dimension); nptiso.volume += nptiso.inv_piston*nptiso.p_diff*0.5*time_step; if (nptiso.volume < 0.0) { char *errtxt = runtime_error(128 + 3*ES_DOUBLE_SPACE); ERROR_SPRINTF(errtxt, "{015 your choice of piston=%g, dt=%g, p_diff=%g just caused the volume to become negative, decrease dt} ", nptiso.piston,time_step,nptiso.p_diff); nptiso.volume = box_l[0]*box_l[1]*box_l[2]; scal[2] = 1; } L_new = pow(nptiso.volume,1.0/nptiso.dimension); // printf(stdout,"Lnew, %f: volume, %f: dim, %f: press, %f \n", L_new, nptiso.volume, nptiso.dimension,nptiso.p_inst ); // fflush(stdout); scal[1] = L_new/box_l[nptiso.non_const_dim]; scal[0] = 1/scal[1]; } MPI_Bcast(scal, 3, MPI_DOUBLE, 0, comm_cart); /* propagate positions while rescaling positions and velocities */ for (c = 0; c < local_cells.n; c++) { cell = local_cells.cell[c]; p = cell->part; np = cell->n; for(i = 0; i < np; i++) { #ifdef VIRTUAL_SITES if (ifParticleIsVirtual(&p[i])) continue; #endif for(j=0; j < 3; j++){ #ifdef EXTERNAL_FORCES if (!(p[i].l.ext_flag & COORD_FIXED(j))) { #endif if(nptiso.geometry & nptiso.nptgeom_dir[j]) { p[i].r.p[j] = scal[1]*(p[i].r.p[j] + scal[2]*p[i].m.v[j]); p[i].l.p_old[j] *= scal[1]; p[i].m.v[j] *= scal[0]; } else { p[i].r.p[j] += p[i].m.v[j]; } #ifdef EXTERNAL_FORCES } #endif } ONEPART_TRACE(if(p[i].p.identity==check_id) fprintf(stderr,"%d: OPT:PV_1 v_new=(%.3e,%.3e,%.3e)\n",this_node,p[i].m.v[0],p[i].m.v[1],p[i].m.v[2])); ONEPART_TRACE(if(p[i].p.identity==check_id) fprintf(stderr,"%d: OPT:PPOS p=(%.3f,%.3f,%.3f)\n",this_node,p[i].r.p[0],p[i].r.p[1],p[i].r.p[2])); #ifdef ADDITIONAL_CHECKS force_and_velocity_check(&p[i]); #endif } } resort_particles = 1; /* Apply new volume to the box-length, communicate it, and account for necessary adjustments to the cell geometry */ if (this_node == 0) { for ( i = 0 ; i < 3 ; i++ ){ if ( nptiso.geometry & nptiso.nptgeom_dir[i] ) { box_l[i] = L_new; } else if ( nptiso.cubic_box ) { box_l[i] = L_new; } } } MPI_Bcast(box_l, 3, MPI_DOUBLE, 0, comm_cart); /* fast box length update */ grid_changed_box_l(); recalc_maximal_cutoff(); cells_on_geometry_change(CELL_FLAG_FAST); }
void on_parameter_change(int field) { /* to prevent two on_coulomb_change */ #if defined(ELECTROSTATICS) || defined(MAGNETOSTATICS) int cc = 0; #endif EVENT_TRACE(fprintf(stderr, "%d: on_parameter_change %s\n", this_node, fields[field].name)); if (field == FIELD_SKIN) { integrate_vv_recalc_maxrange(); on_parameter_change(FIELD_MAXRANGE); } if (field == FIELD_NODEGRID) grid_changed_n_nodes(); if (field == FIELD_BOXL || field == FIELD_NODEGRID) grid_changed_box_l(); if (field == FIELD_TIMESTEP || field == FIELD_TEMPERATURE || field == FIELD_LANGEVIN_GAMMA || field == FIELD_DPD_TGAMMA || field == FIELD_DPD_GAMMA || field == FIELD_NPTISO_G0 || field == FIELD_NPTISO_GV || field == FIELD_NPTISO_PISTON ) reinit_thermo = 1; #ifdef NPT if ((field == FIELD_INTEG_SWITCH) && (integ_switch != INTEG_METHOD_NPT_ISO)) nptiso.invalidate_p_vel = 1; #endif #ifdef ADRESS // if (field == FIELD_BOXL) // adress_changed_box_l(); #endif #ifdef ELECTROSTATICS switch (coulomb.method) { #ifdef ELP3M case COULOMB_ELC_P3M: if (field == FIELD_TEMPERATURE || field == FIELD_BOXL) cc = 1; // fall through case COULOMB_P3M: if (field == FIELD_TEMPERATURE || field == FIELD_NODEGRID || field == FIELD_SKIN) cc = 1; else if (field == FIELD_BOXL) { P3M_scaleby_box_l_charges(); integrate_vv_recalc_maxrange(); } break; #endif case COULOMB_EWALD: if (field == FIELD_TEMPERATURE || field == FIELD_SKIN) cc = 1; else if (field == FIELD_BOXL) { EWALD_scaleby_box_l(); integrate_vv_recalc_maxrange(); } break; case COULOMB_DH: if (field == FIELD_TEMPERATURE) cc = 1; break; case COULOMB_RF: case COULOMB_INTER_RF: if (field == FIELD_TEMPERATURE) cc = 1; break; case COULOMB_MMM1D: if (field == FIELD_TEMPERATURE || field == FIELD_BOXL) cc = 1; break; case COULOMB_MMM2D: if (field == FIELD_TEMPERATURE || field == FIELD_BOXL || field == FIELD_NLAYERS) cc = 1; break; case COULOMB_MAGGS: /* Maggs electrostatics needs ghost velocities */ on_ghost_flags_change(); cells_re_init(CELL_STRUCTURE_CURRENT); break; default: break; } #endif /*ifdef ELECTROSTATICS */ #ifdef MAGNETOSTATICS switch (coulomb.Dmethod) { #ifdef ELP3M case DIPOLAR_MDLC_P3M: if (field == FIELD_TEMPERATURE || field == FIELD_BOXL) cc = 1; // fall through case DIPOLAR_P3M: if (field == FIELD_TEMPERATURE || field == FIELD_NODEGRID || field == FIELD_SKIN) cc = 1; else if (field == FIELD_BOXL) { P3M_scaleby_box_l_dipoles(); integrate_vv_recalc_maxrange(); } break; #endif default: break; } #endif /*ifdef MAGNETOSTATICS */ #if defined(ELECTROSTATICS) || defined(MAGNETOSTATICS) if (cc) on_coulomb_change(); #endif /* DPD needs ghost velocities, other thermostats not */ if (field == FIELD_THERMO_SWITCH) { on_ghost_flags_change(); cells_re_init(CELL_STRUCTURE_CURRENT); } if (field == FIELD_MAXRANGE) rebuild_verletlist = 1; switch (cell_structure.type) { case CELL_STRUCTURE_LAYERED: if (field == FIELD_NODEGRID) { if (node_grid[0] != 1 || node_grid[1] != 1) { char *errtext = runtime_error(128); ERROR_SPRINTF(errtext, "{091 layered cellsystem requires 1 1 n node grid} "); } } if (field == FIELD_BOXL || field == FIELD_MAXRANGE || field == FIELD_THERMO_SWITCH) cells_re_init(CELL_STRUCTURE_LAYERED); break; case CELL_STRUCTURE_DOMDEC: if (field == FIELD_BOXL || field == FIELD_NODEGRID || field == FIELD_MAXRANGE || field == FIELD_MINNUMCELLS || field == FIELD_MAXNUMCELLS || field == FIELD_THERMO_SWITCH) cells_re_init(CELL_STRUCTURE_DOMDEC); break; } #ifdef LB /* LB needs ghost velocities */ if (field == FIELD_LATTICE_SWITCH) { on_ghost_flags_change(); cells_re_init(CELL_STRUCTURE_CURRENT); } if (lattice_switch & LATTICE_LB) { if (field == FIELD_TEMPERATURE) { lb_reinit_parameters(); } if (field == FIELD_BOXL || field == FIELD_CELLGRID || field == FIELD_NNODES || field == FIELD_NODEGRID) { lb_init(); } } #endif #ifdef LB_GPU if(this_node == 0){ if (lattice_switch & LATTICE_LB_GPU) { if (field == FIELD_TEMPERATURE) lb_init_gpu(); } } #endif }