Rename sample_source -> sample.
Use std::string as type of argument to openmc_create_source.
Use reinterpret_cast when accessing dlsym.
Also moves check for dlerror to be before the attempt to create the
source (avoids null reference if fails) and capture error message
before dlclose, so that the error message is still available.
Formatting updates and some refactoring for examples and tests.
In the original example the rings were constructed as 'inner_ring', 'outer_ring' and 'middle_ring'. This naming convention only really works for 3-ringed lattices.
The example has been slightly modified to contain a fourth ring. The lattice is constructed as:
`lattice.universes = [outer_ring, ring_1, ring_2, inner_ring]`
Which is much more translatable to lattices of any size.
This commit also incorporates feedback on the criticality search tutorial changes.
There is a loop in candu that isn't incredibly readable, although I'm not quite sure how/if it can be improved:
`for i, (r, n, a) in enumerate(zip(ring_radii, num_pins, angles)):
for j in range(n):`
Also de-abbreviated some of triso, e.g:
`trisos = [openmc.model.TRISO(outer_radius, triso_univ, c) for c in centers]`
Became:
`trisos = [openmc.model.TRISO(outer_radius, triso_univ, center) for center in centers]`
Let me know if you don't like it and it'll be changed.
Also got rid of warnings by removing manually set ID's for cells. The ID for zirconium, for example was set to 2 which conflicted with an already defined material with an automatically generated ID of 2. Same for some others.
There is a part of the notebook that talks about ID's so I left that one alone. After the central point about ID's is made there's little point in keeping them in for the cells (unless you like looking at pink warning messages).
Did a bit more for this one:
a) Got rid of warning messages that came from setting the root universe's ID to 0.
b) Moved source building to above the settings definition (rather than in the middle of it.)
c) Removed `bracketed_method='bisect'` as this is the default argument.
Perhaps there should be a default tolerance as well? And is there a good reason to default `print_iterations` to false?
Custom sources are now created only through the new class-based method,
which supports parameterization.
New method also slightly adjusted to create the source as managed by a
unique_ptr.
Examples and tests updated to align with this approach.
Documentation updated.
Updates to examples and tests to refer to parameterized sources rather
than serialized sources.
Small update to source.h to remove reference to serialized parameters.
In the existing custom_source implementation, the source will only be
created once. This is much more efficient than the custom serialized
source, where each sampling will create a new instance of the class.
As there could be many samples, this introduces an overhead,
particularly if the operations to instantiate the class are not trivial.
This implementation defines an abstract class, which is then used by the
custom classes to allow the custom serialized class to be created based
on the plugin, sampled from, and then destroyed.
Update documentation and test to reflect this.
Changes the implementation of the serialization to be on an attribute of
the source XML element within settings.xml. This removes the need for a
new file containing the serialization.
Parameters are provided as a key-value string, separated by a comma and
a space, although the implementation can change this is required.
Change example values to align with existing custom_source to make
comparisons easier.
Update documentation to be consistent.
The previous implementation had each sampling run reading from the
serialized file. This introduced a large I/O overhead and the
performance was much slower than the equivalent run with the
unserialized source.
Generates a source ring in a similar manner to the existing
custom_source example.
Allows the radius and energy to be defined via a serialized
representation of the source.
Builds using CMake.
File is largely based on the existing custom_source example.
Uses the serialization attribute on the source to
point to an XML file
containing the serialized representation of the source.
Also builds the serialized_source.xml file with some default values.
Uses a new name for the library containing the serializable source.