Add test for working with depletion_chains in DataLibrary

Load the system default cross section file, register a
depletion chain, and inspect the results. Should
have one additional library, with an empty list
of materials.

Export and create a new library from this exported xml.
Examine the contents of the new depletion chain library
This commit is contained in:
Andrew Johnson 2019-06-13 19:35:15 -04:00
parent 52ff408651
commit e702b5186c
No known key found for this signature in database
GPG key ID: 253418E91B7F6FEB

View file

@ -2,6 +2,7 @@
from collections.abc import Mapping
import os
from pathlib import Path
import numpy as np
import pytest
@ -33,6 +34,30 @@ def test_data_library(tmpdir):
assert new_lib.libraries[-1]['type'] == 'thermal'
def test_depletion_chain_data_library(run_in_tmpdir):
dep_lib = openmc.data.DataLibrary.from_xml()
prev_len = len(dep_lib.libraries)
chain_path = Path(__file__).parents[1] / "chain_simple.xml"
dep_lib.register_file(chain_path)
assert len(dep_lib.libraries) == prev_len + 1
# Inspect
dep_dict = dep_lib.libraries[-1]
assert dep_dict['materials'] == []
assert dep_dict['type'] == 'depletion_chain'
assert dep_dict['path'] == str(chain_path)
out_path = "cross_section_chain.xml"
dep_lib.export_to_xml(out_path)
dep_import = openmc.data.DataLibrary.from_xml(out_path)
for lib in reversed(dep_import.libraries):
if lib['type'] == 'depletion_chain':
break
else:
raise IndexError("depletion_chain not found in exported DataLibrary")
assert os.path.exists(lib['path'])
def test_linearize():
"""Test linearization of a continuous function."""
x, y = openmc.data.linearize([-1., 1.], lambda x: 1 - x*x)