mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 14:35:27 -04:00
Fix cell data parsing (#3848)
This commit is contained in:
parent
70be650003
commit
0ab46dfa35
2 changed files with 6 additions and 13 deletions
|
|
@ -747,15 +747,6 @@ class Cell(IDManagerMixin):
|
|||
c.region = Region.from_expression(region, surfaces)
|
||||
|
||||
# Check for other attributes
|
||||
temperature = get_elem_list(elem, 'temperature', float)
|
||||
if temperature is not None:
|
||||
if len(temperature) > 1:
|
||||
c.temperature = temperature
|
||||
else:
|
||||
c.temperature = temperature[0]
|
||||
density = get_elem_list(elem, 'density', float)
|
||||
if density is not None:
|
||||
c.density = density if len(density) > 1 else density[0]
|
||||
v = get_text(elem, 'volume')
|
||||
if v is not None:
|
||||
c.volume = float(v)
|
||||
|
|
@ -764,6 +755,8 @@ class Cell(IDManagerMixin):
|
|||
if values is not None:
|
||||
if key == 'rotation' and len(values) == 9:
|
||||
values = np.array(values).reshape(3, 3)
|
||||
elif len(values) == 1:
|
||||
values = values[0]
|
||||
setattr(c, key, values)
|
||||
|
||||
# Add this cell to appropriate universe
|
||||
|
|
|
|||
|
|
@ -265,8 +265,8 @@ def test_import_properties(run_in_tmpdir, mpi_intracomm):
|
|||
# Check to see that values are assigned to the C and python representations
|
||||
# First python
|
||||
cell = model.geometry.get_all_cells()[1]
|
||||
assert cell.temperature == [600.0]
|
||||
assert cell.density == [pytest.approx(10.0, 1e-5)]
|
||||
assert cell.temperature == 600.0
|
||||
assert cell.density == pytest.approx(10.0, 1e-5)
|
||||
assert cell.fill.get_mass_density() == pytest.approx(5.0)
|
||||
# Now C
|
||||
assert openmc.lib.cells[1].get_temperature() == 600.
|
||||
|
|
@ -286,8 +286,8 @@ def test_import_properties(run_in_tmpdir, mpi_intracomm):
|
|||
'with_properties/settings.xml'
|
||||
)
|
||||
cell = model_with_properties.geometry.get_all_cells()[1]
|
||||
assert cell.temperature == [600.0]
|
||||
assert cell.density == [pytest.approx(10.0, 1e-5)]
|
||||
assert cell.temperature == 600.0
|
||||
assert cell.density == pytest.approx(10.0, 1e-5)
|
||||
assert cell.fill.get_mass_density() == pytest.approx(5.0)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue