Skip to content

Commit 57d477b

Browse files
author
Martin D. Weinberg
committed
Add scaling for CBDisk to pyEXP
1 parent 222f078 commit 57d477b

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

expui/BiorthBasis.H

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ namespace BasisClasses
607607
void dens(const int m, const double r, Eigen::VectorXd& a);
608608
//@}
609609

610+
//! Potential, force, and density scaling
611+
double fac1, fac2;
612+
610613
protected:
611614

612615
//! Evaluate basis in cylindrical coordinates

expui/BiorthBasis.cc

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,6 +2086,11 @@ namespace BasisClasses
20862086
//
20872087
if (not conf["scale"]) conf["scale"] = 1.0;
20882088

2089+
// Potential, force, and density scaling
2090+
//
2091+
fac1 = pow(scale, -0.5);
2092+
fac2 = pow(scale, -1.5);
2093+
20892094
// Orthogonality sanity check
20902095
//
20912096
orthoTest();
@@ -2122,9 +2127,10 @@ namespace BasisClasses
21222127
tab.resize(mmax+1, nmax);
21232128
Eigen::VectorXd a(nmax);
21242129
for (int m=0; m<=mmax; m++) {
2125-
potl(m, r, a);
2130+
potl(m, r/scale, a);
21262131
tab.row(m) = a;
21272132
}
2133+
tab *= fac1;
21282134
}
21292135

21302136
// Get density
@@ -2133,9 +2139,10 @@ namespace BasisClasses
21332139
tab.resize(mmax+1, nmax);
21342140
Eigen::VectorXd a(nmax);
21352141
for (int m=0; m<=mmax; m++) {
2136-
dens(m, r, a);
2142+
dens(m, r/scale, a);
21372143
tab.row(m) = a;
21382144
}
2145+
tab *= fac2;
21392146
}
21402147

21412148
// Get force
@@ -2144,9 +2151,10 @@ namespace BasisClasses
21442151
tab.resize(mmax+1, nmax);
21452152
Eigen::VectorXd a(nmax);
21462153
for (int m=0; m<=mmax; m++) {
2147-
dpot(m, r, a);
2154+
dpot(m, r/scale, a);
21482155
tab.row(m) = a;
21492156
}
2157+
tab *= fac1/scale;
21502158
}
21512159

21522160
// Routines for computing biorthonormal pairs based on
@@ -2342,17 +2350,29 @@ namespace BasisClasses
23422350
double r = lq.knot(i) * Rmax, fac = lq.weight(i) * Rmax;
23432351
Eigen::VectorXd vpot, vden;
23442352

2345-
potl(m, r, vpot);
2346-
dens(m, r, vden);
2353+
potl(m, r/scale, vpot);
2354+
dens(m, r/scale, vden);
23472355

23482356
for (int j=0; j<nmax; j++) {
23492357
for (int k=0; k<nmax; k++) {
2350-
ret[m](j, k) += fac * vpot(j) * vden(k) * r * 2.0*M_PI;
2358+
ret[m](j, k) += fac * vpot(j) * vden(k) * r * 2.0*M_PI * fac1*fac2;
23512359
}
23522360
}
23532361
}
23542362
}
23552363

2364+
// DEBUG
2365+
std::ofstream out("orthoCheck.dat");
2366+
out << "scale=" << scale << " fac1=" << fac1 << " fac2=" << fac2 << std::endl;
2367+
for (int m=0; m<=mmax; m++) {
2368+
out << std::string(80, '-') << std::endl
2369+
<< "---- m=" << m << std::endl
2370+
<< std::string(80, '-') << std::endl
2371+
<< ret[m] << std::endl
2372+
<< std::string(80, '-') << std::endl << std::endl;
2373+
}
2374+
// END DEBUG
2375+
23562376
return ret;
23572377
}
23582378

@@ -2443,8 +2463,8 @@ namespace BasisClasses
24432463
{
24442464
// Normalization factors
24452465
//
2446-
constexpr double norm0 = 2.0*M_PI * 0.5*M_2_SQRTPI/M_SQRT2;
2447-
constexpr double norm1 = 2.0*M_PI * 0.5*M_2_SQRTPI;
2466+
constexpr double norm0 = 1.0;
2467+
constexpr double norm1 = M_SQRT2;
24482468

24492469
//======================
24502470
// Compute coefficients

0 commit comments

Comments
 (0)