Skip to main content

Runner

Struct Runner 

Source
pub struct Runner { /* private fields */ }
Expand description

Solves neutron transport problems using the Discrete Ordinates (S_N) method with domain decomposition.

The Runner struct implements the sweep-based algorithm for solving the one-dimensional neutron transport equation. It maintains the angular flux distribution across spatial nodes and angular directions, and iteratively updates the scalar flux until convergence.

§Fields

  • config - The configuration parameters defining the problem domain and materials
  • converged - Flag indicating whether the iterative solver has converged
  • iteration - Current iteration count in the convergence loop
  • psi_right - Angular flux for rightward-moving directions (μ > 0), dimensions: [spatial_nodes × n_half]
  • psi_left - Angular flux for leftward-moving directions (μ < 0), dimensions: [spatial_nodes × n_half]
  • scalar_flux - Integrated angular flux over all directions, dimensions: [spatial_cells]
  • total_source - Total source term including external and scattering contributions, dimensions: [spatial_cells]

§Example

use neutron_diffusion_dd::algorithm::{Config, Runner};

let config = Config::new_auto(1e-5, 2000, "data/input.json");
let mut runner = Runner::new(config);
let result = runner.run();

Implementations§

Source§

impl Runner

Source

pub fn new(config: Config) -> Self

Constructs a new Runner with the provided configuration.

Initializes all angular flux matrices with zeros and applies initial boundary conditions from the configuration. The solver is ready to start iterations after construction.

§Arguments
  • config - A Config struct containing all problem parameters
§Returns

A new Runner instance with initialized flux matrices and boundary conditions applied.

§Example
use neutron_diffusion_dd::algorithm::{Config, Runner};

let config = Config::new_auto(1e-5, 2000, "data/input.json");
let runner = Runner::new(config);
Source

pub fn run(&mut self) -> RunnerResult

Runs the iterative S_N solver until convergence or maximum iterations.

Executes the main solution algorithm:

  1. Updates reflective boundary conditions if applicable
  2. Performs a complete sweep of angular fluxes in all spatial cells and directions
  3. Computes scalar flux by integrating angular fluxes
  4. Checks convergence based on relative change in scalar flux

The iteration process continues until either the convergence tolerance is achieved or the maximum number of iterations is exceeded. Convergence diagnostics are printed every 100 iterations.

§Returns

A RunnerResult containing the final scalar flux distribution, convergence status, iteration count, and computation time.

§Example
use neutron_diffusion_dd::algorithm::{Config, Runner};

let config = Config::new_auto(1e-5, 2000, "data/input.json");
let mut runner = Runner::new(config);
let result = runner.run();
println!("Converged: {}", result.converged);
println!("Iterations: {}", result.iteration);

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.