Allow volume calculations to be run alone

This commit is contained in:
Paul Romano 2017-02-16 17:26:23 -06:00
parent ffc3bbfd67
commit 698efb04e2
6 changed files with 25 additions and 36 deletions

View file

@ -264,16 +264,18 @@ contains
end if
end if
! Read run parameters
call get_run_parameters(node_mode)
if (run_mode == MODE_EIGENVALUE .or. run_mode == MODE_FIXEDSOURCE) then
! Read run parameters
call get_run_parameters(node_mode)
! Check number of active batches, inactive batches, and particles
if (n_active <= 0) then
call fatal_error("Number of active batches must be greater than zero.")
elseif (n_inactive < 0) then
call fatal_error("Number of inactive batches must be non-negative.")
elseif (n_particles <= 0) then
call fatal_error("Number of particles must be greater than zero.")
! Check number of active batches, inactive batches, and particles
if (n_active <= 0) then
call fatal_error("Number of active batches must be greater than zero.")
elseif (n_inactive < 0) then
call fatal_error("Number of inactive batches must be non-negative.")
elseif (n_particles <= 0) then
call fatal_error("Number of particles must be greater than zero.")
end if
end if
! Copy random number seed if specified
@ -317,7 +319,10 @@ contains
! Get point to list of <source> elements and make sure there is at least one
call get_node_list(doc, "source", node_source_list)
n = get_list_size(node_source_list)
if (n == 0) call fatal_error("No source specified in settings XML file.")
if (run_mode == MODE_EIGENVALUE .or. run_mode == MODE_FIXEDSOURCE) then
if (n == 0) call fatal_error("No source specified in settings XML file.")
end if
! Allocate array for sources
allocate(external_source(n))

View file

@ -8,6 +8,7 @@ program main
use particle_restart, only: run_particle_restart
use plot, only: run_plot
use simulation, only: run_simulation
use volume_calc, only: run_volume_calculations
implicit none
@ -26,6 +27,8 @@ program main
call run_plot()
case (MODE_PARTICLE)
if (master) call run_particle_restart()
case (MODE_VOLUME)
call run_volume_calculations()
end select
! finalize run

View file

@ -39,9 +39,6 @@ contains
type(Particle) :: p
integer(8) :: i_work
! Volume calculations
if (size(volume_calcs) > 0) call run_volume_calculations()
if (.not. restart_run) call initialize_source()
! Display header

View file

@ -26,15 +26,7 @@
</materials>
<?xml version='1.0' encoding='utf-8'?>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>1000</particles>
<batches>4</batches>
<inactive>0</inactive>
<source strength="1.0">
<space type="box">
<parameters>-1.0 -1.0 -5.0 1.0 1.0 5.0</parameters>
</space>
</source>
<run_mode>volume</run_mode>
<volume_calc>
<domain_type>cell</domain_type>
<domain_ids>1 2 3</domain_ids>

View file

@ -1,4 +1,3 @@
k-combined: 4.165450e-02 3.582533e-04
Volume calculation 0
Domain 1: 31.4693 +/- 0.0721 cm^3
Domain 2: 2.0933 +/- 0.0310 cm^3

View file

@ -52,22 +52,12 @@ class VolumeTest(PyAPITestHarness):
# Define settings
settings = openmc.Settings()
settings.particles = 1000
settings.batches = 4
settings.inactive = 0
settings.source = openmc.Source(space=openmc.stats.Box(
[-1., -1., -5.], [1., 1., 5.]))
settings.run_mode = 'volume'
settings.volume_calculations = vol_calcs
settings.export_to_xml()
def _get_results(self):
# Read the statepoint file.
statepoint = os.path.join(os.getcwd(), self._sp_name)
sp = openmc.StatePoint(statepoint)
# Write out k-combined.
outstr = 'k-combined: {:12.6e} {:12.6e}\n'.format(*sp.k_combined)
outstr = ''
for i, filename in enumerate(sorted(glob.glob(os.path.join(
os.getcwd(), 'volume_*.h5')))):
outstr += 'Volume calculation {}\n'.format(i)
@ -83,6 +73,9 @@ class VolumeTest(PyAPITestHarness):
return outstr
def _test_output_created(self):
pass
if __name__ == '__main__':
harness = VolumeTest('statepoint.4.h5')
harness = VolumeTest('')
harness.main()