From 37d778f08b53ead552b7553bba1f83ca6ee8d633 Mon Sep 17 00:00:00 2001 From: Ardavan Oskooi Date: Fri, 19 Jan 2024 20:48:54 -0800 Subject: [PATCH 1/2] increase initial number of grid points used in phi quadrature for near-to-far field transformation in cylindrical coordinates --- src/near2far.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/near2far.cpp b/src/near2far.cpp index ef3676d6a..f84edae74 100644 --- a/src/near2far.cpp +++ b/src/near2far.cpp @@ -288,7 +288,7 @@ void greencyl(std::complex *EH, const vec &x, double freq, double eps, d /* Perform phi integral. Since phi integrand is smooth, quadrature with equally spaced points should converge exponentially fast with the number N of quadrature points. We repeatedly double N until convergence to tol is achieved, re-using previous points. */ - const int N0 = 4; + const int N0 = 128; double dphi = 2.0 / N0; // factor of 2*pi*r is already included in add_dft weight for (int N = N0; N <= 65536; N *= 2) { std::complex EH_sum[6]; From c729a44182f8f0bff7a9e43bf646a0219a647f3e Mon Sep 17 00:00:00 2001 From: Ardavan Oskooi Date: Tue, 23 Jan 2024 10:36:51 -0800 Subject: [PATCH 2/2] make the initial number of grid points linearly scale with m --- src/near2far.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/near2far.cpp b/src/near2far.cpp index f84edae74..921dd4496 100644 --- a/src/near2far.cpp +++ b/src/near2far.cpp @@ -288,7 +288,7 @@ void greencyl(std::complex *EH, const vec &x, double freq, double eps, d /* Perform phi integral. Since phi integrand is smooth, quadrature with equally spaced points should converge exponentially fast with the number N of quadrature points. We repeatedly double N until convergence to tol is achieved, re-using previous points. */ - const int N0 = 128; + const int N0 = 16 + int(4 * abs(m)); double dphi = 2.0 / N0; // factor of 2*pi*r is already included in add_dft weight for (int N = N0; N <= 65536; N *= 2) { std::complex EH_sum[6];