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

Fix bug for distributed temperatures without distributed materials #1178

Merged
merged 1 commit into from
Mar 5, 2019
Merged
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
30 changes: 20 additions & 10 deletions src/geometry_aux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,26 +167,36 @@ get_temperatures(std::vector<std::vector<double>>& nuc_temps,
int i_material = cell->material_[j];
if (i_material == MATERIAL_VOID) continue;

// Get temperature of cell (rounding to nearest integer)
double sqrtkT = cell->sqrtkT_.size() == 1 ?
cell->sqrtkT_[j] : cell->sqrtkT_[0];
double temperature = sqrtkT*sqrtkT / K_BOLTZMANN;
// Get temperature(s) of cell (rounding to nearest integer)
std::vector<double> cell_temps;
if (cell->sqrtkT_.size() == 1) {
double sqrtkT = cell->sqrtkT_[0];
cell_temps.push_back(sqrtkT*sqrtkT / K_BOLTZMANN);
} else if (cell->sqrtkT_.size() == cell->material_.size()) {
double sqrtkT = cell->sqrtkT_[j];
cell_temps.push_back(sqrtkT*sqrtkT / K_BOLTZMANN);
} else {
for (double sqrtkT : cell->sqrtkT_)
cell_temps.push_back(sqrtkT*sqrtkT / K_BOLTZMANN);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like determining cell_temps ought to be done as a separate loop above the loop over cell->material_.size() (line 165). Effectively in each case, we're iteratating over cell->sqrtkT_.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So populate the cell_temps array before the cell->material_.size() loop? I think that way we could end up with loading more temperature data than needed. If every cell instance has a different material and different temperature, then each material only needs to load one temperature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, you're right. I felt like I might be missing something!


const auto& mat {model::materials[i_material]};
for (const auto& i_nuc : mat->nuclide_) {
// Add temperature if it hasn't already been added
if (!contains(nuc_temps[i_nuc], temperature)) {
nuc_temps[i_nuc].push_back(temperature);
for (double temperature : cell_temps) {
// Add temperature if it hasn't already been added
if (!contains(nuc_temps[i_nuc], temperature))
nuc_temps[i_nuc].push_back(temperature);
}
}

for (const auto& table : mat->thermal_tables_) {
// Get index in data::thermal_scatt array
int i_sab = table.index_table;

// Add temperature if it hasn't already been added
if (!contains(thermal_temps[i_sab], temperature)) {
thermal_temps[i_sab].push_back(temperature);
for (double temperature : cell_temps) {
// Add temperature if it hasn't already been added
if (!contains(thermal_temps[i_sab], temperature))
thermal_temps[i_sab].push_back(temperature);
}
}
}
Expand Down