C++ code for 1D (slab and spherical) solution of neutron transport equation using diamond differencing, using Diffusion Synthetic Acceleration
Uses architecture from hankyleh/SN2D.
- Code skeleton and input specifications written
- Add necessary data types
- Add input file parsing
- Add time-dependent cross sections options (via python definition) -- maybe
- Add BC options (reflected, incoming flux)
- Add DD kernel and sweep functions
- Add adjoint problem
- Add parameters, solution, residual, and iteration summary output options
- Add fission deposition (W) to input
- Add cumulative fission deposition to output
- Create python scripts for data processing (write input, read+plot output)
- Add DSA
- Add time-differencing (Crank-Nicholson and Backward Euler) with constant step size
- Add partisn-style (increasing step size) differencing
- Add time-step summary output file, modify iter. summ. output to include all time steps
Input files are plaintext formatted, and may have any extension, except .out, which is reserved for the output file.
Comments are denoted by # and !: all characters after the first instance of # or before the final instance of ! are ignored by the input parser, e.g.
no. of cells ! 5
Cell widths ! 0.1 0.1 0.1 0.05 0.05 # narrow cells in moderator region
The input file (besides comments) contains only the numeric data or the case-sensitive keyword(s):
READ: copies the contents of the file at the proceeding path into the input file at this location. Useful for running multiple meshes with a single set of material data, etc. For example,READ lwr_materials.txt.
The parser does not recognize line breaks in the main content of the file, so
# Cross sections:
1.2e-3 0.00 1e-4
4.0e-3 2.0e-4 1.0e-4
1.2e-3 0.00 1e-4 4.0e-3
2.0e-4 1.0e-4
1.2e-3 0.00 1e-4 4.0e-3 2.0e-4 1.0e-4
will all be interepreted the same way by the parser. This is useful for large meshes or scattering matrices which may be broken into multiple lines if needed.
Numeric data may be entered in decimal or E-notation using either capital E or lowercase e. Positive values may optionally include +. The following are all valid entries:
1.2e-3-0.234.4E+1+1.2
The input file is separated into sections, separted by case-sensitive headers. The sections required for all problem types are:
- Problem Parameters -- note this section does not have a header
MESH: Spatial MeshQUAD: Angular QuadratureMATS: Material specificationREGION: Cell layoutBCS: Boundary conditions
Time-dependent problems should contain the additional section:
TIME: Time discretization
This section contains general problem parameters that are read before any of the rest of the input. It should contain the following content:
| Name | Details | Syntax |
|---|---|---|
| Case title | Must be unique (output files with the same name will be over-written) | Stem only, no spaces, must be valid for a file name (e.g. lwr_2group'). May not use the section header keywords (MESH, MATS, etc.) |
| Problem type |
0 - Criticality calculation1 - Steady-state2 -Time-dependent |
Integer 0-2 |
| 1D geometry type |
0 - 1D slab1 - 1D sphere |
Integer 0-1 |
| Acceleration on/off |
0 - No acceleration1 - DSA |
Integer 0-1 |
| Problem direction |
0 - Forward1 - ADjoint |
Integer 0-1 |
| Inner, Outer convergence tolerance | Relative tolerance for inner and outer iterations. | 2 floats, must be |
| Inner, Outer maximum iterations | Maximum allowed inner and outer iterations. | 2 integers, must be |
The number of cells (I) and their widths in the mesh. For example,
10
0.1 0.1 0.1 0.1 0.1 0.1
0.2 0.2 0.2 0.2
I must be an integer I positive double-precision floats.
These widths are
The number of quadrature cosines and their weights. For example,
8
-0.9602898 0.101228
-0.7966664 0.222381
-0.5255324 0.313706
-0.1834346 0.362683
0.1834346 0.362683
0.5255324 0.313706
0.7966664 0.222381
0.9602898 0.101228
The first entry is M, the total number of quadrature cosines.
There should be M pairs of values, each corresponding to a cosine and weight pairmu_m, w_m. The cosines must be ascending and be
There must be an equal number of positive and negative quadrature points. If reflective boundary conditions (or 1D spherical geometry) are used, the set must be symmtric.
The first three values in this section are discretization details:
| Name | Syntax |
|---|---|
| Number of materials | Integer $\geq$1 |
G, Number of energy groups |
Integer $\geq$1 |
L, maximum Legendre moment of scattering xs |
Integer $\geq$0 |
This is then followed by the cross section values for each material, starting with total and fission cross sections.
-
$\sigma_{t, g}$ , total cross section -
$\overline{\nu}\sigma_{f, g}$ , fission production cross section times multiplicity -
$\sigma_{f, g}$ , fission cross section
For example,
# Material 1
# total nu*fission fission # Group
1.2e-3 0.00 1e-4 # 1
4.0e-3 2.0e-4 1.0e-4 # 2
This is then followed by the scattering matrices, one
# zeroth moment
1.0e-4 4.1e-5 # 1->g
0.0 6.0e-4 # 2->g
# first moment:
1.0e-8 1.0e-8
0.0 1.0e-6
This section contains two sets of values. First is the material arrangement, which should contain I integers, up to the number of specified materials. For example,
1 1 1 1 1 1 2 2 2 2
Next is the source specification -- note that the units are str$^{-1}$cm$^{-2}$s$^{-1}$, and is considered to be isotropic. There should be
0.10 0.10 0.10 0.10 0.10 0.10 0.0 0.0 0.0 0.0
0.01 0.01 0.01 0.01 0.01 0.01 0.0 0.0 0.0 0.0
Note that source entries will be ignored and set to zero for criticality calculations.
Three types of boundary conditions are supported; vacuum, incoming flux, and reflective.
The first entry of this section should be two integers, corresponding with the left and right boundary conditions. Note that for spherical boundary conditions, the left entry will be ignored.
The conditions are
0- vacuum1- incoming flux2- reflective
For example,
2 1
which corresponds with a reflective left boundary and an incoming-flux right boundary.
If incoming flux is specified for either boundary, they should be provided. For each incoming-flux boundary,
0.01 0.02
0.01 0.02
0.01 0.02
0.01 0.02
The rows should be ordered such that the corresponding cosines are ascending.
Note that incoming flux conditions will be forced to vacuum for criticality calculations.
TODO
This file can be found at examples/steady/.
# SN1D example input file
# --------------------------------------------
# ---------- Problem Parameters --------------
# --------------------------------------------
example_steady
1 # steady-state solve
0 # 1D slab geometry
0 # DSA off
0 # forward solve
1e-5 1e-7 # Inner, outer tolerance
100 200 # inner, outer max. iterations
# --------------------------------------------
# -------------- Spatial mesh ----------------
# --------------------------------------------
# Number of cells
10
# Cell widhts
0.1 0.1 0.1 0.1 0.1
0.1 0.2 0.2 0.2 0.2
# --------------------------------------------
# ----------- Angular Quadrature -------------
# --------------------------------------------
# Number of quadrature angles
8
# quadrature nodes and weights
-0.7966664 0.222381
-0.5255324 0.313706
-0.1834346 0.362683
0.1834346 0.362683
0.5255324 0.313706
0.7966664 0.222381
0.9602898 0.101228
# --------------------------------------------
# ---------- Material Specification ----------
# --------------------------------------------
2 # Number of materials
3 # G = Number of energy groups
1 # L = max. Legendre moment of scattering xs
# Material 1
# total nu*fission fission # Group
1.2e-3 0.00 1e-4 # 1 (highest energy)
4.0e-3 2.0e-4 1.0e-4 # 2 (lowest energy)
# scattering matrices
# zeroth moment:
1.0e-4 4.1e-5 # scattering FROM group 1 (into [1, 2])
0.0 6.0e-4 # scattering FROM group 2
# first moment:
1.0e-8 1.0e-8
0.0 1.0e-6
# Material 2
# total nu*fission fission # Group
1.2e-3 0.00 1e-4 # 1
4.0e-3 0.00 1.0e-4 # 2
# scattering matrices
# zeroth moment:
1.0e-4 4.1e-5 # scattering FROM group 1 (into [1, 2])
0.0 6.0e-4 # scattering FROM group 2
# first moment:
1.0e-8 1.0e-8
0.0 1.0e-6
# --------------------------------------------
# --------------- Cell Layout ----------------
# --------------------------------------------
# material arrangement
1 1 1 1 1 1 2 2 2 2
# source
0.10 0.10 0.10 0.10 0.10 0.10 0.0 0.0 0.0 0.0
0.01 0.01 0.01 0.01 0.01 0.01 0.0 0.0 0.0 0.0
# --------------------------------------------
# ----------- Boundary Conditions ------------
# --------------------------------------------
# boundary conditions
2 1 # Reflective, incoming-flux
# incoming flux, right side
0.01 0.02
0.01 0.02
0.01 0.02
0.01 0.02