Struct Voxel
pub struct Voxel {
pub index: usize,
pub result: f64,
pub error: f64,
}
Expand description
Representation of a single voxel in the mesh
The global index
of the voxel is included to maintain consistency between
output Format variants. Parsing line-by-line rather
than trying to load an entire file into memory leaves the voxels in an
inconsistent order for several formats.
§Memory usage
The minimum information required would be just the result and uncertainty (16 Bytes), and the maximum would include the cooridinates and energy/time groups (80 Bytes).
The current implementation is a compromise between the two at 24 Bytes, and all other values may be derived from the Mesh given the voxel index.
Several operators are implemented for convenience where it makes sense,
including Addition (+
, +=
), Subtraction (-
, -=
),
Multiplication (*
, *=
), and Division (/
, /=
).
In all cases, the LHS index is taken, and the RHS may be either another
Voxel or anything that can be converted into an f64
primitive.
Fields§
§index: usize
Global voxel index
result: f64
Tallied voxel result
error: f64
Relative error on result
Implementations§
§impl Voxel
impl Voxel
pub fn absolute_error(&self) -> f64
pub fn absolute_error(&self) -> f64
Returns the absolute error for the voxel
Example:
let voxel = Voxel {
result: 50.0,
error: 0.10,
..Default::default()
};
/// 10% relative error => 50.0 +/-5.0
assert_eq!(voxel.absolute_error(), 5.0);
pub fn relative_error(&self) -> f64
pub fn relative_error(&self) -> f64
Returns the relative error for the voxel
The MCNP mesh results are output and stored as the relative uncertainty anyway. However, having both absolute_error() and relative_error() methods makes intent explicit.
For example:
let voxel = Voxel {
result: 50.0,
error: 0.10,
..Default::default()
};
/// 10% relative error => 50.0 +/-5.0
assert_eq!(voxel.relative_error(), 0.1);
Trait Implementations§
§impl<T> AddAssign<T> for Voxel
impl<T> AddAssign<T> for Voxel
§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
+=
operation. Read more§impl<T> DivAssign<T> for Voxel
impl<T> DivAssign<T> for Voxel
§fn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
/=
operation. Read more§impl<T> MulAssign<T> for Voxel
impl<T> MulAssign<T> for Voxel
§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
*=
operation. Read more§impl<T> SubAssign<T> for Voxel
impl<T> SubAssign<T> for Voxel
§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
-=
operation. Read moreimpl Copy for Voxel
impl StructuralPartialEq for Voxel
Auto Trait Implementations§
impl Freeze for Voxel
impl RefUnwindSafe for Voxel
impl Send for Voxel
impl Sync for Voxel
impl Unpin for Voxel
impl UnwindSafe for Voxel
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,
§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.