mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
updated particle_restart test
This commit is contained in:
parent
6b70a06a82
commit
5627bb8cd6
3 changed files with 56 additions and 1 deletions
33
tests/test_particle_restart/results.py
Normal file
33
tests/test_particle_restart/results.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
|
||||
# import particle restart
|
||||
sys.path.append('../../src/utils')
|
||||
import particle_restart as pr
|
||||
|
||||
# read in particle restart file
|
||||
p = pr.Particle('particle_10_638.binary')
|
||||
|
||||
# set up output string
|
||||
outstr = ''
|
||||
|
||||
# write out properties
|
||||
outstr += 'current batch:\n'
|
||||
outstr += "{0:10.8f}\n".format(p.current_batch)
|
||||
outstr += 'current gen:\n'
|
||||
outstr += "{0:10.8f}\n".format(p.current_gen)
|
||||
outstr += 'particle id:\n'
|
||||
outstr += "{0:10.8f}\n".format(p.id)
|
||||
outstr += 'particle weight:\n'
|
||||
outstr += "{0:10.8f}\n".format(p.weight)
|
||||
outstr += 'particle energy:\n'
|
||||
outstr += "{0:10.8f}\n".format(p.energy)
|
||||
outstr += 'particle xyz:\n'
|
||||
outstr += "{0:10.8f} {1:10.8f} {2:10.8f}\n".format(p.xyz[0],p.xyz[1],p.xyz[2])
|
||||
outstr += 'particle uvw:\n'
|
||||
outstr += "{0:10.8f} {1:10.8f} {2:10.8f}\n".format(p.uvw[0],p.uvw[1],p.uvw[2])
|
||||
|
||||
# write results to file
|
||||
with open('results_test.dat','w') as fh:
|
||||
fh.write(outstr)
|
||||
14
tests/test_particle_restart/results_true.dat
Normal file
14
tests/test_particle_restart/results_true.dat
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
current batch:
|
||||
10.00000000
|
||||
current gen:
|
||||
1.00000000
|
||||
particle id:
|
||||
638.00000000
|
||||
particle weight:
|
||||
1.00000000
|
||||
particle energy:
|
||||
2.19644588
|
||||
particle xyz:
|
||||
30.87637144 57.78785719 35.19837347
|
||||
particle uvw:
|
||||
-0.69841548 -0.09803596 0.70894624
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
from subprocess import Popen, STDOUT, PIPE
|
||||
import filecmp
|
||||
|
||||
pwd = os.path.dirname(__file__)
|
||||
|
||||
|
|
@ -17,6 +18,13 @@ def test_run():
|
|||
def test_created_restart():
|
||||
assert os.path.exists(pwd + '/particle_10_638.binary')
|
||||
|
||||
def test_results():
|
||||
os.system('python results.py')
|
||||
compare = filecmp.cmp('results_test.dat', 'results_true.dat')
|
||||
if not compare:
|
||||
os.system('cp results_test.dat results_error.dat')
|
||||
assert compare
|
||||
|
||||
def test_run_restart():
|
||||
proc = Popen([pwd + '/../../src/openmc -s particle_10_638.binary'],
|
||||
stderr=PIPE, stdout=PIPE, shell=True)
|
||||
|
|
@ -24,7 +32,7 @@ def test_run_restart():
|
|||
assert stderr != ''
|
||||
|
||||
def teardown():
|
||||
output = [pwd + '/particle_10_638.binary']
|
||||
output = [pwd + '/particle_10_638.binary', pwd + '/results_test.dat']
|
||||
for f in output:
|
||||
if os.path.exists(f):
|
||||
os.remove(f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue