mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Merge branch 'function' into plot_mat
This commit is contained in:
commit
9eb73d8bfe
2 changed files with 27 additions and 10 deletions
|
|
@ -410,7 +410,9 @@ class Combination(EqualityMixin):
|
|||
Functions which are to be added together
|
||||
operations : Iterable of numpy.ufunc
|
||||
Operations to perform between functions; note that the standard order
|
||||
of operations (i.e., PEMDAS) will not be followed.
|
||||
of operations will not be followed, but can be simulated by
|
||||
combinations of Combination objects. The operations parameter must have
|
||||
a length one less than the number of functions.
|
||||
|
||||
|
||||
Attributes
|
||||
|
|
@ -427,9 +429,9 @@ class Combination(EqualityMixin):
|
|||
self.operations = operations
|
||||
|
||||
def __call__(self, x):
|
||||
ans = np.zeros_like(x)
|
||||
ans = self.functions[0](x)
|
||||
for i, operation in enumerate(self.operations):
|
||||
ans = operation(ans, self.functions[i](x))
|
||||
ans = operation(ans, self.functions[i + 1](x))
|
||||
return ans
|
||||
|
||||
@property
|
||||
|
|
@ -448,7 +450,7 @@ class Combination(EqualityMixin):
|
|||
@operations.setter
|
||||
def operations(self, operations):
|
||||
cv.check_type('operations', operations, Iterable, np.ufunc)
|
||||
length = len(self.functions)
|
||||
length = len(self.functions) - 1
|
||||
cv.check_length('operations', operations, length, length_max=length)
|
||||
self._operations = operations
|
||||
|
||||
|
|
@ -488,7 +490,7 @@ class Sum(EqualityMixin):
|
|||
self._functions = functions
|
||||
|
||||
|
||||
class Piecewise(EqualityMixin):
|
||||
class Regions1D(EqualityMixin):
|
||||
"""Piecewise composition of multiple functions.
|
||||
|
||||
This class allows you to create a callable object which is composed
|
||||
|
|
@ -499,9 +501,9 @@ class Piecewise(EqualityMixin):
|
|||
functions : Iterable of Callable
|
||||
Functions which are to be combined in a piecewise fashion
|
||||
breakpoints : Iterable of float
|
||||
The breakpoints between each function. The functions
|
||||
in the functions attribute must be provided in order of
|
||||
increasing intervals.
|
||||
The values of the dependent variable that define the domain of
|
||||
each function. The *i*th and *(i+1)*th values are the limits of the
|
||||
domain of the *i*th function. Values must be monotonically increasing.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
|
|
|
|||
|
|
@ -22,9 +22,19 @@ class DataLibrary(EqualityMixin):
|
|||
def __init__(self):
|
||||
self.libraries = []
|
||||
|
||||
def __getitem__(self, material):
|
||||
def get_by_materials(self, value):
|
||||
"""Access a library entry by passing a value of the 'materials'
|
||||
attribute of the library entry.
|
||||
|
||||
Returns
|
||||
-------
|
||||
library : dict
|
||||
Dictionary summarizing cross section data from a single file;
|
||||
the dictionary has keys 'path', 'type', and 'materials'.
|
||||
|
||||
"""
|
||||
for library in self.libraries:
|
||||
if material in library['materials']:
|
||||
if value in library['materials']:
|
||||
return library
|
||||
return None
|
||||
|
||||
|
|
@ -94,6 +104,11 @@ class DataLibrary(EqualityMixin):
|
|||
path : str
|
||||
Path to XML file to read.
|
||||
|
||||
Returns
|
||||
-------
|
||||
data : openmc.data.DataLibrary
|
||||
openmc.data.DataLibrary object initialized from the provided XML
|
||||
|
||||
"""
|
||||
|
||||
data = cls()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue