Skip to content

Commit

Permalink
Merge pull request #233 from ilhamv/remove_dsm
Browse files Browse the repository at this point in the history
Remove DSM temporarily
  • Loading branch information
ilhamv authored Aug 17, 2024
2 parents 8b4770d + 2be8ac8 commit 6a9e56c
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 718 deletions.
1 change: 0 additions & 1 deletion mcdc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
iQMC,
weight_roulette,
IC_generator,
dsm,
uq,
reset,
domain_decomposition,
Expand Down
7 changes: 0 additions & 7 deletions mcdc/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ def __init__(self, G=1, J=0):
self.chi_s = np.zeros([G, G])
self.chi_p = np.zeros([G, G])
self.chi_d = np.zeros([J, G])
self.sensitivity = False
self.sensitivity_ID = 0
self.dsm_Np = 1.0
self.uq = False
self.flags = []
self.distribution = ""
Expand Down Expand Up @@ -85,7 +82,6 @@ def __init__(self, N_nuclide, G=1, J=0):
self.nu_f = np.zeros(G)
self.chi_s = np.zeros([G, G])
self.chi_p = np.zeros([G, G])
self.sensitivity = False
self.uq = False
self.flags = []
self.distribution = ""
Expand Down Expand Up @@ -167,9 +163,6 @@ def __init__(self):
self.nx = 0.0
self.ny = 0.0
self.nz = 0.0
self.sensitivity = False
self.sensitivity_ID = 0
self.dsm_Np = 1.0

def _create_halfspace(self, positive):
region = RegionCard("halfspace")
Expand Down
3 changes: 0 additions & 3 deletions mcdc/global_.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ def reset(self):
# Below are parameters not copied to mcdc.setting
"bank_active_buff": 100,
"bank_census_buff": 1.0,
# TODO: Move to technique
"N_sensitivity": 0,
}

self.technique = {
Expand Down Expand Up @@ -158,7 +156,6 @@ def reset(self):
"IC_precursor_density_max": 0.0,
"IC_cycle_stretch": 1.0,
"branchless_collision": False,
"dsm_order": 1,
"uq": False,
}

Expand Down
73 changes: 2 additions & 71 deletions mcdc/input_.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ def nuclide(
chi_d=None,
speed=None,
decay=None,
sensitivity=False,
dsm_Np=1.0,
):
"""
Create a nuclide
Expand All @@ -80,11 +78,6 @@ def nuclide(
Energy group speed [cm/s].
decay : numpy.ndarray (1D), optional
Precursor group decay constant [/s].
sensitivity : bool, optional
Set to `True` to calculate sensitivities to the nuclide.
dsm_Np : float
Average number of derivative particles produced at each
sensitivity nuclide collision.
Returns
-------
Expand Down Expand Up @@ -208,20 +201,6 @@ def nuclide(
if np.sum(card.chi_d[dg, :]) > 0.0:
card.chi_d[dg, :] /= np.sum(card.chi_d[dg, :])

# Sensitivity setup
if sensitivity:
# Set flag
card.sensitivity = True
global_.input_deck.technique["sensitivity"] = True
global_.input_deck.technique["weighted_emission"] = False

# Set ID
global_.input_deck.setting["N_sensitivity"] += 1
card.sensitivity_ID = global_.input_deck.setting["N_sensitivity"]

# Set dsm_Np
card.dsm_Np = dsm_Np

# Add to deck
global_.input_deck.nuclides.append(card)

Expand All @@ -240,8 +219,6 @@ def material(
chi_d=None,
speed=None,
decay=None,
sensitivity=False,
dsm_Np=1.0,
):
"""
Create a material
Expand Down Expand Up @@ -273,12 +250,6 @@ def material(
Energy group speed [cm/s].
decay : numpy.ndarray (1D), optional
Precursor group decay constant [/s].
sensitivity : bool, optional
Set to `True` to calculate sensitivities to the material
(only relevant for single-nuclide material).
dsm_Np : float
Average number of derivative particles produced at each
sensitivity material collision (only relevant for single_nuclide material).
Returns
-------
Expand All @@ -303,8 +274,6 @@ def material(
chi_d,
speed,
decay,
sensitivity,
dsm_Np,
)
nuclides = [[card_nuclide, 1.0]]

Expand Down Expand Up @@ -379,7 +348,7 @@ def material(
# Set ID
card.ID = len(global_.input_deck.materials)

# Calculate basic XS and determine sensitivity flag
# Calculate basic XS
for i in range(N_nuclide):
nuc = nuclides[i][0]
density = nuclides[i][1]
Expand All @@ -390,8 +359,6 @@ def material(
card.scatter += nuc.scatter * density
card.fission += nuc.fission * density
card.total += nuc.total * density
card.sensitivity += nuc.sensitivity * density
card.sensitivity = bool(card.sensitivity)

# Calculate effective speed
# Current approach: weighted by nuclide macroscopic total cross section
Expand Down Expand Up @@ -450,7 +417,7 @@ def material(
return card


def surface(type_, bc="interface", sensitivity=False, dsm_Np=1.0, **kw):
def surface(type_, bc="interface", **kw):
"""
Create a surface to define the region of a cell.
Expand All @@ -461,11 +428,6 @@ def surface(type_, bc="interface", sensitivity=False, dsm_Np=1.0, **kw):
Surface type.
bc : {"interface", "vacuum", "reflective"}
Surface boundary condition.
sensitivity : bool, optional
Set to `True` to calculate sensitivities to the surface position.
dsm_Np : int
Average number of derivative particles produced at each
sensitivity surface crossing.
Other Parameters
----------------
Expand Down Expand Up @@ -538,20 +500,6 @@ def surface(type_, bc="interface", sensitivity=False, dsm_Np=1.0, **kw):
)
card.boundary_type = bc

# Sensitivity
if sensitivity:
# Set flag
card.sensitivity = True
global_.input_deck.technique["sensitivity"] = True
global_.input_deck.technique["weighted_emission"] = False

# Set ID
global_.input_deck.setting["N_sensitivity"] += 1
card.sensitivity_ID = global_.input_deck.setting["N_sensitivity"]

# Set dsm_Np
card.dsm_Np = dsm_Np

# ==========================================================================
# Surface attributes
# ==========================================================================
Expand Down Expand Up @@ -1776,22 +1724,6 @@ def IC_generator(
card_setting["N_active"] = N_cycle


def dsm(order=1):
"""
Direct sensitivity method
Parameters
----------
order : int, optional
order of the sensitivity to probe, by default 1
"""

card = global_.input_deck.technique
if order > 2:
print_error("DSM currently only supports up to second-order sensitivities")
card["dsm_order"] = order


def uq(**kw):
"""
Activate uncertainty quantification.
Expand Down Expand Up @@ -1950,7 +1882,6 @@ def make_particle_bank(size):
("g", np.uint64),
("E", np.float64),
("w", np.float64),
("sensitivity_ID", np.int64),
("rng_seed", np.uint64),
]
iqmc_struct = [("w", np.float64, (1,))]
Expand Down
Loading

0 comments on commit 6a9e56c

Please sign in to comment.