Skip to content

Commit d9ebf82

Browse files
author
Roberto Di Remigio
committed
Some renaming of member variables
1 parent aa05e40 commit d9ebf82

File tree

4 files changed

+39
-34
lines changed

4 files changed

+39
-34
lines changed

src/green/SphericalDiffuse.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,27 +82,27 @@ class SphericalDiffuse : public GreensFunction<Numerical, ProfilePolicy>
8282
{
8383
public:
8484
/*!
85-
* \param[in] eL left-side dielectric constant
86-
* \param[in] eR right-side dielectric constant
85+
* \param[in] e1 left-side dielectric constant
86+
* \param[in] e2 right-side dielectric constant
8787
* \param[in] w width of the interface layer
8888
* \param[in] c center of the diffuse layer
8989
*/
90-
SphericalDiffuse(double eL, double eR, double w, double c) : GreensFunction<Numerical, ProfilePolicy>(false)
90+
SphericalDiffuse(double e1, double e2, double w, double c) : GreensFunction<Numerical, ProfilePolicy>(false)
9191
{
92-
initProfilePolicy(eL, eR, w, c);
92+
initProfilePolicy(e1, e2, w, c);
9393
initSphericalDiffuse();
9494
}
9595
/*!
96-
* \param[in] eL left-side dielectric constant
97-
* \param[in] eR right-side dielectric constant
96+
* \param[in] e1 left-side dielectric constant
97+
* \param[in] e2 right-side dielectric constant
9898
* \param[in] w width of the interface layer
9999
* \param[in] c center of the diffuse layer
100100
* \param[in] diag strategy to calculate the diagonal elements of the boundary integral operator
101101
*/
102-
SphericalDiffuse(double eL, double eR, double w, double c, DiagonalIntegrator * diag)
102+
SphericalDiffuse(double e1, double e2, double w, double c, DiagonalIntegrator * diag)
103103
: GreensFunction<Numerical, ProfilePolicy>(false, diag)
104104
{
105-
initProfilePolicy(eL, eR, w, c);
105+
initProfilePolicy(e1, e2, w, c);
106106
initSphericalDiffuse();
107107
}
108108
virtual ~SphericalDiffuse() {}
@@ -243,13 +243,13 @@ class SphericalDiffuse : public GreensFunction<Numerical, ProfilePolicy>
243243
return os;
244244
}
245245
/*!
246-
* \param[in] eL left-side dielectric constant
247-
* \param[in] eR right-side dielectric constant
246+
* \param[in] e1 left-side dielectric constant
247+
* \param[in] e2 right-side dielectric constant
248248
* \param[in] w width of the interface layer
249249
* \param[in] c center of the diffuse layer
250250
*/
251-
void initProfilePolicy(double eL, double eR, double w, double c)
252-
{ this->profile_ = ProfilePolicy(eL, eR, w, c); }
251+
void initProfilePolicy(double e1, double e2, double w, double c)
252+
{ this->profile_ = ProfilePolicy(e1, e2, w, c); }
253253
/*! This calculates all the components needed to evaluate the Green's function */
254254
void initSphericalDiffuse();
255255

src/green/TanhSphericalDiffuse.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,13 @@ namespace
352352
{
353353
IGreensFunction * createTanhSphericalDiffuse(const greenData & _data)
354354
{
355-
double eL, eR, w, c; // To be read from _data
356-
eL = _data.epsilon2, eR = _data.epsilon1, w = _data.width, c = _data.center;
355+
double e1 = _data.epsilon1;
356+
double e2 = _data.epsilon2;
357+
double w = _data.width;
358+
double c = _data.center;
357359
DiagonalIntegrator * integrator =
358360
DiagonalIntegratorFactory::TheDiagonalIntegratorFactory().createDiagonalIntegrator(_data.integratorType);
359-
return new TanhSphericalDiffuse(eL, eR, w, c, integrator);
361+
return new TanhSphericalDiffuse(e1, e2, w, c, integrator);
360362
}
361363
const std::string TANHSPHERICALDIFFUSE("TANHSPHERICALDIFFUSE");
362364
const bool registeredTanhSphericalDiffuse =

src/green/dielectric_profile/TanhDiffuse.hpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,33 @@
4040
class TanhDiffuse
4141
{
4242
private:
43-
double epsilonLeft_;
44-
double epsilonRight_;
43+
double epsilon1_;
44+
double epsilon2_;
4545
double width_;
4646
double center_;
4747
double value(double point) const {
48+
double epsPlus = (epsilon1_ + epsilon2_) / 2.0;
49+
double epsMinus = (epsilon2_ - epsilon1_) / 2.0;
4850
double tanh_r = std::tanh((point - center_) / width_);
49-
return (0.5 * (epsilonLeft_ + epsilonRight_)
50-
+ 0.5 * (epsilonRight_ - epsilonLeft_) * tanh_r); //epsilon(r)
51+
return (epsPlus + epsMinus * tanh_r); //epsilon(r)
5152
}
5253
double derivative(double point) const {
54+
double factor = (epsilon1_ - epsilon2_) / (2.0 * width_);
5355
double tanh_r = std::tanh((point - center_) / width_);
54-
return (0.5 * (epsilonLeft_ - epsilonRight_)
55-
* ( 1 - tanh_r * tanh_r) / width_); //first derivative of epsilon(r)
56+
return (factor * (1 - std::pow(tanh_r, 2))); //first derivative of epsilon(r)
5657
}
5758
std::ostream & printObject(std::ostream & os)
5859
{
59-
os << "Permittivity inside = " << epsilonLeft_ << std::endl;
60-
os << "Permittivity outside = " << epsilonRight_ << std::endl;
61-
os << "Profile center = " << center_ << std::endl;
62-
os << "Profile width = " << width_;
60+
os << "Permittivity inside = " << epsilon1_ << std::endl;
61+
os << "Permittivity outside = " << epsilon2_ << std::endl;
62+
os << "Profile width = " << width_ << std::endl;
63+
os << "Profile center = " << center_;
6364
return os;
6465
}
6566
public:
6667
TanhDiffuse() {}
67-
TanhDiffuse(double eL, double eR, double w, double c) :
68-
epsilonLeft_(eL), epsilonRight_(eR), width_(w), center_(c) {}
68+
TanhDiffuse(double e1, double e2, double w, double c) :
69+
epsilon1_(e1), epsilon2_(e2), width_(w), center_(c) {}
6970
/*! The permittivity profile of the transition layer
7071
* \param[out] e the value of the dielectric constant at point r
7172
* \param[out] de the value of the derivative of the dielectric constant
@@ -77,8 +78,8 @@ class TanhDiffuse
7778
e = value(r);
7879
de = derivative(r);
7980
}
80-
double epsilonLeft() const { return epsilonLeft_; }
81-
double epsilonRight() const { return epsilonRight_; }
81+
double epsilon1() const { return epsilon1_; }
82+
double epsilon2() const { return epsilon2_; }
8283
double width() const { return width_; }
8384
double center() const { return center_; }
8485
friend std::ostream & operator<<(std::ostream & os, TanhDiffuse & th) {

tests/green/green_tanh_spherical_diffuse.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@
1616
#include "TanhSphericalDiffuse.hpp"
1717

1818
struct TanhSphericalDiffuseTest {
19-
double epsInside, epsOutside, sphereRadius, width;
19+
double eps1, eps2, sphereRadius, width;
2020
double inside_reference, outside_reference;
2121
double deriv_inside_reference, deriv_outside_reference;
2222
Eigen::Vector3d sphereCenter;
2323
Eigen::Vector3d source1, probe1, sourceNormal1, probeNormal1;
2424
Eigen::Vector3d source2, probe2, sourceNormal2, probeNormal2;
2525
TanhSphericalDiffuseTest() { SetUp(); }
2626
void SetUp() {
27-
epsInside = 80.0;
28-
epsOutside = 2.0;
27+
// High dielectric constant inside
28+
eps1 = 80.0;
29+
// Low dielectric constant outside
30+
eps2 = 2.0;
2931
sphereCenter << 0.0, 0.0, 0.0;
3032
sphereRadius = 100.0;
3133
width = 5.0;
@@ -61,7 +63,7 @@ BOOST_FIXTURE_TEST_SUITE(TanhSphericalDiffuse1, TanhSphericalDiffuseTest)
6163
*/
6264
BOOST_FIXTURE_TEST_CASE(inside, TanhSphericalDiffuseTest)
6365
{
64-
TanhSphericalDiffuse gf(epsInside, epsOutside, width, sphereRadius);
66+
TanhSphericalDiffuse gf(eps1, eps2, width, sphereRadius);
6567
double value = inside_reference;
6668
double gf_value = gf.function(source1, probe1);
6769
BOOST_TEST_MESSAGE("value = " << std::setprecision(std::numeric_limits<long double>::digits10) << value);
@@ -87,7 +89,7 @@ BOOST_FIXTURE_TEST_CASE(inside, TanhSphericalDiffuseTest)
8789
*/
8890
BOOST_FIXTURE_TEST_CASE(outside, TanhSphericalDiffuseTest)
8991
{
90-
TanhSphericalDiffuse gf(epsInside, epsOutside, width, sphereRadius);
92+
TanhSphericalDiffuse gf(eps1, eps2, width, sphereRadius);
9193
double value = outside_reference;
9294
double gf_value = gf.function(source2, probe2);
9395
BOOST_TEST_MESSAGE("value = " << std::setprecision(std::numeric_limits<long double>::digits10) << value);

0 commit comments

Comments
 (0)