mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
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:
parent
52ff408651
commit
e702b5186c
1 changed files with 25 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue