Struct WeightWindow
pub struct WeightWindow {Show 30 fields
pub f: u8,
pub iv: u8,
pub ni: u8,
pub ne: usize,
pub nt: usize,
pub nr: u8,
pub nwg: u8,
pub probid: String,
pub nfx: usize,
pub nfy: usize,
pub nfz: usize,
pub ncx: usize,
pub ncy: usize,
pub ncz: usize,
pub x0: f64,
pub y0: f64,
pub z0: f64,
pub x1: f64,
pub y1: f64,
pub z1: f64,
pub x2: f64,
pub y2: f64,
pub z2: f64,
pub e: Vec<f64>,
pub t: Vec<f64>,
pub qps_x: Vec<[f64; 3]>,
pub qps_y: Vec<[f64; 3]>,
pub qps_z: Vec<[f64; 3]>,
pub weights: Vec<f64>,
pub particle: u8,
}
Expand description
Mesh-based global weight window data for WWINP/WWOUT/WWONE
The WeightWindow data structure represents a set of weight windows for a single mesh and particle type.
Writers are implemented to generate the standardised UTF-8 file format for WWINP/WWOUT/WWONE files for direct use in MCNP simulations.
§Memory use
Large weight window meshes are approximately ~8 bytes per unique voxel
§Field naming
While unreadable, the WeightWindow fields correspond closely to the internal FORTRAN MCNP variables outlined in the Appendicies of the MCNPv6.2 and MCNPv6.3 user manuals.
This really helps to maintain consistency with the underlying data.
§Formatting
All formats will match fortran formats in the table below, explicitly using the scientific number representation for any genral ‘g’ format.
Block | Format | Variable List |
---|---|---|
1 | 4i10, 20x, a19 | if iv ni nr probid |
1 | 7i10 | nt(1) … nt(ni) [if iv=2] |
1 | 7i10 | ne(1) … ne(ni) |
1 | 6g13.5 | nfx nfy nfz x0 y0 z0 |
1 | 6g13.5 | ncx ncy ncz nwg [if nr=10] |
1 | 6g13.5 | ncx ncy ncz x1 y1 z1 [if nr=16] |
1 | 6g13.5 | x2 y2 z2 nwg [if nr=16] |
2 | 6g13.5 | x0 (qx(i), px(i), sx(i), i=1,ncx) |
2 | 6g13.5 | y0 (qy(i), py(i), sy(i), i=1,ncy) |
2 | 6g13.5 | z0 (qz(i), pz(i), sz(i), i=1,ncz) |
3 | 6g13.5 | t(i,1) … t(i,nt(i)) [if nt(i)>1] |
3 | 6g13.5 | e(i,1) … e(i,ne(i)) |
3 | 6g13.5 | (((w(i,j,k,l,1) j=1,nft), k=1,ne(i)), l=1,nt(i)) |
Formatting is done in blocks for consistency with the specifications provided in the user manual appendices.
Fields§
§f: u8
File type, manual states unused, so always 1.
iv: u8
Time-dependent windows flag, 1=no 2=yes.
ni: u8
Number of particle types
ne: usize
Number of energy bins for each particle type
nt: usize
Number of time bins for each particle type
nr: u8
Number of ‘words’ to describe mesh. rec=10, cyl/sph=16
nwg: u8
Mesh type 1=rec, 2=cyl, 3=sph
probid: String
Problem description, 19-char string, can be blank.
nfx: usize
Total number of fine mesh points in i
nfy: usize
Total number of fine mesh points in j
nfz: usize
Total number of fine mesh points in k
ncx: usize
Total number of coarse mesh points in i
ncy: usize
Total number of coarse mesh points in j
ncz: usize
Total number of coarse mesh points in k
x0: f64
Origin i coordinate
y0: f64
Origin j coordinate
z0: f64
Origin k coordinate
x1: f64
Axis i coordinate
y1: f64
Axis j coordinate
z1: f64
Axis k coordinate
x2: f64
Vec i coordinate
y2: f64
Vec j coordinate
z2: f64
Vec k coordinate
e: Vec<f64>
Upper energy bounds for each particle type
t: Vec<f64>
Upper time bounds for each particle type if nt(i)>1
qps_x: Vec<[f64; 3]>
List of (qx(i), px(i), sx(i)) tuples for i=1,ncx
qps_y: Vec<[f64; 3]>
List of (qy(i), py(i), sy(i)) tuples for i=1,ncy
qps_z: Vec<[f64; 3]>
List of (qz(i), pz(i), sz(i)) tuples for i=1,ncz
weights: Vec<f64>
Flattened vector of lower weights for each voxel, for each energy bin, for each time bin
particle: u8
Retain particle type for use in multi-particle sets
Implementations§
§impl WeightWindow
impl WeightWindow
pub fn write(&self, path: &str)
pub fn write(&self, path: &str)
Write the weight window to the standard fromatted UTF-8 file
Generates the WWINP/WWOUT/WWONE formatted files for direct input to MCNP simulations.
Tools to combine weight window sets for multiple particles are provided see write_multi_particle().
pub fn scale(&mut self, factor: f64)
pub fn scale(&mut self, factor: f64)
Multiply all weights by a constant factor
This is just a blanket multiplication that applies to every weight across all energy/time groups and particle types.
let mut wwout = WeightWindow {
weights: vec![0.2, 0.15, 0.4],
..Default::default()
};
// Double every weight
wwout.scale(2.0);
assert_eq!(wwout.weights, vec![0.4, 0.3, 0.8])
pub fn non_analogue_percentage(&self) -> f64
pub fn non_analogue_percentage(&self) -> f64
Calculate number of non-zero weights
Useful common sense value for checking the conversion to weights and that successive weight windows are imporving. Do not expect it to reach 100% if the mesh geometry covers any areas of zero importance for a given particle type.
let wwout = WeightWindow {
weights: vec![0.2, 0.15, 0.0, 0.0],
..Default::default()
};
assert_eq!(wwout.non_analogue_percentage(), 50.0)
pub fn file_content(&self) -> String
pub fn file_content(&self) -> String
Generate file content as a string (not for large files)
Build a string for the full wwout file. Can be useful for small files and quick checks. However, this can end up duplicating a lot of data and the memory usage could be large for a significant number of weights.
pub fn etijk_from_cell_index(
&self,
idx: usize,
) -> (usize, usize, usize, usize, usize)
pub fn etijk_from_cell_index( &self, idx: usize, ) -> (usize, usize, usize, usize, usize)
Find the (e,t,i,j,k) indicies for a given cell index
pub fn voxel_index_from_etijk(
&self,
e_idx: usize,
t_idx: usize,
i_idx: usize,
j_idx: usize,
k_idx: usize,
) -> usize
pub fn voxel_index_from_etijk( &self, e_idx: usize, t_idx: usize, i_idx: usize, j_idx: usize, k_idx: usize, ) -> usize
Convert indexed bins to a voxel index
pub fn voxel_index_from_cell_index(&self, idx: usize) -> usize
pub fn voxel_index_from_cell_index(&self, idx: usize) -> usize
Convert from a cell index to a voxel index
Generally useful for weight windows to vtk plotting orders.
§impl WeightWindow
impl WeightWindow
pub fn block_1_header(&self) -> String
pub fn block_1_header(&self) -> String
Only the formatted header String
Trait Implementations§
§impl Clone for WeightWindow
impl Clone for WeightWindow
§fn clone(&self) -> WeightWindow
fn clone(&self) -> WeightWindow
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for WeightWindow
impl Debug for WeightWindow
§impl Default for WeightWindow
impl Default for WeightWindow
§fn default() -> WeightWindow
fn default() -> WeightWindow
Auto Trait Implementations§
impl Freeze for WeightWindow
impl RefUnwindSafe for WeightWindow
impl Send for WeightWindow
impl Sync for WeightWindow
impl Unpin for WeightWindow
impl UnwindSafe for WeightWindow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.