2016-11-14 11:26:08 -06:00
|
|
|
import h5py
|
|
|
|
|
|
2017-02-17 14:29:34 -06:00
|
|
|
import openmc.checkvalue as cv
|
2026-02-03 01:23:24 -06:00
|
|
|
from .particle_type import ParticleType
|
2017-02-17 14:29:34 -06:00
|
|
|
|
|
|
|
|
_VERSION_PARTICLE_RESTART = 2
|
|
|
|
|
|
2020-03-19 15:21:15 -05:00
|
|
|
|
|
|
|
|
class Particle:
|
2015-06-02 19:22:33 +07:00
|
|
|
"""Information used to restart a specific particle that caused a simulation to
|
|
|
|
|
fail.
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
|
----------
|
|
|
|
|
filename : str
|
|
|
|
|
Path to the particle restart file
|
|
|
|
|
|
|
|
|
|
Attributes
|
|
|
|
|
----------
|
|
|
|
|
current_batch : int
|
|
|
|
|
The batch containing the particle
|
2017-02-20 10:47:51 -06:00
|
|
|
generations_per_batch : int
|
2015-06-02 19:22:33 +07:00
|
|
|
Number of generations per batch
|
2017-02-20 10:47:51 -06:00
|
|
|
current_generation : int
|
2015-06-02 19:22:33 +07:00
|
|
|
The generation containing the particle
|
|
|
|
|
n_particles : int
|
|
|
|
|
Number of particles per generation
|
|
|
|
|
run_mode : int
|
|
|
|
|
Type of simulation (criticality or fixed source)
|
|
|
|
|
id : long
|
|
|
|
|
Identifier of the particle
|
2026-02-03 01:23:24 -06:00
|
|
|
type : openmc.ParticleType
|
|
|
|
|
Particle type
|
2015-06-02 19:22:33 +07:00
|
|
|
weight : float
|
|
|
|
|
Weight of the particle
|
|
|
|
|
energy : float
|
2016-10-24 18:44:51 -05:00
|
|
|
Energy of the particle in eV
|
2015-06-02 19:22:33 +07:00
|
|
|
xyz : list of float
|
|
|
|
|
Position of the particle
|
|
|
|
|
uvw : list of float
|
|
|
|
|
Directional cosines of the particle
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
2013-08-12 15:28:34 -04:00
|
|
|
def __init__(self, filename):
|
2020-04-01 11:22:50 -05:00
|
|
|
with h5py.File(filename, 'r') as f:
|
|
|
|
|
|
|
|
|
|
# Ensure filetype and version are correct
|
|
|
|
|
cv.check_filetype_version(f, 'particle restart', _VERSION_PARTICLE_RESTART)
|
|
|
|
|
|
|
|
|
|
self.current_batch = f['current_batch'][()]
|
|
|
|
|
self.current_generation = f['current_generation'][()]
|
|
|
|
|
self.energy = f['energy'][()]
|
|
|
|
|
self.generations_per_batch = f['generations_per_batch'][()]
|
|
|
|
|
self.id = f['id'][()]
|
2026-02-03 01:23:24 -06:00
|
|
|
self.type = ParticleType(f['type'][()])
|
2020-04-01 11:22:50 -05:00
|
|
|
self.n_particles = f['n_particles'][()]
|
|
|
|
|
self.run_mode = f['run_mode'][()].decode()
|
|
|
|
|
self.uvw = f['uvw'][()]
|
|
|
|
|
self.weight = f['weight'][()]
|
|
|
|
|
self.xyz = f['xyz'][()]
|