diff --git a/pypact/input/inputdata.py b/pypact/input/inputdata.py index 8e00f59..a2e43f7 100644 --- a/pypact/input/inputdata.py +++ b/pypact/input/inputdata.py @@ -451,4 +451,10 @@ def _deserialize(self, f): if num_elements == 0: in_mass_section = False else: - raise PypactInvalidOptionException("Invalid element line format in MASS section.") \ No newline at end of file + raise PypactInvalidOptionException("Invalid element line format in MASS section.") + + elif line.startswith("DENSITY"): + parts = line.split() + if len(parts) != 2: + raise PypactInvalidOptionException("Invalid DENSITY line format.") + self.setDensity(float(parts[1])) diff --git a/tests/input/inputfiletest.py b/tests/input/inputfiletest.py index 7dc92db..8c7712e 100644 --- a/tests/input/inputfiletest.py +++ b/tests/input/inputfiletest.py @@ -27,4 +27,10 @@ def test_reading_in_mass(self): ] for i, (element, percentage) in enumerate(expected_elements): assert ff._inventorymass.entries[i][0] == element, f"Element {i} should be {element}" - assert ff._inventorymass.entries[i][1] == percentage, f"Percentage of {element} should be {percentage}" \ No newline at end of file + assert ff._inventorymass.entries[i][1] == percentage, f"Percentage of {element} should be {percentage}" + + def test_reading_in_density(self): + ff = pp.InputData() + pp.from_file(ff, 'reference/test.i') + + assert ff._density == 19.5