From 022aa75c75abf8d3595f6505cd94b6a08cf164e7 Mon Sep 17 00:00:00 2001 From: Rafael Ravedutti Date: Mon, 28 Feb 2022 22:34:42 +0100 Subject: [PATCH] Add cutoff radius and skin as parameters of simulation Signed-off-by: Rafael Ravedutti --- gromacs/includes/parameter.h | 1 + gromacs/main.c | 44 +++++++++++++++++++----------------- lammps/includes/parameter.h | 1 + lammps/main.c | 44 +++++++++++++++++++----------------- 4 files changed, 48 insertions(+), 42 deletions(-) diff --git a/gromacs/includes/parameter.h b/gromacs/includes/parameter.h index 5cb151a..84a0cdb 100644 --- a/gromacs/includes/parameter.h +++ b/gromacs/includes/parameter.h @@ -46,6 +46,7 @@ typedef struct { MD_FLOAT dt; MD_FLOAT dtforce; MD_FLOAT cutforce; + MD_FLOAT skin; MD_FLOAT cutneigh; int nx, ny, nz; MD_FLOAT lattice; diff --git a/gromacs/main.c b/gromacs/main.c index e25911a..2c5f013 100644 --- a/gromacs/main.c +++ b/gromacs/main.c @@ -69,7 +69,8 @@ void init(Parameter *param) { param->ny = 32; param->nz = 32; param->cutforce = 2.5; - param->cutneigh = param->cutforce + 0.30; + param->skin = 0.3; + param->cutneigh = param->cutforce + param->skin; param->temp = 1.44; param->nstat = 100; param->mass = 1.0; @@ -193,56 +194,54 @@ int main(int argc, char** argv) { for(int i = 0; i < argc; i++) { - if((strcmp(argv[i], "-f") == 0)) - { + if((strcmp(argv[i], "-f") == 0)) { if((param.force_field = str2ff(argv[++i])) < 0) { fprintf(stderr, "Invalid force field!\n"); exit(-1); } continue; } - if((strcmp(argv[i], "-i") == 0)) - { + if((strcmp(argv[i], "-i") == 0)) { param.input_file = strdup(argv[++i]); continue; } - if((strcmp(argv[i], "-e") == 0)) - { + if((strcmp(argv[i], "-e") == 0)) { param.eam_file = strdup(argv[++i]); continue; } - if((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0)) - { + if((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0)) { param.ntimes = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "-nx") == 0)) - { + if((strcmp(argv[i], "-nx") == 0)) { param.nx = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "-ny") == 0)) - { + if((strcmp(argv[i], "-ny") == 0)) { param.ny = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "-nz") == 0)) - { + if((strcmp(argv[i], "-nz") == 0)) { param.nz = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "--freq") == 0)) - { + if((strcmp(argv[i], "-r") == 0) || (strcmp(argv[i], "--radius") == 0)) { + param.cutforce = atof(argv[++i]); + continue; + } + if((strcmp(argv[i], "-s") == 0) || (strcmp(argv[i], "--skin") == 0)) { + param.skin = atof(argv[++i]); + continue; + } + if((strcmp(argv[i], "--freq") == 0)) { param.proc_freq = atof(argv[++i]); continue; } - if((strcmp(argv[i], "--vtk") == 0)) - { + if((strcmp(argv[i], "--vtk") == 0)) { param.vtk_file = strdup(argv[++i]); continue; } - if((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) - { + if((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) { printf("MD Bench: A minimalistic re-implementation of miniMD\n"); printf(HLINE); printf("-f : force field (lj or eam), default lj\n"); @@ -250,6 +249,8 @@ int main(int argc, char** argv) { printf("-e : input file for EAM\n"); printf("-n / --nsteps : set number of timesteps for simulation\n"); printf("-nx/-ny/-nz : set linear dimension of systembox in x/y/z direction\n"); + printf("-r / --radius : set cutoff radius\n"); + printf("-s / --skin : set skin (verlet buffer)\n"); printf("--freq : processor frequency (GHz)\n"); printf("--vtk : VTK file for visualization\n"); printf(HLINE); @@ -257,6 +258,7 @@ int main(int argc, char** argv) { } } + param.cutneigh = param.cutforce + param.skin; setup(¶m, &eam, &atom, &neighbor, &stats); computeThermo(0, ¶m, &atom); #if defined(MEM_TRACER) || defined(INDEX_TRACER) diff --git a/lammps/includes/parameter.h b/lammps/includes/parameter.h index bff46dd..0a21d09 100644 --- a/lammps/includes/parameter.h +++ b/lammps/includes/parameter.h @@ -44,6 +44,7 @@ typedef struct { int every; MD_FLOAT dt; MD_FLOAT dtforce; + MD_FLOAT skin; MD_FLOAT cutforce; MD_FLOAT cutneigh; int nx, ny, nz; diff --git a/lammps/main.c b/lammps/main.c index ebb2dbd..bdf67b5 100644 --- a/lammps/main.c +++ b/lammps/main.c @@ -63,7 +63,8 @@ void init(Parameter *param) param->ny = 32; param->nz = 32; param->cutforce = 2.5; - param->cutneigh = param->cutforce + 0.30; + param->skin = 0.3; + param->cutneigh = param->cutforce + param->skin; param->temp = 1.44; param->nstat = 100; param->mass = 1.0; @@ -186,56 +187,54 @@ int main(int argc, char** argv) for(int i = 0; i < argc; i++) { - if((strcmp(argv[i], "-f") == 0)) - { + if((strcmp(argv[i], "-f") == 0)) { if((param.force_field = str2ff(argv[++i])) < 0) { fprintf(stderr, "Invalid force field!\n"); exit(-1); } continue; } - if((strcmp(argv[i], "-i") == 0)) - { + if((strcmp(argv[i], "-i") == 0)) { param.input_file = strdup(argv[++i]); continue; } - if((strcmp(argv[i], "-e") == 0)) - { + if((strcmp(argv[i], "-e") == 0)) { param.eam_file = strdup(argv[++i]); continue; } - if((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0)) - { + if((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0)) { param.ntimes = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "-nx") == 0)) - { + if((strcmp(argv[i], "-nx") == 0)) { param.nx = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "-ny") == 0)) - { + if((strcmp(argv[i], "-ny") == 0)) { param.ny = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "-nz") == 0)) - { + if((strcmp(argv[i], "-nz") == 0)) { param.nz = atoi(argv[++i]); continue; } - if((strcmp(argv[i], "--freq") == 0)) - { + if((strcmp(argv[i], "-r") == 0) || (strcmp(argv[i], "--radius") == 0)) { + param.cutforce = atof(argv[++i]); + continue; + } + if((strcmp(argv[i], "-s") == 0) || (strcmp(argv[i], "--skin") == 0)) { + param.skin = atof(argv[++i]); + continue; + } + if((strcmp(argv[i], "--freq") == 0)) { param.proc_freq = atof(argv[++i]); continue; } - if((strcmp(argv[i], "--vtk") == 0)) - { + if((strcmp(argv[i], "--vtk") == 0)) { param.vtk_file = strdup(argv[++i]); continue; } - if((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) - { + if((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) { printf("MD Bench: A minimalistic re-implementation of miniMD\n"); printf(HLINE); printf("-f : force field (lj or eam), default lj\n"); @@ -243,6 +242,8 @@ int main(int argc, char** argv) printf("-e : input file for EAM\n"); printf("-n / --nsteps : set number of timesteps for simulation\n"); printf("-nx/-ny/-nz : set linear dimension of systembox in x/y/z direction\n"); + printf("-r / --radius : set cutoff radius\n"); + printf("-s / --skin : set skin (verlet buffer)\n"); printf("--freq : processor frequency (GHz)\n"); printf("--vtk : VTK file for visualization\n"); printf(HLINE); @@ -250,6 +251,7 @@ int main(int argc, char** argv) } } + param.cutneigh = param.cutforce + param.skin; setup(¶m, &eam, &atom, &neighbor, &stats); computeThermo(0, ¶m, &atom); #if defined(MEM_TRACER) || defined(INDEX_TRACER)