int ljcos2_set_params(int part_type_a, int part_type_b, double eps, double sig, double offset, double w) { IA_parameters *data, *data_sym; make_particle_type_exist(part_type_a); make_particle_type_exist(part_type_b); data = get_ia_param(part_type_a, part_type_b); data_sym = get_ia_param(part_type_b, part_type_a); if (!data || !data_sym) { return TCL_ERROR; } /* lj-cos2 should be symmetrically */ data->LJCOS2_eps = data_sym->LJCOS2_eps = eps; data->LJCOS2_sig = data_sym->LJCOS2_sig = sig; data->LJCOS2_offset = data_sym->LJCOS2_offset = offset; data->LJCOS2_w = data_sym->LJCOS2_w = w; /* calculate dependent parameters */ data->LJCOS2_rchange = data_sym->LJCOS2_rchange = pow(2,1/6.)*sig; data->LJCOS2_cut = data_sym->LJCOS2_cut = w + data_sym->LJCOS2_rchange; /* broadcast interaction parameters */ mpi_bcast_ia_params(part_type_a, part_type_b); mpi_bcast_ia_params(part_type_b, part_type_a); if (lj_force_cap != -1.0) mpi_lj_cap_forces(lj_force_cap); return TCL_OK; }
int ljangle_set_params(int part_type_a, int part_type_b, double eps, double sig, double cut, int b1p, int b1n, int b2p, int b2n, double cap_radius, double z0, double dz, double kappa, double epsprime) { IA_parameters *data, *data_sym; make_particle_type_exist(part_type_a); make_particle_type_exist(part_type_b); data = get_ia_param(part_type_a, part_type_b); data_sym = get_ia_param(part_type_b, part_type_a); if (!data || !data_sym) { return TCL_ERROR; } /* LJ_ANGLE should be symmetrically */ data->LJANGLE_eps = data_sym->LJANGLE_eps = eps; data->LJANGLE_sig = data_sym->LJANGLE_sig = sig; data->LJANGLE_cut = data_sym->LJANGLE_cut = cut; data->LJANGLE_bonded1pos = data_sym->LJANGLE_bonded1pos = b1p; data->LJANGLE_bonded1neg = data_sym->LJANGLE_bonded1neg = b1n; data->LJANGLE_bonded2pos = data_sym->LJANGLE_bonded2pos = b2p; data->LJANGLE_bonded2neg = data_sym->LJANGLE_bonded2neg = b2n; data->LJANGLE_bonded1type = data_sym->LJANGLE_bonded1type = part_type_a; if (cap_radius > 0) { data->LJANGLE_capradius = cap_radius; data_sym->LJANGLE_capradius = cap_radius; } if (dz > 0.) { data->LJANGLE_z0 = data_sym->LJANGLE_z0 = z0; data->LJANGLE_dz = data_sym->LJANGLE_dz = dz; data->LJANGLE_kappa = data_sym->LJANGLE_kappa = kappa; data->LJANGLE_epsprime = data_sym->LJANGLE_epsprime = epsprime; } /* broadcast interaction parameters */ mpi_bcast_ia_params(part_type_a, part_type_b); mpi_bcast_ia_params(part_type_b, part_type_a); if (ljangle_force_cap != -1.0) mpi_ljangle_cap_forces(ljangle_force_cap); return TCL_OK; }
int collision_detection_set_params(int mode, double d, int bond_centers, int bond_vs,int t) { // If we don't have virtual sites relative feature, mode 2 isn't allowed. #ifndef VIRTUAL_SITES_RELATIVE if (mode==2) return 1; #endif // Collision detection only works on a single cpu if (mode!=0 && n_nodes !=1) return 2; // Check if bonded ia exist if (((mode>0) && (bond_centers+1>n_bonded_ia)) || ((mode==2) && (bond_vs+1>n_bonded_ia))) return 3; if (bonded_ia_params[bond_centers].num != 1) return 4; if ((mode ==2) && ( bonded_ia_params[bond_vs].num != 1 && bonded_ia_params[bond_vs].num != 2)) return 5; // Set params collision_detection_mode=mode; collision_detection_bond_centers=bond_centers; collision_detection_bond_vs=bond_vs; collision_distance=d; collision_vs_particle_type=t; make_particle_type_exist(t); recalc_forces=1; return 0; }
/* TODO: This function is not used anywhere. To be removed? */ int tf_print(Tcl_Interp * interp, int part_type) { TF_parameters *data; Tcl_ResetResult(interp); make_particle_type_exist(part_type); data = get_tf_param(part_type); return tclprint_to_result_TF(interp, part_type); }
int tclcommand_inter_print_non_bonded(Tcl_Interp * interp, int part_type_a, int part_type_b) { IA_parameters *data, *data_sym; Tcl_ResetResult(interp); make_particle_type_exist(part_type_a); make_particle_type_exist(part_type_b); data = get_ia_param(part_type_a, part_type_b); data_sym = get_ia_param(part_type_b, part_type_a); if (!data || !data_sym) { Tcl_AppendResult(interp, "particle types must be nonnegative", (char *) NULL); return TCL_ERROR; } return tclprint_to_result_NonbondedIA(interp, part_type_a, part_type_b); }
int on_program_start(Tcl_Interp *interp) { EVENT_TRACE(fprintf(stderr, "%d: on_program_start\n", this_node)); /* call the initialization of the modules here */ init_random(); init_bit_random(); setup_node_grid(); /* calculate initial minimimal number of cells (see tclcallback_min_num_cells) */ min_num_cells = calc_processor_min_num_cells(); cells_pre_init(); ghost_init(); /* Initialise force and energy tables */ force_and_energy_tables_init(); #ifdef ADRESS #ifdef INTERFACE_CORRECTION adress_force_and_energy_tables_init(); #endif /** #ifdef THERMODYNAMIC_FORCE */ tf_tables_init(); /** #endif */ #endif #ifdef ELP3M fft_pre_init(); #endif #ifdef LB_GPU if(this_node == 0){ lb_pre_init_gpu(); } #endif #ifdef LB lb_pre_init(); #endif /* call all initializations to do only on the master node here. */ if (this_node == 0) { /* interaction_data.c: make sure 0<->0 ia always exists */ make_particle_type_exist(0); init_tcl(interp); } return TCL_OK; }
void setup_reaction() { MPI_Bcast(&reaction.reactant_type, 1, MPI_INT, 0, comm_cart); MPI_Bcast(&reaction.product_type, 1, MPI_INT, 0, comm_cart); MPI_Bcast(&reaction.catalyzer_type, 1, MPI_INT, 0, comm_cart); MPI_Bcast(&reaction.range, 1, MPI_DOUBLE, 0, comm_cart); MPI_Bcast(&reaction.rate, 1, MPI_DOUBLE, 0, comm_cart); MPI_Bcast(&reaction.back_rate, 1, MPI_DOUBLE, 0, comm_cart); make_particle_type_exist(reaction.catalyzer_type); make_particle_type_exist(reaction.product_type); make_particle_type_exist(reaction.reactant_type); IA_parameters *data = get_ia_param_safe(reaction.reactant_type, reaction.catalyzer_type); if(!data) { char *error_msg = runtime_error(128); ERROR_SPRINTF(error_msg, "{106 interaction parameters for reaction could not be set} "); } data->REACTION_range = reaction.range; /* broadcast interaction parameters */ mpi_bcast_ia_params(reaction.reactant_type, reaction.catalyzer_type); }
int set_particle_type(int part, int type) { int pnode; make_particle_type_exist(type); if (!particle_node) build_particle_node(); if (part < 0 || part > max_seen_particle) return ES_ERROR; pnode = particle_node[part]; if (pnode == -1) return ES_ERROR; // check if the particle exists already and the type is changed, then remove it from the list which contains it Particle *cur_par = (Particle *) malloc( sizeof(Particle) ); if ( Type_array_init ) { if ( cur_par != (Particle *) 0 ) { if ( get_particle_data(part, cur_par) != ES_ERROR ) { int prev_type = cur_par->p.type; if ( prev_type != type ) { // particle existed before so delete it from the list remove_id_type_array(part, prev_type); } } } free(cur_par); } mpi_send_type(pnode, part, type); #ifdef ADDITIONAL_CHECKS if ( Type_array_init ) { if ( add_particle_to_list(part, type) == ES_ERROR ){ //Tcl_AppendResult(interp, "gc particle add failed", (char *) NULL); return ES_ERROR; } } #endif return ES_OK; }
IA_parameters *get_ia_param_safe(int i, int j) { make_particle_type_exist(std::max(i, j)); return get_ia_param(i, j); }
void on_program_start() { EVENT_TRACE(fprintf(stderr, "%d: on_program_start\n", this_node)); /* tell Electric fence that we do realloc(0) on purpose. */ #ifdef EFENCE extern int EF_ALLOW_MALLOC_0; EF_ALLOW_MALLOC_0 = 1; #endif register_sigint_handler(); if (this_node == 0) { /* master node */ #ifdef FORCE_CORE /* core should be the last exit handler (process dies) */ atexit(core); #endif atexit(mpi_stop); } /* call the initialization of the modules here */ init_random(); init_bit_random(); setup_node_grid(); /* calculate initial minimimal number of cells (see tclcallback_min_num_cells) */ min_num_cells = calc_processor_min_num_cells(); /* initially go for domain decomposition */ dd_topology_init(&local_cells); ghost_init(); /* Initialise force and energy tables */ force_and_energy_tables_init(); #ifdef ADRESS #ifdef INTERFACE_CORRECTION adress_force_and_energy_tables_init(); #endif /* #ifdef THERMODYNAMIC_FORCE */ tf_tables_init(); /* #endif */ #endif #ifdef P3M p3m_pre_init(); #endif #ifdef DP3M dp3m_pre_init(); #endif #ifdef LB_GPU if(this_node == 0) { //lb_pre_init_gpu(); } #endif #ifdef LB lb_pre_init(); #endif #ifdef REACTIONS reaction.back_rate=-1.0; #endif /* call all initializations to do only on the master node here. */ if (this_node == 0) { /* interaction_data.c: make sure 0<->0 ia always exists */ make_particle_type_exist(0); } }