Skip to content

Commit a58b320

Browse files
author
Roberto Di Remigio
committed
Merge branch 'Rob-green_spherical' into Rob-green_metalnp
Conflicts: src/bi_operators/CollocationIntegrator.hpp src/bi_operators/NumericalIntegrator.hpp src/green/RegisterToFactory.hpp src/green/SphericalDiffuse.hpp src/green/dielectric_profile/Sharp.hpp tests/green/CMakeLists.txt
2 parents 562ad4d + 3e4073c commit a58b320

File tree

111 files changed

+1467
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1467
-360
lines changed

src/bi_operators/CollocationIntegrator.hpp

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@
3535

3636
#include "Config.hpp"
3737

38-
#include <Eigen/Dense>
38+
#include <Eigen/Core>
3939

4040
#include "IntegratorHelperFunctions.hpp"
4141
#include "Element.hpp"
4242
#include "Exception.hpp"
43+
#include "AlternateSphericalDiffuse.hpp"
4344
#include "AnisotropicLiquid.hpp"
4445
#include "IonicLiquid.hpp"
4546
#include "MetalNP.hpp"
@@ -214,6 +215,69 @@ struct CollocationIntegrator
214215
}
215216
/**@}*/
216217

218+
/**@{ Single and double layer potentials for a SphericalDiffuse Green's function with alternative handling of Coulomb singularty by collocation */
219+
/*! \tparam ProfilePolicy the permittivity profile for the diffuse interface
220+
* \param[in] gf Green's function
221+
* \param[in] e list of finite elements
222+
*/
223+
template <typename ProfilePolicy>
224+
Eigen::MatrixXd singleLayer(const AlternateSphericalDiffuse<CollocationIntegrator, ProfilePolicy> & gf, const std::vector<Element> & e) const {
225+
// The singular part is "integrated" as usual, while the nonsingular part is evaluated in full
226+
size_t mat_size = e.size();
227+
Eigen::MatrixXd S = Eigen::MatrixXd::Zero(mat_size, mat_size);
228+
for (size_t i = 0; i < mat_size; ++i) {
229+
// Fill diagonal
230+
// Diagonal of S inside the cavity
231+
double Sii_I = factor_ * std::sqrt(4 * M_PI / e[i].area());
232+
double eps_r2 = 0.0;
233+
std::tie(eps_r2, std::ignore) = gf.epsilon(e[i].center());
234+
S(i, i) = Sii_I / eps_r2;
235+
Eigen::Vector3d source = e[i].center();
236+
for (size_t j = 0; j < mat_size; ++j) {
237+
// Fill off-diagonal
238+
Eigen::Vector3d probe = e[j].center();
239+
if (i != j) S(i, j) = gf.kernelS(source, probe);
240+
}
241+
}
242+
return S;
243+
}
244+
/*! \tparam ProfilePolicy the permittivity profile for the diffuse interface
245+
* \param[in] gf Green's function
246+
* \param[in] e list of finite elements
247+
*/
248+
template <typename ProfilePolicy>
249+
Eigen::MatrixXd doubleLayer(const AlternateSphericalDiffuse<CollocationIntegrator, ProfilePolicy> & gf, const std::vector<Element> & e) const {
250+
// The singular part is "integrated" as usual, while the nonsingular part is evaluated in full
251+
size_t mat_size = e.size();
252+
Eigen::MatrixXd D = Eigen::MatrixXd::Zero(mat_size, mat_size);
253+
for (size_t i = 0; i < mat_size; ++i) {
254+
// Fill diagonal
255+
double area = e[i].area();
256+
double radius = e[i].sphere().radius();
257+
// Diagonal of S inside the cavity
258+
double Sii_I = factor_ * std::sqrt(4 * M_PI / area);
259+
// Diagonal of D inside the cavity
260+
double Dii_I = -factor_ * std::sqrt(M_PI/ area) * (1.0 / radius);
261+
// "Diagonal" of the directional derivative of the Coulomb singularity separation coefficient
262+
double invE_grad = gf.inverseEDerivative(e[i].normal(), e[i].center(), e[i].center());
263+
264+
double eps_r2 = 0.0;
265+
std::tie(eps_r2, std::ignore) = gf.epsilon(e[i].center());
266+
267+
D(i, i) = Dii_I + eps_r2 * Sii_I * invE_grad;
268+
Eigen::Vector3d source = e[i].center();
269+
for (size_t j = 0; j < mat_size; ++j) {
270+
// Fill off-diagonal
271+
Eigen::Vector3d probe = e[j].center();
272+
Eigen::Vector3d probeNormal = e[j].normal();
273+
probeNormal.normalize();
274+
if (i != j) D(i, j) = gf.kernelD(probeNormal, source, probe);
275+
}
276+
}
277+
return D;
278+
}
279+
/**@}*/
280+
217281
/**@{ Single and double layer potentials for a MetalNP Green's function by collocation */
218282
template <typename DerivativeTraits>
219283
Eigen::MatrixXd singleLayer(const MetalNP<DerivativeTraits, CollocationIntegrator> & /* gf */, const std::vector<Element> & /* e */) const {

src/bi_operators/IntegratorHelperFunctions.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232

3333
#include "Config.hpp"
3434

35-
#include <Eigen/Dense>
35+
#include <Eigen/Core>
36+
37+
#include <boost/mpl/at.hpp>
38+
#include <boost/mpl/int.hpp>
39+
#include <boost/mpl/map.hpp>
3640

3741
#include "Element.hpp"
3842
#include "QuadratureRules.hpp"

src/bi_operators/NumericalIntegrator.hpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434

3535
#include "Config.hpp"
3636

37-
#include <Eigen/Dense>
37+
#include <Eigen/Core>
3838

3939
#include "IntegratorHelperFunctions.hpp"
4040
#include "Element.hpp"
41+
#include "AlternateSphericalDiffuse.hpp"
4142
#include "AnisotropicLiquid.hpp"
4243
#include "SphericalDiffuse.hpp"
4344
#include "IonicLiquid.hpp"
@@ -186,6 +187,45 @@ struct NumericalIntegrator
186187
// double eps_r2 = 0.0;
187188
// std::tie(eps_r2, std::ignore) = gf.epsilon(e.center());
188189

190+
// return eps_r2 * (Dii_I / coulomb_coeff - Sii_I * coeff_grad + image_grad);
191+
return Eigen::MatrixXd::Zero(e.size(), e.size());
192+
}
193+
/**@}*/
194+
195+
/**@{ Single and double layer potentials for a SphericalDiffuse Green's function with alternative handling of Coulomb singularty by collocation: numerical integration of diagonal */
196+
template <typename ProfilePolicy>
197+
Eigen::MatrixXd singleLayer(const AlternateSphericalDiffuse<NumericalIntegrator, ProfilePolicy> & /* gf */, const std::vector<Element> & e) const {
198+
// // The singular part is "integrated" as usual, while the nonsingular part is evaluated in full
199+
// double area = e.area();
200+
// // Diagonal of S inside the cavity
201+
// double Sii_I = factor_ * std::sqrt(4 * M_PI / area);
202+
// // "Diagonal" of Coulomb singularity separation coefficient
203+
// double coulomb_coeff = gf.coefficientCoulomb(e.center(), e.center());
204+
// // "Diagonal" of the image Green's function
205+
// double image = gf.imagePotential(e.center(), e.center());
206+
207+
// return (Sii_I / coulomb_coeff + image);
208+
return Eigen::MatrixXd::Zero(e.size(), e.size());
209+
}
210+
template <typename ProfilePolicy>
211+
Eigen::MatrixXd doubleLayer(const AlternateSphericalDiffuse<NumericalIntegrator, ProfilePolicy> & /* gf */, const std::vector<Element> & e) const {
212+
// // The singular part is "integrated" as usual, while the nonsingular part is evaluated in full
213+
// double area = e.area();
214+
// double radius = e.sphere().radius();
215+
// // Diagonal of S inside the cavity
216+
// double Sii_I = factor_ * std::sqrt(4 * M_PI / area);
217+
// // Diagonal of D inside the cavity
218+
// double Dii_I = -factor_ * std::sqrt(M_PI/ area) * (1.0 / radius);
219+
// // "Diagonal" of Coulomb singularity separation coefficient
220+
// double coulomb_coeff = gf.coefficientCoulomb(e.center(), e.center());
221+
// // "Diagonal" of the directional derivative of the Coulomb singularity separation coefficient
222+
// double coeff_grad = gf.coefficientCoulombDerivative(e.normal(), e.center(), e.center()) / std::pow(coulomb_coeff, 2);
223+
// // "Diagonal" of the directional derivative of the image Green's function
224+
// double image_grad = gf.imagePotentialDerivative(e.normal(), e.center(), e.center());
225+
226+
// double eps_r2 = 0.0;
227+
// std::tie(eps_r2, std::ignore) = gf.epsilon(e.center());
228+
189229
// return eps_r2 * (Dii_I / coulomb_coeff - Sii_I * coeff_grad + image_grad);
190230
return Eigen::MatrixXd::Zero(e.size(), e.size());
191231
}

src/bi_operators/PurisimaIntegrator.hpp

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@
3535

3636
#include "Config.hpp"
3737

38-
#include <Eigen/Dense>
38+
#include <Eigen/Core>
3939

4040
#include "IntegratorHelperFunctions.hpp"
4141
#include "Element.hpp"
4242
#include "Exception.hpp"
43+
#include "AlternateSphericalDiffuse.hpp"
4344
#include "AnisotropicLiquid.hpp"
4445
#include "IonicLiquid.hpp"
4546
#include "MetalNP.hpp"
@@ -223,6 +224,69 @@ struct PurisimaIntegrator
223224
return D;
224225
}
225226
/**@}*/
227+
228+
/**@{ Single and double layer potentials for a SphericalDiffuse Green's function with alternative handling of Coulomb singularty by collocation */
229+
/*! \tparam ProfilePolicy the permittivity profile for the diffuse interface
230+
* \param[in] gf Green's function
231+
* \param[in] e list of finite elements
232+
*/
233+
template <typename ProfilePolicy>
234+
Eigen::MatrixXd singleLayer(const AlternateSphericalDiffuse<PurisimaIntegrator, ProfilePolicy> & gf, const std::vector<Element> & e) const {
235+
// The singular part is "integrated" as usual, while the nonsingular part is evaluated in full
236+
size_t mat_size = e.size();
237+
Eigen::MatrixXd S = Eigen::MatrixXd::Zero(mat_size, mat_size);
238+
for (size_t i = 0; i < mat_size; ++i) {
239+
// Fill diagonal
240+
// Diagonal of S inside the cavity
241+
double Sii_I = factor_ * std::sqrt(4 * M_PI / e[i].area());
242+
double eps_r2 = 0.0;
243+
std::tie(eps_r2, std::ignore) = gf.epsilon(e[i].center());
244+
S(i, i) = Sii_I / eps_r2;
245+
Eigen::Vector3d source = e[i].center();
246+
for (size_t j = 0; j < mat_size; ++j) {
247+
// Fill off-diagonal
248+
Eigen::Vector3d probe = e[j].center();
249+
if (i != j) S(i, j) = gf.kernelS(source, probe);
250+
}
251+
}
252+
return S;
253+
}
254+
/*! \tparam ProfilePolicy the permittivity profile for the diffuse interface
255+
* \param[in] gf Green's function
256+
* \param[in] e list of finite elements
257+
*/
258+
template <typename ProfilePolicy>
259+
Eigen::MatrixXd doubleLayer(const AlternateSphericalDiffuse<PurisimaIntegrator, ProfilePolicy> & gf, const std::vector<Element> & e) const {
260+
// The singular part is "integrated" as usual, while the nonsingular part is evaluated in full
261+
size_t mat_size = e.size();
262+
Eigen::MatrixXd D = Eigen::MatrixXd::Zero(mat_size, mat_size);
263+
for (size_t i = 0; i < mat_size; ++i) {
264+
// Fill diagonal
265+
double area = e[i].area();
266+
double radius = e[i].sphere().radius();
267+
// Diagonal of S inside the cavity
268+
double Sii_I = factor_ * std::sqrt(4 * M_PI / area);
269+
// Diagonal of D inside the cavity
270+
double Dii_I = -factor_ * std::sqrt(M_PI/ area) * (1.0 / radius);
271+
// "Diagonal" of the directional derivative of the Coulomb singularity separation coefficient
272+
double invE_grad = gf.inverseEDerivative(e[i].normal(), e[i].center(), e[i].center());
273+
274+
double eps_r2 = 0.0;
275+
std::tie(eps_r2, std::ignore) = gf.epsilon(e[i].center());
276+
277+
D(i, i) = Dii_I + eps_r2 * Sii_I * invE_grad;
278+
Eigen::Vector3d source = e[i].center();
279+
for (size_t j = 0; j < mat_size; ++j) {
280+
// Fill off-diagonal
281+
Eigen::Vector3d probe = e[j].center();
282+
Eigen::Vector3d probeNormal = e[j].normal();
283+
probeNormal.normalize();
284+
if (i != j) D(i, j) = gf.kernelD(probeNormal, source, probe);
285+
}
286+
}
287+
return D;
288+
}
289+
/**@}*/
226290

227291
/**@{ Single and double layer potentials for a MetalNP Green's function by collocation */
228292
template <typename DerivativeTraits>

src/bin/check_Coulomb_coefficient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <ostream>
33
#include <fstream>
44

5-
#include <Eigen/Dense>
5+
#include <Eigen/Core>
66

77
#include "DerivativeTypes.hpp"
88
#include "UniformDielectric.hpp"

src/bin/debug_wavcav.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <fstream>
2828
#include <string>
2929

30-
#include <Eigen/Dense>
30+
#include <Eigen/Core>
3131

3232
#include "PWCSolver.hpp"
3333
#include "Vacuum.hpp"

src/bin/plot_green_spherical-CASE1.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <ostream>
33
#include <fstream>
44

5-
#include <Eigen/Dense>
5+
#include <Eigen/Core>
66

77
#include "CollocationIntegrator.hpp"
88
#include "DerivativeTypes.hpp"
@@ -19,6 +19,7 @@ int main()
1919
sphereCenter << 0.0, 0.0, 0.0;
2020
double sphereRadius = 100.0;
2121
double width = 10.0;
22+
int maxL = 30;
2223

2324
Eigen::Vector3d source;
2425
source << 4.0, 0.0, 85.0;
@@ -29,7 +30,7 @@ int main()
2930
double zMax = 300.0;
3031
double step = (zMax - zMin) / nPoints;
3132

32-
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter);
33+
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter, maxL);
3334
LOG(gf);
3435
std::ofstream out;
3536
out.open("gf_spherical_CASE1.dat");

src/bin/plot_green_spherical-CASE2.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <ostream>
33
#include <fstream>
44

5-
#include <Eigen/Dense>
5+
#include <Eigen/Core>
66

77
#include "CollocationIntegrator.hpp"
88
#include "DerivativeTypes.hpp"
@@ -19,6 +19,7 @@ int main()
1919
sphereCenter << 0.0, 0.0, 0.0;
2020
double sphereRadius = 100.0;
2121
double width = 10.0;
22+
int maxL = 30;
2223

2324
Eigen::Vector3d source;
2425
source << 4.0, 0.0, 150.0;
@@ -29,7 +30,7 @@ int main()
2930
double zMax = 300.0;
3031
double step = (zMax - zMin) / nPoints;
3132

32-
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter);
33+
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter, maxL);
3334
LOG(gf);
3435
std::ofstream out;
3536
out.open("gf_spherical_CASE1.dat");

src/bin/plot_green_spherical-CASE3.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <ostream>
33
#include <fstream>
44

5-
#include <Eigen/Dense>
5+
#include <Eigen/Core>
66

77
#include "CollocationIntegrator.hpp"
88
#include "DerivativeTypes.hpp"
@@ -19,6 +19,7 @@ int main()
1919
sphereCenter << 0.0, 0.0, 0.0;
2020
double sphereRadius = 100.0;
2121
double width = 10.0;
22+
int maxL = 30;
2223

2324
Eigen::Vector3d source;
2425
source << 4.0, 0.0, 100.0;
@@ -29,7 +30,7 @@ int main()
2930
double zMax = 300.0;
3031
double step = (zMax - zMin) / nPoints;
3132

32-
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter);
33+
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter, maxL);
3334
LOG(gf);
3435
std::ofstream out;
3536
out.open("gf_spherical_CASE1.dat");

src/bin/plot_green_spherical-CASE4.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <ostream>
44
#include <fstream>
55

6-
#include <Eigen/Dense>
6+
#include <Eigen/Core>
77

88
#include "CollocationIntegrator.hpp"
99
#include "DerivativeTypes.hpp"
@@ -20,6 +20,7 @@ int main()
2020
sphereCenter << 0.0, 0.0, 0.0;
2121
double sphereRadius = 100.0;
2222
double width = 10.0;
23+
int maxL = 30;
2324

2425
Eigen::Vector3d source;
2526
source << 0.0, 0.0, 1.0;
@@ -30,7 +31,7 @@ int main()
3031
double zMax = 300.0;
3132
double step = (zMax - zMin) / nPoints;
3233

33-
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter);
34+
SphericalDiffuse<CollocationIntegrator, OneLayerTanh> gf(epsInside, epsOutside, width, sphereRadius, sphereCenter, maxL);
3435
LOG(gf);
3536
std::ofstream out;
3637
out.open("gf_spherical_CASE1.dat");

0 commit comments

Comments
 (0)