Skip to content

Commit

Permalink
Rename 'rs' to 'rmapping' in pyEXP and EXP
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Oct 2, 2023
1 parent ff11559 commit 862c60c
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 89 deletions.
2 changes: 1 addition & 1 deletion coefs/BasisFactory.H
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace BasisClasses

std::string model_file;
int lmax, nmax, cmap, numr;
double rmin, rmax;
double rmin, rmax, rmap;

bool NO_L0, NO_L1, EVEN_L, EVEN_M, M0_only;

Expand Down
12 changes: 6 additions & 6 deletions coefs/BasisFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace BasisClasses

const std::set<std::string>
SphericalSL::valid_keys = {
"rs",
"rmapping",
"cmap",
"Lmax",
"dof",
Expand Down Expand Up @@ -173,18 +173,18 @@ namespace BasisClasses

// Assign values from YAML
//
double rs = 1.0;
double rmap = 1.0;

try {
if (conf["cmap"]) cmap = conf["cmap"].as<int>();
if (conf["Lmax"]) lmax = conf["Lmax"].as<int>();
if (conf["nmax"]) nmax = conf["nmax"].as<int>();
if (conf["modelname"]) model_file = conf["modelname"].as<std::string>();

if (conf["rs"])
rs = conf["rs"].as<double>();
if (conf["rmapping"])
rmap = conf["rmapping"].as<double>();
else
rs = 1.0;
rmap = 1.0;

if (conf["scale"])
scale = conf["scale"].as<double>();
Expand Down Expand Up @@ -258,7 +258,7 @@ namespace BasisClasses

// Finally, make the Sturm-Lioville basis...
sl = std::make_shared<SLGridSph>
(model_file, lmax, nmax, numr, rmin, rmax, true, cmap, rs,
(model_file, lmax, nmax, numr, rmin, rmax, true, cmap, rmap,
0, 1, cachename);

// Test basis for consistency
Expand Down
136 changes: 68 additions & 68 deletions exputil/SLGridMP2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void SLGridCyl::bomb(std::string oops)

SLGridCyl::SLGridCyl(int MMAX, int NMAX, int NUMR, int NUMK,
double RMIN, double RMAX, double L,
bool CACHE, int CMAP, double RS,
bool CACHE, int CMAP, double RMAP,
const std::string type, bool VERBOSE)
{
int m, k;
Expand All @@ -217,7 +217,7 @@ SLGridCyl::SLGridCyl(int MMAX, int NMAX, int NUMR, int NUMK,

cache = CACHE;
cmap = CMAP;
rs = RS;
rmap = RMAP;

tbdbg = VERBOSE;

Expand Down Expand Up @@ -458,7 +458,7 @@ int SLGridCyl::read_cached_table(void)
if (!in) return 0;

int MMAX, NMAX, NUMR, NUMK, i, j, CMAP;
double RMIN, RMAX, L, AA, RS;
double RMIN, RMAX, L, AA, RMAP;
std::string MODEL;

if (myid==0)
Expand Down Expand Up @@ -498,17 +498,17 @@ int SLGridCyl::read_cached_table(void)

// Get parameters
//
MMAX = node["mmax" ].as<int>();
NMAX = node["nmax" ].as<int>();
NUMK = node["numk" ].as<int>();
NUMR = node["numr" ].as<int>();
CMAP = node["cmap" ].as<int>();
RMIN = node["rmin" ].as<double>();
RMAX = node["rmax" ].as<double>();
RS = node["rs" ].as<double>();
L = node["L" ].as<double>();
AA = node["A" ].as<double>();
MODEL = node["model" ].as<std::string>();
MMAX = node["mmax" ].as<int>();
NMAX = node["nmax" ].as<int>();
NUMK = node["numk" ].as<int>();
NUMR = node["numr" ].as<int>();
CMAP = node["cmap" ].as<int>();
RMIN = node["rmin" ].as<double>();
RMAX = node["rmax" ].as<double>();
RMAP = node["rmapping"].as<double>();
L = node["L" ].as<double>();
AA = node["A" ].as<double>();
MODEL = node["model" ].as<std::string>();
} else {
std::cout << "---- SLGridCyl: bad magic number in cache file" << std::endl;
return 0;
Expand Down Expand Up @@ -564,10 +564,10 @@ int SLGridCyl::read_cached_table(void)
return 0;
}

if (RS!=rs) {
if (RMAP!=rmap) {
if (myid==0)
std::cout << "---- SLGridCyl::read_cached_table: found rs=" << RS
<< " wanted " << rs << std::endl;
std::cout << "---- SLGridCyl::read_cached_table: found rmapping=" << RMAP
<< " wanted " << rmap << std::endl;
return 0;
}

Expand Down Expand Up @@ -640,17 +640,17 @@ void SLGridCyl::write_cached_table(void)
// content can be added as needed.
YAML::Node node;

node["mmax" ] = mmax;
node["nmax" ] = nmax;
node["numk" ] = numk;
node["numr" ] = numr;
node["cmap" ] = cmap;
node["rmin" ] = rmin;
node["rmax" ] = rmax;
node["rs" ] = rs;
node["L" ] = l;
node["A" ] = A;
node["model" ] = cyl->ID();
node["mmax" ] = mmax;
node["nmax" ] = nmax;
node["numk" ] = numk;
node["numr" ] = numr;
node["cmap" ] = cmap;
node["rmin" ] = rmin;
node["rmax" ] = rmax;
node["rmapping"] = rmap;
node["L" ] = l;
node["A" ] = A;
node["model" ] = cyl->ID();

// Serialize the node
//
Expand Down Expand Up @@ -714,7 +714,7 @@ double SLGridCyl::r_to_xi(double r)
}

if (cmap) {
return (r/rs-1.0)/(r/rs+1.0);
return (r/rmap-1.0)/(r/rmap+1.0);
} else {
return r;
}
Expand All @@ -735,7 +735,7 @@ double SLGridCyl::xi_to_r(double xi)
bomb(ostr.str());
}

return (1.0+xi)/(1.0 - xi) * rs;
return (1.0+xi)/(1.0 - xi) * rmap;
} else {
return xi;
}
Expand All @@ -757,7 +757,7 @@ double SLGridCyl::d_xi_to_r(double xi)
bomb(ostr.str());
}

return 0.5*(1.0-xi)*(1.0-xi)/rs;
return 0.5*(1.0-xi)*(1.0-xi)/rmap;
} else {
return 1.0;
}
Expand Down Expand Up @@ -1267,9 +1267,9 @@ void SLGridCyl::compute_table(struct TableCyl* table, int m, int k)
{

double cons[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
double tol[6] = {1.0e-4*rs,1.0e-5,
1.0e-4*rs,1.0e-5,
1.0e-4*rs,1.0e-5};
double tol[6] = {1.0e-4*rmap,1.0e-5,
1.0e-4*rmap,1.0e-5,
1.0e-4*rmap,1.0e-5};
int VERBOSE=0;
integer NUM, N, M;
logical type[8];
Expand Down Expand Up @@ -1472,8 +1472,8 @@ void SLGridCyl::init_table(void)
d0.resize(numr);

if (cmap) {
xmin = (rmin/rs - 1.0)/(rmin/rs + 1.0);
xmax = (rmax/rs - 1.0)/(rmax/rs + 1.0);
xmin = (rmin/rmap - 1.0)/(rmin/rmap + 1.0);
xmax = (rmax/rmap - 1.0)/(rmax/rmap + 1.0);
dxi = (xmax-xmin)/(numr-1);
} else {
xmin = rmin;
Expand All @@ -1495,9 +1495,9 @@ void SLGridCyl::compute_table_worker(void)
{

double cons[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
double tol[6] = {1.0e-4*rs,1.0e-5,
1.0e-4*rs,1.0e-5,
1.0e-4*rs,1.0e-5};
double tol[6] = {1.0e-4*rmap,1.0e-5,
1.0e-4*rmap,1.0e-5,
1.0e-4*rmap,1.0e-5};
int i, j, VERBOSE=0;
integer NUM;
logical type[8];
Expand Down Expand Up @@ -1876,7 +1876,7 @@ void SLGridSph::bomb(string oops)
SLGridSph::SLGridSph(std::string modelname,
int LMAX, int NMAX, int NUMR,
double RMIN, double RMAX,
bool CACHE, int CMAP, double RS,
bool CACHE, int CMAP, double RMAP,
int DIVERGE, double DFAC,
std::string cachename, bool VERBOSE)
{
Expand All @@ -1892,12 +1892,12 @@ SLGridSph::SLGridSph(std::string modelname,
diverge = DIVERGE;
dfac = DFAC;

initialize(LMAX, NMAX, NUMR, RMIN, RMAX, CACHE, CMAP, RS);
initialize(LMAX, NMAX, NUMR, RMIN, RMAX, CACHE, CMAP, RMAP);
}

SLGridSph::SLGridSph(std::shared_ptr<SphericalModelTable> mod,
int LMAX, int NMAX, int NUMR, double RMIN, double RMAX,
bool CACHE, int CMAP, double RS,
bool CACHE, int CMAP, double RMAP,
std::string cachename, bool VERBOSE)
{
mpi_buf = 0;
Expand All @@ -1909,7 +1909,7 @@ SLGridSph::SLGridSph(std::shared_ptr<SphericalModelTable> mod,
if (cachename.size()) sph_cache_name = cachename;
else sph_cache_name = default_cache;

initialize(LMAX, NMAX, NUMR, RMIN, RMAX, CACHE, CMAP, RS);
initialize(LMAX, NMAX, NUMR, RMIN, RMAX, CACHE, CMAP, RMAP);
}


Expand Down Expand Up @@ -1939,7 +1939,7 @@ SLGridSph::cacheInfo(const std::string& cachefile, bool verbose)

void SLGridSph::initialize(int LMAX, int NMAX, int NUMR,
double RMIN, double RMAX,
bool CACHE, int CMAP, double RS)
bool CACHE, int CMAP, double RMAP)
{
int l;

Expand All @@ -1952,7 +1952,7 @@ void SLGridSph::initialize(int LMAX, int NMAX, int NUMR,

cache = CACHE;
cmap = CMAP;
rs = RS;
rmap = RMAP;

init_table();

Expand Down Expand Up @@ -2258,7 +2258,7 @@ bool SLGridSph::ReadH5Cache(void)
if (not checkInt(cmap, "cmap")) return false;
if (not checkDbl(rmin, "rmin")) return false;
if (not checkDbl(rmax, "rmax")) return false;
if (not checkDbl(rs, "rs")) return false;
if (not checkDbl(rmap, "rmapping")) return false;
if (not checkInt(diverge, "diverge")) return false;
if (not checkDbl(dfac, "dfac")) return false;

Expand Down Expand Up @@ -2349,7 +2349,7 @@ void SLGridSph::WriteH5Cache(void)
file.createAttribute<int> ("cmap", HighFive::DataSpace::From(cmap)).write(cmap);
file.createAttribute<double> ("rmin", HighFive::DataSpace::From(rmin)).write(rmin);
file.createAttribute<double> ("rmax", HighFive::DataSpace::From(rmax)).write(rmax);
file.createAttribute<double> ("rs", HighFive::DataSpace::From(rs)).write(rs);
file.createAttribute<double> ("rmapping", HighFive::DataSpace::From(rmap)).write(rmap);
file.createAttribute<int> ("diverge", HighFive::DataSpace::From(diverge)).write(diverge);
file.createAttribute<double> ("dfac", HighFive::DataSpace::From(dfac)).write(dfac);

Expand Down Expand Up @@ -2391,7 +2391,7 @@ double SLGridSph::r_to_xi(double r)

if (cmap==1) {
if (r<0.0) bomb("radius < 0!");
ret = (r/rs-1.0)/(r/rs+1.0);
ret = (r/rmap-1.0)/(r/rmap+1.0);
} else if (cmap==2) {
if (r<=0.0) bomb("radius <= 0!");
ret = log(r);
Expand All @@ -2410,7 +2410,7 @@ double SLGridSph::xi_to_r(double xi)
if (xi<-1.0) bomb("xi < -1!");
if (xi>=1.0) bomb("xi >= 1!");

ret =(1.0+xi)/(1.0 - xi) * rs;
ret =(1.0+xi)/(1.0 - xi) * rmap;
} else if (cmap==2) {
ret = exp(xi);
} else {
Expand All @@ -2430,7 +2430,7 @@ double SLGridSph::d_xi_to_r(double xi)
if (xi<-1.0) bomb("xi < -1!");
if (xi>=1.0) bomb("xi >= 1!");

ret = 0.5*(1.0-xi)*(1.0-xi)/rs;
ret = 0.5*(1.0-xi)*(1.0-xi)/rmap;
} else if (cmap==2) {
ret = exp(-xi);
} else {
Expand Down Expand Up @@ -2781,9 +2781,9 @@ void SLGridSph::compute_table(struct TableSph* table, int l)
{

double cons[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
double tol [6] = {1.0e-4*rs, 1.0e-6,
1.0e-4*rs, 1.0e-6,
1.0e-4*rs, 1.0e-6};
double tol [6] = {1.0e-4*rmap, 1.0e-6,
1.0e-4*rmap, 1.0e-6,
1.0e-4*rmap, 1.0e-6};
int VERBOSE=0;
integer NUM, N;
logical type[8] = {0, 0, 1, 0, 0, 0, 1, 0};
Expand Down Expand Up @@ -2992,8 +2992,8 @@ void SLGridSph::init_table(void)
d0.resize(numr);

if (cmap==1) {
xmin = (rmin/rs - 1.0)/(rmin/rs + 1.0);
xmax = (rmax/rs - 1.0)/(rmax/rs + 1.0);
xmin = (rmin/rmap - 1.0)/(rmin/rmap + 1.0);
xmax = (rmax/rmap - 1.0)/(rmax/rmap + 1.0);
}
else if (cmap==2) {
xmin = log(rmin);
Expand All @@ -3018,9 +3018,9 @@ void SLGridSph::compute_table_worker(void)
{

double cons[8] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
double tol [6] = {1.0e-1*rs, 1.0e-6,
1.0e-1*rs, 1.0e-6,
1.0e-1*rs, 1.0e-6};
double tol [6] = {1.0e-1*rmap, 1.0e-6,
1.0e-1*rmap, 1.0e-6,
1.0e-1*rmap, 1.0e-6};

int VERBOSE=0;
integer NUM;
Expand Down Expand Up @@ -3360,16 +3360,16 @@ YAML::Node SLGridSph::getHeader(const std::string& cachefile)
return v;
};

node["model"] = getStr("model");
node["lmax"] = getInt("lmax");
node["nmax"] = getInt("nmax");
node["numr"] = getInt("numr");
node["cmap"] = getInt("cmap");
node["rmin"] = getDbl("rmin");
node["rmax"] = getDbl("rmax");
node["rs" ] = getDbl("rs");
node["diverge"] = getInt("diverge");
node["dfac"] = getDbl("dfac");
node["model"] = getStr("model");
node["lmax"] = getInt("lmax");
node["nmax"] = getInt("nmax");
node["numr"] = getInt("numr");
node["cmap"] = getInt("cmap");
node["rmin"] = getDbl("rmin");
node["rmax"] = getDbl("rmax");
node["rmapping"] = getDbl("rmapping");
node["diverge"] = getInt("diverge");
node["dfac"] = getDbl("dfac");
}
catch (YAML::Exception& error) {
std::ostringstream sout;
Expand Down
Loading

0 comments on commit 862c60c

Please sign in to comment.