hummingbird
Solving the self-adjoint angular flux transport equation using spectral elements on Cartesian geometry
Loading...
Searching...
No Matches
hummingbird Namespace Reference

Classes

class  AngularQuadratureSet
 Wrapper class that owns an angular QuadratureBase<Ordinate> of the type corresponding to the given AngularQuadSet. More...
struct  AngularTreatmentParams
 Parameters from the "angular_treatment" section of the input file. More...
class  BankBase
 Base class for banks that store objects of type T by integer ID and look them up by the name given in the JSON input file. More...
class  BCBank
 Bank holding the boundary conditions defined in the input file. More...
class  CGProblem
 Class defining a Continuous Galerkin formulation of the SAAF transport equation. More...
class  ConstantVolumetricSource
 Defines a constant-value, isotropic volumetric source. More...
class  Element
 Defines a subset of the domain (an "element"). More...
class  GaussChebyshev
 Class defines a Gauss-Chebyshev quadrature set, which approximates the integral of the form: More...
class  GaussLegendre
 Defines a Gauss-Legendre quadrature set on the interval [-1,1]. More...
class  GaussLegendreChebyshev
 Class defines a Gauss-Legendre-Chebyshev quadrature set on the unit sphere, where a Gauss-Legendre quadrature set is used along the polar direction, and a Gauss-Chebyshev quadrature set is used along the azimuthal direction. More...
class  GaussLegendreTrapezoid
 Class defines a Gauss-Legendre-Trapezoid rule on the unit sphere, where a Gauss-Legendre rule is used on the polar coordinate, and a trapezoid rule is used on the azimuthal. More...
class  GaussLobattoLegendre
 Class defining a 1D Gauss-Legendre-Lobatto quadrature set on [-1,1]. The quadrature set approximates the integral using a set of weights ( \(w_k\)) and abscissas ( \(\xi_k\)): More...
struct  GlobalForcingData
 Convenience struct for hold the contribution for an entry in a single element to the global forcing vector. More...
struct  GlobalMatrixData
 Convenience struct for holding the contribution for an entry in a single element to the global matrix. More...
struct  InputParams
 All parameters parsed from the input file. More...
struct  Material
 Defines a monoenergetic, constant-properties material. More...
class  MaterialBank
 Bank holding the materials defined in the input file. More...
class  Mesh
 Class defing a mesh. More...
struct  MeshParams
 Parameters from the "mesh" section of the input file. More...
struct  Node
 A point in the mesh holding its coordinates, boundary info, and flux solution values. More...
class  Ordinate
 Defines a solid angle, or ordinate, in spherical geometry. More...
class  ParsedVolumetricSource
 Defines a volumetric source defined by a parsed function passed by the user. More...
class  ProblemBase
 Base class defining a formulation of the transport equation to be solved. More...
struct  ProblemParams
 Parameters from the "problem" section of the input file. More...
class  QuadratureBase
 Base class for defining a quadrature set. More...
struct  QuadraturePair
 Simple struct holding a function value evaluated at the supplied abscissa value. More...
class  Results
 Exports simulation results to a file. More...
class  Segment
 1D line element defined by two boundary nodes, with interior nodes placed at Gauss-Lobatto-Legendre points More...
class  SEMProblem
 Wrapper class that owns a ProblemBase of the type corresponding to the given FEFormulation. More...
struct  Simulation
 Tracks the running state of a simulation across source iterations. More...
class  SourceBank
 Bank holding the volumetric sources defined in the input file. More...
class  SourceBase
 Base class for independent sources. More...
struct  SourceIterationParams
 Parameters from the "source_iteration" section of the input file. More...
struct  SpectralElementParams
 Parameters from the "spectral_elements" section of the input file. More...

Enumerations

enum class  BC { VACUUM , REFLECTIVE , NONE }
 Available boundary conditions. More...
enum class  Boundary { NORTH , SOUTH , EAST , WEST }
 Boundary locations. More...
enum class  SourceType { PARSED_FUNCTION }
 Available volumetric source types. More...
enum class  FEFormulation { CG }
 Available finite element formulations. More...
enum class  TransportForm { SAAF }
 Available forms of the transport equation. More...
enum class  AngularQuadSet { GLT , GL , GLC }
 Angular quadrature set. More...
enum class  RunMode { FIXED_SOURCE }
 Run modes available. More...
enum class  OutputFormat { VTK , CSV }
 Output forms available for export. More...

Functions

void from_json (const json &j, Material &material)
 Get the Material information from the json input.
void from_json (const json &j, ProblemParams &problem_params)
 Retrieve problem params from input.
void from_json (const json &j, MeshParams &mesh_params)
 Retrieve mesh parameters from input.
void from_json (const json &j, AngularTreatmentParams &angular_treatment_params)
 Retrieve the angular treatment params from input.
void from_json (const json &j, SpectralElementParams &se_params)
 Retrieve spectral element params from input.
void from_json (const json &j, SourceIterationParams &source_iter_params)
 Retrieve the source iteration params from input.
void from_json (const json &j, InputParams &input_params)
 Retrieve input parameters from the user.
double LegendrePolynomial (const int n, const double x)
 Computes the Legendre polynomial of degree n at a point x using the formula:
double LegendrePolynomialPrime (const int n, const double x)
 Computes the first derivative of the Legendre polynomial of degree n at a point x using the recurrence relation:
double LegendrePolynomialPrimePrime (const int n, const double x)
 Computes the second derivative of the Legendre polynomial of degree n using Legendre's differential equation:
std::vector< double > AllLegendreRoots (const int n)
 Compute all roots of the Legendre polynomial of order n.
double LegendreRoot (const int n, const int k)
 Computes the k-th root of the n-th order Legendre polynomial by first approximating the root with ApproximateLegendreRoot, then using Newton's method to converge to the root.
double ApproximateLegendreRoot (const int n, const int k)
 Approximates the k-th root of the n-th order Legendre polynomial with:
std::vector< double > AllLegendrePrimeRoots (const int n)
 Computes all roots of the \(P'_n(x)\) polynomial. A total of n-1 roots will be computed and returned.
double LegendrePrimeRoot (const int n, const int k)
 Computes the k-th root of the n-th order first derivative of the Legendre polynomial by first approximating with ApproximateLegendrePrimeRoot, then using Newton's method to converge.
double ApproximateLegendrePrimeRoot (const int n, const int k)
 Approximates the k-th root of the first derivative of the n-th degree Legendre polynomial using the average of the approximations (ApproximateLegendreRoot()) of the surrounding roots of the n-th degree Legendre polynomial. Note that zero-indexing is used, so the roots of the \(P'_4 (x)\) polynomial are \(k=0,1,2\). The approximations of these are given by:
double DistanceBetweenNodes (const Node &node_1, const Node &node_2)
 Compute the Euclidean distance between two nodes.
void UpdateScalarFlux (Node &node, const QuadratureBase< Ordinate > angular_quadrature)
 Update the scalar flux of a node using the angular quadrature set.
std::vector< double > ComputeNodeSourceFluxes (const Node &node, const int material_id, const int source_id, const MaterialBank &material_bank, const SourceBank &source_bank, const QuadratureBase< Ordinate > &angular_quadrature)
 Compute the node source flux values.
void to_json (nlohmann::json &j, const BC &bc)
void from_json (const nlohmann::json &j, BC &bc)
 NLOHMANN_JSON_SERIALIZE_ENUM (FEFormulation, {{FEFormulation::CG, "cg"}})
 NLOHMANN_JSON_SERIALIZE_ENUM (TransportForm, {{TransportForm::SAAF, "saaf"}})
 NLOHMANN_JSON_SERIALIZE_ENUM (AngularQuadSet, {{AngularQuadSet::GLT, "gauss_legendre_trapezoid"}, {AngularQuadSet::GLC, "gauss_legendre_chebyshev"}, {AngularQuadSet::GL, "gauss_legendre"}})
 NLOHMANN_JSON_SERIALIZE_ENUM (RunMode, {{RunMode::FIXED_SOURCE, "fixed_source"}})
 NLOHMANN_JSON_SERIALIZE_ENUM (OutputFormat, {{OutputFormat::CSV, "csv"}, {OutputFormat::VTK, "vtk"}})
json JSONFromFile (const std::string filename)
 Create a json object from a string. Will throw an error if the file could not be opened.
bool DoubleEqual (const double first, const double second, const double tolerance=TOLERANCE)
 Tests if two double-type numbers are equal using the TOLERANCE value. Taken from https://github.com/starling.
double RelativeError (const double new_val, const double old_val)
 Compute the relative error between two values.
void print_header ()
 Print the program banner, description, and license information.
void print_input_files (const std::string input, const std::string mesh)
 Print the paths of the input and mesh files being used.
void print_columns ()
 Print the column headers for the k-eff/scatter iteration status table.
void print_k_status (const double k_eff, const double error, const unsigned int iter)
 Print the k-eff status for the current iteration.
void print_scatter_status (const double flux_l2_error, const double relative_error, const unsigned int iter)
 Print the scalar flux convergence status for the current source iteration.
void print_scatter_complete (const double final_k_eff, const RunMode sim_typ)
 Print a message indicating source iterations have completed.
void print_mesh_info (const size_t n_nodes, const size_t n_elements, const unsigned int dimension)
 Print information about the mesh.

Variables

constexpr double TOLERANCE = 1e-15
 General tolerance value for double comparisons.
constexpr double EXP_NEAR_TOLERANCE = 1e-14
 Tolerance value for EXPECT_NEAR in tests.

Enumeration Type Documentation

◆ AngularQuadSet

enum class hummingbird::AngularQuadSet
strong

Angular quadrature set.

Enumerator
GLT 
GL 
GLC 

Definition at line 79 of file enums.h.

◆ BC

enum class hummingbird::BC
strong

Available boundary conditions.

Enumerator
VACUUM 
REFLECTIVE 
NONE 

Definition at line 16 of file enums.h.

◆ Boundary

enum class hummingbird::Boundary
strong

Boundary locations.

Enumerator
NORTH 
SOUTH 
EAST 
WEST 

Definition at line 51 of file enums.h.

◆ FEFormulation

enum class hummingbird::FEFormulation
strong

Available finite element formulations.

Enumerator
CG 

Definition at line 63 of file enums.h.

◆ OutputFormat

enum class hummingbird::OutputFormat
strong

Output forms available for export.

Enumerator
VTK 
CSV 

Definition at line 99 of file enums.h.

◆ RunMode

enum class hummingbird::RunMode
strong

Run modes available.

Enumerator
FIXED_SOURCE 

Definition at line 90 of file enums.h.

◆ SourceType

enum class hummingbird::SourceType
strong

Available volumetric source types.

Enumerator
PARSED_FUNCTION 

Definition at line 57 of file enums.h.

◆ TransportForm

enum class hummingbird::TransportForm
strong

Available forms of the transport equation.

Enumerator
SAAF 

Definition at line 71 of file enums.h.

Function Documentation

◆ AllLegendrePrimeRoots()

std::vector< double > hummingbird::AllLegendrePrimeRoots ( const int n)

Computes all roots of the \(P'_n(x)\) polynomial. A total of n-1 roots will be computed and returned.

Parameters
nOrder
Returns
std::vector<double>

Definition at line 95 of file legendre_polynomials.cc.

◆ AllLegendreRoots()

std::vector< double > hummingbird::AllLegendreRoots ( const int n)

Compute all roots of the Legendre polynomial of order n.

Parameters
nOrder
Returns
std::vector<double>

Definition at line 61 of file legendre_polynomials.cc.

◆ ApproximateLegendrePrimeRoot()

double hummingbird::ApproximateLegendrePrimeRoot ( const int n,
const int k )

Approximates the k-th root of the first derivative of the n-th degree Legendre polynomial using the average of the approximations (ApproximateLegendreRoot()) of the surrounding roots of the n-th degree Legendre polynomial. Note that zero-indexing is used, so the roots of the \(P'_4 (x)\) polynomial are \(k=0,1,2\). The approximations of these are given by:

\[x_k\approx \frac{1}{2} \left( \cos \left(\frac{4k+3}{4n+2}\pi\right) + \cos \left(\frac{4(k+1)+3}{4n+2}\pi\right) \right) \]

Parameters
nOrder
kRoot number (zero-indexed)
Returns
double

Definition at line 131 of file legendre_polynomials.cc.

◆ ApproximateLegendreRoot()

double hummingbird::ApproximateLegendreRoot ( const int n,
const int k )

Approximates the k-th root of the n-th order Legendre polynomial with:

\[x_k^{(0)}\approx \cos \left(\frac{4k+3}{4n+2}\pi\right) \]

Parameters
nOrder
kRoot number
Returns
double
Exceptions
std::invalid_argumentRoot number must be less than polynomial order

Definition at line 88 of file legendre_polynomials.cc.

◆ ComputeNodeSourceFluxes()

std::vector< double > hummingbird::ComputeNodeSourceFluxes ( const Node & node,
const int material_id,
const int source_id,
const MaterialBank & material_bank,
const SourceBank & source_bank,
const QuadratureBase< Ordinate > & angular_quadrature )

Compute the node source flux values.

Parameters
nodeNode
material_idMaterial ID
source_idSource ID
material_bankMaterial bank
source_bankSource bank
angular_quadratureAngular quadrature set
Returns
std::vector<double>

Definition at line 24 of file node.cc.

◆ DistanceBetweenNodes()

double hummingbird::DistanceBetweenNodes ( const Node & node_1,
const Node & node_2 )

Compute the Euclidean distance between two nodes.

Parameters
node_1First node
node_2Second node
Returns
Distance in units of the mesh

Definition at line 8 of file node.cc.

◆ DoubleEqual()

bool hummingbird::DoubleEqual ( const double first,
const double second,
const double tolerance = TOLERANCE )

Tests if two double-type numbers are equal using the TOLERANCE value. Taken from https://github.com/starling.

Parameters
firstFirst number to compare
secondSecond number to compare
toleranceTolerance for the absolute difference between the first and second values
Returns
true
false

Definition at line 9 of file misc.cc.

◆ from_json() [1/8]

void hummingbird::from_json ( const json & j,
AngularTreatmentParams & angular_treatment_params )

Retrieve the angular treatment params from input.

Parameters
jJSON object built from input file
angular_treatment_paramsAngularTreatmentParams struct

Definition at line 22 of file input_parameters.cc.

◆ from_json() [2/8]

void hummingbird::from_json ( const json & j,
InputParams & input_params )

Retrieve input parameters from the user.

Parameters
jJSON object built from input file
input_paramsInputParams struct

Definition at line 4 of file input_parameters.cc.

◆ from_json() [3/8]

void hummingbird::from_json ( const json & j,
Material & material )

Get the Material information from the json input.

Parameters
jJSON input
materialMaterial struct to populate

Definition at line 4 of file material_bank.cc.

◆ from_json() [4/8]

void hummingbird::from_json ( const json & j,
MeshParams & mesh_params )

Retrieve mesh parameters from input.

Parameters
jJSON object built from input file
mesh_paramsMeshParams struct

Definition at line 18 of file input_parameters.cc.

◆ from_json() [5/8]

void hummingbird::from_json ( const json & j,
ProblemParams & problem_params )

Retrieve problem params from input.

Parameters
jJSON object built from input file
problem_paramsProblemParams struct

Definition at line 12 of file input_parameters.cc.

◆ from_json() [6/8]

void hummingbird::from_json ( const json & j,
SourceIterationParams & source_iter_params )

Retrieve the source iteration params from input.

Parameters
jJSON object built from input file
source_iter_paramsSourceIterationParams struct

Definition at line 45 of file input_parameters.cc.

◆ from_json() [7/8]

void hummingbird::from_json ( const json & j,
SpectralElementParams & se_params )

Retrieve spectral element params from input.

Parameters
jJSON object built from input file
se_paramsSpectralElementParams struct

Definition at line 35 of file input_parameters.cc.

◆ from_json() [8/8]

void hummingbird::from_json ( const nlohmann::json & j,
BC & bc )
inline

Definition at line 36 of file enums.h.

◆ JSONFromFile()

json hummingbird::JSONFromFile ( const std::string filename)

Create a json object from a string. Will throw an error if the file could not be opened.

Parameters
filenameFile name (relative path) to be opened
Returns
json

Definition at line 11 of file json.cc.

◆ LegendrePolynomial()

double hummingbird::LegendrePolynomial ( const int n,
const double x )

Computes the Legendre polynomial of degree n at a point x using the formula:

\[P_{n+1}(x)=\frac{(2n+1)xP_{n}(x)-nP_{n-1}(x)}{n+1} \]

with:

\[P_0=1,\quad P_1=x \]

The above is implemented to evaluate the n-th order Legendre polynomial by building from the bottom up, as opposed to using a recursion relation. This greatly improves the evaluation speed. This algorithm was taken from https://github.com/CambridgeUniversityPress/NumericalMethodsPhysicsWithPython/blob/master/second_edition/codes/legendre.py written by Alex Gezerlis for his book, Numerical Methods in Physics With Python, Second Edition.

Legendre polynomials are defined on the interval \(x\in [-1,1]\).

Parameters
nOrder of polynomial to evaluate
xPoint to evaluate at
Returns
double

Definition at line 14 of file legendre_polynomials.cc.

◆ LegendrePolynomialPrime()

double hummingbird::LegendrePolynomialPrime ( const int n,
const double x )

Computes the first derivative of the Legendre polynomial of degree n at a point x using the recurrence relation:

\[P'_n (x)=\frac{nP_{n-1}(x)-nxP_n(x)}{1-x^2} \]

The value of the derivative at the bounds is special:

\[P'_n(x)=\begin{cases} (-1)^{n-1}\frac{n(n+1)}{2} & x=-1 \\ \frac{n(n+1)}{2} &x=1 \end{cases} \]

Parameters
nOrder of polynomial
xPoint to evaluate at
Returns
double

Definition at line 35 of file legendre_polynomials.cc.

◆ LegendrePolynomialPrimePrime()

double hummingbird::LegendrePolynomialPrimePrime ( const int n,
const double x )

Computes the second derivative of the Legendre polynomial of degree n using Legendre's differential equation:

\[(1-x^2)P_n''(x)-2xP_n'(x)+n(n+1)P_n(x)=0 \]

Parameters
nOrder
xLocation to evaluate at
Returns
double

Definition at line 55 of file legendre_polynomials.cc.

◆ LegendrePrimeRoot()

double hummingbird::LegendrePrimeRoot ( const int n,
const int k )

Computes the k-th root of the n-th order first derivative of the Legendre polynomial by first approximating with ApproximateLegendrePrimeRoot, then using Newton's method to converge.

Parameters
nOrder
kRoot number
Returns
double

Definition at line 107 of file legendre_polynomials.cc.

◆ LegendreRoot()

double hummingbird::LegendreRoot ( const int n,
const int k )

Computes the k-th root of the n-th order Legendre polynomial by first approximating the root with ApproximateLegendreRoot, then using Newton's method to converge to the root.

Parameters
nOrder of the polynomial
kRoot to find
Returns
double

Definition at line 73 of file legendre_polynomials.cc.

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [1/5]

hummingbird::NLOHMANN_JSON_SERIALIZE_ENUM ( AngularQuadSet ,
{{AngularQuadSet::GLT, "gauss_legendre_trapezoid"}, {AngularQuadSet::GLC, "gauss_legendre_chebyshev"}, {AngularQuadSet::GL, "gauss_legendre"}}  )

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [2/5]

hummingbird::NLOHMANN_JSON_SERIALIZE_ENUM ( FEFormulation ,
{{FEFormulation::CG, "cg"}}  )

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [3/5]

hummingbird::NLOHMANN_JSON_SERIALIZE_ENUM ( OutputFormat ,
{{OutputFormat::CSV, "csv"}, {OutputFormat::VTK, "vtk"}}  )

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [4/5]

hummingbird::NLOHMANN_JSON_SERIALIZE_ENUM ( RunMode ,
{{RunMode::FIXED_SOURCE, "fixed_source"}}  )

◆ NLOHMANN_JSON_SERIALIZE_ENUM() [5/5]

hummingbird::NLOHMANN_JSON_SERIALIZE_ENUM ( TransportForm ,
{{TransportForm::SAAF, "saaf"}}  )

◆ print_columns()

void hummingbird::print_columns ( )

Print the column headers for the k-eff/scatter iteration status table.

Definition at line 23 of file output.cc.

◆ print_header()

void hummingbird::print_header ( )

Print the program banner, description, and license information.

Definition at line 6 of file output.cc.

◆ print_input_files()

void hummingbird::print_input_files ( const std::string input,
const std::string mesh )

Print the paths of the input and mesh files being used.

Parameters
inputPath to the input file
meshPath to the mesh file

Definition at line 30 of file output.cc.

◆ print_k_status()

void hummingbird::print_k_status ( const double k_eff,
const double error,
const unsigned int iter )

Print the k-eff status for the current iteration.

Parameters
k_effCurrent k-eff value
errorRelative error in k-eff from the previous iteration
iterIteration number

Definition at line 35 of file output.cc.

◆ print_mesh_info()

void hummingbird::print_mesh_info ( const size_t n_nodes,
const size_t n_elements,
const unsigned int dimension )

Print information about the mesh.

Parameters
n_nodesNumber of nodes in mesh
n_elementsNumber of elements in mesh
dimensionMesh dimension

Definition at line 66 of file output.cc.

◆ print_scatter_complete()

void hummingbird::print_scatter_complete ( const double final_k_eff,
const RunMode sim_typ )

Print a message indicating source iterations have completed.

Parameters
final_k_effFinal k-eff value
sim_typRun mode used for the simulation

Definition at line 58 of file output.cc.

◆ print_scatter_status()

void hummingbird::print_scatter_status ( const double flux_l2_error,
const double relative_error,
const unsigned int iter )

Print the scalar flux convergence status for the current source iteration.

Parameters
flux_l2_errorL2 norm of the change in scalar flux from the previous iteration
relative_errorRelative L2 error in the scalar flux (flux_l2_error normalized by the current iteration's flux L2 norm)
iterIteration number

Definition at line 43 of file output.cc.

◆ RelativeError()

double hummingbird::RelativeError ( const double new_val,
const double old_val )

Compute the relative error between two values.

Parameters
new_valNew value
old_valOld value
Returns
double

Definition at line 15 of file misc.cc.

◆ to_json()

void hummingbird::to_json ( nlohmann::json & j,
const BC & bc )
inline

Definition at line 22 of file enums.h.

◆ UpdateScalarFlux()

void hummingbird::UpdateScalarFlux ( Node & node,
const QuadratureBase< Ordinate > angular_quadrature )

Update the scalar flux of a node using the angular quadrature set.

Parameters
nodeNode to update
angular_quadratureAngular quadrature set

Definition at line 15 of file node.cc.

Variable Documentation

◆ EXP_NEAR_TOLERANCE

double hummingbird::EXP_NEAR_TOLERANCE = 1e-14
constexpr

Tolerance value for EXPECT_NEAR in tests.

Definition at line 13 of file constants.h.

◆ TOLERANCE

double hummingbird::TOLERANCE = 1e-15
constexpr

General tolerance value for double comparisons.

Definition at line 10 of file constants.h.