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

Update to Quadrature #296

Merged
merged 53 commits into from
Apr 14, 2016
Merged

Conversation

geogunow
Copy link
Contributor

In this PR I update the quadrature used in OpenMOC to better generalize. In particular the following major changes were made:

  • The PolarQuad class has been changed to Quadrature to imply generalizations outside of just the polar angle
  • All weights have been moved to the Quadrature class. This includes azimuthal weights and azimuthal spacings.
  • The Quadrature class is no longer owned by instances of the Solver class - but rather instances of the TrackGenerator class
  • Total weights are precomputed inside the Quadrature class
  • The TrackGenerator has been changed so that all angles in [0, 2*pi] are stored. This improves the readability so that the definition of _num_azim is consistent. Although this does mean storing duplicate data, there should be no performance hit.

This PR is the first step to syncing OpenMOC with ClosedMOC's 3D-MOC solver.

@geogunow geogunow assigned geogunow and wbinventor and unassigned geogunow Mar 27, 2016
@wbinventor
Copy link
Member

Cool stuff @geogunow! I'll look this over later today. The test suite appears to have failed, any idea why? Also, would you mind putting in one or more new tests of the various Quadrature options? I don't think we have any tests explicitly devoted to testing that part of our API.

@wbinventor
Copy link
Member

Also, two other things:

  • update @samuelshaner's docs on the old PolarQuad to reflect these changes
  • run doxygen and the "doxy2swig.py" script to update our docstrings in "docstring.i"

@geogunow
Copy link
Contributor Author

geogunow commented Apr 6, 2016

@wbinventor @samuelshaner this PR is ready for review

@wbinventor
Copy link
Member

Great, I'll review this tonight.

@@ -748,6 +748,11 @@ void CPUSolver::tallyScalarFlux(segment* curr_segment, int azim_index,
FP_PRECISION* sigma_t = curr_segment->_material->getSigmaT();
FP_PRECISION delta_psi, exponential;

/* Extract weights for all polar angles */
FP_PRECISION weights[_num_polar];
Copy link
Member

Choose a reason for hiding this comment

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

So we are using allocating weights on the stack each and every time CPUSolver::tallyScalarFlux(...) is called? Might it not be better to call _quad->getWeight(...) directly within the nested loop over energies and groups? If you inline this Quadrature::getWeight() I doubt that this would lead to a performance hit, and would reduce the code in this method by a few lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I inline the Quadrature::getWeight(...) function I would probably need to get rid of the error checking conditionals. Do you think I should do that?

@samuelshaner
Copy link
Contributor

The documentation for the azim spacing in docs/source/usersguide/input.rst should be updated.

@samuelshaner
Copy link
Contributor

It looks like the inputs in the profile directory have not been updated. Could you update those?

exponential = _exp_evaluator->computeExponential(sigma_t[e] * length, p);
delta_psi = (track_flux(p,e)-_reduced_sources(fsr_id,e)) * exponential;
fsr_flux[e] += delta_psi * _polar_weights(azim_index,p);
fsr_flux[e] += delta_psi * _quadrature->getWeightInline(azim_index, p);
Copy link
Contributor

Choose a reason for hiding this comment

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

I like how clean this is and that it avoids making a weights pointer attribute in the Solver class!

@samuelshaner
Copy link
Contributor

The tests/test_plot_quadrature/true-0.png looks like it has 4 quadrature points instead of 3.

* @endcode
*
* @param weights The polar weights
* @param num_azim_times_polar the total number of angles (azimuthal x polar)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you note that this is just the total number of angles in one octant?

@geogunow
Copy link
Contributor Author

@samuelshaner I don't think I ever failed the tests/test_plot_quadrature test. So it must have been that way before.

@samuelshaner
Copy link
Contributor

You updated the results for tests/test_plot_quadrature in this PR and if you look at the files that were changed in this PR it should be clear that the plot quadrature test results have 4 points, instead of the desired 3 points. Do you see the updated fill in the files changed for this PR?

@geogunow
Copy link
Contributor Author

@samuelshaner you're right. It did change and the new plot looks incorrect. It is corrected now. However, I was right too - I never failed the tests/test_plot_quadrature test. It seems the test is broken in that it delivers a false positive test result. Maybe @wbinventor knows how to fix this? We might have the same situation for all plotting tests.

@wbinventor
Copy link
Member

@geogunow our plotting tests all use a thresholded comparison of a 3D RGB histogram of the pixels in the reference and generated images (link). This (or something similar) is necessary since the size of the matplotlib images generated on different machines is inconsistent. The threshold used is completely arbitrary right now, and is probably too high to catch just the few pixel difference between the quadrature plots with 3 vs. 4 points. It should be large enough, however, to catch blatant discrepancies in plots, but it is certainly not good enough to catch everything. You can always tighten the tolerance for the quadrature test if you want to ensure this doesn't happen again.

@samuelshaner
Copy link
Contributor

I just ran the test_plot_quadrature locally with the fourth point removed and the distance metric used to judge the difference between two plots only changed slightly from 0.00301 to 0.00306 so I'm not sure tightening the tolerance would work for this case. I'm not really sure of an easy way to compare the plot files and get a clear pass/fail for the test. Perhaps just correct the plot and post an issue about that?

@wbinventor
Copy link
Member

I don't think the distance metric for our plotting tests needs to be fixed in this PR. But certainly making note of it as an issue as @samuelshaner proposes sounds like reasonable.

@geogunow
Copy link
Contributor Author

@wbinventor @samuelshaner The problem has been fixed for this PR. I just posted an issue about the test suite checking .png images.

@wbinventor
Copy link
Member

This looks up to par and ready to merge to me.

@samuelshaner samuelshaner merged commit 4f7176a into mit-crpg:develop Apr 14, 2016
@samuelshaner
Copy link
Contributor

Thanks again for syncing up the quadrature @geogunow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants