diff --git a/CHANGES.md b/CHANGES.md index 8c77e2361..afa582ee8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ ### Changes +version 0.16.0 + +- Reinstated the boundary (wall) - colloid soft sphere potential. + See https://ludwig.epcc.ed.ac.uk/inputs/colloid.html + Thanks to Rishish Mishra for spotting this problem. + version 0.15.0 - Active stress implementation is updated to conform to the documented diff --git a/src/colloids_rt.c b/src/colloids_rt.c index 19d93b327..004ba3bdf 100644 --- a/src/colloids_rt.c +++ b/src/colloids_rt.c @@ -7,7 +7,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2014-2021 The University of Edinburgh + * (c) 2014-2022 The University of Edinburgh * * Contributing authors: * Kevin Stratford (kevin@epcc.ed.ac.uk) @@ -32,6 +32,7 @@ #include "pair_yukawa.h" #include "bond_fene.h" #include "angle_cosine.h" +#include "wall_ss_cut.h" #include "colloids_halo.h" #include "colloids_init.h" @@ -47,9 +48,11 @@ int pair_yukawa_init(pe_t * pe, cs_t * cs, rt_t * rt, interact_t * inter); int pair_lj_cut_init(pe_t * pe, cs_t * cs, rt_t * rt, interact_t * inter); int bond_fene_init(pe_t * pe, cs_t * cs, rt_t * rt, interact_t * interact); int angle_cosine_init(pe_t * pe, cs_t * cs, rt_t * rt, interact_t * interact); - int pair_ss_cut_ij_init(pe_t * pe, cs_t * cs, rt_t * rt, interact_t * intrct); +int wall_ss_cut_init(pe_t * pe, cs_t * cs, rt_t * rt, wall_t * wall, + interact_t * inter); + int colloids_rt_dynamics(cs_t * cs, colloids_info_t * cinfo, wall_t * wall, map_t * map, const lb_model_t * model); int colloids_rt_gravity(pe_t * pe, rt_t * rt, colloids_info_t * cinfo); @@ -146,6 +149,8 @@ int colloids_init_rt(pe_t * pe, rt_t * rt, cs_t * cs, colloids_info_t ** pinfo, pair_ss_cut_ij_init(pe, cs, rt, *interact); + wall_ss_cut_init(pe, cs, rt, wall, *interact); + colloids_rt_cell_list_checks(pe, cs, pinfo, *interact); colloids_init_halo_range_check(pe, cs, *pinfo); if (nc > 1) interact_range_check(*interact, *pinfo); @@ -756,18 +761,13 @@ int pair_ss_cut_init(pe_t * pe, cs_t * cs, rt_t * rt, interact_t * inter) { double epsilon ; double sigma; int nu; - double kt; double cutoff; - physics_t * phys = NULL; pair_ss_cut_t * pair = NULL; assert(pe); assert(rt); - physics_ref(&phys); - physics_kt(phys, &kt); - rt_int_parameter(rt, "soft_sphere_on", &on); if (on) { @@ -1071,3 +1071,46 @@ int colloids_init_halo_range_check(pe_t * pe, cs_t * cs, return ifail; } + +/***************************************************************************** + * + * wall_ss_cut_init + * + *****************************************************************************/ + +int wall_ss_cut_init(pe_t * pe, cs_t * cs, rt_t * rt, wall_t * wall, + interact_t * interact) { + + int have_wall_ss_cut = 0; + + assert(pe); + assert(cs); + assert(rt); + + have_wall_ss_cut = rt_switch(rt, "wall_ss_cut_on"); + + if (have_wall_ss_cut) { + + wall_ss_cut_t * wall_ss_cut = NULL; + wall_ss_cut_options_t opts = {}; + + rt_key_required(rt, "wall_ss_cut_epsilon", RT_FATAL); + rt_key_required(rt, "wall_ss_cut_sigma", RT_FATAL); + rt_key_required(rt, "wall_ss_cut_nu", RT_FATAL); + rt_key_required(rt, "wall_ss_cut_hc", RT_FATAL); + + rt_double_parameter(rt, "wall_ss_cut_epsilon", &opts.epsilon); + rt_double_parameter(rt, "wall_ss_cut_sigma", &opts.sigma); + rt_double_parameter(rt, "wall_ss_cut_nu", &opts.nu); + rt_double_parameter(rt, "wall_ss_cut_hc", &opts.hc); + + if (opts.nu <= 0) pe_fatal(pe, "Please ensure wall_ss_cut_nu is +ve\n"); + if (opts.hc <= 0) pe_fatal(pe, "Please ensure wall_ss_cut_hc is +ve\n"); + + wall_ss_cut_create(pe, cs, wall, &opts, &wall_ss_cut); + wall_ss_cut_register(wall_ss_cut, interact); + wall_ss_cut_info(wall_ss_cut); + } + + return 0; +} diff --git a/src/wall_ss_cut.c b/src/wall_ss_cut.c index 982cc544e..741de6fc0 100644 --- a/src/wall_ss_cut.c +++ b/src/wall_ss_cut.c @@ -23,7 +23,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) 2010-2016 The University of Edinburgh + * (c) 2010-2022 The University of Edinburgh * Juho Lintuvuori (juho.lintuvuori@u-psud.fr) * *****************************************************************************/ @@ -47,7 +47,7 @@ struct wall_ss_cut_s { double hc; /* cut-off */ double vlocal; /* local contribution to energy */ double hminlocal; /* local nearest separation */ - double rminlocal; /* local min centre-centre separation */ + double rminlocal; /* local min wall-centre separation */ }; /***************************************************************************** @@ -57,12 +57,15 @@ struct wall_ss_cut_s { *****************************************************************************/ int wall_ss_cut_create(pe_t * pe, cs_t * cs, wall_t * wall, + const wall_ss_cut_options_t * opts, wall_ss_cut_t ** pobj) { wall_ss_cut_t * obj = NULL; assert(pe); assert(cs); + assert(wall); + assert(opts); assert(pobj); obj = (wall_ss_cut_t *) calloc(1, sizeof(wall_ss_cut_t)); @@ -73,6 +76,11 @@ int wall_ss_cut_create(pe_t * pe, cs_t * cs, wall_t * wall, obj->cs = cs; obj->wall = wall; + obj->epsilon = opts->epsilon; + obj->sigma = opts->sigma; + obj->nu = opts->nu; + obj->hc = opts->hc; + *pobj = obj; return 0; @@ -93,24 +101,6 @@ int wall_ss_cut_free(wall_ss_cut_t * obj) { return 0; } -/***************************************************************************** - * - * wall_ss_cut_param_set - * - *****************************************************************************/ - -int wall_ss_cut_param_set(wall_ss_cut_t * obj, double epsilon, double sigma, - int nu, double hc) { - assert(obj); - - obj->epsilon = epsilon; - obj->sigma = sigma; - obj->nu = nu; - obj->hc = hc; - - return 0; -} - /***************************************************************************** * * wall_ss_cut_info @@ -126,11 +116,12 @@ int wall_ss_cut_info(wall_ss_cut_t * obj) { physics_kt(phys, &kt); pe_info(obj->pe, "\n"); - pe_info(obj->pe, "Soft sphere for wall potential\n"); + pe_info(obj->pe, "Wall-colloid soft-sphere potential\n"); + pe_info(obj->pe, "----------------------------------\n"); pe_info(obj->pe, "epsilon: %14.7e\n", obj->epsilon); pe_info(obj->pe, "sigma: %14.7e\n", obj->sigma); pe_info(obj->pe, "exponent nu: %14.7e\n", obj->nu); - pe_info(obj->pe, "cut off (surface-surface) %14.7e\n", obj->hc); + pe_info(obj->pe, "cut off hc (wall-surface) %14.7e\n", obj->hc); if (kt > 0.0) { pe_info(obj->pe, "epsilon / kT %14.7e\n", obj->epsilon/kt); } @@ -166,23 +157,11 @@ int wall_ss_cut_compute(colloids_info_t * cinfo, void * obj) { wall_ss_cut_t * self = (wall_ss_cut_t *) obj; - int ic1, jc1, kc1; - int ncell[3]; - int ia; - int iswall[3]; - - double r; /* centre-centre sepration */ - double h; /* surface-surface separation */ - double rh; /* reciprocal h */ - double rsigma; /* reciproal sigma */ - double vcut; /* potential at cut off */ - double dvcut; /* derivative at cut off */ - double forcewall[3]; /* force on the wall for accounting purposes */ + double forcewall[3] = {}; /* force on the wall for accounting */ double lmin[3]; double ltot[3]; - double f; - colloid_t * pc1; + colloid_t * pc = NULL; assert(cinfo); assert(self); @@ -194,65 +173,49 @@ int wall_ss_cut_compute(colloids_info_t * cinfo, void * obj) { self->hminlocal = dmax(ltot[X], dmax(ltot[Y], ltot[Z])); self->rminlocal = self->hminlocal; - rsigma = 1.0/self->sigma; - vcut = self->epsilon*pow(self->sigma/self->hc, self->nu); - dvcut = -self->epsilon*self->nu*rsigma*pow(self->sigma/self->hc, self->nu+1); + colloids_info_local_head(cinfo, &pc); - forcewall[X] = 0.0; - forcewall[Y] = 0.0; - forcewall[Z] = 0.0; + for (; pc; pc = pc->nextlocal) { - wall_present_dim(self->wall, iswall); - colloids_info_ncell(cinfo, ncell); + for (int ia = 0; ia < 3; ia++) { - for (ic1 = 1; ic1 <= ncell[X]; ic1++) { - for (jc1 = 1; jc1 <= ncell[Y]; jc1++) { - for (kc1 = 1; kc1 <= ncell[Z]; kc1++) { - - colloids_info_cell_list_head(cinfo, ic1, jc1, kc1, &pc1); - for (; pc1; pc1 = pc1->next) { + double f = 0.0; + double r = 0.0; /* wall-centre sepration */ + double h = 0.0; /* wall-surface separation */ - for (ia = 0; ia < 3; ia++) { - if (iswall[ia]) { - - f = 0.0; - /* lower wall */ - r = pc1->s.r[ia] - lmin[ia]; - if (r < self->rminlocal) self->rminlocal = r; + if (self->wall->param->isboundary[ia] == 0) continue; - h = r - pc1->s.ah; - assert(h > 0.0); - if (h < self->hminlocal) self->hminlocal = h; - - if (h < self->hc) { - rh = 1.0/h; - self->vlocal += self->epsilon*pow(rh*self->sigma, self->nu) - - vcut - (h - self->hc)*dvcut; - f = -(-self->epsilon*self->nu*rsigma - *pow(rh*self->sigma, self->nu+1) - dvcut); - } + /* lower wall */ + r = pc->s.r[ia] - lmin[ia]; + h = r - pc->s.ah; + + if (h < self->hminlocal) self->hminlocal = h; + if (r < self->rminlocal) self->rminlocal = r; - /*upper wall*/ - r = lmin[ia] + ltot[ia] - pc1->s.r[ia]; - if (r < self->rminlocal) self->rminlocal = r; + if (h < self->hc) { + double v = 0.0; + double fl = 0.0; + wall_ss_cut_single(self, h, &fl, &v); + self->vlocal += v; + f += fl; + } - h = r - pc1->s.ah; - assert(h > 0.0); - if (h < self->hminlocal) self->hminlocal = h; + /* upper wall */ + r = lmin[ia] + ltot[ia] - pc->s.r[ia]; + h = r - pc->s.ah; + + if (r < self->rminlocal) self->rminlocal = r; + if (h < self->hminlocal) self->hminlocal = h; - if (h < self->hc) { - rh = 1.0/h; - self->vlocal += self->epsilon*pow(rh*self->sigma, self->nu) - - vcut - (h - self->hc)*dvcut; - f -= -(-self->epsilon*self->nu*rsigma - *pow(rh*self->sigma, self->nu+1) - dvcut); - } - pc1->force[ia] += f; - forcewall[ia] -= f; - } - } - } + if (h < self->hc) { + double v = 0.0; + double fu = 0.0; + wall_ss_cut_single(self, h, &fu, &v); + self->vlocal += v; + f -= fu; /* upper wall gives -ve (repulsive) force */ } + pc->force[ia] += f; + forcewall[ia] -= f; } } diff --git a/src/wall_ss_cut.h b/src/wall_ss_cut.h index 82dc98f54..5ec9984bd 100644 --- a/src/wall_ss_cut.h +++ b/src/wall_ss_cut.h @@ -5,7 +5,7 @@ * Edinburgh Soft Matter and Statistical Physics Group and * Edinburgh Parallel Computing Centre * - * (c) The University of Edinburgh (2014) + * (c) 2014-2022 The University of Edinburgh * Juho Lintuvuori (juho.lintuvuori@u-psud.fr) * *****************************************************************************/ @@ -19,9 +19,18 @@ #include "colloids.h" #include "interaction.h" +typedef struct wall_ss_cut_options_s wall_ss_cut_options_t; typedef struct wall_ss_cut_s wall_ss_cut_t; +struct wall_ss_cut_options_s { + double epsilon; /* Energy scale */ + double sigma; /* Sigma (length) */ + double nu; /* exponent */ + double hc; /* Surface-surface cut off */ +}; + int wall_ss_cut_create(pe_t * pe, cs_t * cs, wall_t * wall, + const wall_ss_cut_options_t * opts, wall_ss_cut_t ** pobj); int wall_ss_cut_free(wall_ss_cut_t * obj); int wall_ss_cut_info(wall_ss_cut_t * obj); @@ -29,7 +38,5 @@ int wall_ss_cut_register(wall_ss_cut_t * obj, interact_t * parent); int wall_ss_cut_compute(colloids_info_t * cinfo, void * self); int wall_ss_cut_stats(void * self, double * stats); int wall_ss_cut_single(wall_ss_cut_t * obj, double h, double * f, double * v); -int wall_ss_cut_param_set(wall_ss_cut_t * obj, double epsilon, double sigma, - int nu, double hc); #endif diff --git a/tests/regression/d3q19-short/serial-wall-st5.inp b/tests/regression/d3q19-short/serial-wall-st5.inp new file mode 100644 index 000000000..ed112730d --- /dev/null +++ b/tests/regression/d3q19-short/serial-wall-st5.inp @@ -0,0 +1,98 @@ +############################################################################## +# +# Wall / soft-sphere smoke test +# +# A colloid close to the wall with wall_ss_cut potential +# +############################################################################## + +N_cycles 10 + +############################################################################## +# +# System and MPI +# +############################################################################## + +size 24_24_24 +periodicity 0_0_0 +reduced_halo no + +############################################################################## +# +# Fluid parameters +# +############################################################################## + +viscosity 0.1 + +isothermal_fluctuations off + +############################################################################## +# +# Free energy parameters +# +############################################################################### + +free_energy none + +############################################################################### +# +# Colloid parameters +# +############################################################################### + +colloid_init input_one + +colloid_one_a0 2.3 +colloid_one_ah 2.3 +colloid_one_r 3.0_12.5_12.5 +colloid_one_v 0.0_0.0_0.0 + +# Constant body force on all colloids ("gravity") [default is zero] + +colloid_gravity -0.001_0.0_0.0 + + +wall_ss_cut_on yes +wall_ss_cut_epsilon 0.001 +wall_ss_cut_sigma 0.1 +wall_ss_cut_nu 2.0 +wall_ss_cut_hc 0.5 + +############################################################################### +# +# Walls / boundaries +# +############################################################################### + +boundary_walls 1_1_1 +boundary_speed_bottom 0.0 +boundary_speed_top 0.0 + +############################################################################### +# +# Output frequency and type +# +############################################################################### + +freq_statistics 10 +config_at_end no + +############################################################################## +# +# colloid i/o +# +############################################################################## + +colloid_io_freq 100000 + +############################################################################### +# +# Miscellaneous +# +# random_seed +ve integer is the random number generator seed +# +############################################################################### + +random_seed 8361235 diff --git a/tests/regression/d3q19-short/serial-wall-st5.log b/tests/regression/d3q19-short/serial-wall-st5.log new file mode 100644 index 000000000..186f0c7e8 --- /dev/null +++ b/tests/regression/d3q19-short/serial-wall-st5.log @@ -0,0 +1,163 @@ +Welcome to Ludwig v0.15.0 (Serial version running on 1 process) +Start time: Sat Apr 2 20:13:41 2022 + +Compiler: + name: Clang 13.1.6 + version-string: 13.1.6 (clang-1316.0.21.2) + +Note assertions via standard C assert() are on. + +Target thread model: None. + +Read 25 user parameters from serial-wall-st5.inp + +No free energy selected + +System details +-------------- +System size: 24 24 24 +Decomposition: 1 1 1 +Local domain: 24 24 24 +Periodic: 0 0 0 +Halo nhalo: 1 +Reorder: true +Initialised: 1 + +System properties +---------------- +Mean fluid density: 1.00000e+00 +Shear viscosity 1.00000e-01 +Bulk viscosity 1.00000e-01 +Temperature 0.00000e+00 +External body force density 0.00000e+00 0.00000e+00 0.00000e+00 +External E-field amplitude 0.00000e+00 0.00000e+00 0.00000e+00 +External E-field frequency 0.00000e+00 +External magnetic field 0.00000e+00 0.00000e+00 0.00000e+00 + +Lattice Boltzmann distributions +------------------------------- +Model: d3q19 +SIMD vector len: 1 +Number of sets: 1 +Halo type: full +Input format: binary +Output format: binary +I/O grid: 1 1 1 + +Lattice Boltzmann collision +--------------------------- +Relaxation time scheme: M10 +Hydrodynamic modes: on +Ghost modes: on +Isothermal fluctuations: off +Shear relaxation time: 8.00000e-01 +Bulk relaxation time: 8.00000e-01 +Ghost relaxation time: 1.00000e+00 +[User ] Random number seed: 8361235 + +Hydrodynamics +------------- +Hydrodynamics: on + +Boundary walls +-------------- +Boundary walls: X Y Z +Boundary speed u_x (bottom): 0.0000000e+00 +Boundary speed u_x (top): 0.0000000e+00 +Boundary normal lubrication rc: 0.0000000e+00 +Wall boundary links allocated: 16992 +Memory (total, bytes): 271872 +Boundary shear initialise: 0 + +Colloid information +------------------- + +Colloid I/O settings +-------------------- +Decomposition: 1 1 1 +Number of files: 1 +Input format: ascii +Output format: ascii +Single file read flag: 0 + +Requested one colloid via input: +colloid_one_a0 2.3000000e+00 +colloid_one_ah 2.3000000e+00 +colloid_one_r 3.0000000e+00 1.2500000e+01 1.2500000e+01 +colloid_one_v 0.0000000e+00 0.0000000e+00 0.0000000e+00 + +Initialised 1 colloid + +Wall-colloid soft-sphere potential +---------------------------------- +epsilon: 1.0000000e-03 +sigma: 1.0000000e-01 +exponent nu: 2.0000000e+00 +cut off hc (wall-surface) 5.0000000e-01 + +Colloid cell list information +----------------------------- +Input radius maximum: 2.3000000e+00 +Final cell list: 8 8 8 +Final cell lengths: 3.0000000e+00 3.0000000e+00 3.0000000e+00 + +Sedimentation force on: yes +Sedimentation force: -1.0000000e-03 0.0000000e+00 0.0000000e+00 + +Initial conditions. + +Scalars - total mean variance min max +[rho] 13776.00 1.00000000000 2.2204460e-16 1.00000000000 1.00000000000 + +Momentum - x y z +[total ] 0.0000000e+00 0.0000000e+00 0.0000000e+00 +[fluid ] 0.0000000e+00 0.0000000e+00 0.0000000e+00 +[colloids] 0.0000000e+00 0.0000000e+00 0.0000000e+00 +[walls ] 0.0000000e+00 0.0000000e+00 0.0000000e+00 + +Starting time step loop. + +Particle statistics: +Wall potential minimum h is: 2.0037974e-01 +Wall potential energy is: 1.6111411e-04 + +Colloid velocities - x y z +[minimum ] 6.0667740e-05 3.8982092e-18 4.4175480e-18 +[maximum ] 6.0667740e-05 3.8982092e-18 4.4175480e-18 + +Scalars - total mean variance min max +[rho] 13776.00 1.00000000000 2.4273028e-11 0.99987097316 1.00002663247 + +Momentum - x y z +[total ] 4.9460956e-13 6.7014322e-15 2.1248064e-14 +[fluid ] 8.8394048e-03 -1.6157561e-13 7.2809814e-14 +[colloids] 3.1708202e-03 3.2805819e-16 2.9260438e-16 +[walls ] -1.2010225e-02 1.6794899e-13 -5.1854354e-14 + +Velocity - x y z +[minimum ] -8.5205736e-06 -2.9745063e-05 -2.9745063e-05 +[maximum ] 4.3807348e-05 2.9745063e-05 2.9745063e-05 + +Completed cycle 10 + +Timer resolution: 1e-06 second + +Timer statistics + Section: tmin tmax total + Total: 0.195 0.195 0.195 0.194830 (1 call) + Time step loop: 0.016 0.017 0.169 0.016875 (10 calls) + Propagation: 0.003 0.004 0.035 0.003459 (10 calls) + Propagtn (krnl) : 0.003 0.004 0.035 0.003452 (10 calls) + Collision: 0.007 0.008 0.075 0.007523 (10 calls) + Collision (krnl) : 0.007 0.008 0.075 0.007515 (10 calls) + Lattice halos: 0.001 0.001 0.022 0.001118 (20 calls) + phi gradients: 0.000 0.000 0.000 0.000001 (10 calls) + Forces: 0.000 0.000 0.001 0.000103 (10 calls) + Rebuild: 0.000 0.001 0.004 0.000412 (10 calls) + BBL: 0.003 0.003 0.027 0.002731 (10 calls) + Particle halos: 0.000 0.000 0.000 0.000023 (10 calls) + Force calculation: 0.000 0.000 0.000 0.000001 (10 calls) + phi update: 0.000 0.000 0.000 0.000000 (10 calls) + Free1: 0.000 0.007 0.007 0.000248 (30 calls) +End time: Sat Apr 2 20:13:41 2022 +Ludwig finished normally. diff --git a/tests/unit/test_wall_ss_cut.c b/tests/unit/test_wall_ss_cut.c new file mode 100644 index 000000000..fd3dddfb5 --- /dev/null +++ b/tests/unit/test_wall_ss_cut.c @@ -0,0 +1,177 @@ +/***************************************************************************** + * + * test_wall_ss_cut.c + * + * Test for wall-colloid 'pair' interaction. + * + * Edinburgh Soft Matter and Statistical Physics Group and + * Edinburgh Parallel Computing Centre + * + * (c) 2022 The University of Edinburgh + * Kevin Stratford (kevin@epcc.ed.ac.uk) + * + *****************************************************************************/ + +#include +#include +#include + +#include "wall_ss_cut.h" + +int test_wall_ss_cut_create(pe_t * pe, cs_t * cs, wall_t * wall); +int test_wall_ss_cut_single(pe_t * pe, cs_t * cs, wall_t * wall); +int test_wall_ss_cut_compute(pe_t * pe, cs_t * cs, wall_t * wall); + +/***************************************************************************** + * + * test_wall_ss_cut_suite + * + *****************************************************************************/ + +int test_wall_ss_cut_suite(void) { + + pe_t * pe = NULL; + cs_t * cs = NULL; + + pe_create(MPI_COMM_WORLD, PE_QUIET, &pe); + cs_create(pe, &cs); + cs_init(cs); + + { + lb_t * lb = NULL; + map_t * map = NULL; + wall_t * wall = NULL; + + wall_param_t param = {.iswall = 1, .isboundary = {1,1,1}}; + lb_data_options_t opts = lb_data_options_default(); + + lb_data_create(pe, cs, &opts, &lb); + map_create(pe, cs, 1, &map); + wall_create(pe, cs, map, lb, &wall); + wall_commit(wall, ¶m); + + test_wall_ss_cut_create(pe, cs, wall); + test_wall_ss_cut_single(pe, cs, wall); + test_wall_ss_cut_compute(pe, cs, wall); + + wall_free(wall); + map_free(map); + lb_free(lb); + } + + pe_info(pe, "PASS ./unit/test_wall_ss_cut\n"); + cs_free(cs); + pe_free(pe); + + return 0; +} + +/***************************************************************************** + * + * test_wall_ss_cut_create + * + *****************************************************************************/ + +int test_wall_ss_cut_create(pe_t * pe, cs_t * cs, wall_t * wall) { + + wall_ss_cut_t * wall_ss_cut = NULL; + wall_ss_cut_options_t opts = {.epsilon = 0.1, .sigma = 0.2, .nu = 0.3, + .hc = 0.4}; + assert(pe); + assert(cs); + assert(wall); + + wall_ss_cut_create(pe, cs, wall, &opts, &wall_ss_cut); + assert(wall_ss_cut); + + wall_ss_cut_free(wall_ss_cut); + + return 0; +} + +/***************************************************************************** + * + * test_wall_ss_cut_single + * + *****************************************************************************/ + +int test_wall_ss_cut_single(pe_t * pe, cs_t * cs, wall_t * wall) { + + wall_ss_cut_t * wall_ss_cut = NULL; + wall_ss_cut_options_t opts = {.epsilon = 0.001, + .sigma = 0.8, + .nu = 2.0, + .hc = 0.25}; + assert(pe); + assert(cs); + assert(wall); + + wall_ss_cut_create(pe, cs, wall, &opts, &wall_ss_cut); + + { + double h = 0.0125; + double f = 0.0; + double v = 0.0; + + wall_ss_cut_single(wall_ss_cut, h, &f, &v); + assert(fabs(f - 655.27808) < FLT_EPSILON); + assert(fabs(v - 4.0663040) < FLT_EPSILON); + } + wall_ss_cut_free(wall_ss_cut); + + return 0; +} + +/***************************************************************************** + * + * test_wall_ss_cut_compute + * + *****************************************************************************/ + +int test_wall_ss_cut_compute(pe_t * pe, cs_t * cs, wall_t * wall) { + + int ncell[3] = {2, 2, 2}; + colloids_info_t * cinfo = NULL; + + wall_ss_cut_t * wall_ss_cut = NULL; + wall_ss_cut_options_t opts = {.epsilon = 0.001, + .sigma = 0.8, + .nu = 2.0, + .hc = 0.25}; + + assert(pe); + assert(cs); + assert(wall); + + colloids_info_create(pe, cs, ncell, &cinfo); + wall_ss_cut_create(pe, cs, wall, &opts, &wall_ss_cut); + + { + /* Add a colloid at a suitable position */ + double a0 = 1.0; + double ah = 1.0; + double h = 0.0125; + double r[3] = {0.5 + a0 + h, 0.5 + a0 + opts.hc, 0.5 + a0 + opts.hc}; + colloid_t * pc = NULL; + + colloids_info_add_local(cinfo, 1, r, &pc); + if (pc) { + pc->s.a0 = a0; + pc->s.ah = ah; + } + /* Need the local list up-to-date... */ + colloids_info_list_local_build(cinfo); + + wall_ss_cut_compute(cinfo, wall_ss_cut); + if (pc) { + assert(fabs(pc->force[X] - 655.27808) < FLT_EPSILON); + assert(fabs(pc->force[Y] - 0.0) < DBL_EPSILON); + assert(fabs(pc->force[Z] - 0.0) < DBL_EPSILON); + } + } + + wall_ss_cut_free(wall_ss_cut); + colloids_info_free(cinfo); + + return 0; +} diff --git a/tests/unit/tests.c b/tests/unit/tests.c index 03c57288a..7bdde2b13 100644 --- a/tests/unit/tests.c +++ b/tests/unit/tests.c @@ -104,6 +104,7 @@ __host__ int tests_create() { test_util_sum_suite(); test_visc_arrhenius_suite(); test_wall_suite(); + test_wall_ss_cut_suite(); test_fe_surfactant1_suite(); test_fe_symmetric_suite(); diff --git a/tests/unit/tests.h b/tests/unit/tests.h index 800ff3110..2fb77823c 100644 --- a/tests/unit/tests.h +++ b/tests/unit/tests.h @@ -89,5 +89,6 @@ int test_util_suite(void); int test_util_sum_suite(void); int test_visc_arrhenius_suite(void); int test_wall_suite(void); +int test_wall_ss_cut_suite(void); #endif