Skip to content

Commit 872662f

Browse files
authored
Fix(material): Fixed thermal scattering law never being written to file.
Fix bug with how thermal scattering law data is not written to file: fixes: #395.
2 parents 7a24ac0 + 57f8933 commit 872662f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

montepy/data_inputs/material.py

+15
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ def cells(self):
116116
if cell.material == self:
117117
yield cell
118118

119+
def format_for_mcnp_input(self, mcnp_version):
120+
"""
121+
Creates a string representation of this MCNP_Object that can be
122+
written to file.
123+
124+
:param mcnp_version: The tuple for the MCNP version that must be exported to.
125+
:type mcnp_version: tuple
126+
:return: a list of strings for the lines that this input will occupy.
127+
:rtype: list
128+
"""
129+
lines = super().format_for_mcnp_input(mcnp_version)
130+
if self.thermal_scattering is not None:
131+
lines += self.thermal_scattering.format_for_mcnp_input(mcnp_version)
132+
return lines
133+
119134
def add_thermal_scattering(self, law):
120135
"""
121136
Adds thermal scattering law to the material

tests/test_integration.py

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def test_write_to_file(self):
138138
for i, data in enumerate(self.simple_problem.data_inputs):
139139
if isinstance(data, material.Material):
140140
self.assertEqual(data.number, test_problem.data_inputs[i].number)
141+
if data.thermal_scattering is not None:
142+
assert (
143+
test_problem.data_inputs[i].thermal_scattering is not None
144+
)
141145
elif isinstance(data, volume.Volume):
142146
self.assertEqual(str(data), str(test_problem.data_inputs[i]))
143147
else:

0 commit comments

Comments
 (0)