int tclcommand_thermostat_parse_npt_isotropic(Tcl_Interp *interp, int argc, char **argv) { double temp, gamma0, gammav; /* check number of arguments */ if (argc < 5) { Tcl_AppendResult(interp, "wrong # args: should be \n\"", argv[0]," set ",argv[1]," <temp> <gamma0> <gammav>\"", (char *)NULL); return (TCL_ERROR); } /* check argument types */ if ( !ARG_IS_D(2, temp) || !ARG_IS_D(3, gamma0) || !ARG_IS_D(4, gammav) ) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs four DOUBLES", (char *)NULL); return (TCL_ERROR); } /* broadcast parameters */ temperature = temp; nptiso_gamma0 = gamma0; nptiso_gammav = gammav; thermo_switch = ( thermo_switch | THERMO_NPT_ISO ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); mpi_bcast_parameter(FIELD_NPTISO_G0); mpi_bcast_parameter(FIELD_NPTISO_GV); return (TCL_OK); }
int tclcommand_thermostat_parse_cpu(Tcl_Interp *interp, int argc, char **argv) { int temp; #ifndef __linux__ Tcl_AppendResult(interp, "This feature is currently only supported on Linux platforms.", (char *)NULL); return (TCL_ERROR); #endif /* check number of arguments */ if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \n\"", argv[0]," ",argv[1]," <temp>\"", (char *)NULL); return (TCL_ERROR); } /* check argument types */ if ( !ARG_IS_I(2, temp) ) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs one INT", (char *)NULL); return (TCL_ERROR); } /* broadcast parameters */ temperature = temp; thermo_switch = ( thermo_switch | THERMO_CPU ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); return (TCL_OK); }
void tune_skin(double min, double max, double tol, int steps) { skin_set = true; double a = min; double b = max; double time_a, time_b; while(fabs(a - b) > tol) { skin = a; mpi_bcast_parameter(FIELD_SKIN); time_a = time_calc(steps); skin = b; mpi_bcast_parameter(FIELD_SKIN); time_b = time_calc(steps); if(time_a > time_b) { a = 0.5*(a + b); } else { b = 0.5*(a + b); } } skin = 0.5*(a+b); mpi_bcast_parameter(FIELD_SKIN); }
int tclcommand_thermostat_parse_lb(Tcl_Interp *interp, int argc, char ** argv) { #if defined(LB) || defined(LB_GPU) double temp; /* get lb interaction type */ if (argc < 2) { Tcl_AppendResult(interp, "lb needs 1 parameter: " "<temperature>", (char *) NULL); return TCL_ERROR; } /* copy lattice-boltzmann parameters */ if (! ARG_IS_D(1, temp)) { return TCL_ERROR; } if ( temp < 0.0 ) { Tcl_AppendResult(interp, "temperature must be non-negative", (char *) NULL); return TCL_ERROR; } temperature = temp; thermo_switch = ( thermo_switch | THERMO_LB ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); #endif return TCL_OK; }
int tclcommand_thermostat_parse_bd(Tcl_Interp *interp, int argc, char **argv) { double temp; /* check number of arguments */ if (argc < 3) { Tcl_AppendResult(interp, "wrong # args: should be \n\"", argv[0]," ",argv[1]," <temp>\"", (char *)NULL); return (TCL_ERROR); } /* check argument types */ if ( !ARG_IS_D(2, temp) ) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs a DOUBLE", (char *)NULL); return (TCL_ERROR); } if (temp < 0) { Tcl_AppendResult(interp, "temperature must be positive", (char *)NULL); return (TCL_ERROR); } /* broadcast parameters */ temperature = temp; thermo_switch = ( thermo_switch | THERMO_BD ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); return (TCL_OK); }
int tclcommand_thermostat_parse_inter_dpd(Tcl_Interp *interp, int argc, char ** argv) { double temp; if (argc < 2) { Tcl_AppendResult(interp, "thermostat needs 1 parameter: " "<temperature>", (char *) NULL); return TCL_ERROR; } if (argc>2 && ARG_IS_S(2, "ignore_fixed_particles")) { if (argc == 3) dpd_ignore_fixed_particles=1; else if (argc!= 4 || (!ARG_IS_I(3, dpd_ignore_fixed_particles))) return TCL_ERROR; mpi_bcast_parameter(FIELD_DPD_IGNORE_FIXED_PARTICLES); return TCL_OK; } /* copy lattice-boltzmann parameters */ if (! ARG_IS_D(2, temp)) { return TCL_ERROR; } if ( temp < 0.0 ) { Tcl_AppendResult(interp, "temperature must be non-negative", (char *) NULL); return TCL_ERROR; } temperature = temp; thermo_switch = ( thermo_switch | THERMO_INTER_DPD ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); return (TCL_OK); }
int tclcallback_npt_piston(Tcl_Interp *interp, void *_data) { double data = *(double *)_data; if (data < 0.0) { Tcl_AppendResult(interp, "the piston's mass must be positive.", (char *) NULL); return (TCL_ERROR); } nptiso.piston = data; mpi_bcast_parameter(FIELD_NPTISO_PISTON); return (TCL_OK); }
int remove_particle(int part) { int pnode; Particle *cur_par = (Particle *) malloc (sizeof(Particle)); if (get_particle_data(part, cur_par) == ES_ERROR ) return ES_ERROR; int type = cur_par->p.type; free(cur_par); if (remove_id_type_array(part, type) == ES_ERROR ) return ES_ERROR; if (!particle_node) build_particle_node(); if (part > max_seen_particle) return ES_ERROR; pnode = particle_node[part]; if (pnode == -1) return ES_ERROR; particle_node[part] = -1; mpi_remove_particle(pnode, part); if (part == max_seen_particle) { while (max_seen_particle >= 0 && particle_node[max_seen_particle] == -1) max_seen_particle--; mpi_bcast_parameter(FIELD_MAXPART); } return ES_OK; }
int tclcallback_time(Tcl_Interp *interp, void *_data) { double data = *(double *)_data; sim_time = data; mpi_bcast_parameter(FIELD_SIMTIME); return (TCL_OK); }
int tclcallback_node_grid(Tcl_Interp *interp, void *_data) { int *data = (int *)_data; if ((data[0] < 0) || (data[1] < 0) || (data[2] < 0)) { Tcl_AppendResult(interp, "illegal value", (char *) NULL); return (TCL_ERROR); } if (data[0]*data[1]*data[2] != n_nodes) { Tcl_AppendResult(interp, "node grid does not fit n_nodes", (char *) NULL); return (TCL_ERROR); } /* outsourced to sort_int_array(data,3); */ node_grid[0] = data[0]; node_grid[1] = data[1]; node_grid[2] = data[2]; mpi_bcast_parameter(FIELD_NODEGRID); return (TCL_OK); }
/** Parser for the \ref lbfluid command gpu. */ int tclcommand_lbfluid_gpu(Tcl_Interp *interp, int argc, char **argv) { #ifdef LB_GPU int err = TCL_OK; int change = 0; while (argc > 0) { if (ARG0_IS_S("grid") || ARG0_IS_S("agrid")) err = lbfluid_parse_agrid(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("tau")) err = lbfluid_parse_tau(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("density") || ARG0_IS_S("dens")) err = lbfluid_parse_density(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("viscosity") || ARG0_IS_S("visc")) err = lbfluid_parse_viscosity(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("bulk_viscosity") || ARG0_IS_S("b_visc")) err = lbfluid_parse_bulk_visc(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("friction") || ARG0_IS_S("coupling")) err = lbfluid_parse_friction(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("ext_force")) err = lbfluid_parse_ext_force(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("gamma_odd")) err = lbfluid_parse_gamma_odd(interp, argc-1, argv+1, &change); else if (ARG0_IS_S("gamma_even")) err = lbfluid_parse_gamma_even(interp, argc-1, argv+1, &change); else { Tcl_AppendResult(interp, "unknown feature \"", argv[0],"\" of lbfluid", (char *)NULL); err = TCL_ERROR ; } if (err == TCL_ERROR) return TCL_ERROR; argc -= (change + 1); argv += (change + 1); } mpi_bcast_parameter(FIELD_LATTICE_SWITCH) ; /* thermo_switch is retained for backwards compatibility */ thermo_switch = (thermo_switch | THERMO_LB); mpi_bcast_parameter(FIELD_THERMO_SWITCH); LB_TRACE (fprintf(stderr,"tclcommand_lbfluid_gpu parser ok \n")); return err; #else /* !defined LB_GPU */ Tcl_AppendResult(interp, "LB_GPU is not compiled in!", NULL); return TCL_ERROR; #endif }
int tclcommand_cellsystem(ClientData data, Tcl_Interp *interp, int argc, char **argv) { int err = 0; if (argc <= 1) { Tcl_AppendResult(interp, "usage: cellsystem <system> <params>", (char *)NULL); return TCL_ERROR; } if (ARG1_IS_S("domain_decomposition")) { if (argc > 2) { if (ARG_IS_S(2,"-verlet_list")) dd.use_vList = 1; else if(ARG_IS_S(2,"-no_verlet_list")) dd.use_vList = 0; else{ Tcl_AppendResult(interp, "wrong flag to",argv[0], " : should be \" -verlet_list or -no_verlet_list \"", (char *) NULL); return (TCL_ERROR); } } /** by default use verlet list */ else dd.use_vList = 1; mpi_bcast_cell_structure(CELL_STRUCTURE_DOMDEC); } else if (ARG1_IS_S("nsquare")) mpi_bcast_cell_structure(CELL_STRUCTURE_NSQUARE); else if (ARG1_IS_S("layered")) { if (argc > 2) { if (!ARG_IS_I(2, n_layers)) return TCL_ERROR; if (n_layers <= 0) { Tcl_AppendResult(interp, "layer height should be positive", (char *)NULL); return TCL_ERROR; } determine_n_layers = 0; } /* check node grid. All we can do is 1x1xn. */ if (node_grid[0] != 1 || node_grid[1] != 1) { node_grid[0] = node_grid[1] = 1; node_grid[2] = n_nodes; err = mpi_bcast_parameter(FIELD_NODEGRID); } else err = 0; if (!err) mpi_bcast_cell_structure(CELL_STRUCTURE_LAYERED); } else { Tcl_AppendResult(interp, "unkown cell structure type \"", argv[1],"\"", (char *)NULL); return TCL_ERROR; } return gather_runtime_errors(interp, TCL_OK); }
int tclcallback_periodicity(Tcl_Interp *interp, void *_data) { periodic = *(int *)_data; mpi_bcast_parameter(FIELD_PERIODIC); return (TCL_OK); }
/* 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()); }
int tclcommand_thermostat_parse_off(Tcl_Interp *interp, int argc, char **argv) { /* set temperature to zero */ temperature = 0; mpi_bcast_parameter(FIELD_TEMPERATURE); /* langevin thermostat */ langevin_gamma = 0; /* Friction coefficient gamma for rotation */ langevin_gamma_rotation = 0; mpi_bcast_parameter(FIELD_LANGEVIN_GAMMA); /* Langevin for translations */ langevin_trans = true; /* Langevin for rotations */ langevin_rotate = true; #ifdef DPD /* dpd thermostat */ dpd_switch_off(); #endif #ifdef INTER_DPD inter_dpd_switch_off(); #endif #ifdef NPT /* npt isotropic thermostat */ nptiso_gamma0 = 0; mpi_bcast_parameter(FIELD_NPTISO_G0); nptiso_gammav = 0; mpi_bcast_parameter(FIELD_NPTISO_GV); #endif #ifdef GHMC /* ghmc thermostat */ ghmc_nmd = 1; mpi_bcast_parameter(FIELD_GHMC_NMD); ghmc_phi = 1; mpi_bcast_parameter(FIELD_GHMC_PHI); ghmc_mflip = GHMC_MFLIP_OFF; mpi_bcast_parameter(FIELD_GHMC_FLIP); ghmc_tscale = GHMC_TSCALE_OFF; mpi_bcast_parameter(FIELD_GHMC_SCALE); #endif /* switch thermostat off */ thermo_switch = THERMO_OFF; mpi_bcast_parameter(FIELD_THERMO_SWITCH); return (TCL_OK); }
void rescale_boxl(int dir, double d_new) { double scale = (dir-3) ? d_new/box_l[dir] : d_new/box_l[0]; if (scale < 1.) { mpi_rescale_particles(dir,scale); if (dir < 3) box_l[dir] = d_new; else box_l[0] = box_l[1] = box_l[2] = d_new; mpi_bcast_parameter(FIELD_BOXL); } else if (scale > 1.) { if (dir < 3) box_l[dir] = d_new; else box_l[0] = box_l[1] = box_l[2] = d_new; mpi_bcast_parameter(FIELD_BOXL); mpi_rescale_particles(dir,scale); } }
int tclcallback_max_num_cells(Tcl_Interp *interp, void *_data) { int data = *(int *)_data; if (data < min_num_cells) { Tcl_AppendResult(interp, "max_num_cells cannot be smaller than min_num_cells", (char *) NULL); return (TCL_ERROR); } max_num_cells = data; mpi_bcast_parameter(FIELD_MAXNUMCELLS); return (TCL_OK); }
int tclcallback_skin(Tcl_Interp *interp, void *_data) { double data = *(double *)_data; if (data < 0) { Tcl_AppendResult(interp, "skin must be positive.", (char *) NULL); return (TCL_ERROR); } skin = data; mpi_bcast_parameter(FIELD_SKIN); return (TCL_OK); }
int tclcallback_dpd_ignore_fixed_particles(Tcl_Interp *interp, void *_data) { int data = *(int *)_data; if ((data == 0) || (data == 1)) { dpd_ignore_fixed_particles = data; mpi_bcast_parameter(FIELD_DPD_IGNORE_FIXED_PARTICLES); return (TCL_OK); } else{ Tcl_AppendResult(interp, "illegal value", (char *) NULL); return (TCL_ERROR); } }
int tclcommand_thermostat_parse_inter_dpd(Tcl_Interp *interp, int argc, char ** argv) { double temp; if (argc < 2) { Tcl_AppendResult(interp, "thermostat needs 1 parameter: " "<temperature>", (char *) NULL); return TCL_ERROR; } /* copy lattice-boltzmann parameters */ if (! ARG_IS_D(2, temp)) { return TCL_ERROR; } if ( temp < 0.0 ) { Tcl_AppendResult(interp, "temperature must be non-negative", (char *) NULL); return TCL_ERROR; } temperature = temp; thermo_switch = ( thermo_switch | THERMO_INTER_DPD ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); return (TCL_OK); }
int tclcallback_box_l(Tcl_Interp *interp, void *_data) { double *data = _data; if ((data[0] <= 0) || (data[1] <= 0) || (data[2] <= 0)) { Tcl_AppendResult(interp, "illegal value", (char *) NULL); return (TCL_ERROR); } box_l[0] = data[0]; box_l[1] = data[1]; box_l[2] = data[2]; mpi_bcast_parameter(FIELD_BOXL); return (TCL_OK); }
/***************************************************************************** * setting parameters *****************************************************************************/ int rigid_bond_set_params(int bond_type, double d, double p_tol, double v_tol) { if(bond_type < 0) return ES_ERROR; make_bond_type_exist(bond_type); bonded_ia_params[bond_type].p.rigid_bond.d2 = d*d; bonded_ia_params[bond_type].p.rigid_bond.p_tol = 2.0*p_tol; bonded_ia_params[bond_type].p.rigid_bond.v_tol = v_tol*time_step; bonded_ia_params[bond_type].type = BONDED_IA_RIGID_BOND; bonded_ia_params[bond_type].num = 1; n_rigidbonds += 1; mpi_bcast_ia_params(bond_type, -1); mpi_bcast_parameter(FIELD_RIGIDBONDS); return ES_OK; }
int tclcallback_min_num_cells(Tcl_Interp *interp, void *_data) { char buf[TCL_INTEGER_SPACE]; int data = *(int *)_data; int min = calc_processor_min_num_cells(); if (data < min) { sprintf(buf, "%d", min); Tcl_AppendResult(interp, "min_num_cells must be at least ", buf, (char *) NULL); return (TCL_ERROR); } if (data > max_num_cells) { Tcl_AppendResult(interp, "min_num_cells cannot be larger than max_num_cells", (char *) NULL); return (TCL_ERROR); } min_num_cells = data; mpi_bcast_parameter(FIELD_MINNUMCELLS); return (TCL_OK); }
void dpd_switch_off() { extern double dpd_gamma,dpd_r_cut; extern int dpd_wf; #ifdef TRANS_DPD extern double dpd_tgamma,dpd_tr_cut; extern int dpd_twf; #endif dpd_gamma = 0; mpi_bcast_parameter(FIELD_DPD_GAMMA); dpd_r_cut = 0; mpi_bcast_parameter(FIELD_DPD_RCUT); dpd_wf=0; mpi_bcast_parameter(FIELD_DPD_WF); #ifdef TRANS_DPD dpd_tgamma = 0; mpi_bcast_parameter(FIELD_DPD_TGAMMA); dpd_tr_cut=0; mpi_bcast_parameter(FIELD_DPD_TRCUT); dpd_twf=0; mpi_bcast_parameter(FIELD_DPD_TWF); #endif }
/** Parse integrate npt_isotropic command */ int tclcommand_integrate_set_npt_isotropic(Tcl_Interp *interp, int argc, char **argv) { int xdir, ydir, zdir; xdir = ydir = zdir = nptiso.cubic_box = 0; if (argc < 4) { Tcl_AppendResult(interp, "wrong # args: \n", (char *)NULL); return tclcommand_integrate_print_usage(interp); } /* set parameters p_ext and piston */ if ( !ARG_IS_D(3, nptiso.p_ext) ) return tclcommand_integrate_print_usage(interp); tclcallback_p_ext(interp, &nptiso.p_ext); if ( argc > 4 ) { if(!ARG_IS_D(4, nptiso.piston) ) return tclcommand_integrate_print_usage(interp); tclcallback_npt_piston(interp, &nptiso.piston); } else if ( nptiso.piston <= 0.0 ) { Tcl_AppendResult(interp, "You must set <piston> as well before you can use this integrator! \n", (char *)NULL); return tclcommand_integrate_print_usage(interp); } if ( argc > 5 ) { if (!ARG_IS_I(5,xdir) || !ARG_IS_I(6,ydir) || !ARG_IS_I(7,zdir) ) { return tclcommand_integrate_print_usage(interp);} else { /* set the geometry to include rescaling specified directions only*/ nptiso.geometry = 0; nptiso.dimension = 0; nptiso.non_const_dim = -1; if ( xdir ) { nptiso.geometry = ( nptiso.geometry | NPTGEOM_XDIR ); nptiso.dimension += 1; nptiso.non_const_dim = 0; } if ( ydir ) { nptiso.geometry = ( nptiso.geometry | NPTGEOM_YDIR ); nptiso.dimension += 1; nptiso.non_const_dim = 1; } if ( zdir ) { nptiso.geometry = ( nptiso.geometry | NPTGEOM_ZDIR ); nptiso.dimension += 1; nptiso.non_const_dim = 2; } } } else { /* set the geometry to include rescaling in all directions; the default*/ nptiso.geometry = 0; nptiso.geometry = ( nptiso.geometry | NPTGEOM_XDIR ); nptiso.geometry = ( nptiso.geometry | NPTGEOM_YDIR ); nptiso.geometry = ( nptiso.geometry | NPTGEOM_ZDIR ); nptiso.dimension = 3; nptiso.non_const_dim = 2; } if ( argc > 8 ) { /* enable if the volume fluctuations should also apply to dimensions which are switched off by the above flags and which do not contribute to the pressure (3D) / tension (2D, 1D) */ if (!ARG_IS_S(8,"-cubic_box")) { return tclcommand_integrate_print_usage(interp); } else { nptiso.cubic_box = 1; } } /* Sanity Checks */ #ifdef ELECTROSTATICS if ( nptiso.dimension < 3 && !nptiso.cubic_box && coulomb.bjerrum > 0 ){ fprintf(stderr,"WARNING: If electrostatics is being used you must use the -cubic_box option!\n"); fprintf(stderr,"Automatically reverting to a cubic box for npt integration.\n"); fprintf(stderr,"Be aware though that all of the coulombic pressure is added to the x-direction only!\n"); nptiso.cubic_box = 1; } #endif #ifdef DIPOLES if ( nptiso.dimension < 3 && !nptiso.cubic_box && coulomb.Dbjerrum > 0 ){ fprintf(stderr,"WARNING: If magnetostatics is being used you must use the -cubic_box option!\n"); fprintf(stderr,"Automatically reverting to a cubic box for npt integration.\n"); fprintf(stderr,"Be aware though that all of the magnetostatic pressure is added to the x-direction only!\n"); nptiso.cubic_box = 1; } #endif if( nptiso.dimension == 0 || nptiso.non_const_dim == -1) { Tcl_AppendResult(interp, "You must enable at least one of the x y z components as fluctuating dimension(s) for box length motion!", (char *)NULL); Tcl_AppendResult(interp, "Cannot proceed with npt_isotropic, reverting to nvt integration... \n", (char *)NULL); integ_switch = INTEG_METHOD_NVT; mpi_bcast_parameter(FIELD_INTEG_SWITCH); return (TCL_ERROR); } /* set integrator switch */ integ_switch = INTEG_METHOD_NPT_ISO; mpi_bcast_parameter(FIELD_INTEG_SWITCH); /* broadcast npt geometry information to all nodes */ mpi_bcast_nptiso_geom(); return (TCL_OK); }
/** Parse integrate nvt command */ int tclcommand_integrate_set_nvt(Tcl_Interp *interp, int argc, char **argv) { integ_switch = INTEG_METHOD_NVT; mpi_bcast_parameter(FIELD_INTEG_SWITCH); return (TCL_OK); }
int tclcommand_adress_parse_set(Tcl_Interp *interp,int argc, char **argv){ int topo=-1,i,wf=0,set_center=0; double width[2],center[3]; char buffer[3*TCL_DOUBLE_SPACE]; argv+=2;argc-=2; for(i=0;i<3;i++) center[i]=box_l[i]/2; if (argc < 2) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "Wrong # of args! adress set needs at least 2 arguments\n", (char *)NULL); Tcl_AppendResult(interp, "Usage: adress set topo [0|1|2|3] width X.X Y.Y (center X.X Y.Y Z.Z) (wf [0|1])\n", (char *)NULL); Tcl_AppendResult(interp, "topo: 0 - switched off (no more values needed)\n", (char *)NULL); Tcl_AppendResult(interp, " 1 - constant (weight will be first value of width)\n", (char *)NULL); Tcl_AppendResult(interp, " 2 - divided in one direction (default x, or give a negative center coordinate\n", (char *)NULL); Tcl_AppendResult(interp, " 3 - spherical topology\n", (char *)NULL); Tcl_AppendResult(interp, "width: X.X - half of size of ex zone(r0/2 in the papers)\n", (char *)NULL); Tcl_AppendResult(interp, " Y.Y - size of hybrid zone (d in the papers)\n", (char *)NULL); Tcl_AppendResult(interp, " Note: Only one value need for topo 1 \n", (char *)NULL); Tcl_AppendResult(interp, "center: center of the ex zone (default middle of the box) \n", (char *)NULL); Tcl_AppendResult(interp, " Note: x|y|x X.X for topo 2 \n", (char *)NULL); Tcl_AppendResult(interp, " Note: X.X Y.Y Z.Z for topo 3 \n", (char *)NULL); Tcl_AppendResult(interp, "wf: 0 - cos weighting function (default)\n", (char *)NULL); Tcl_AppendResult(interp, " 1 - polynom weighting function\n", (char *)NULL); Tcl_AppendResult(interp, "ALWAYS set box_l first !!!", (char *)NULL); return (TCL_ERROR); } //parse topo if ( (argc<2) || (!ARG0_IS_S("topo")) || (!ARG1_IS_I(topo)) || (topo < 0) || (topo > 3) ) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected \'topo 0|1|2|3\'\n", (char *)NULL); return (TCL_ERROR); } argv+=2;argc-=2; //stop if topo is 0 if (topo==0) { adress_vars[0]=0.0; mpi_bcast_parameter(FIELD_ADRESS); return TCL_OK; } //parse width if ( (argc>1) && (ARG0_IS_S("width")) ) { if (topo==1) { if ( (!ARG1_IS_D(width[0])) || (width[0]<0) ){ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected \'width X.X (X.X non-negative)\'", (char *)NULL); return (TCL_ERROR); } if ((width[0]> 1.0) || (width[0]< 0.0)) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "for constant topo, first width must be between 0 and 1", (char *)NULL); return (TCL_ERROR); } //stop if topo is 1 adress_vars[0]=1; adress_vars[1]=width[0]; mpi_bcast_parameter(FIELD_ADRESS); return TCL_OK; } else {//topo 2 and 3 are left over if ( (argc<3) || (!ARG1_IS_D(width[0])) || (width[0]<0) ||(!ARG_IS_D(2,width[1])) || (width[1]<0) ){ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected \'width X.X Y.Y (both non-negative)\'", (char *)NULL); return (TCL_ERROR); } argv+=3;argc-=3; } } else{ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected \'width\'", (char *)NULL); return (TCL_ERROR); } while (argc!=0){ if (ARG0_IS_S("wf")){ if ( (argc<2) || (!ARG1_IS_I(wf)) || (wf < 0) || (wf > 1) ){ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected \'wf 0|1\'", (char *)NULL); return (TCL_ERROR); } else{ argv+=2;argc-=2; } } else if (ARG0_IS_S("center")){ if (topo == 2) { if ( (argc<3) || ( (!ARG1_IS_S("x"))&&(!ARG1_IS_S("y"))&&(!ARG1_IS_S("z")) ) || (!ARG_IS_D(2,center[1])) ){ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected \'center x|y|z X.X\'", (char *)NULL); return (TCL_ERROR); } if (ARG1_IS_S("x")) center[0]=0; else if (ARG1_IS_S("y")) center[0]=1; else center[0]=2; if ( (center[1]<0) || (center[1]>box_l[(int)center[0]]) ) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "The center component is outside the box", (char *)NULL); return (TCL_ERROR); } set_center=1; argv+=3;argc-=3; } else { //topo 3 if ( (argc<4) || (!ARG_IS_D(1,center[0])) || (!ARG_IS_D(2,center[1])) || (!ARG_IS_D(3,center[2])) ){ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "expected \'center X.X Y.Y Z.Z\'", (char *)NULL); return (TCL_ERROR); } argv+=4;argc-=4; //check components of center for (i=0;i<3;i++){ if ( (center[i]<0)||(center[i]>box_l[i]) ){ Tcl_ResetResult(interp); sprintf(buffer,"%i",i); Tcl_AppendResult(interp, "The ",buffer," th component of center is outside the box\n", (char *)NULL); return (TCL_ERROR); } } } } else{ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "The unknown operation \"", argv[0],"\".", (char *)NULL); return (TCL_ERROR); } } //set standard center value for topo 2 if ((topo==2) && (set_center==0) ) center[0]=0; //width check if (topo==2){ if (width[0]+width[1]>box_l[(int)center[0]]/2){ Tcl_ResetResult(interp); Tcl_AppendResult(interp, "The width of ex+hy must smaller than box_l/2\n", (char *)NULL); return (TCL_ERROR); } } else if (topo==3){ for (i=0;i<3;i++){ if (width[0]+width[1]>box_l[i]/2){ Tcl_ResetResult(interp); sprintf(buffer,"%i",i); Tcl_AppendResult(interp, "The width of ex+hy must smaller than box_l/2 in dim " ,buffer,"\n", (char *)NULL); return (TCL_ERROR); } } } adress_vars[0]=topo; adress_vars[1]=width[0]; adress_vars[2]=width[1]; adress_vars[3]=center[0]; adress_vars[4]=center[1]; adress_vars[5]=center[2]; adress_vars[6]=wf; mpi_bcast_parameter(FIELD_ADRESS); return TCL_OK; }
int tclcommand_integrate(ClientData data, Tcl_Interp *interp, int argc, char **argv) { int n_steps, reuse_forces = 0; INTEG_TRACE(fprintf(stderr, "%d: integrate:\n", this_node)); if (argc < 1) { Tcl_AppendResult(interp, "wrong # args: \n\"", (char *)NULL); return tclcommand_integrate_print_usage(interp); } else if (argc < 2) { return tclcommand_integrate_print_status(interp); } if (ARG1_IS_S("set")) { if (argc < 3) return tclcommand_integrate_print_status(interp); if (ARG_IS_S(2, "nvt")) return tclcommand_integrate_set_nvt(interp, argc, argv); #ifdef NPT else if (ARG_IS_S(2, "npt_isotropic")) return tclcommand_integrate_set_npt_isotropic(interp, argc, argv); #endif else { Tcl_AppendResult(interp, "unknown integrator method:\n", (char *)NULL); return tclcommand_integrate_print_usage(interp); } } else { if (!ARG_IS_I(1, n_steps)) return tclcommand_integrate_print_usage(interp); // actual integration if ((argc == 3) && ARG_IS_S(2, "reuse_forces")) { reuse_forces = 1; } else if ((argc == 3) && ARG_IS_S(2, "recalc_forces")) { reuse_forces = -1; } else if (argc != 2) return tclcommand_integrate_print_usage(interp); } /* go on with integrate <n_steps> */ if (n_steps < 0) { Tcl_AppendResult(interp, "illegal number of steps (must be >0) \n", (char *)NULL); return tclcommand_integrate_print_usage(interp); ; } /* if skin wasn't set, do an educated guess now */ if (!skin_set) { if (max_cut == 0.0) { Tcl_AppendResult(interp, "cannot automatically determine skin, please " "set it manually via \"setmd skin\"\n", (char *)NULL); return TCL_ERROR; } skin = 0.4 * max_cut; mpi_bcast_parameter(FIELD_SKIN); } /* perform integration */ if (!correlations_autoupdate && !observables_autoupdate) { if (mpi_integrate(n_steps, reuse_forces)) return gather_runtime_errors(interp, TCL_OK); } else { for (int i = 0; i < n_steps; i++) { if (mpi_integrate(1, reuse_forces)) return gather_runtime_errors(interp, TCL_OK); reuse_forces = 1; autoupdate_observables(); autoupdate_correlations(); } if (n_steps == 0) { if (mpi_integrate(0, reuse_forces)) return gather_runtime_errors(interp, TCL_OK); } } return TCL_OK; }
int tclcommand_thermostat_parse_langevin(Tcl_Interp *interp, int argc, char **argv) { double temp, gammat = 0.0, gammar = 0.0; bool trans = true, rot = true; /* check number of arguments */ if (argc < 4) { Tcl_AppendResult(interp, "wrong # args: should be \n\"", argv[0]," ",argv[1]," <temp> <gamma_trans> [<gamma_rot> <on/off> <on/off>]\"", (char *)NULL); return (TCL_ERROR); } /* check argument types */ if ( !ARG_IS_D(2, temp) || !ARG_IS_D(3, gammat)) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs two DOUBLES", (char *)NULL); return (TCL_ERROR); } if (argc > 4 && argc < 6) { if ( !ARG_IS_D(4, gammar) ) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs three DOUBLES", (char *)NULL); return (TCL_ERROR); } } if (argc > 5 && argc < 7) { if ( !ARG_IS_S(5, "on") && !ARG_IS_S(5, "off") ) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs on/off", (char *)NULL); return (TCL_ERROR); } else { if ( ARG_IS_S(5, "on") ) { trans = true; } else { trans = false; } } } if (argc > 6 && argc < 8) { if ( !ARG_IS_S(6, "on") && !ARG_IS_S(6, "off") ) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs on/off", (char *)NULL); return (TCL_ERROR); } else { if ( ARG_IS_S(6, "on") ) { rot = true; } else { rot = false; } } } if (temp < 0 || gammat < 0 || gammar < 0) { Tcl_AppendResult(interp, "temperature and friction must be positive", (char *)NULL); return (TCL_ERROR); } /* broadcast parameters */ temperature = temp; langevin_gamma = gammat; langevin_gamma_rotation = gammar; langevin_trans = trans; langevin_rotate = rot; thermo_switch = ( thermo_switch | THERMO_LANGEVIN ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); mpi_bcast_parameter(FIELD_LANGEVIN_GAMMA); fprintf(stderr,"WARNING: The behavior of the Langevin thermostat has changed\n"); fprintf(stderr," as of this version! Please consult the user's guide.\n"); return (TCL_OK); }
int tclcommand_thermostat_parse_dpd(Tcl_Interp *interp, int argc, char **argv) { extern double dpd_gamma,dpd_r_cut; extern int dpd_wf; #ifdef TRANS_DPD extern double dpd_tgamma,dpd_tr_cut; extern int dpd_twf; #endif double temp, gamma, r_cut; int wf=0; #ifdef TRANS_DPD double tgamma=0.0,tr_cut; int twf; int set_tgamma=0; #endif #ifdef ROTATION fprintf(stderr,"WARNING: Do not use DPD with ROTATION compiled in\n"); fprintf(stderr," You should first check if a combination of a DPD thermostat\n"); fprintf(stderr," for the translational degrees of freedom and a LANGEVIN thermostat\n"); fprintf(stderr," for the rotational ones yields correct physics!\n"); fprintf(stderr," After this you may remove these lines (thermostat.c::tclcommand_thermostat_parse_dpd)!\n"); #endif /* check number of arguments */ if (argc < 5) { Tcl_AppendResult(interp, "wrong # args: should be \n\"", argv[0]," ",argv[1]," <temp> <gamma> <r_cut>", (char *)NULL); #ifdef TRANS_DPD Tcl_AppendResult(interp,"[<tgamma>] [<tR_cut>]", (char *)NULL); #endif Tcl_AppendResult(interp," [WF <wf>]", (char *)NULL); #ifdef TRANS_DPD Tcl_AppendResult(interp," [TWF <twf>]", (char *)NULL); #endif Tcl_AppendResult(interp,"\"", (char *)NULL); return (TCL_ERROR); } /* check argument types */ if ( !ARG_IS_D(2, temp) || !ARG_IS_D(3, gamma) || !ARG_IS_D(4, r_cut)) { Tcl_AppendResult(interp, argv[0]," ",argv[1]," needs at least three DOUBLES", (char *)NULL); return (TCL_ERROR); } argc-=5; argv+=5; #ifdef TRANS_DPD tgamma=0; tr_cut=r_cut; twf=wf; if ( (argc>0) && (!ARG0_IS_S("WF")) ) { if (!ARG0_IS_D(tgamma)) { Tcl_AppendResult(interp," thermostat dpd: tgamma should be double",(char *)NULL); return (TCL_ERROR); } else{ argc--; argv++; set_tgamma++; } } #endif //try for WF if ( (argc>0) && (ARG0_IS_S("WF")) ){ if (!ARG1_IS_I(wf)){ Tcl_AppendResult(interp," thermostat dpd: wf should be int",(char *)NULL); return (TCL_ERROR); } else{ argc-=2;argv+=2; #ifdef TRANS_DPD twf=wf; #endif } } #ifdef TRANS_DPD if ( (set_tgamma==0) && (argc>0) && (!ARG0_IS_S("TWF")) ) { if (!ARG0_IS_D(tgamma)) { Tcl_AppendResult(interp," thermostat dpd: tgamma should be double",(char *)NULL); return (TCL_ERROR); } else{ argc--; argv++; set_tgamma++; } } if ( (argc>0) && (!ARG0_IS_S("TWF")) ) { if (set_tgamma!=0) { if (!ARG0_IS_D(tr_cut)) { Tcl_AppendResult(interp," thermostat dpd: tr_cut should be double",(char *)NULL); return (TCL_ERROR); } else{ argc--; argv++; } } else{ Tcl_AppendResult(interp," thermostat dpd: tgamma must be set before twf",(char *)NULL); return (TCL_ERROR); } } if ( (argc>0) && (ARG0_IS_S("TWF")) ) { if (set_tgamma!=0) { if (!ARG1_IS_I(wf)) { Tcl_AppendResult(interp," thermostat dpd: twf should be int",(char *)NULL); return (TCL_ERROR); } else{ argc-=2;argv+=2; } } else{ Tcl_AppendResult(interp," thermostat dpd: tgamma must be set before twf",(char *)NULL); return (TCL_ERROR); } } #endif if (argc > 0){ Tcl_AppendResult(interp," thermostat dpd: too many arguments - don't know how to parse them!!!",(char *)NULL); return (TCL_ERROR); } /* broadcast parameters */ temperature = temp; dpd_gamma = gamma; dpd_r_cut = r_cut; dpd_wf = wf; #ifdef TRANS_DPD dpd_tgamma = tgamma; dpd_tr_cut= tr_cut; dpd_twf=twf; #endif thermo_switch = ( thermo_switch | THERMO_DPD ); mpi_bcast_parameter(FIELD_THERMO_SWITCH); mpi_bcast_parameter(FIELD_TEMPERATURE); mpi_bcast_parameter(FIELD_DPD_GAMMA); mpi_bcast_parameter(FIELD_DPD_RCUT); mpi_bcast_parameter(FIELD_DPD_WF); #ifdef TRANS_DPD mpi_bcast_parameter(FIELD_DPD_TGAMMA); mpi_bcast_parameter(FIELD_DPD_TRCUT); mpi_bcast_parameter(FIELD_DPD_TWF); #endif return (TCL_OK); }