Skip to content

Commit

Permalink
Merge branch 'dev' into csg
Browse files Browse the repository at this point in the history
  • Loading branch information
ilhamv authored Jul 2, 2024
2 parents 7e54293 + 201d86d commit 520c8ba
Show file tree
Hide file tree
Showing 22 changed files with 1,162 additions and 1,102 deletions.
5 changes: 1 addition & 4 deletions examples/eigenvalue/2d_c5g7_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ def set_mat(mat):
G = 7
x_grid = np.linspace(0.0, pitch * 17 * 3, Nx + 1)
y_grid = np.linspace(-pitch * 17 * 3, 0.0, Ny + 1)

generator = "halton"
solver = "power_iteration"

phi0 = np.ones((G, Nx, Ny))
Expand All @@ -186,9 +184,8 @@ def set_mat(mat):
phi0=phi0,
fixed_source=fixed_source,
eigenmode_solver=solver,
maxitt=maxit,
maxit=maxit,
tol=tol,
generator=generator,
)

# =============================================================================
Expand Down
4 changes: 1 addition & 3 deletions examples/eigenvalue/slab_2gu_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
tol = 1e-3
pre_sweeps = 3
x = np.linspace(0.0, 6.01275, num=Nx + 1)
generator = "halton"
solver = "davidson"
fixed_source = np.zeros((2, Nx))
phi0 = np.ones((2, Nx))
Expand All @@ -48,9 +47,8 @@
g=np.ones(2),
phi0=phi0,
fixed_source=fixed_source,
maxitt=maxit,
maxit=maxit,
tol=tol,
generator=generator,
eigenmode_solver=solver,
preconditioner_sweeps=pre_sweeps,
)
Expand Down
4 changes: 1 addition & 3 deletions examples/eigenvalue/slab_kornreich_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
tol = 1e-3
x = np.arange(0.0, 2.6, 0.1)
Nx = len(x) - 1
generator = "halton"
solver = "power_iteration"
fixed_source = np.zeros(Nx)
phi0 = np.ones((Nx))
Expand All @@ -53,9 +52,8 @@
x=x,
fixed_source=fixed_source,
phi0=phi0,
maxitt=maxit,
maxit=maxit,
tol=tol,
generator=generator,
eigenmode_solver=solver,
score=["tilt-x"],
)
Expand Down
2 changes: 0 additions & 2 deletions examples/fixed_source/cooper2_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
tol = 1e-6
x = np.linspace(0, 4, num=Nx + 1)
y = np.linspace(0, 4, num=Ny + 1)
generator = "halton"
solver = "gmres"

# fixed source in lower left corner
Expand All @@ -55,7 +54,6 @@
phi0=phi0,
maxitt=maxit,
tol=tol,
generator=generator,
fixed_source_solver=solver,
score=["tilt-x", "tilt-y"],
)
Expand Down
4 changes: 1 addition & 3 deletions examples/fixed_source/slab_reed_iqmc/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
maxit = 20
tol = 1e-4
x = np.linspace(-8, 8, num=Nx + 1)
generator = "halton"
solver = "gmres"


Expand Down Expand Up @@ -82,9 +81,8 @@ def reeds_source(Nx, LB=-8.0, RB=8.0):
x=x,
fixed_source=fixed_source,
phi0=phi0,
maxitt=maxit,
maxit=maxit,
tol=tol,
generator=generator,
fixed_source_solver=solver,
score=["tilt-x"],
)
Expand Down
52 changes: 24 additions & 28 deletions mcdc/input_.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,34 +1519,32 @@ def domain_decomposition(


def iQMC(
phi0=None,
g=None,
t=None,
x=None,
y=None,
z=None,
phi0=None,
source0=None,
source_x0=None,
source_y0=None,
source_z0=None,
krylov_restart=None,
fixed_source=None,
scramble=False,
maxitt=25,
maxit=25,
tol=1e-6,
N_dim=6,
seed=12345,
preconditioner_sweeps=5,
generator="halton",
fixed_source_solver="source_iteration",
eigenmode_solver="power_iteration",
score=[],
):
"""
Set iQMC settings.
Activate the iterative Quasi-Monte Carlo (iQMC) neutron transport method.
Parameters
----------
phi0 : array_like[float], optional
Initial scalar flux approximation (default None).
g : array_like[float], optional
Energy values that define energy mesh (default None).
t : array_like[float], optional
Expand All @@ -1557,8 +1555,9 @@ def iQMC(
y-coordinates that define spacial mesh (default None).
z : array_like[float], optional
z-coordinates that define spacial mesh (default None).
phi0 : array_like[float], optional
Initial scalar flux (default None).
Other Parameters
----------
source0 : array_like[float], optional
Initial particle source (default None).
source_x0 : array_like[float], optional
Expand All @@ -1571,40 +1570,37 @@ def iQMC(
Max number of iterations for Krylov iteration (default same as maxitt).
fixed_source : array_like[float], optional
Fixed source (default same as phi0).
scramble : bool, optional
Whether to scramble (default False, implies over-easy).
maxitt : int, optional
maxit : int, optional
Maximum number of iterations allowed before termination (default 25).
tol : float, optional
Convergence tolerance (default 1e-6).
N_dim : int, optional
Problem dimensionality (default 6).
seed : int, optional
Random number seed (default 12345).
preconditioner_sweeps : int, optional
Number of preconditioner sweeps (default 5).
generator : str, optional
Low-discrepancy sequence generator (default "halton").
fixed_source_solver : str, optional
fixed_source_solver : {'source_iteration', 'gmres'}
Deterministic solver for fixed-source problem (default "source_iteration").
eigenmode_solver : str, optional
eigenmode_solver : {'power_iteration'}
Solver for k-eigenvalue problem (default "power_iteration").
score : list of str
List of tally types (default empty list).
score : list of str, optional
List of tallies to score in addition to the mandatory flux and
source strength. Additional scores include
{'tilt-x', 'tilt-y', 'tilt-z', 'fission-power'} (default empty list).
Returns
-------
None (in-place card alterations).
Notes
-----
phi0 is used to estimate the initial source strength. If source0 is
provided, source0 will be used instead of phi0. Either phi0 or
source0 must be provided as they are used to initialize particle
weights.
"""

card = global_.input_deck.technique
card["iQMC"] = True
card["iqmc"]["tol"] = tol
card["iqmc"]["maxitt"] = maxitt
card["iqmc"]["generator"] = generator
card["iqmc"]["N_dim"] = N_dim
card["iqmc"]["scramble"] = scramble
card["iqmc"]["seed"] = seed
card["iqmc"]["maxitt"] = maxit

# Set mesh
if g is not None:
Expand Down Expand Up @@ -1637,7 +1633,7 @@ def iQMC(
fixed_source = np.zeros_like(phi0)

if krylov_restart is None:
krylov_restart = maxitt
krylov_restart = maxit

if source0 is None:
source0 = np.zeros_like(phi0)
Expand Down
Empty file added mcdc/iqmc/__init__.py
Empty file.
Loading

0 comments on commit 520c8ba

Please sign in to comment.