An open source method of characteristics neutron transport code.
|
A class for Coarse Mesh Finite Difference (CMFD) acceleration. More...
#include "src/Cmfd.h"
Public Member Functions | |
Cmfd () | |
Constructor initializes boundaries and variables that describe the CMFD object. More... | |
virtual | ~Cmfd () |
Destructor deletes arrays of A and M row insertion arrays. | |
double | computeKeff (int moc_iteration) |
Solve the nonlinear diffusion acceleration problem to accelerate the convergence of the MOC problem. More... | |
void | initialize () |
Initialize the Matrix and Vector objects, k-nearest stencils, the CMFD cell currents and MOC materials. | |
void | initializeCellMap () |
Initializes the vector of vectors that links CMFD cells with FSRs. More... | |
void | initializeGroupMap () |
Initialize and set array that links the MOC energy groups to the CMFD energy groups. More... | |
void | allocateTallies () |
Allocates memory for the CMFD tallies. More... | |
void | initializeLattice (Point *offset, bool is_2D=false) |
Initialize the CMFD lattice and compute mesh dimensions, considering both uniform/non-uniform and 2D/3D cases. More... | |
void | initializeBackupCmfdSolver () |
Initializes a backup CMFD solver. More... | |
void | copyCurrentsToBackup () |
Copies the current from the regular to the backup CMFD solver. More... | |
int | findCmfdCell (LocalCoords *coords) |
Find the CMFD cell that a LocalCoords object is in. More... | |
int | findCmfdSurface (int cell_id, LocalCoords *coords) |
Find the CMFD surface that a LocalCoords object lies on. More... | |
int | findCmfdSurfaceOTF (int cell_id, double z, int surface_2D) |
Quickly finds a 3D CMFD surface given a cell, global coordinate, and 2D CMFD surface. Intended for use in axial on-the-fly ray tracing. More... | |
void | addFSRToCell (int cell_id, long fsr_id) |
Add an FSR ID to a vector that contains all the FSR IDs contained within a CMFD mesh cell. More... | |
void | zeroCurrents () |
Zero the surface currents for each mesh cell and energy group. | |
void | tallyCurrent (segment *curr_segment, float *track_flux, int azim_index, int polar_index, bool fwd) |
Tallies the current contribution from this segment across the the appropriate CMFD mesh cell surface. More... | |
void | tallyStartingCurrent (Point *point, double delta_x, double delta_y, double delta_z, float *track_flux, double weight) |
This function tallies the current impinging on the domain from starting fluxes. More... | |
void | recordNetCurrents () |
Records net currents (leakage) on every CMFD cell for every group. | |
void | printInputParamsSummary () |
A function that prints a summary of the CMFD input parameters. | |
void | printTimerReport () |
Report the physical time use by major components of the CMFD solver. | |
void | checkBalance () |
Forces CMFD to check neutron balance on every solve. | |
int | getNumCmfdGroups () |
Get the number of coarse CMFD energy groups. More... | |
int | getNumMOCGroups () |
Get the number of MOC energy groups. More... | |
int | getNumCells () |
Get the number of CMFD cells. More... | |
int | getCmfdGroup (int group) |
Get the CMFD group given an MOC group. More... | |
int | getBoundary (int side) |
Get the boundaryType for one side of the CMFD mesh. More... | |
Lattice * | getLattice () |
Returns the Lattice object used as the CMFD mesh. More... | |
int | getNumX () |
Get the number of Mesh cells in a row. More... | |
int | getNumY () |
Get the number of Mesh cells in a column. More... | |
int | getNumZ () |
Get the number of Mesh cells in the z-direction. More... | |
Vector * | getLocalCurrents () |
Get the Vector of surface currents. More... | |
CMFD_PRECISION *** | getBoundarySurfaceCurrents () |
Get the array of surface currents on the boundaries. More... | |
int | convertFSRIdToCmfdCell (long fsr_id) |
Return the CMFD cell ID that a FSR lies in. More... | |
int | convertGlobalFSRIdToCmfdCell (long global_fsr_id) |
Return the CMFD cell ID that a FSR lies in. More... | |
std::vector< std::vector< long > > * | getCellFSRs () |
Return a pointer to the vector of vectors that contains the FSRs that lie in each cell. More... | |
bool | isFluxUpdateOn () |
Get flag indicating whether to update the MOC flux. More... | |
bool | isCentroidUpdateOn () |
Get flag indicating whether to use FSR centroids to update the MOC flux. More... | |
bool | isSigmaTRebalanceOn () |
Returns a flag indicating whether the sigma-t rebalance is on. More... | |
void | setSORRelaxationFactor (double SOR_factor) |
Set successive over-relaxation relaxation factor. More... | |
void | setCMFDRelaxationFactor (double relaxation_factor) |
Set the CMFD relaxation factor applied to diffusion coefficients. More... | |
void | setGeometry (Geometry *geometry) |
Set a pointer to the Geometry. More... | |
void | setWidthX (double width) |
Set Mesh width in the x-direction. More... | |
void | setWidthY (double width) |
Set Mesh width in the y-direction. More... | |
void | setWidthZ (double width) |
Set Mesh width in the z-direction. More... | |
void | setNumX (int num_x) |
Set the number of Mesh cells in a row. More... | |
void | setNumY (int num_y) |
Set the number of Mesh cells in a column. More... | |
void | setNumZ (int num_z) |
Set the number of Mesh cells in the z-direction. More... | |
void | setNumFSRs (long num_fsrs) |
set the number of FSRs. More... | |
void | setNumMOCGroups (int num_moc_groups) |
Set the number of MOC energy groups. More... | |
void | setBoundary (int side, boundaryType boundary) |
Set the CMFD boundary type for a given surface. More... | |
void | setLatticeStructure (int num_x, int num_y, int num_z=1) |
The structure of the Lattice to be used as the CMFD mesh. More... | |
void | setFluxUpdateOn (bool flux_update_on) |
Set flag indicating whether to update the MOC flux. More... | |
void | setCentroidUpdateOn (bool centroid_update_on) |
Set flag indicating whether to use FSR centroids to update the MOC flux. More... | |
void | setGroupStructure (std::vector< std::vector< int > > group_indices) |
Set a coarse energy group structure for CMFD. More... | |
void | setSourceConvergenceThreshold (double source_thresh) |
Sets the threshold for CMFD source convergence (>0). More... | |
void | setQuadrature (Quadrature *quadrature) |
Sets the Quadrature object in use by the MOC Solver. More... | |
void | setKNearest (int k_nearest) |
Set a number of k-nearest neighbor cells to use in updating the FSR flux. More... | |
void | setSolve3D (bool solve_3d) |
Sets a flag to indicate whether a 2D or 3D problem is being solved. More... | |
void | setAzimSpacings (const std::vector< double > &azim_spacings, int num_azim) |
Sets the azimuthal spacings. More... | |
void | setPolarSpacings (const std::vector< std::vector< double > > &polar_spacings, int num_azim, int num_polar) |
Sets the polar spacings. More... | |
void | setKeff (double k_eff) |
Set the value of the k effective for the CMFD solver. This is meant for research / debugging purposes. More... | |
void | setBackupGroupStructure (std::vector< std::vector< int > > group_indices) |
Set the backup CMFD solver's group structure. It is necessarily coarser than and must align with the regular CMFD group structure. More... | |
void | setConvergenceData (ConvergenceData *convergence_data) |
Sets the a ConvergenceData object to record diagnostics. More... | |
void | useAxialInterpolation (int interpolate) |
Set the flag indicating whether to use quadratic axial interpolation for update ratios. More... | |
void | useFluxLimiting (bool flux_limiting) |
Turns on the flux limiting condition. More... | |
void | enforceBalanceOnDiagonal (int cmfd_cell, int group) |
Modifies the diagonal element to be consistent with the MOC solve. More... | |
void | rebalanceSigmaT (bool balance_sigma_t) |
Rebalances the total cross section to be consistent with the MOC solution on every sweep. More... | |
void | setFSRMaterials (Material **FSR_materials) |
Set the FSR materials array pointer. More... | |
void | setFSRVolumes (FP_PRECISION *FSR_volumes) |
Set the pointer to the array of FSR_volumes. More... | |
void | setFSRFluxes (FP_PRECISION *scalar_flux) |
Set pointer to FSR flux array. More... | |
void | setFSRSources (FP_PRECISION *sources) |
Set pointer to FSR source array. More... | |
void | setCellFSRs (std::vector< std::vector< long > > *cell_fsrs) |
Set the vector of vectors that contains the FSRs that lie in each cell. More... | |
void | setFluxMoments (FP_PRECISION *flux_moments) |
Set pointer to source region flux moments array. More... | |
void | setWidths (std::vector< std::vector< double > > widths) |
Set width of non-uniform meshes in x y z directions. More... | |
void | printCmfdCellSizes () |
Print information about CMFD cell dimensions. More... | |
A class for Coarse Mesh Finite Difference (CMFD) acceleration.
Cmfd::Cmfd | ( | ) |
Constructor initializes boundaries and variables that describe the CMFD object.
The constructor initializes the many variables that describe the CMFD mesh and are used to solve the nonlinear diffusion acceleration problem.
void Cmfd::addFSRToCell | ( | int | cmfd_cell, |
long | fsr_id | ||
) |
Add an FSR ID to a vector that contains all the FSR IDs contained within a CMFD mesh cell.
cmfd_cell | the CMFD cell ID. |
fsr_id | the FSR ID. |
void Cmfd::allocateTallies | ( | ) |
Allocates memory for the CMFD tallies.
This method is called by the CMFD initialization routine, and allocates memory for the diffusion, reaction and volume tallies for every CMFD cells.
double Cmfd::computeKeff | ( | int | moc_iteration | ) |
Solve the nonlinear diffusion acceleration problem to accelerate the convergence of the MOC problem.
This method uses the information from the last MOC transport sweep and solves a simplified nonlinear diffusion problem. The diffusion problem is tightly converged and the solution is used to update the the solution of the MOC problem.
moc_iteration | MOC iteration number |
int Cmfd::convertFSRIdToCmfdCell | ( | long | fsr_id | ) |
Return the CMFD cell ID that a FSR lies in.
Note that a CMFD cell is not an actual Cell object; rather, a CMFD cell is just a way of describing each of the rectangular regions that make up a CMFD lattice. CMFD cells are numbered with 0 in the lower left corner and monotonically increasing from left to right, from bottom to top. For example, the indices for a 4 x 4 lattice are: 12 13 14 15 8 9 10 11 4 5 6 7 0 1 2 3
fsr_id | the FSR ID. |
int Cmfd::convertGlobalFSRIdToCmfdCell | ( | long | global_fsr_id | ) |
Return the CMFD cell ID that a FSR lies in.
global_fsr_id | The global FSR ID. |
void Cmfd::copyCurrentsToBackup | ( | ) |
Copies the current from the regular to the backup CMFD solver.
The currents are condensed to the backup solver's energy structure when transfered as well.
void Cmfd::enforceBalanceOnDiagonal | ( | int | cmfd_cell, |
int | group | ||
) |
Modifies the diagonal element to be consistent with the MOC solve.
This function re-computes a new total cross-section x volume that maintains consistency with the MOC solution. Generally, this will not change the diagonal element at all since CMFD should be consistent with MOC. However, if negative fluxes are corrected to zero after the MOC transport sweep, there will be an inconsistency. This function modifies sigma-t so that there is consistency with the altered solution.
cmfd_cell | The cmfd cell of the element to adjust |
group | The cmfd group of the element to adjust |
int Cmfd::findCmfdCell | ( | LocalCoords * | coords | ) |
Find the CMFD cell that a LocalCoords object is in.
coords | the coords being evaluated. |
int Cmfd::findCmfdSurface | ( | int | cell, |
LocalCoords * | coords | ||
) |
Find the CMFD surface that a LocalCoords object lies on.
If the coords is not on a surface, -1 is returned. Otherwise, the surface ID is returned.
cell | the CMFD cell ID that the local coords is in. |
coords | the coords being evaluated. |
|
inline |
Quickly finds a 3D CMFD surface given a cell, global coordinate, and 2D CMFD surface. Intended for use in axial on-the-fly ray tracing.
If the coords is not on a surface, -1 is returned. If there is no 2D CMFD surface intersection, -1 should be input for the 2D CMFD surface.
cell_id | The CMFD cell ID that the local coords is in. |
z | the axial height in the root universe of the point being evaluated. |
surface_2D | The ID of the 2D CMFD surface that the LocalCoords object intersects. If there is no 2D intersection, -1 should be input. |
int Cmfd::getBoundary | ( | int | side | ) |
Get the boundaryType for one side of the CMFD mesh.
side | the CMFD mesh surface ID. |
CMFD_PRECISION *** Cmfd::getBoundarySurfaceCurrents | ( | ) |
Get the array of surface currents on the boundaries.
std::vector< std::vector< long > > * Cmfd::getCellFSRs | ( | ) |
Return a pointer to the vector of vectors that contains the FSRs that lie in each cell.
|
inline |
Get the CMFD group given an MOC group.
group | the MOC energy group |
Lattice * Cmfd::getLattice | ( | ) |
Vector * Cmfd::getLocalCurrents | ( | ) |
Get the Vector of surface currents.
int Cmfd::getNumCells | ( | ) |
Get the number of CMFD cells.
int Cmfd::getNumCmfdGroups | ( | ) |
Get the number of coarse CMFD energy groups.
int Cmfd::getNumMOCGroups | ( | ) |
Get the number of MOC energy groups.
int Cmfd::getNumY | ( | ) |
int Cmfd::getNumZ | ( | ) |
void Cmfd::initializeBackupCmfdSolver | ( | ) |
Initializes a backup CMFD solver.
This backup solver is not necessary to run simulations, but may be used if the regular solver fails and the user wants to try another group structure without restarting the simulation.
void Cmfd::initializeCellMap | ( | ) |
Initializes the vector of vectors that links CMFD cells with FSRs.
This method is called by the geometry once the CMFD mesh has been initialized by the geometry. This method allocates a vector for each CMFD cell that is used to store the FSR ids contained within that cell.
void Cmfd::initializeGroupMap | ( | ) |
Initialize and set array that links the MOC energy groups to the CMFD energy groups.
This method initializes the _group_indices_map, which is a 1D array of length _num_moc_groups that maps the MOC energy groups to CMFD energy groups. The indices into _group_indices_map are the MOC energy groups and the values are the CMFD energy groups.
void Cmfd::initializeLattice | ( | Point * | offset, |
bool | is_2D = false |
||
) |
Initialize the CMFD lattice and compute mesh dimensions, considering both uniform/non-uniform and 2D/3D cases.
offset | the offset point of the CMFD Lattice |
is_2D | whether CMFD will be used in a 2D simulation (true) or 3D |
bool Cmfd::isCentroidUpdateOn | ( | ) |
Get flag indicating whether to use FSR centroids to update the MOC flux.
bool Cmfd::isFluxUpdateOn | ( | ) |
Get flag indicating whether to update the MOC flux.
bool Cmfd::isSigmaTRebalanceOn | ( | ) |
Returns a flag indicating whether the sigma-t rebalance is on.
void Cmfd::printCmfdCellSizes | ( | ) |
Print information about CMFD cell dimensions.
For debug use.
void Cmfd::rebalanceSigmaT | ( | bool | balance_sigma_t | ) |
Rebalances the total cross section to be consistent with the MOC solution on every sweep.
balance_sigma_t | Wheter to compute the rebalanced total cross-section |
void Cmfd::setAzimSpacings | ( | const std::vector< double > & | azim_spacings, |
int | num_azim | ||
) |
Sets the azimuthal spacings.
azim_spacings | An array of azimuthal spacings for each azimuthal angle. |
num_azim | the number of azimuthal angles. |
void Cmfd::setBackupGroupStructure | ( | std::vector< std::vector< int > > | group_indices | ) |
Set the backup CMFD solver's group structure. It is necessarily coarser than and must align with the regular CMFD group structure.
group_indices | the indices of the CMFD groups in the MOC groups |
void Cmfd::setBoundary | ( | int | side, |
boundaryType | boundary | ||
) |
Set the CMFD boundary type for a given surface.
The CMFD boundary is assumed to be rectangular with the surfaces identified by constants in the constants.h file.
side | The CMFD surface UID. |
boundary | The boundaryType of the surface. |
void Cmfd::setCellFSRs | ( | std::vector< std::vector< long > > * | cell_fsrs | ) |
Set the vector of vectors that contains the FSRs that lie in each cell.
cell_fsrs | vector of vectors containing FSR IDs in each cell. |
void Cmfd::setCentroidUpdateOn | ( | bool | centroid_update_on | ) |
Set flag indicating whether to use FSR centroids to update the MOC flux.
centroid_update_on | Flag saying whether to use centroids to update MOC flux |
void Cmfd::setCMFDRelaxationFactor | ( | double | relaxation_factor | ) |
Set the CMFD relaxation factor applied to diffusion coefficients.
relaxation_factor | CMFD relaxation factor |
void Cmfd::setConvergenceData | ( | ConvergenceData * | convergence_data | ) |
Sets the a ConvergenceData object to record diagnostics.
The ConvergenceData object records the number of fission source and flux iterations for the CMFD solver as well as the maximum magnitude prolongation factor
convergence_data | The convergence data object |
void Cmfd::setFluxMoments | ( | FP_PRECISION * | flux_moments | ) |
Set pointer to source region flux moments array.
flux_moments | pointer to source region flux moments array |
void Cmfd::setFluxUpdateOn | ( | bool | flux_update_on | ) |
Set flag indicating whether to update the MOC flux.
flux_update_on | Flag saying whether to update MOC flux. |
void Cmfd::setFSRFluxes | ( | FP_PRECISION * | scalar_flux | ) |
Set pointer to FSR flux array.
scalar_flux | pointer to FSR flux array |
void Cmfd::setFSRMaterials | ( | Material ** | FSR_materials | ) |
Set the FSR materials array pointer.
FSR_materials | pointer to FSR_materials array |
void Cmfd::setFSRSources | ( | FP_PRECISION * | sources | ) |
Set pointer to FSR source array.
sources | pointer to FSR source array |
void Cmfd::setFSRVolumes | ( | FP_PRECISION * | FSR_volumes | ) |
Set the pointer to the array of FSR_volumes.
FSR_volumes | array of FSR volumes |
void Cmfd::setGeometry | ( | Geometry * | geometry | ) |
void Cmfd::setGroupStructure | ( | std::vector< std::vector< int > > | group_indices | ) |
Set a coarse energy group structure for CMFD.
CMFD does not necessarily need to have the same energy group structure as the MOC problem. This function can be used to set a sparse energy group structure to speed up the CMFD solve. An example of how this may be called from Python to use a coarse 2-group CMFD structure atop a fine 7-group MOC structure is illustrated below:
group_indices | A nested vector of MOC-to-CMFD group mapping |
void Cmfd::setKeff | ( | double | k_eff | ) |
Set the value of the k effective for the CMFD solver. This is meant for research / debugging purposes.
k_eff | the k_eff value to set. |
void Cmfd::setKNearest | ( | int | k_nearest | ) |
Set a number of k-nearest neighbor cells to use in updating the FSR flux.
k_nearest | The number of nearest neighbor CMFD cells. |
void Cmfd::setLatticeStructure | ( | int | num_x, |
int | num_y, | ||
int | num_z = 1 |
||
) |
The structure of the Lattice to be used as the CMFD mesh.
num_x | The number of cells in the x direction. |
num_y | The number of cells in the y direction. |
num_z | The number of cells in the z direction. |
void Cmfd::setNumFSRs | ( | long | num_fsrs | ) |
set the number of FSRs.
num_fsrs | the number of FSRs |
void Cmfd::setNumMOCGroups | ( | int | num_groups | ) |
Set the number of MOC energy groups.
num_groups | number of MOC energy groups |
void Cmfd::setNumX | ( | int | num_x | ) |
void Cmfd::setNumY | ( | int | num_y | ) |
void Cmfd::setNumZ | ( | int | num_z | ) |
void Cmfd::setPolarSpacings | ( | const std::vector< std::vector< double > > & | polar_spacings, |
int | num_azim, | ||
int | num_polar | ||
) |
Sets the polar spacings.
polar_spacings | A 2D array of polar spacings for each azimuthal and polar angle combination. |
num_azim | the number of azimuthal angles. |
num_polar | the number of polar angles. |
void Cmfd::setQuadrature | ( | Quadrature * | quadrature | ) |
Sets the Quadrature object in use by the MOC Solver.
quadrature | a Quadrature object pointer from the Solver |
void Cmfd::setSolve3D | ( | bool | solve_3D | ) |
Sets a flag to indicate whether a 2D or 3D problem is being solved.
solve_3D | A boolean indicate whether a 2D or 3D problem is being solved. |
void Cmfd::setSORRelaxationFactor | ( | double | SOR_factor | ) |
Set successive over-relaxation relaxation factor.
SOR_factor | over-relaxation factor |
void Cmfd::setSourceConvergenceThreshold | ( | double | source_thresh | ) |
Sets the threshold for CMFD source convergence (>0).
source_thresh | the threshold for source convergence |
void Cmfd::setWidths | ( | std::vector< std::vector< double > > | widths | ) |
Set width of non-uniform meshes in x y z directions.
An example of how this may be called from Python illustrated below:
widths | A vector of 3 vectors for the x y z sizes of non-uniform meshes |
void Cmfd::setWidthX | ( | double | width | ) |
void Cmfd::setWidthY | ( | double | width | ) |
void Cmfd::setWidthZ | ( | double | width | ) |
|
inline |
Tallies the current contribution from this segment across the the appropriate CMFD mesh cell surface.
curr_segment | the current Track segment |
track_flux | the outgoing angular flux for this segment |
azim_index | azimuthal index of track angle |
polar_index | polar index of track angle |
fwd | boolean indicating direction of integration along segment |
void Cmfd::tallyStartingCurrent | ( | Point * | point, |
double | delta_x, | ||
double | delta_y, | ||
double | delta_z, | ||
float * | track_flux, | ||
double | weight | ||
) |
This function tallies the current impinging on the domain from starting fluxes.
Incoming currents are tallied for use in diagnostics, debugging, and adjusting sigma-t to enforce consistency with the MOC solution, if requested
point | The point where the fluxes enter the geometry |
delta_x | The a small x-nudge in the direction of travel |
delta_y | The a small y-nudge in the direction of travel |
delta_z | The a small z-nudge in the direction of travel |
track_flux | The angular fluxes impinging on the domain |
weight | The weight of the Track |
void Cmfd::useAxialInterpolation | ( | int | interpolate | ) |
Set the flag indicating whether to use quadratic axial interpolation for update ratios.
interpolate | flag meaning No interpolation(0), FSR axially averaged value(1) or centroid z-coordinate evaluated value(2) |
void Cmfd::useFluxLimiting | ( | bool | flux_limiting | ) |
Turns on the flux limiting condition.
If the CMFD correction diffusion coefficient is larger than the diffusion coefficient, recompute the diffusion coefficient as the ratio of current to twice the flux, and re-compute a correction diffusion coefficient.
flux_limiting | whether to turn on the flux limiting condition |