mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Fix bug in openmc_material_add_nuclide
This commit is contained in:
parent
75b97b0b34
commit
433e6a4dfd
2 changed files with 9 additions and 2 deletions
|
|
@ -1169,7 +1169,7 @@ openmc_material_add_nuclide(int32_t index, const char* name, double density)
|
|||
// Create copy of atom_density_ array with one extra entry
|
||||
xt::xtensor<double, 1> atom_density = xt::zeros<double>({n});
|
||||
xt::view(atom_density, xt::range(0, n-1)) = m->atom_density_;
|
||||
atom_density(n) = density;
|
||||
atom_density(n-1) = density;
|
||||
m->atom_density_ = atom_density;
|
||||
|
||||
m->density_ += density;
|
||||
|
|
|
|||
|
|
@ -124,6 +124,13 @@ def test_material(capi_init):
|
|||
assert m.density == pytest.approx(0.1)
|
||||
|
||||
|
||||
def test_material_add_nuclide(capi_init):
|
||||
m = openmc.capi.materials[3]
|
||||
m.add_nuclide('Xe135', 1e-12)
|
||||
assert m.nuclides[-1] == 'Xe135'
|
||||
assert m.densities[-1] == 1e-12
|
||||
|
||||
|
||||
def test_new_material(capi_init):
|
||||
with pytest.raises(exc.AllocationError):
|
||||
openmc.capi.Material(1)
|
||||
|
|
@ -135,7 +142,7 @@ def test_new_material(capi_init):
|
|||
def test_nuclide_mapping(capi_init):
|
||||
nucs = openmc.capi.nuclides
|
||||
assert isinstance(nucs, Mapping)
|
||||
assert len(nucs) == 12
|
||||
assert len(nucs) == 13
|
||||
for name, nuc in nucs.items():
|
||||
assert isinstance(nuc, openmc.capi.Nuclide)
|
||||
assert name == nuc.name
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue