/* Calculate the CMS of the system */ int tclcommand_system_CMS(ClientData data, Tcl_Interp * interp, int argc, char ** argv){ char buffer[256]; double cmspos[3]; int box[3]; if (argc != 1 && argc != 2 ) { return tcl_command_system_CMS_print_usage(interp); } else { if (ARG_IS_S_EXACT(0,"system_CMS")) { if ( argc == 2 ) { if (ARG_IS_S_EXACT(1,"folded")) { mpi_system_CMS(); memmove(cmspos, gal.cms, 3*sizeof(double)); box[0] = 0; box[1] = 0; box[2] = 0; fold_position(cmspos, box); Tcl_PrintDouble(interp, cmspos[0], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, cmspos[1], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, cmspos[2], buffer); Tcl_AppendResult(interp, buffer, (char *)NULL); return TCL_OK; } else { return tcl_command_system_CMS_print_usage(interp); } } else { mpi_system_CMS(); Tcl_PrintDouble(interp, gal.cms[0], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, gal.cms[1], buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, gal.cms[2], buffer); Tcl_AppendResult(interp, buffer, (char *)NULL); return TCL_OK; } } else { return tcl_command_system_CMS_print_usage(interp); } } }
/* Stop motion of the particles */ int tclcommand_kill_particle_motion(ClientData data, Tcl_Interp * interp, int argc, char ** argv){ if (argc != 1 && argc != 2 ) { return tcl_command_kill_particle_motion_print_usage(interp); } else { if (ARG_IS_S_EXACT(0,"kill_particle_motion")) { if ( argc == 2 ) { if (ARG_IS_S_EXACT(1,"rotation")) { mpi_kill_particle_motion( 1 ); return TCL_OK; } else { return tcl_command_kill_particle_motion_print_usage(interp); } } else { mpi_kill_particle_motion( 0 ); return TCL_OK; } } else { return tcl_command_kill_particle_motion_print_usage(interp); } } }
/* Remove the CMS velocity of the system */ int tclcommand_galilei_transform(ClientData data, Tcl_Interp * interp, int argc, char ** argv){ if (argc != 1 ) { return tcl_command_galilei_transform_print_usage(interp); } else { if (ARG_IS_S_EXACT(0,"galilei_transform")) { mpi_galilei_transform(); return TCL_OK; } else { return tcl_command_galilei_transform_print_usage(interp); } } }
/* Calculate the CMS velocity of the system */ int tclcommand_system_CMS_velocity(ClientData data, Tcl_Interp * interp, int argc, char ** argv){ char buffer[256]; if (argc != 1 ) { return tcl_command_system_CMS_velocity_print_usage(interp); } else { if (ARG_IS_S_EXACT(0,"system_CMS_velocity")) { mpi_system_CMS_velocity(); Tcl_PrintDouble(interp, gal.cms_vel[0]/time_step, buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, gal.cms_vel[1]/time_step, buffer); Tcl_AppendResult(interp, buffer, " ", (char *)NULL); Tcl_PrintDouble(interp, gal.cms_vel[2]/time_step, buffer); Tcl_AppendResult(interp, buffer, (char *)NULL); return TCL_OK; } else { return tcl_command_system_CMS_velocity_print_usage(interp); } } }
int tclcommand_reaction(ClientData data, Tcl_Interp * interp, int argc, char ** argv){ #ifdef REACTIONS if (argc == 1 ) return tcl_command_reaction_print_usage(interp); if (argc == 2 ) { if (ARG1_IS_S("off")) { reaction.rate=0.0; mpi_bcast_event(REACTION); return TCL_OK; } if (ARG1_IS_S("print")) { return tcl_command_reaction_print(interp); } } if( argc!=11 && argc!=13) return tcl_command_reaction_print_usage(interp); if(reaction.rate != 0.0) { Tcl_AppendResult(interp, "Currently a simulation can only contain a single reaction!", (char *) NULL); return (TCL_ERROR); } if(time_step < 0.0) { Tcl_AppendResult(interp, "Time step needs to be set before setting up a reaction!", (char *) NULL); return (TCL_ERROR); } argc--; argv++; while (argc>0){ if (ARG_IS_S(0,"product_type")) { if (!ARG_IS_I(1,reaction.product_type)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S(0,"reactant_type")) { if (!ARG_IS_I(1,reaction.reactant_type)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S(0,"catalyzer_type")) { if (!ARG_IS_I(1,reaction.catalyzer_type)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"range")) { if (!ARG_IS_D(1,reaction.range)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"rate")) { if (!ARG_IS_D(1,reaction.rate)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"back_rate")) { if (!ARG_IS_D(1,reaction.back_rate)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else { return tcl_command_reaction_print_usage(interp); } } mpi_bcast_event(REACTION); return TCL_OK; #else /* ifdef REACTIONS */ Tcl_AppendResult(interp, "REACTIONS not compiled in!" ,(char *) NULL); return (TCL_ERROR); #endif /* ifdef REACTIONS */ }
int tclcommand_reaction(ClientData data, Tcl_Interp * interp, int argc, char ** argv){ #ifdef CATALYTIC_REACTIONS /* Determine the currently set types, to block the user from trying to set up multiple reactions */ int react_type, prdct_type, catal_type; react_type = reaction.reactant_type; prdct_type = reaction.product_type; catal_type = reaction.catalyzer_type; if (argc == 1 ) return tcl_command_reaction_print_usage(interp); if (argc == 2 ) { if (ARG1_IS_S("off")) { /* We only need to set ct_rate to zero and we do not enter the reaction integration loop */ reaction.ct_rate=0.0; mpi_setup_reaction(); return TCL_OK; } if (ARG1_IS_S("print")) { return tcl_command_reaction_print(interp); } } if( argc!=11 && argc!=13 && argc!=15 && argc!=17 && argc!=3) { return tcl_command_reaction_print_usage(interp); } if(time_step < 0.0) { Tcl_AppendResult(interp, "Time step needs to be set before setting up a reaction!", (char *) NULL); return (TCL_ERROR); } argc--; argv++; while (argc>0){ if (ARG_IS_S(0,"product_type")) { if (!ARG_IS_I(1,reaction.product_type)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S(0,"reactant_type")) { if (!ARG_IS_I(1,reaction.reactant_type)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S(0,"catalyzer_type")) { if (!ARG_IS_I(1,reaction.catalyzer_type)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"range")) { if (!ARG_IS_D(1,reaction.range)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"ct_rate")) { if (!ARG_IS_D(1,reaction.ct_rate)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"eq_rate")) { if (!ARG_IS_D(1,reaction.eq_rate)) return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"react_once")) { if (!ARG_IS_S(1,"on")&&!ARG_IS_S(1,"off")) { return tcl_command_reaction_print_usage(interp);} if (ARG_IS_S(1,"on")) reaction.sing_mult = 1; if (ARG_IS_S(1,"off")) reaction.sing_mult = 0; argc-=2; argv+=2; } else if (ARG_IS_S_EXACT(0,"swap")) { #ifndef ROTATION char buffer[80]; sprintf(buffer, "WARNING: Parameter \"swap\" has no effect when ROTATION is not compiled in."); Tcl_AppendResult(interp, buffer, (char *)NULL); #endif if (ARG_IS_S(1,"on")) reaction.swap = 1; else if (ARG_IS_S(1,"off")) reaction.swap = 0; else return tcl_command_reaction_print_usage(interp); argc-=2; argv+=2; } else { return tcl_command_reaction_print_usage(interp); } } if( reaction.ct_rate < 0.0 ) { Tcl_AppendResult(interp, "Negative catalytic reaction rate constant is not allowed!", (char *) NULL); return (TCL_ERROR); } if( reaction.eq_rate < 0.0 && fabs(reaction.eq_rate + 1.0) > 0.001 ) { Tcl_AppendResult(interp, "Negative equilibrium reaction rate contstant is not allowed!", (char *) NULL); return (TCL_ERROR); } if( (reaction.product_type == reaction.reactant_type) || (reaction.product_type == reaction.catalyzer_type) || (reaction.catalyzer_type == reaction.reactant_type) ) { Tcl_AppendResult(interp, "One particle type cannot be a part more than one reaction species!", (char *) NULL); return (TCL_ERROR); } if ( ((react_type != reaction.reactant_type) || (prdct_type != reaction.product_type) || (catal_type != reaction.catalyzer_type)) && (react_type != prdct_type) ) { Tcl_AppendResult(interp, "A simulation can only contain a single reaction!", (char *) NULL); return (TCL_ERROR); } mpi_setup_reaction(); return TCL_OK; #else Tcl_AppendResult(interp, "CATALYTIC_REACTIONS not compiled in!" ,(char *) NULL); return (TCL_ERROR); #endif }