@@ -109,3 +109,50 @@ def test_density_no_whitespace():
109109 model = mcnp_str_to_model (mcnp_model )
110110 m = model .materials [0 ]
111111 assert m .get_mass_density () == approx (4.5 )
112+
113+
114+ def test_material_keywords_at_beginning ():
115+ """Test material card with keywords at the beginning"""
116+ mat_card = "m1 NLIB=70c PLIB=04p 92235.70c 1.0 92238.70c 0.5"
117+ m = convert_material (mat_card , - 1.0 )
118+ nd = m .get_nuclide_densities ()
119+ assert 'U235' in nd and nd ['U235' ].percent == approx (1.0 )
120+ assert 'U238' in nd and nd ['U238' ].percent == approx (0.5 )
121+
122+
123+ def test_material_keywords_in_middle ():
124+ """Test material card with keywords interspersed with nuclide pairs"""
125+ mat_card = "m1 92235.70c 1.0 NLIB=70c 92238.70c 0.5 PLIB=04p 92234.70c 0.3"
126+ m = convert_material (mat_card , - 1.0 )
127+ nd = m .get_nuclide_densities ()
128+ assert 'U235' in nd and nd ['U235' ].percent == approx (1.0 )
129+ assert 'U238' in nd and nd ['U238' ].percent == approx (0.5 )
130+ assert 'U234' in nd and nd ['U234' ].percent == approx (0.3 )
131+
132+
133+ def test_material_keywords_with_spaces ():
134+ """Test material card with keywords that have spaces around equals sign"""
135+ mat_card = "m1 92235.70c 1.5 NLIB = 80c 92238.70c 0.5 GAS = 0"
136+ m = convert_material (mat_card , - 2.0 )
137+ nd = m .get_nuclide_densities ()
138+ assert 'U235' in nd and nd ['U235' ].percent == approx (1.5 )
139+ assert 'U238' in nd and nd ['U238' ].percent == approx (0.5 )
140+ assert m .get_mass_density () == approx (2.0 )
141+
142+
143+ def test_material_keywords_at_end ():
144+ """Test material card with keywords at the end"""
145+ mat_card = "m1 92235.70c 2.0 92238.70c 1.0 NLIB=70c PLIB=04p"
146+ m = convert_material (mat_card , - 1.0 )
147+ nd = m .get_nuclide_densities ()
148+ assert 'U235' in nd and nd ['U235' ].percent == approx (2.0 )
149+ assert 'U238' in nd and nd ['U238' ].percent == approx (1.0 )
150+
151+
152+ def test_material_without_keywords ():
153+ """Test that material cards without keywords still work correctly"""
154+ mat_card = "m1 92235.70c 1.0 92238.70c 0.5"
155+ m = convert_material (mat_card , - 1.0 )
156+ nd = m .get_nuclide_densities ()
157+ assert 'U235' in nd and nd ['U235' ].percent == approx (1.0 )
158+ assert 'U238' in nd and nd ['U238' ].percent == approx (0.5 )
0 commit comments