void cells_on_max_cut_change(int shrink) { double old_max_range = max_range; calc_maximal_cutoff(); if (max_cut > 0.0) { if (skin >= 0.0) max_range = max_cut + skin; else /* if the skin is not yet set, assume zero. */ max_range = max_cut; } else /* if no interactions yet, we also don't need a skin */ max_range = 0.0; /* no need to do something if 1. the range didn't change numerically (<= necessary for the start case, when max_range and old_max_range == 0.0) 2. it shrank, and we shouldn't shrink (NpT) */ if ((fabs(max_range - old_max_range) <= ROUND_ERROR_PREC * max_range) || (!shrink && (max_range < old_max_range))) return; cells_re_init(CELL_STRUCTURE_CURRENT); for (int i = 0; i < 3; i++) if (local_box_l[i] < max_range) { char *errtext = runtime_error(128 + TCL_INTEGER_SPACE); ERROR_SPRINTF(errtext,"{013 box_l in direction %d is still too small} ", i); } }
void cells_on_geometry_change(int flags) { if (max_cut > 0.0) { max_range = max_cut + skin; } else /* if no interactions yet, we also don't need a skin */ max_range = 0.0; CELL_TRACE(fprintf(stderr,"%d: on_geometry_change with max range %f\n", this_node, max_range)); switch (cell_structure.type) { case CELL_STRUCTURE_DOMDEC: dd_on_geometry_change(flags); break; case CELL_STRUCTURE_LAYERED: /* there is no fast version, always redo everything. */ cells_re_init(CELL_STRUCTURE_LAYERED); break; case CELL_STRUCTURE_NSQUARE: /* this cell system doesn't need to react, just tell the others */ on_boxl_change(); break; } }
void on_ghost_flags_change() { EVENT_TRACE(fprintf(stderr, "%d: on_ghost_flags_change\n", this_node)); /* that's all we change here */ extern int ghosts_have_v; int old_have_v = ghosts_have_v; ghosts_have_v = 0; /* DPD and LB need also ghost velocities */ if (thermo_switch & THERMO_DPD) ghosts_have_v = 1; #ifdef LB if (lattice_switch & LATTICE_LB) ghosts_have_v = 1; #endif #ifdef BOND_CONSTRAINT else if (n_rigidbonds) ghosts_have_v = 1; #endif #ifdef ELECTROSTATICS /* Maggs electrostatics needs ghost velocities too */ else if(coulomb.method == COULOMB_MAGGS) ghosts_have_v = 1; #endif #ifdef INTER_DPD //maybe we have to add a new global to differ between compile in and acctual use. ghosts_have_v = 1; #endif #ifdef VIRTUAL_SITES //VIRUTAL_SITES need v to update v of virtual sites ghosts_have_v = 1; #endif if (old_have_v != ghosts_have_v) cells_re_init(CELL_STRUCTURE_CURRENT); }
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 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 }