diff --git a/src/eam_utils.c b/src/eam_utils.c index 7d2ef77..8ffbad8 100644 --- a/src/eam_utils.c +++ b/src/eam_utils.c @@ -1,3 +1,25 @@ +/* + * ======================================================================================= + * + * Author: Jan Eitzinger (je), jan.eitzinger@fau.de + * Copyright (c) 2020 RRZE, University Erlangen-Nuremberg + * + * This file is part of MD-Bench. + * + * MD-Bench is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MD-Bench is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with MD-Bench. If not, see . + * ======================================================================================= + */ #include #include #include @@ -12,19 +34,20 @@ #define MAXLINE 4096 #endif -void initEam(Eam* eam, const char *input_file, int ntypes) { +void initEam(Eam* eam, const char* input_file, int ntypes) { eam->nmax = 0; eam->fp = NULL; eam->ntypes = ntypes; eam->cutforcesq = (MD_FLOAT *) allocate(ALIGNMENT, ntypes * ntypes * sizeof(MD_FLOAT)); coeff(eam, input_file); + init_style(eam); } void coeff(Eam* eam, const char* arg) { - read_file(eam->file, arg); + read_file(&eam->file, arg); int n = strlen(arg) + 1; int ntypes = eam->ntypes; - double cutmax = eam->file->cut; + double cutmax = eam->file.cut; for(int i=0; icutforcesq[i] = cutmax * cutmax; } @@ -75,7 +98,7 @@ void file2array(Eam* eam) { double rmax, rhomax; eam->dr = eam->drho = rmax = rhomax = 0.0; active = 0; - Funcfl* file = eam->file; + Funcfl* file = &eam->file; eam->dr = MAX(eam->dr, file->dr); eam->drho = MAX(eam->drho, file->drho); rmax = MAX(rmax, (file->nr - 1) * file->dr); @@ -156,8 +179,8 @@ void file2array(Eam* eam) { // create a z2r array for each file against other files, only for I >= J // interpolate zri and zrj to a single grid and cutoff double zri, zrj; - Funcfl* ifile = eam->file; - Funcfl* jfile = eam->file; + Funcfl* ifile = &eam->file; + Funcfl* jfile = &eam->file; for(m = 1; m <= eam->nr; m++) { r = (m - 1) * eam->dr; diff --git a/src/force_eam.c b/src/force_eam.c index 1e5bb72..ce32d91 100644 --- a/src/force_eam.c +++ b/src/force_eam.c @@ -139,17 +139,17 @@ double computeForceEam(Eam* eam, Atom *atom, Neighbor *neighbor, Stats *stats, i // hence embed' = Fi(sum rho_ij) rhojp + Fj(sum rho_ji) rhoip MD_FLOAT rhoip = (rhor_spline[type_ij * nr_tot + m * 7 + 0] * p + - rhor_spline[type_ij * nr_tot + m * 7 + 1]) * p + - rhor_spline[type_ij * nr_tot + m * 7 + 2]; + rhor_spline[type_ij * nr_tot + m * 7 + 1]) * p + + rhor_spline[type_ij * nr_tot + m * 7 + 2]; MD_FLOAT z2p = (z2r_spline[type_ij * nr_tot + m * 7 + 0] * p + - z2r_spline[type_ij * nr_tot + m * 7 + 1]) * p + - z2r_spline[type_ij * nr_tot + m * 7 + 2]; + z2r_spline[type_ij * nr_tot + m * 7 + 1]) * p + + z2r_spline[type_ij * nr_tot + m * 7 + 2]; MD_FLOAT z2 = ((z2r_spline[type_ij * nr_tot + m * 7 + 3] * p + - z2r_spline[type_ij * nr_tot + m * 7 + 4]) * p + - z2r_spline[type_ij * nr_tot + m * 7 + 5]) * p + - z2r_spline[type_ij * nr_tot + m * 7 + 6]; + z2r_spline[type_ij * nr_tot + m * 7 + 4]) * p + + z2r_spline[type_ij * nr_tot + m * 7 + 5]) * p + + z2r_spline[type_ij * nr_tot + m * 7 + 6]; MD_FLOAT recip = 1.0 / r; MD_FLOAT phi = z2 * recip; diff --git a/src/includes/eam.h b/src/includes/eam.h index 0ac250d..280f419 100644 --- a/src/includes/eam.h +++ b/src/includes/eam.h @@ -43,7 +43,7 @@ typedef struct { MD_FLOAT *frho, *rhor, *z2r; MD_FLOAT *rhor_spline, *frho_spline, *z2r_spline; MD_FLOAT *cutforcesq; - Funcfl* file; + Funcfl file; } Eam; void initEam(Eam* eam, const char* input_file, int ntypes);