Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions montepy/data_inputs/importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _generate_default_cell_tree(self, particle=None):
particles.particles = self._problem.mode.particles
classifier.particles = particles
list_node = syntax_node.ListNode("imp data")
list_node.append(self._generate_default_node(float, 0.0))
list_node.append(self._generate_default_node(float, 1.0))
tree = syntax_node.SyntaxNode(
"Importance",
{
Expand Down Expand Up @@ -163,7 +163,7 @@ def __getitem__(self, particle):
val = self._particle_importances[particle]["data"][0]
return val.value
except KeyError:
return 0.0
return 1.0

def __setitem__(self, particle, value):
if not isinstance(particle, Particle):
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ authors = [
{name = "Brenna Carbno", email="[email protected]"},
{name = "Benjaminas Marcinkevicius", email="[email protected]"},
{name = "Paul Ferney", email="[email protected]"},
{name = "Digvijay Yeware", email="[email protected]"}
{name = "Digvijay Yeware", email="[email protected]"},
{name = "Harsh Dayal", email="[email protected]"}
]
keywords = ["MCNP", "neutronics", "imcnp", "input file", "monte carlo", "radiation transport"]
license = "MIT"
Expand Down
13 changes: 9 additions & 4 deletions tests/test_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create_cell_from_input(self, in_str, block=block_type.BlockType.CELL):
"neutron": 1.0,
"photon": 1.0,
"all": None,
"alpha_particle": 0.0,
"alpha_particle": 1.0,
"in_cell_block": True,
},
None,
Expand All @@ -40,7 +40,7 @@ def create_cell_from_input(self, in_str, block=block_type.BlockType.CELL):
),
(
"1 0 -1",
{"neutron": 0.0},
{"neutron": 1.0},
None,
), # default neutron importance when nothing is set
# Error cases
Expand Down Expand Up @@ -267,9 +267,9 @@ def test_importance_deleter(self, cell_with_importance):
"""
cell = cell_with_importance
del cell.importance.neutron
assert cell.importance.neutron == pytest.approx(0.0)
assert cell.importance.neutron == pytest.approx(1.0)
del cell.importance[Particle.PHOTON]
assert cell.importance.photon == pytest.approx(0.0)
assert cell.importance.photon == pytest.approx(1.0)
with pytest.raises(TypeError):
del cell.importance[""]

Expand Down Expand Up @@ -312,3 +312,8 @@ def test_default_importance_not_implemented(self):
prob.print_in_data_block["imp"] = True
with pytest.raises(NotImplementedError):
prob.write_problem(io.StringIO())

def test_default_cell_importance(self):
"""Test that new cells have default importance of 1.0 (Issue #735)"""
cell = montepy.Cell()
assert cell.importance.neutron == 1.0
Loading