void init_eam(void) { /* read the tabulated embedding energy function */ read_pot_table(&embed_pot,eam_emb_E_filename,ntypes); /* read the tabulated electron density function */ read_pot_table(&rho_h_tab,eam_at_rho_filename,ntypes*ntypes); }
void read_input_files(int argc, char** argv) { // only root process reads input files if (g_mpi.myid == 0) { read_parameters(argc, argv); read_pot_table(g_files.startpot); read_config(g_files.config); printf("Global energy weight: %f\n", g_param.eweight); #if defined(STRESS) printf("Global stress weight: %f\n", g_param.sweight); #endif // STRESS /* initialize additional force variables and parameters */ init_force_common(0); init_force(0); g_mpi.init_done = 1; init_rng(g_param.rng_seed); } }
void init_pair(void) { /* read pair potential file */ read_pot_table(&pair_pot, potfilename, ntypes*ntypes); }
int main(int argc, char **argv) { int i, j, k; strcpy(progname, argv[0]); read_parameters(argc, argv); /* pair interactions */ if (mode == PAIR) { /* read potential table */ if (2 * ncols == (ntypes + 1) * ntypes) { printf("Reading Pair Potential\n"); eam = 0; } else if (2 * ncols == (ntypes + 5) * ntypes) { printf("Reading EAM Potentials\n"); eam = 1; } else { error("ntypes and ncols are incompatible"); } if (eam) { read_pot_table(&pt, phi_r2_file, ntypes * ntypes); read_pot_table(&embed_pt, f_rho_file, ntypes); read_pot_table(&rho_tab, rho_r2_file, ntypes * ntypes); } else { read_pot_table(&pt, infilename, ntypes * ntypes); } /* set up permutation index */ if (idx == NULL) { idx = (int *)malloc(ntypes * ntypes * sizeof(int)); if (idx == NULL) error("allocation of idx failed"); } if (reorder == NULL) { reorder = (int *)malloc(ntypes * sizeof(int)); if (reorder == NULL) error("allocation of reorder failed"); for (i = 0; i < ntypes; i++) { reorder[i] = i; } for (i = 0; i < ntypes * ntypes; i++) { idx[i] = i; } } else { /* reordering necessary */ /* check reorder field */ for (i = 0; i < ntypes; i++) { idx[i] = 0; } for (i = 0; i < ntypes; i++) { if (reorder[i] < 0 || reorder[i] >= ntypes) error("Reordering failure - out of range"); idx[reorder[i]]++; } for (i = 0; i < ntypes; i++) { if (idx[i] != 1) error("Reordering failure - doubly used index"); } /* pair pot */ k = 0; for (i = 0; i < ntypes; i++) { for (j = 0; j < ntypes; j++) { idx[k++] = ntypes * reorder[i] + reorder[j]; } } } /* always set r_end from potential table */ if (r_end == NULL) { r_end = (real *)malloc(ncols * sizeof(real)); if (NULL == r_end) error("allocation of r_end failed"); } k = 0; for (i = 0; i < ntypes; i++) for (j = i; j < ntypes; j++) r_end[k++] = sqrt(pt.end[idx[i * ntypes + j]]); if (eam) { for (i = 0; i < ntypes; i++) r_end[k++] = sqrt(rho_tab.end[idx[i]]); for (i = 0; i < ntypes; i++) /* move a little to the left for interpolation reasons */ r_end[k++] = embed_pt.end[reorder[i]] - 2. * embed_pt.step[reorder[i]]; } /* set r_start, if not read in */ if (r_start == NULL) { r_start = (real *)malloc(ncols * sizeof(real)); if (r_start == NULL) error("allocation of r_start failed"); k = 0; for (i = 0; i < ntypes; i++) for (j = i; j < ntypes; j++) { r_start[k++] = sqrt(pt.begin[idx[i * ntypes + j]]); while (POTVAL(&pt, idx[i * ntypes + j], ntypes * ntypes, r_start[k - 1] * r_start[k - 1]) > MAXVAL) { r_start[k - 1] += (r_end[k - 1] - r_start[k - 1]) / 1000.; } if (r_start[k - 1] <= sqrt(pt.begin[idx[i * ntypes + j]] + 2. * pt.step[idx[i * ntypes + j]])) r_start[k - 1] = sqrt(2. * pt.step[idx[i * ntypes + j]]); } if (eam) { for (i = 0; i < ntypes; i++) r_start[k++] = sqrt(rho_tab.begin[idx[i]] + 2. * rho_tab.step[idx[i]]); for (i = 0; i < ntypes; i++) r_start[k++] = embed_pt.begin[reorder[i]] + 2. * embed_pt.step[reorder[i]]; } } /* write potential table */ if (eam) write_pot_table_eam(&pt, &embed_pt, &rho_tab, outfilename); else write_pot_table_pair(&pt, outfilename); // write_plotpot_pair(&pt,plotfilename); } return 0; }