Skip to content

Commit

Permalink
Added atom fraction unit to isotopic chnge. Shifted step input for is…
Browse files Browse the repository at this point in the history
…otopic and density change
  • Loading branch information
Open-Burnup committed Dec 7, 2019
1 parent f3bbe6c commit 6157fd7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
32 changes: 27 additions & 5 deletions onix/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,14 @@ def _change_total_density(self, s):

if self.name in density_change_dict:
bucell_density_change_dict = density_change_dict[self.name]
if s in bucell_density_change_dict:

new_tot_dens = bucell_density_change_dict[s]
# When user sets a new density for step s+1, the Monte Carlo simulation of step s+1
# needs to run with this new density
# For conveniency, ONIX thus changes the density at the end of step s
# This means that if we are now at step s, we need to look if the user has specified a new
# density for step s+1
if s+1 in bucell_density_change_dict:

new_tot_dens = bucell_density_change_dict[s+1]
current_total_dens = self.get_total_dens()
factor = new_tot_dens/current_total_dens
passport_list = self.passlist.passport_list
Expand All @@ -560,17 +565,34 @@ def _change_isotope_density(self,s):
if isotopic_change_dict != None:
if self.name in isotopic_change_dict:
bucell_isotopic_change_dict = isotopic_change_dict[self.name]
unit = bucell_isotopic_change_dict['unit']
current_total_dens = self.get_total_dens()
for nucl_name in bucell_isotopic_change_dict:
if nucl_name == 'unit':
continue
nuclide_isotopic_change_dict = bucell_isotopic_change_dict[nucl_name]
if s in nuclide_isotopic_change_dict:

# When user sets a new density for step s+1, the Monte Carlo simulation of step s+1
# needs to run with this new density
# For conveniency, ONIX thus changes the density at the end of step s
# This means that if we are now at step s, we need to look if the user has specified a new
# density for step s+1
if s+1 in nuclide_isotopic_change_dict:
nucl_passport = self.get_nuclide(nucl_name)
# Only the current_dens is set to the user-defined density
# the dens_seq and dens_subseq_mat last value are left unchanged
# However both set_dens_cells (which updates material for new openmc simulation)
# and mat_builder (which prepares the matrix for new depletion calculation) uses
# current_dens. Therefore, only changing current_dens will update calculation without
# changing stored value that will be printed
new_dens = nuclide_isotopic_change_dict[s]

# If unit is number density
if unit == 'number density':
new_dens = nuclide_isotopic_change_dict[s+1]
# else if unit is atom fraction
if unit == 'atom fraction':
new_dens = nuclide_isotopic_change_dict[s+1]*current_total_dens

nucl_passport.current_dens = new_dens


Expand Down
17 changes: 13 additions & 4 deletions onix/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,26 @@ def norma_unit(self, norma_unit):
def isotopic_change_dict(self):
return self._isotopic_change_dict

def set_isotopic_change(self, cell, cell_isotopic_change):
"""Manually changes the isotopic densities (in atm per cm3) of user-specified nuclides in the BUCell for user-specified
def set_isotopic_change(self, cell, cell_isotopic_change, unit='number density'):
"""Manually changes the isotopic densities of user-specified nuclides in the BUCell for user-specified
macrosteps
Parameter:
unit: specifies the unit of the new isotopic density
'number density' (default) for density in atm per cm3
'atom fraction' for density as atomic fraction
IMPORTANT: The other method "set_density_change" trumps this method, i.e., the new isotopic densities set in
set_isotopic_change will be renormalized by the new value from set_density_change"""
IMPORTANT: If the method "set_density_change" is also used for the same BUCell, the isotopic change set by the user
must be in atom fraction"""
# If this is the first cell which is set isotopic change, create the dict
if self.isotopic_change_dict == None:
self._isotopic_change_dict = {}

self._isotopic_change_dict[cell.name] = cell_isotopic_change
self._isotopic_change_dict[cell.name]['unit'] = unit




@property
Expand Down

0 comments on commit 6157fd7

Please sign in to comment.