Struct Mctal

pub struct Mctal {
    pub header: Header,
    pub tallies: Vec<Tally>,
    pub tmesh: Vec<Tmesh>,
    pub kcode: Option<Kcode>,
}
Expand description

Data structure to store MCTAL file content

This Mctal is the primary data structure containing the parsed file data.

The MCNP MCTAL file contains all tally results of one dump of a RUNTAPE file in a relatively fixed-format.

There are many data collections available, but can be broken into one of the following blocks:

Data blockDescription
Headerfile metadata and run information
Tallyall standard F tallies, including tally fluctuation chart
Tmeshsuperimposed Mesh Tally Type A (a.k.a TMESH)
Kcodecriticality results (KCODE)

Note that TMESH mesh tallies are written to the MCTAL file, while FMESH mesh tallies are not. Tools for reading FMESH data are available in other ntools crates (See mesh).

Fields§

§header: Header

Header information and metadata

§tallies: Vec<Tally>

Collection of standard tallies

§tmesh: Vec<Tmesh>

Collection of TMESH tallies (MCNPv6.3 only)

§kcode: Option<Kcode>

Kcode run information

Implementations§

§

impl Mctal

pub fn new() -> Self

Create a new empty Mctal struct with default values

Returns

A new instance of Mctal with default values.

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Read a MCTAL file

Parses the file at path into the Mctal data structure for post-processing.

The path may be a &str, String, Path, etc.

Parameters

  • path: A reference to a path that points to the MCTAL file.

Returns

A Result which is Ok if the file was successfully read and parsed, or an Err if an error occurred.

Example

// Read every tally contained in the MCTAL file
let mctal: Mctal = Mctal::from_file("path/to/mctal_file").unwrap();

pub fn get_header(&self) -> &Header

Get a reference to header data

Returns

A reference to the Header data.

pub fn get_tally(&self, id: u32) -> Option<&Tally>

Find a specific tally

Parameters

  • id: The ID of the tally to find.

Returns

An Option containing a reference to the Tally if found, otherwise None.

Example

// Dummy tally with id=104
let mut tally = Tally::default();
tally.id = 104;

// Add the dummy tally to a MCTAL
let mut mctal = Mctal::default();
mctal.tallies = vec![tally];

// Will return `Some(&Tally)` if it exists, otherwise `None`
assert!(mctal.get_tally(104).is_some());
assert!(mctal.get_tally(114).is_none());

pub fn get_tmesh(&self, id: u32) -> Option<&Tmesh>

Find a specific tmesh

Parameters

  • id: The ID of the tmesh to find.

Returns

An Option containing a reference to the Tmesh if found, otherwise None.

Example

// Dummy mesh with id=104
let mut tmesh = Tmesh::default();
tmesh.id = 104;

// Add the dummy mesh to a MCTAL
let mut mctal = Mctal::default();
mctal.tmesh = vec![tmesh];

// Will return `Some(&Tmesh)` if it exists, otherwise `None`
assert!(mctal.get_tmesh(104).is_some());
assert!(mctal.get_tmesh(114).is_none());

pub fn get_kcode(&self) -> Option<&Kcode>

Get a reference to kcode results

Returns

An Option containing a reference to the Kcode if it exists, otherwise None.

§

impl Mctal

pub fn get_code(&self) -> &str

Name of the code, e.g. “MCNP6”

pub fn get_version(&self) -> &str

Code version, e.g. “6.3”

pub fn get_probid(&self) -> &str

Message from the input deck

pub fn get_dump(&self) -> u32

Dump number

pub fn get_nps(&self) -> u64

Number of particle histories

pub fn get_randoms(&self) -> u64

Number of pseudo-random numbers

pub fn get_tally_list(&self) -> &[u32]

List of tally numbers available in in the the MCTAL file

Trait Implementations§

§

impl Debug for Mctal

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for Mctal

§

fn default() -> Mctal

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Mctal

§

impl RefUnwindSafe for Mctal

§

impl Send for Mctal

§

impl Sync for Mctal

§

impl Unpin for Mctal

§

impl UnwindSafe for Mctal

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.