From a54bd6603dd6b36dc411e1ea812436881a5bbc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sat, 22 Sep 2018 21:42:04 +0300 Subject: [PATCH] Testing Ewald self-interaction at K Former-commit-id: d71bb8039c3c612d2795ab06f8eaad3932ffa05f --- tests/ewaldshift2.c | 46 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/tests/ewaldshift2.c b/tests/ewaldshift2.c index 72cc404..1fdabd3 100644 --- a/tests/ewaldshift2.c +++ b/tests/ewaldshift2.c @@ -3,6 +3,7 @@ // implementation of the [LT(4.16)] test #include #define M_SQRTPI 1.7724538509055160272981674833411452 +#define M_SQRT3 1.7320508075688772935274463415058724 #include #include #include @@ -37,6 +38,16 @@ typedef struct ewaldtest_triang_results { } ewaldtest_triang_results; +/* +const double a = 582e-9; +const double inv_a = 4*M_PI/a/M_SQRT3; +const double Klen = 4*M_PI/a/3; +*/ + +#define AA (582.e-9) +#define INV_A (4*M_PI/AA/M_SQRT3) +#define KLEN (4*M_PI/AA/3) + ewaldtest_triang_params paramslist[] = { // lMax, beta, shift, k, a, eta, maxR, maxK, csphase, orientation /* @@ -55,10 +66,21 @@ ewaldtest_triang_params paramslist[] = { { 2, {1.1, 1}, {0.5,0.}, 2.3, 0.97, 2.5, 20, 160, 1., TRIANGULAR_VERTICAL}, { 2, {1.1, 1}, {0.5,0.}, 2.3, 0.97, 3.5, 20, 160, 1., TRIANGULAR_VERTICAL}, */ - { 2, {1.1, 1}, {0.5,0.1325}, 2.3, 0.97, 0.5, 20, 160, 1., TRIANGULAR_VERTICAL}, - { 2, {1.1, 1}, {0.5,0.1325}, 2.3, 0.97, 1.5, 20, 160, 1., TRIANGULAR_VERTICAL}, - { 2, {1.1, 1}, {0.5,0.1325}, 2.3, 0.97, 2.5, 20, 160, 1., TRIANGULAR_VERTICAL}, - { 2, {1.1, 1}, {0.5,0.1325}, 2.3, 0.97, 3.5, 20, 160, 1., TRIANGULAR_VERTICAL}, + + +// { 3, {0,KLEN}, {0,0}, 2.62 * 4 * M_PI/3/AA, AA, 0.5 / AA, 20*AA, 160/AA, 1., TRIANGULAR_VERTICAL}, + { 3, {0,KLEN}, {0,0}, 2.62 * 4 * M_PI/3/AA, AA, 2.5 / AA, 20*AA, 160/AA, 1., TRIANGULAR_VERTICAL}, + { 3, {0,KLEN}, {0,0}, 2.62 * 4 * M_PI/3/AA, AA, 4.5 / AA, 20*AA, 160/AA, 1., TRIANGULAR_VERTICAL}, + { 3, {0,KLEN}, {0,0}, 2.62 * 4 * M_PI/3/AA, AA, 6.5 / AA, 20*AA, 160/AA, 1., TRIANGULAR_VERTICAL}, + { 3, {0,KLEN}, {0,0}, 2.62 * 4 * M_PI/3/AA, AA, 8.5 / AA, 20*AA, 160/AA, 1., TRIANGULAR_VERTICAL}, +/* + { 3, {0,Klen}, {0,0}, 2.62 * 4 * M_PI/3/a, a, 0.5 / a, 20*a, 2*M_PI*160/a, 1., TRIANGULAR_VERTICAL}, + { 3, {0,Klen}, {0,0}, 2.62 * 4 * M_PI/3/a, a, 2.5 / a, 20*a, 2*M_PI*160/a, 1., TRIANGULAR_VERTICAL}, + { 3, {0,Klen}, {0,0}, 2.62 * 4 * M_PI/3/a, a, 4.5 / a, 20*a, 2*M_PI*160/a, 1., TRIANGULAR_VERTICAL}, + { 3, {0,Klen}, {0,0}, 2.62 * 4 * M_PI/3/a, a, 6.5 / a, 20*a, 2*M_PI*160/a, 1., TRIANGULAR_VERTICAL}, + { 3, {0,Klen}, {0,0}, 2.62 * 4 * M_PI/3/a, a, 8.5 / a, 20*a, 2*M_PI*160/a, 1., TRIANGULAR_VERTICAL}, +*/ + { 2, {1.1, 2.1}, {0.5,0.1325}, 2.3, 0.97, 0.5, 20, 160, 1., TRIANGULAR_VERTICAL}, { 2, {1.1, 2.1}, {0.5,0.1325}, 2.3, 0.97, 1.5, 20, 160, 1., TRIANGULAR_VERTICAL}, @@ -234,9 +256,19 @@ ewaldtest_triang_results *ewaldtest_triang(const ewaldtest_triang_params p) { triangular_lattice_gen_extend_to_r(Klg, p.maxK + K_len); point2d *Rpoints = Rlg->ps.base; + size_t nR = Rlg->ps.r_offsets[Rlg->ps.nrs]; + + if (fabs(p.particle_shift.x) ==0 && fabs(p.particle_shift.y) == 0) { + points2d_rordered_t Rpos = points2d_rordered_annulus(&(Rlg->ps), 0, false, INFINITY, false); + Rpoints = Rpos.base + Rpos.r_offsets[0]; + nR = Rpos.r_offsets[Rpos.nrs] - Rpos.r_offsets[0]; + } + + + + point2d *Kpoints = Klg->ps.base; - size_t nR = Rlg->ps.r_offsets[Rlg->ps.nrs], - nK = Klg->ps.r_offsets[Klg->ps.nrs]; + size_t nK = Klg->ps.r_offsets[Klg->ps.nrs]; point2d particle_shift = p.particle_shift; point2d minus_ps = {-particle_shift.x, -particle_shift.y}; @@ -246,6 +278,8 @@ ewaldtest_triang_results *ewaldtest_triang(const ewaldtest_triang_params p) { Rpoints_plus_shift[i].y = Rpoints[i].y - particle_shift.y; } + + qpms_y_t nelem_sc = qpms_lMax2nelem_sc(p.lMax); results->sigmas_short = malloc(sizeof(complex double)*nelem_sc);