mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Add a C-API based restart test
This commit is contained in:
parent
309a913b06
commit
2ff8eb4696
2 changed files with 30 additions and 1 deletions
|
|
@ -70,6 +70,7 @@ contains
|
|||
integer(HID_T) :: cmfd_group, tallies_group, tally_group, meshes_group, &
|
||||
filters_group, filter_group, derivs_group, &
|
||||
deriv_group, runtime_group
|
||||
integer(C_INT) :: ignored_err
|
||||
real(C_DOUBLE) :: k_combined(2)
|
||||
character(MAX_WORD_LEN), allocatable :: str_array(:)
|
||||
character(C_CHAR), pointer :: string(:)
|
||||
|
|
@ -151,7 +152,7 @@ contains
|
|||
call write_dataset(file_id, "k_col_abs", k_col_abs)
|
||||
call write_dataset(file_id, "k_col_tra", k_col_tra)
|
||||
call write_dataset(file_id, "k_abs_tra", k_abs_tra)
|
||||
err = openmc_get_keff(k_combined)
|
||||
ignored_err = openmc_get_keff(k_combined)
|
||||
call write_dataset(file_id, "k_combined", k_combined)
|
||||
|
||||
! Write out CMFD info
|
||||
|
|
|
|||
|
|
@ -311,3 +311,31 @@ def test_mesh(capi_init):
|
|||
|
||||
msf = openmc.capi.MeshSurfaceFilter(mesh)
|
||||
assert msf.mesh == mesh
|
||||
|
||||
|
||||
def test_restart(pincell_model):
|
||||
# Run for 7 batches then write a statepoint.
|
||||
openmc.capi.init()
|
||||
openmc.capi.simulation_init()
|
||||
for i in range(7):
|
||||
openmc.capi.next_batch()
|
||||
openmc.capi.statepoint_write('restart_test.h5', True)
|
||||
|
||||
# Run 3 more batches and copy the keff.
|
||||
for i in range(3):
|
||||
openmc.capi.next_batch()
|
||||
keff0 = openmc.capi.keff()
|
||||
openmc.capi.simulation_finalize()
|
||||
openmc.capi.finalize()
|
||||
|
||||
# Restart the simulation and run all 10 batches.
|
||||
openmc.capi.init(args=('-r', 'restart_test.h5'))
|
||||
openmc.capi.simulation_init()
|
||||
for i in range(10):
|
||||
openmc.capi.next_batch()
|
||||
keff1 = openmc.capi.keff()
|
||||
openmc.capi.simulation_finalize()
|
||||
openmc.capi.finalize()
|
||||
|
||||
# Compare the keff values.
|
||||
assert keff0 == pytest.approx(keff1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue