mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Rename TrackFile --> Tracks
This commit is contained in:
parent
7b0862c4dc
commit
2e54c31915
7 changed files with 29 additions and 23 deletions
|
|
@ -189,7 +189,7 @@ Post-processing
|
|||
openmc.StatePoint
|
||||
openmc.Summary
|
||||
openmc.Track
|
||||
openmc.TrackFile
|
||||
openmc.Tracks
|
||||
|
||||
The following classes and functions are used for functional expansion reconstruction.
|
||||
|
||||
|
|
|
|||
|
|
@ -545,9 +545,9 @@ tracks will be written as follows::
|
|||
settings.max_tracks = 1000
|
||||
|
||||
Particle track information is written to the ``tracks.h5`` file, which can be
|
||||
analyzed using the :class:`~openmc.TrackFile` class::
|
||||
analyzed using the :class:`~openmc.Tracks` class::
|
||||
|
||||
>>> tracks = openmc.TrackFile('tracks.h5')
|
||||
>>> tracks = openmc.Tracks('tracks.h5')
|
||||
>>> tracks
|
||||
[<Track (1, 1, 50): 151 particles>,
|
||||
<Track (2, 1, 30): 191 particles>,
|
||||
|
|
@ -557,19 +557,25 @@ Each :class:`~openmc.Track` object stores a list of track information for every
|
|||
primary/secondary particle. In the above example, the first source particle
|
||||
produced 150 secondary particles for a total of 151 particles. Information for
|
||||
each primary/secondary particle can be accessed using the
|
||||
:attr:`~openmc.Track.particles` attribute::
|
||||
:attr:`~openmc.Track.particle_tracks` attribute::
|
||||
|
||||
>>> first_track = tracks[0]
|
||||
>>> len(first_track.particles)
|
||||
151
|
||||
>>> photon = first_track.particles[10]
|
||||
ParticleTrack(particle=<ParticleType.PHOTON: 1>, states=array([...]))
|
||||
>>> first_track.particle_tracks
|
||||
[<ParticleTrack: neutron, 120 states>,
|
||||
<ParticleTrack: photon, 6 states>,
|
||||
<ParticleTrack: electron, 2 states>,
|
||||
<ParticleTrack: electron, 2 states>,
|
||||
<ParticleTrack: electron, 2 states>,
|
||||
...
|
||||
<ParticleTrack: electron, 2 states>,
|
||||
<ParticleTrack: electron, 2 states>]
|
||||
>>> photon = first_track.particle_tracks[1]
|
||||
|
||||
The :class:`~openmc.ParticleTrack` class is a named tuple indicating the particle
|
||||
type and then a NumPy array of the "states". The states array is a compound type
|
||||
with a field for each physical quantity (position, direction, energy, time,
|
||||
weight, cell ID, and material ID). For example, to get the position for the
|
||||
above particle track::
|
||||
The :class:`~openmc.ParticleTrack` class is a named tuple indicating the
|
||||
particle type and then a NumPy array of the "states". The states array is a
|
||||
compound type with a field for each physical quantity (position, direction,
|
||||
energy, time, weight, cell ID, and material ID). For example, to get the
|
||||
position for the above particle track::
|
||||
|
||||
>>> photon.states['r']
|
||||
array([(-11.92987939, -12.28467295, 0.67837495),
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class Track(Sequence):
|
|||
return sources
|
||||
|
||||
|
||||
class TrackFile(list):
|
||||
class Tracks(list):
|
||||
"""Collection of particle tracks
|
||||
|
||||
This class behaves like a list and can be indexed using the normal subscript
|
||||
|
|
@ -202,7 +202,7 @@ class TrackFile(list):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, filepath):
|
||||
def __init__(self, filepath='tracks.h5'):
|
||||
# Read data from track file
|
||||
with h5py.File(filepath, 'r') as fh:
|
||||
# Check filetype and version
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ def main():
|
|||
help='Output HDF5 particle track file.')
|
||||
|
||||
args = parser.parse_args()
|
||||
openmc.TrackFile.combine(args.input, args.out)
|
||||
openmc.Tracks.combine(args.input, args.out)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ def main():
|
|||
point_offset = 0
|
||||
for fname in args.input:
|
||||
# Write coordinate values to points array.
|
||||
track_file = openmc.TrackFile(fname)
|
||||
track_file = openmc.Tracks(fname)
|
||||
for track in track_file:
|
||||
for particle in track.particles:
|
||||
for state in particle.states:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class TrackTestHarness(TestHarness):
|
|||
|
||||
# Get string of track file information
|
||||
outstr = ''
|
||||
tracks = openmc.TrackFile('tracks.h5')
|
||||
tracks = openmc.Tracks('tracks.h5')
|
||||
for track in tracks:
|
||||
with np.printoptions(formatter={'float_kind': '{:.6e}'.format}):
|
||||
for ptrack in track:
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ def generate_track_file(model, **kwargs):
|
|||
if config['mpi'] and int(config['mpi_np']) > 1:
|
||||
# With MPI, we need to combine track files
|
||||
track_files = Path.cwd().glob('tracks_p*.h5')
|
||||
openmc.TrackFile.combine(track_files, 'tracks.h5')
|
||||
openmc.Tracks.combine(track_files, 'tracks.h5')
|
||||
else:
|
||||
track_file = Path('tracks.h5')
|
||||
assert track_file.is_file()
|
||||
|
|
@ -54,7 +54,7 @@ def test_tracks(sphere_model, particle, run_in_tmpdir):
|
|||
generate_track_file(sphere_model)
|
||||
|
||||
# Open track file and make sure we have correct number of tracks
|
||||
tracks = openmc.TrackFile('tracks.h5')
|
||||
tracks = openmc.Tracks('tracks.h5')
|
||||
assert len(tracks) == len(sphere_model.settings.track)
|
||||
|
||||
for track, identifier in zip(tracks, sphere_model.settings.track):
|
||||
|
|
@ -105,7 +105,7 @@ def test_max_tracks(sphere_model, run_in_tmpdir):
|
|||
generate_track_file(sphere_model, tracks=True)
|
||||
|
||||
# Open track file and make sure we have correct number of tracks
|
||||
tracks = openmc.TrackFile('tracks.h5')
|
||||
tracks = openmc.Tracks('tracks.h5')
|
||||
assert len(tracks) == expected_num_tracks
|
||||
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ def test_filter(sphere_model, run_in_tmpdir):
|
|||
# Run OpenMC to generate tracks.h5 file
|
||||
generate_track_file(sphere_model, tracks=True)
|
||||
|
||||
tracks = openmc.TrackFile('tracks.h5')
|
||||
tracks = openmc.Tracks('tracks.h5')
|
||||
for track in tracks:
|
||||
# Test filtering by particle
|
||||
matches = track.filter(particle='photon')
|
||||
|
|
@ -132,7 +132,7 @@ def test_filter(sphere_model, run_in_tmpdir):
|
|||
matches = track.filter(state_filter=lambda s: s['E'] < 0.0)
|
||||
assert matches == []
|
||||
|
||||
# Test filter method on TrackFile
|
||||
# Test filter method on Tracks
|
||||
matches = tracks.filter(particle='neutron')
|
||||
assert matches == tracks
|
||||
matches = tracks.filter(state_filter=lambda s: s['E'] > 0.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue