-
Notifications
You must be signed in to change notification settings - Fork 503
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
Add PointCloud spatial distribution #3161
Conversation
1d86130
to
733337d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this snappy PR @gonuke! A useful distribution that we haven't been able to support before!
openmc/stats/multivariate.py
Outdated
psoitions: numpy.ndarray (3xN) | ||
The points in space to be sampled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
psoitions: numpy.ndarray (3xN) | |
The points in space to be sampled | |
positions: numpy.ndarray | |
The points in space to be sampled with shape (N, 3) |
openmc/stats/multivariate.py
Outdated
return cls(positions, strengths) | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openmc/stats/multivariate.py
Outdated
""" | ||
coord = {} | ||
|
||
for axis in ('x','y','z'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking the XML format of the data as a flat list of points (X1, Y1, Z1, X2, Y2, Z2, ...) would make the import export code simpler, and it isn't more or less readable in an XML format (for my brain anyway).
openmc/stats/multivariate.py
Outdated
|
||
for idx, axis in enumerate(('x','y','z')): | ||
subelement = ET.SubElement(element, axis) | ||
subelement.text = ' '.join(str(e) for e in self.positions[idx,:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subelement.text = ' '.join(str(e) for e in self.positions[idx,:]) | |
subelement.text = ' '.join(str(e) for e in self.positions[..., idx]) |
I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gonuke Thanks for this PR! Out of curiosity, what is the intended application of this feature?
We have a user who has an existing approximation of a volumetric source by a high density list of isotropic point sources. They want to use that source for comparison to other simulations. |
While it may have been elegant to add an Thus, I've relied on just reading a list of doubles and packing them into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small line suggestions here @gonuke. I went ahead and added test that samples the external source distribution on the C++ side and factored out a function in the XML interface for parsing a set of Position
s from a flat array of values on a node. Hope that's okay!
Thanks again for this addition.
openmc/stats/multivariate.py
Outdated
if given_positions is None: | ||
raise ValueError('No positions were provided') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd opt to let the check_iterable_type
throw an error here instead.
…rance and number of particles.
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed a couple of small changes, but this looks good to me! @paulromano, you mentioned you'd like to have a look at this as well, so I'll give you a little time to review.
Pinging @paulromano to see if this can move forward? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gonuke! I did a bit of refactoring and simplification. I'm good to merge but before I do, let me know if you object to any of my changes.
All looks good to me - thanks @paulromano |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @gonuke!
Description
Allows users to define a list of points in space, each with a different relative intensity, to be sampled discretely. This is a valid
SpatialDistribution
and can be used anywhere that aSpatialDistribution
is valid.Fixes #3159
Checklist