@@ -21,7 +21,6 @@ struct TanhSphericalDiffuseTest {
2121 Eigen::Vector3d sphereCenter;
2222 Eigen::Vector3d source1, probe1, sourceNormal1, probeNormal1;
2323 Eigen::Vector3d source2, probe2, sourceNormal2, probeNormal2;
24- Eigen::Array4d resultInside, resultOutside;
2524 TanhSphericalDiffuseTest () { SetUp (); }
2625 void SetUp () {
2726 epsInside = 80.0 ;
@@ -38,7 +37,7 @@ struct TanhSphericalDiffuseTest {
3837 probeNormal1.normalize ();
3938 // Reference value
4039 // Checked by comparing the asymptotic behaviour
41- inside_reference = 0.50008829802731714 ;
40+ inside_reference = 0.012377848015483936 ;
4241 // Evaluation outside the sphere
4342 source2 << 150.0 , 150.0 , 150.0 ;
4443 sourceNormal2 = source2; // + Eigen::Vector3d::Random();
@@ -108,8 +107,28 @@ BOOST_FIXTURE_TEST_CASE(outside, TanhSphericalDiffuseTest)
108107}
109108BOOST_AUTO_TEST_SUITE_END ()
110109
111- /*
112110struct TanhSphericalDiffuseBogusTest {
111+ Eigen::Array4d analyticEvaluate (double eps, const Eigen::Vector3d & spNormal,
112+ const Eigen::Vector3d & sp,
113+ const Eigen::Vector3d & ppNormal, const Eigen::Vector3d & pp) {
114+ Eigen::Array4d result = Eigen::Array4d::Zero ();
115+ double distance = (sp - pp).norm ();
116+ double distance_3 = std::pow (distance, 3 );
117+ double distance_5 = std::pow (distance, 5 );
118+
119+ // Value of the function
120+ result (0 ) = 1.0 / (eps * distance);
121+ // Value of the directional derivative wrt probe
122+ result (1 ) = (sp - pp).dot (ppNormal) / (eps * distance_3);
123+ // Directional derivative wrt source
124+ result (2 ) = - (sp - pp).dot (spNormal) / (eps * distance_3);
125+ // Value of the Hessian
126+ result (3 ) = spNormal.dot (ppNormal) / (eps * distance_3) - 3 * ((
127+ sp - pp).dot (spNormal))*((sp - pp).dot (
128+ ppNormal)) / (eps * distance_5);
129+
130+ return result;
131+ }
113132 double epsInside, epsOutside, sphereRadius, width;
114133 Eigen::Vector3d sphereCenter;
115134 Eigen::Vector3d source1, probe1, sourceNormal1, probeNormal1;
@@ -119,48 +138,44 @@ struct TanhSphericalDiffuseBogusTest {
119138 void SetUp () {
120139 epsInside = 80.0 ;
121140 epsOutside = 80.0 ;
122- sphereCenter << 0.0, 0.0, 0.0;
123- sphereRadius = 50 .0;
124- width = 0.5 ;
125- // Evaluation inside the sphere
141+ sphereCenter << 0.0 , 0.0 , 0.0 ;
142+ sphereRadius = 100 .0 ;
143+ width = 5.0 ;
144+ // Evaluation inside the sphere
126145 source1 << 1.0 , 0.0 , 0.0 ;
127146 sourceNormal1 = source1; // + Eigen::Vector3d::Random();
128147 sourceNormal1.normalize ();
129148 probe1 << 2.0 , 0.0 , 0.0 ;
130149 probeNormal1 = probe1; // + Eigen::Vector3d::Random();
131150 probeNormal1.normalize ();
132- // Analytic evaluation of the Green's function and its derivatives
133- // for a uniform dielectric
134- resultInside = analyticUniformDielectric(epsInside, sourceNormal1, source1, probeNormal1, probe1);
135- // Evaluation outside the sphere
136- source2 << 100.0, 100.0, 100.0;
151+ // Reference value
152+ resultInside = analyticEvaluate (epsInside, sourceNormal1, source1, probeNormal1, probe1);
153+ // Evaluation outside the sphere
154+ source2 << 150.0 , 150.0 , 150.0 ;
137155 sourceNormal2 = source2; // + Eigen::Vector3d::Random();
138156 sourceNormal2.normalize ();
139- probe2 << 101 .0, 100 .0, 100 .0;
157+ probe2 << 151 .0 , 150 .0 , 150 .0 ;
140158 probeNormal2 = probe2; // + Eigen::Vector3d::Random();
141159 probeNormal2.normalize ();
142- // Analytic evaluation of the Green's function and its derivatives
143- // for a uniform dielectric
144- resultOutside = analyticUniformDielectric(epsOutside, sourceNormal2, source2, probeNormal2, probe2);
160+ // Reference value
161+ resultOutside = analyticEvaluate (epsOutside, sourceNormal2, source2, probeNormal2, probe2);
145162 }
146163};
147164
148165BOOST_FIXTURE_TEST_SUITE (TanhSphericalDiffuse2, TanhSphericalDiffuseBogusTest)
149- */
150166/* ! \class TanhSphericalDiffuse
151167 * \test \b TanhSphericalDiffuseBogusTest_inside tests the evaluation of the TanhSphericalDiffuse Green's function against analytical result for uniform dielectric
152168 */
153- /*
154169BOOST_FIXTURE_TEST_CASE(inside, TanhSphericalDiffuseBogusTest)
155170{
156- TanhSphericalDiffuse gf(epsInside, epsOutside, sphereCenter, sphereRadius, width);
157- std::cout << gf << std::endl;
171+ TanhSphericalDiffuse gf (epsInside, epsOutside, width, sphereRadius);
158172 double value = resultInside (0 );
159173 double gf_value = gf.function (source1, probe1);
160174 BOOST_TEST_MESSAGE (" value = " << std::setprecision (std::numeric_limits<long double >::digits10) << value);
161175 BOOST_TEST_MESSAGE (" gf_value = " << std::setprecision (std::numeric_limits<long double >::digits10) << gf_value);
162- BOOST_CHECK_CLOSE(value, gf_value , 1.0e-12 );
176+ BOOST_CHECK_CLOSE (gf_value, value , 1.0e-07 );
163177
178+ /*
164179 double derProbe = resultInside(1);
165180 double gf_derProbe = gf.derivativeProbe(probeNormal1, source1, probe1);
166181 BOOST_TEST_MESSAGE("derProbe = " << std::setprecision(std::numeric_limits<long double>::digits10) << derProbe);
@@ -172,34 +187,34 @@ BOOST_FIXTURE_TEST_CASE(inside, TanhSphericalDiffuseBogusTest)
172187 BOOST_TEST_MESSAGE("derSource = " << std::setprecision(std::numeric_limits<long double>::digits10) << derSource);
173188 BOOST_TEST_MESSAGE("gf_derSource = " << std::setprecision(std::numeric_limits<long double>::digits10) << gf_derSource);
174189 BOOST_CHECK_CLOSE(derSource, gf_derSource, 1.0e-06);
190+ */
175191}
176- */
192+
177193/* ! \class TanhSphericalDiffuse
178194 * \test \b TanhSphericalDiffuseBogusTest_outside tests the evaluation of the TanhSphericalDiffuse Green's function against analytical result for uniform dielectric
179195 */
180- /*
181196BOOST_FIXTURE_TEST_CASE (outside, TanhSphericalDiffuseBogusTest)
182197{
183- TanhSphericalDiffuse gf(epsInside, epsOutside, sphereCenter, sphereRadius, width);
184- std::cout << gf << std::endl;
198+ TanhSphericalDiffuse gf (epsInside, epsOutside, width, sphereRadius);
185199 double value = resultOutside (0 );
186200 double gf_value = gf.function (source2, probe2);
187201 BOOST_TEST_MESSAGE (" value = " << std::setprecision (std::numeric_limits<long double >::digits10) << value);
188202 BOOST_TEST_MESSAGE (" gf_value = " << std::setprecision (std::numeric_limits<long double >::digits10) << gf_value);
189- BOOST_CHECK_CLOSE(value, gf_value, 2 .0e-08 );
203+ BOOST_CHECK_CLOSE (gf_value, value, 1 .0e-07 );
190204
205+ /*
191206 double derProbe = resultOutside(1);
192207 double gf_derProbe = gf.derivativeProbe(probeNormal2, source2, probe2);
193208 BOOST_TEST_MESSAGE("derProbe = " << std::setprecision(std::numeric_limits<long double>::digits10) << derProbe);
194209 BOOST_TEST_MESSAGE("gf_derProbe = " << std::setprecision(std::numeric_limits<long double>::digits10) << gf_derProbe);
195- BOOST_CHECK_CLOSE(derProbe, gf_derProbe, 3 .0e-04 );
210+ BOOST_CHECK_CLOSE(derProbe, gf_derProbe, 1 .0e-06 );
196211
197212 double derSource = resultOutside(2);
198213 double gf_derSource = gf.derivativeSource(sourceNormal2, source2, probe2);
199214 BOOST_TEST_MESSAGE("derSource = " << std::setprecision(std::numeric_limits<long double>::digits10) << derSource);
200215 BOOST_TEST_MESSAGE("gf_derSource = " << std::setprecision(std::numeric_limits<long double>::digits10) << gf_derSource);
201- BOOST_CHECK_CLOSE(derSource, gf_derSource, 3.0e-04);
216+ BOOST_CHECK_CLOSE(derSource, gf_derSource, 1.0e-06);
217+ */
202218}
203219
204220BOOST_AUTO_TEST_SUITE_END ()
205- */
0 commit comments