-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
bugsA deviation from expected behavior that does not reach the level of being reportable as an "Error".A deviation from expected behavior that does not reach the level of being reportable as an "Error".
Description
Bug Description
Cells in MCNP have an importance parameter. This is set using montepy.data_inputs.importance.Importance objects. When a file is written out, importances are either required or highly recommended for all cells, depending on the situation.
In MontePy, a cell's importance may be set by using Importance.all or Importance.particle for a particular particle type (neutron, electron, etc.). However, when setting the importance of a newly created cell, the importance is not always printed:
- When not setting an importance value, accepting the default value
- When setting
cell.importance.allto any value - When explicitly setting all importances to the default value individually
It does work:
- When setting an importance individually to a non-default value
- When explicitly setting an importance to the default value when also setting another importance on the same cell to a non-default value
I suspect this has something to do with detecting whether the parameter has changed, attempting to preserve original user formatting.
To Reproduce
See below. Cells are added to a problem with mode n p in a variety of ways.
import io
import montepy
deck = montepy.read_input("base_problem.i")
# Modify an existing cell. Importance remains.
deck.cells[1].geometry &= +deck.surfaces[2]
# Cell 2 should give "imp:n=2.0 imp:p=2.0"
c2 = montepy.Cell(number=2)
c2.geometry = -deck.surfaces[2] & +deck.surfaces[3]
c2.importance.all = 2.0
deck.cells.append(c2)
# Cell 3 should give "imp:n=1.0 imp:p=1.0"
c3 = montepy.Cell(number=3)
c3.geometry = -deck.surfaces[3] & +deck.surfaces[4]
c3.importance.neutron = 1.0
c3.importance.photon = 1.0
deck.cells.append(c3)
# Cell 4 should give "imp:n=4.0 imp:p=1.0"
c4 = montepy.Cell(number=4)
c4.geometry = -deck.surfaces[4]
c4.importance.neutron = 4.0
deck.cells.append(c4)
# Cell 5 DOES give "imp:n=5.0 imp:p=1.0"
c5 = montepy.Cell(number=5)
c5.geometry = -deck.surfaces[5]
c5.importance.neutron = 5.0
c5.importance.photon = 1.0
deck.cells.append(c5)
# Ensure that this is set:
# Ensure that this is set:
deck.print_in_data_block["imp"] = False
stream = io.StringIO()
deck.write_problem(stream)
stream.seek(0)
print(stream.read())
stream.close()Input MCNP file snippet
Details
base_problem.i
Example MCNP Input File
C cells
1 1 20 -1
imp:n,p=1
9 0 +1 imp:n,p=0
C New cells are added here without importance parameters
C surfaces
1 SO 9
2 SO 8
3 SO 7
4 SO 6
5 SO 5
C data
mode n p
C materials
C UO2 5 atpt enriched
m1 92238.80c 1.0
c transforms
c run parameters
ksrc 0.0 0.0 1.0
kcode 100 0.1 1 11Output MCNP file snippet
Details
Example MCNP Input File
C cells
1 1 20 -1
2 imp:n,p=1
9 0 +1 imp:n,p=0
C New cells are added here without importance parameters
2 0 -2 3
3 0 -3 4
4 0 -4 IMP:n=4.0
5 0 -5 IMP:n=5.0 IMP:p=1.0
C surfaces
1 SO 9
2 SO 8
3 SO 7
4 SO 6
5 SO 5
C data
mode n p
C materials
C UO2 5 atpt enriched
m1 92238.80c 1.0
c transforms
c run parameters
ksrc 0.0 0.0 1.0
kcode 100 0.1 1 11Version
- Version 1.2
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugsA deviation from expected behavior that does not reach the level of being reportable as an "Error".A deviation from expected behavior that does not reach the level of being reportable as an "Error".