Apply clang-format on entire source

This commit is contained in:
Paul Romano 2021-08-11 11:41:49 -05:00
parent 4c17061a1d
commit 1bc2bd8460
181 changed files with 7372 additions and 6952 deletions

View file

@ -29,7 +29,7 @@ DiscretePhoton::DiscretePhoton(hid_t group)
double DiscretePhoton::sample(double E, uint64_t* seed) const
{
if (primary_flag_ == 2) {
return energy_ + A_/(A_+ 1)*E;
return energy_ + A_ / (A_ + 1) * E;
} else {
return energy_;
}
@ -47,7 +47,7 @@ LevelInelastic::LevelInelastic(hid_t group)
double LevelInelastic::sample(double E, uint64_t* seed) const
{
return mass_ratio_*(E - threshold_);
return mass_ratio_ * (E - threshold_);
}
//==============================================================================
@ -94,7 +94,7 @@ ContinuousTabular::ContinuousTabular(hid_t group)
int j = offsets[i];
int n;
if (i < n_energy - 1) {
n = offsets[i+1] - j;
n = offsets[i + 1] - j;
} else {
n = eout.shape()[1] - j;
}
@ -105,35 +105,35 @@ ContinuousTabular::ContinuousTabular(hid_t group)
d.n_discrete = n_discrete[i];
// Copy data
d.e_out = xt::view(eout, 0, xt::range(j, j+n));
d.p = xt::view(eout, 1, xt::range(j, j+n));
d.e_out = xt::view(eout, 0, xt::range(j, j + n));
d.p = xt::view(eout, 1, xt::range(j, j + n));
// To get answers that match ACE data, for now we still use the tabulated
// CDF values that were passed through to the HDF5 library. At a later
// time, we can remove the CDF values from the HDF5 library and
// reconstruct them using the PDF
if (true) {
d.c = xt::view(eout, 2, xt::range(j, j+n));
d.c = xt::view(eout, 2, xt::range(j, j + n));
} else {
// Calculate cumulative distribution function -- discrete portion
for (int k = 0; k < d.n_discrete; ++k) {
if (k == 0) {
d.c[k] = d.p[k];
} else {
d.c[k] = d.c[k-1] + d.p[k];
d.c[k] = d.c[k - 1] + d.p[k];
}
}
// Continuous portion
for (int k = d.n_discrete; k < n; ++k) {
if (k == d.n_discrete) {
d.c[k] = d.c[k-1] + d.p[k];
d.c[k] = d.c[k - 1] + d.p[k];
} else {
if (d.interpolation == Interpolation::histogram) {
d.c[k] = d.c[k-1] + d.p[k-1]*(d.e_out[k] - d.e_out[k-1]);
d.c[k] = d.c[k - 1] + d.p[k - 1] * (d.e_out[k] - d.e_out[k - 1]);
} else if (d.interpolation == Interpolation::lin_lin) {
d.c[k] = d.c[k-1] + 0.5*(d.p[k-1] + d.p[k]) *
(d.e_out[k] - d.e_out[k-1]);
d.c[k] = d.c[k - 1] + 0.5 * (d.p[k - 1] + d.p[k]) *
(d.e_out[k] - d.e_out[k - 1]);
}
}
}
@ -170,7 +170,7 @@ double ContinuousTabular::sample(double E, uint64_t* seed) const
r = 1.0;
} else {
i = lower_bound_index(energy_.begin(), energy_.end(), E);
r = (E - energy_[i]) / (energy_[i+1] - energy_[i]);
r = (E - energy_[i]) / (energy_[i + 1] - energy_[i]);
}
// Sample between the ith and [i+1]th bin
@ -187,10 +187,10 @@ double ContinuousTabular::sample(double E, uint64_t* seed) const
double E_i_1 = distribution_[i].e_out[n_discrete];
double E_i_K = distribution_[i].e_out[n_energy_out - 1];
n_energy_out = distribution_[i+1].e_out.size();
n_discrete = distribution_[i+1].n_discrete;
double E_i1_1 = distribution_[i+1].e_out[n_discrete];
double E_i1_K = distribution_[i+1].e_out[n_energy_out - 1];
n_energy_out = distribution_[i + 1].e_out.size();
n_discrete = distribution_[i + 1].n_discrete;
double E_i1_1 = distribution_[i + 1].e_out[n_discrete];
double E_i1_K = distribution_[i + 1].e_out[n_energy_out - 1];
double E_1 = E_i_1 + r * (E_i1_1 - E_i_1);
double E_K = E_i_K + r * (E_i1_K - E_i_K);
@ -217,8 +217,9 @@ double ContinuousTabular::sample(double E, uint64_t* seed) const
double c_k1;
for (int j = n_discrete; j < end; ++j) {
k = j;
c_k1 = distribution_[l].c[k+1];
if (r1 < c_k1) break;
c_k1 = distribution_[l].c[k + 1];
if (r1 < c_k1)
break;
k = j + 1;
c_k = c_k1;
}
@ -229,39 +230,41 @@ double ContinuousTabular::sample(double E, uint64_t* seed) const
if (distribution_[l].interpolation == Interpolation::histogram) {
// Histogram interpolation
if (p_l_k > 0.0 && k >= n_discrete) {
E_out = E_l_k + (r1 - c_k)/p_l_k;
E_out = E_l_k + (r1 - c_k) / p_l_k;
}
} else if (distribution_[l].interpolation == Interpolation::lin_lin) {
// Linear-linear interpolation
double E_l_k1 = distribution_[l].e_out[k+1];
double p_l_k1 = distribution_[l].p[k+1];
double E_l_k1 = distribution_[l].e_out[k + 1];
double p_l_k1 = distribution_[l].p[k + 1];
if (E_l_k != E_l_k1) {
double frac = (p_l_k1 - p_l_k)/(E_l_k1 - E_l_k);
double frac = (p_l_k1 - p_l_k) / (E_l_k1 - E_l_k);
if (frac == 0.0) {
E_out = E_l_k + (r1 - c_k)/p_l_k;
E_out = E_l_k + (r1 - c_k) / p_l_k;
} else {
E_out = E_l_k + (std::sqrt(std::max(0.0, p_l_k*p_l_k +
2.0*frac*(r1 - c_k))) - p_l_k)/frac;
E_out =
E_l_k +
(std::sqrt(std::max(0.0, p_l_k * p_l_k + 2.0 * frac * (r1 - c_k))) -
p_l_k) /
frac;
}
}
} else {
throw std::runtime_error{"Unexpected interpolation for continuous energy "
"distribution."};
throw std::runtime_error {"Unexpected interpolation for continuous energy "
"distribution."};
}
// Now interpolate between incident energy bins i and i + 1
if (!histogram_interp && n_energy_out > 1 && k >= n_discrete) {
if (l == i) {
return E_1 + (E_out - E_i_1)*(E_K - E_1)/(E_i_K - E_i_1);
return E_1 + (E_out - E_i_1) * (E_K - E_1) / (E_i_K - E_i_1);
} else {
return E_1 + (E_out - E_i1_1)*(E_K - E_1)/(E_i1_K - E_i1_1);
return E_1 + (E_out - E_i1_1) * (E_K - E_1) / (E_i1_K - E_i1_1);
}
} else {
return E_out;
}
}
//==============================================================================
@ -272,7 +275,7 @@ MaxwellEnergy::MaxwellEnergy(hid_t group)
{
read_attribute(group, "u", u_);
hid_t dset = open_dataset(group, "theta");
theta_ = Tabulated1D{dset};
theta_ = Tabulated1D {dset};
close_dataset(dset);
}
@ -286,7 +289,8 @@ double MaxwellEnergy::sample(double E, uint64_t* seed) const
double E_out = maxwell_spectrum(theta, seed);
// Accept energy based on restriction energy
if (E_out <= E - u_) return E_out;
if (E_out <= E - u_)
return E_out;
}
}
@ -298,7 +302,7 @@ Evaporation::Evaporation(hid_t group)
{
read_attribute(group, "u", u_);
hid_t dset = open_dataset(group, "theta");
theta_ = Tabulated1D{dset};
theta_ = Tabulated1D {dset};
close_dataset(dset);
}
@ -307,15 +311,16 @@ double Evaporation::sample(double E, uint64_t* seed) const
// Get temperature corresponding to incoming energy
double theta = theta_(E);
double y = (E - u_)/theta;
double y = (E - u_) / theta;
double v = 1.0 - std::exp(-y);
// Sample outgoing energy based on evaporation spectrum probability
// density function
double x;
while (true) {
x = -std::log((1.0 - v*prn(seed))*(1.0 - v*prn(seed)));
if (x <= y) break;
x = -std::log((1.0 - v * prn(seed)) * (1.0 - v * prn(seed)));
if (x <= y)
break;
}
return x * theta;
@ -332,10 +337,10 @@ WattEnergy::WattEnergy(hid_t group)
// Read tabulated functions
hid_t dset = open_dataset(group, "a");
a_ = Tabulated1D{dset};
a_ = Tabulated1D {dset};
close_dataset(dset);
dset = open_dataset(group, "b");
b_ = Tabulated1D{dset};
b_ = Tabulated1D {dset};
close_dataset(dset);
}
@ -350,8 +355,9 @@ double WattEnergy::sample(double E, uint64_t* seed) const
double E_out = watt_spectrum(a, b, seed);
// Accept energy based on restriction energy
if (E_out <= E - u_) return E_out;
if (E_out <= E - u_)
return E_out;
}
}
}
} // namespace openmc