Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) A couple of fixes for un-verified options. #33

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions src/CBrockDisk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ CBrockDisk::valid_keys = {
"self_consistent",
"playback",
"coefCompute",
"coefMaster"
"coefMaster",
"NO_M0",
"NO_M1",
"EVEN_M",
"M0_only"
"M0_ONLY"
};

CBrockDisk::CBrockDisk(Component* c0, const YAML::Node& conf, MixtureBasis* m) : AxisymmetricBasis(c0, conf)
Expand Down Expand Up @@ -67,7 +67,6 @@ CBrockDisk::CBrockDisk(Component* c0, const YAML::Node& conf, MixtureBasis* m) :

// Allocate and compute normalization matrix

normM.resize(Lmax+1, nmax);
dend .resize(Lmax+1, nmax);
work .resize(Lmax+2, nmax);

Expand All @@ -93,8 +92,7 @@ CBrockDisk::CBrockDisk(Component* c0, const YAML::Node& conf, MixtureBasis* m) :

for (int l=0; l<=Lmax; l++) {
for (int n=0; n<nmax; n++) {
normM (l, n) = norm(n, l);
sqnorm(l, n) = sqrt(normM(l, n));
sqnorm(l, n) = sqrt(norm(n, l));
}
}

Expand Down Expand Up @@ -360,12 +358,12 @@ void * CBrockDisk::determine_coefficients_thread(void * arg)
// l loop

for (int n=0; n<nmax; n++) {
expcoef0[id](0, n) += potd[id](0, n)*mass/normM(0, n);
expcoef0[id](0, n) += potd[id](0, n)*mass/sqnorm(0, n);
if (pcavar && compute) {
pthread_mutex_lock(&cc_lock);
for (int nn=n; nn<nmax; nn++)
cc1[0](n, nn) += potd[id](0, n)*potd[id](0, nn)*mass/
(normM(0, n)*normM(0, nn));
(sqnorm(0, n)*sqnorm(0, nn));
pthread_mutex_unlock(&cc_lock);
}
}
Expand All @@ -376,15 +374,15 @@ void * CBrockDisk::determine_coefficients_thread(void * arg)
fac2 = sinm[id][l] * M_SQRT2;

for (int n=0; n<nmax; n++) {
expcoef0[id](2*l - 1, n) += potd[id](l, n)*fac1*mass/normM(l, n);
expcoef0[id](2*l , n) += potd[id](l, n)*fac2*mass/normM(l, n);
expcoef0[id](2*l - 1, n) += potd[id](l, n)*fac1*mass/sqnorm(l, n);
expcoef0[id](2*l , n) += potd[id](l, n)*fac2*mass/sqnorm(l, n);
if (pcavar && compute) {
pthread_mutex_lock(&cc_lock);
for (int nn=n; nn<nmax; nn++) {
cc1[2*l - 1](n, nn) += potd[id](l, n)*potd[id](l, nn)*fac1*fac1*
mass/(normM(l, n)*normM(l, nn));
mass/(sqnorm(l, n)*sqnorm(l, nn));
cc1[2*l ](n, nn) += potd[id](l, n)*potd[id](l, nn)*fac2*fac2*
mass/(normM(l, n)*normM(l, nn));
mass/(sqnorm(l, n)*sqnorm(l, nn));
}
pthread_mutex_unlock(&cc_lock);
}
Expand Down Expand Up @@ -461,8 +459,8 @@ void * CBrockDisk::determine_acceleration_and_potential_thread(void * arg)
if (not NO_M0) {
get_pot_coefs_safe(0, expcoef->row(0), p, dp, potd[id], dpot[id]);

double potl = p;
double potr = dp;
potl = p;
potr = dp;
}

// Asymmetric terms?
Expand Down Expand Up @@ -622,8 +620,8 @@ void CBrockDisk::get_pot_coefs(int l, const Eigen::VectorXd& coef,
pp = dpp = 0.0;

for (int i=0; i<nmax; i++) {
pp += potd[0](l, i) * coef[i];
dpp += dpot[0](l, i) * coef[i];
pp += potd[0](l, i) * coef[i] / sqnorm(l,i);
dpp += dpot[0](l, i) * coef[i] / sqnorm(l,i);
}

p = -pp;
Expand All @@ -640,8 +638,8 @@ void CBrockDisk::get_pot_coefs_safe
pp = dpp = 0.0;

for (int i=0; i<nmax; i++) {
pp += potd1(l, i) * coef[i];
dpp += dpot1(l, i) * coef[i];
pp += potd1(l, i) * coef[i] / sqnorm(l,i);
dpp += dpot1(l, i) * coef[i] / sqnorm(l,i);
}

p = -pp;
Expand All @@ -655,7 +653,7 @@ void CBrockDisk::get_dens_coefs
double pp = 0.0;

for (int i=0; i<nmax; i++)
pp += dend(l, i) * coef[i];
pp += dend(l, i) * coef[i] / sqnorm(l,i);

p = pp;
}
Expand Down Expand Up @@ -900,11 +898,10 @@ void CBrockDisk::dump_coefs_h5(const std::string& file)
cylCoefs.add(cur);
cylCoefs.ExtendH5Coefs(file);
} else {

// Copy the YAML config. We only need this on the first call.
std::ostringstream sout; sout << conf;
size_t hsize = sout.str().size() + 1;
cur->buf = std::shared_ptr<char[]>(new char [hsize]);
sout.str().copy(cur->buf.get(), hsize); // Copy to CoefStruct buffer
cur->buf = sout.str(); // Copy to CoefStruct buffer

// Add the name attribute. We only need this on the first call.
cylCoefs.setName(component->name);
Expand Down
Loading