mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Adding similar test for Muir distribution
This commit is contained in:
parent
2f22474aea
commit
2c74dcf336
2 changed files with 16 additions and 2 deletions
|
|
@ -764,11 +764,14 @@ class Muir(Univariate):
|
|||
cv.check_greater_than('Muir kt', kt, 0.0)
|
||||
self._kt = kt
|
||||
|
||||
@property
|
||||
def std_dev(self):
|
||||
return np.sqrt(4.*self.e0*self.kt/self.m_rat)
|
||||
|
||||
def sample(self, n_samples=1, seed=None):
|
||||
# https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lareport/LA-05411-MS
|
||||
np.random.seed(seed)
|
||||
sigma = np.sqrt(4.*self.e0*self.kt/self.m_rat)
|
||||
return np.random.normal(self.e0, sigma, n_samples)
|
||||
return np.random.normal(self.e0, self.std_dev, n_samples)
|
||||
|
||||
def to_xml_element(self, element_name):
|
||||
"""Return XML representation of the Watt distribution
|
||||
|
|
|
|||
|
|
@ -292,3 +292,14 @@ def test_muir():
|
|||
assert d.m_rat == pytest.approx(mass)
|
||||
assert d.kt == pytest.approx(temp)
|
||||
assert len(d) == 3
|
||||
|
||||
# sample normal distribution
|
||||
n_samples = 10000
|
||||
samples = d.sample(n_samples, seed=100)
|
||||
samples = np.abs(samples - mean)
|
||||
within_1_sigma = np.count_nonzero(samples < d.std_dev)
|
||||
assert within_1_sigma / n_samples >= 0.68
|
||||
within_2_sigma = np.count_nonzero(samples < 2*d.std_dev)
|
||||
assert within_2_sigma / n_samples >= 0.95
|
||||
within_3_sigma = np.count_nonzero(samples < 3*d.std_dev)
|
||||
assert within_3_sigma / n_samples >= 0.99
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue