saltproc.depcode module

class saltproc.depcode.Depcode(codename, exec_path, template_path, input_path, iter_matfile, geo_file=None, npop=50, active_cycles=20, inactive_cycles=20)[source]

Bases: ABC

Abstract class for interfacing with monte-carlo particle transport codes. Contains information about input, output, geometry, and template files for running depletion simulations. Also contains neutron population, active, and inactive cycles. Contains methods to read template and output files, and write new input files for the depletion code.

__init__(codename, exec_path, template_path, input_path, iter_matfile, geo_file=None, npop=50, active_cycles=20, inactive_cycles=20)[source]

Initializes the Depcode object.

Parameters
  • codename (str) – Name of depletion code.

  • exec_path (str) – Path to depletion code executable.

  • template_path (str) – Path to user input file for depletion code.

  • input_path (str) – Name of input file for depletion code rerunning.

  • iter_matfile (str) – Name of iterative, rewritable material file for depletion code rerunning. This file is modified during the simulation.

  • geo_file (str or list, optional) – Path to file that contains the reactor geometry. List of str if reactivity control by switching geometry is On or just str otherwise.

  • npop (int, optional) – Size of neutron population per cycle for Monte Carlo.

  • active_cycles (int, optional) – Number of active cycles.

  • inactive_cycles (int, optional) – Number of inactive cycles.

abstract read_dep_comp(dep_file, read_at_end=False)[source]

Reads the depleted material data from the depcode simulation and returns a dictionary with a Materialflow object for each burnable material.

Parameters
  • dep_file (str) – Path to file containing results of depletion simulation

  • read_at_end (bool, optional) – Controls at which moment in the depletion step to read the data. If True, the function reads data at the end of the depletion step. Otherwise, the function reads data at the beginning of the depletion step.

Returns

mats – Dictionary that contains Materialflow objects.

key

Name of burnable material.

value

Materialflow object holding composition and properties.

Return type

dict of str to Materialflow

abstract run_depcode(cores, nodes)[source]

Runs depletion code as a subprocess with the given parameters.

Parameters
  • cores (int) – Number of cores to use for depletion code run.

  • nodes (int) – Number of nodes to use for depletion code run.

abstract write_depcode_input(temp, inp, reactor, dep_step, restart)[source]

Writes prepared data into depletion code input file(s).

Parameters
  • temp (str) – Path to depletion code template file

  • inp (str) – Path to input file for depletion code rerunning

  • reactor (Reactor) – Contains information about power load curve and cumulative depletion time for the integration test.

  • dep_step (int) – Current depletion time step.

  • restart (bool) – Is the current simulation restarted?

abstract write_mat_file(dep_dict, mat_file, dep_end_time)[source]

Writes the iteration input file containing the burnable materials composition used in depletion runs and updated after each depletion step.

Parameters
  • dep_dict (dict of str to Materialflow) –

    Dictionary that contains Materialflow objects.

    key

    Name of burnable material.

    value

    Materialflow object holding composition and properties.

  • mat_file (str) – Path to file containing burnable materials composition.

  • dep_end_time (float) – Current time at the end of the depletion step (d).

class saltproc.depcode.DepcodeSerpent(exec_path='sss2', template_path='reactor.serpent', input_path='data/saltproc_reactor', iter_matfile='data/saltproc_mat', geo_file=None, npop=50, active_cycles=20, inactive_cycles=20)[source]

Bases: Depcode

Class contains information about input, output, geometry, and template files for running Serpent2 depletion simulations. Also contains neutrons population, active, and inactive cycles. Contains methods to read template and output files, write new input files for Serpent2.

__init__(exec_path='sss2', template_path='reactor.serpent', input_path='data/saltproc_reactor', iter_matfile='data/saltproc_mat', geo_file=None, npop=50, active_cycles=20, inactive_cycles=20)[source]

Initializes the DepcodeSerpent object.

Parameters
  • exec_path (str) – Path to Serpent2 executable.

  • template_path (str) – Path to user input file for Serpent2.

  • input_path (str) – Name of input file for Serpent2 rerunning.

  • iter_matfile (str) – Name of iterative, rewritable material file for Serpent2 rerunning. This file is modified during the simulation.

  • geo_file (str or list, optional) – Path to file that contains the reactor geometry. List of str if reactivity control by switching geometry is On or just str otherwise.

  • npop (int, optional) – Size of neutron population per cycle for Monte Carlo.

  • active_cycles (int, optional) – Number of active cycles.

  • inactive_cycles (int, optional) – Number of inactive cycles.

change_sim_par(template_data)[source]

Finds simulation parameters (neutron population, cycles) in the Serpent2 template file and change them to the parameters from the SaltProc input file.

Parameters

template_data (list) – List of strings parsed from user’s Serpent2 template file.

Returns

input_data – List of strings containing Serpent2 input file with new simulation parameters.

Return type

list

create_iter_matfile(template_data)[source]

Finds include line with path to material file, copies content of this file to iteration material file, changes path in include line to newly created iteration material file.

Parameters

template_data (list) – List of strings parsed from user’s template file.

Returns

input_data – List of strings containing modified user template file.

Return type

list

get_nuc_name(nuc_code)[source]

Returns nuclide name in human-readable notation: chemical symbol (one or two characters), dash, and the atomic weight. Lastly, if the nuclide is in metastable state, the letter m is concatenated with number of excited state. For example, Am-242m1.

Parameters

nuc_code (str) – Name of nuclide in Serpent2 form. For instance, Am-242m.

Returns

  • nuc_name (str) – Name of nuclide in human-readable notation (Am-242m1).

  • nuc_zzaaam (str) – Name of nuclide in zzaaam form (952421).

get_tra_or_dec(input_file)[source]

Returns the isotopes map to transform isotope zzaaam code to Serpent2. Uses Serpent2 *.out file with list of all isotopes in simulation.

Parameters

input_file (str) – Serpent2 input file name and path.

Returns

isotope_map – Contains mapping for isotopes names from zzaaam to Serpent2 name imported from Serpent2 ouput file:

key

The key is nuclide name in zzaaam format. For example, 922350 or 982510.

value

Serpent2-oriented name. For instance, 92235.09c for transport isotope or 982510 for decay only isotope).

Return type

dict of str to str

insert_path_to_geometry(template_data)[source]

Inserts include <first_geometry_file> line on the 6th line of Serpent2 input file.

Parameters

template_data (list) – List of strings parsed from user’s template file.

Returns

template_data – List of strings containing modified path to geometry in user’s template file.

Return type

list

read_dep_comp(input_file, read_at_end=False)[source]

Reads the Serpent2 *_dep.m file and returns a dictionary with a Materialflow object for each burnable material.

Parameters
  • input_file (str) – Path to Serpent2 input file.

  • read_at_end (bool, optional) – Controls at which moment in the depletion step to read the data. If True, the function reads data at the end of the depletion step. Otherwise, the function reads data at the beginning of the depletion step.

Returns

mats – Dictionary that contains Materialflow objects.

key

Name of burnable material.

value

Materialflow object holding composition and properties.

Return type

dict of str to Materialflow

read_depcode_info()[source]

Parses initial simulation info data from Serpent2 output and stores it in the DepcodeSerpent object’s sim_info attributes.

read_depcode_step_param()[source]

Parses data from Serpent2 output for each step and stores it in DepcodeSerpent object’s param attributes.

read_depcode_template(template_path)[source]

Reads prepared Serpent2 template (input) file for use in other class functions that prepare the input file for multiple runs.

Parameters

template_path (str) – Path to user template file for depletion code.

Returns

tempalate_data – List of strings containing user template file.

Return type

list

replace_burnup_parameters(template_data, reactor, current_depstep_idx)[source]

Adds or replaces the set power P dep daystep DEPSTEP line in the Serpent2 input file. This line defines depletion history and power levels with respect to the depletion step in the single run and activates depletion calculation mode.

Parameters
  • template_data (list) – List of strings parsed from user template file.

  • reactor (Reactor) – Contains information about power load curve and cumulative depletion time for the integration test.

  • current_depstep_idx (int) – Current depletion step.

Returns

template_data – List of strings containing modified in this function template file.

Return type

list

run_depcode(cores, nodes)[source]

Runs Serpent2 as a subprocess with the given parameters.

Parameters
  • cores (int) – Number of cores to use for Serpent2 run (-omp flag in Serpent2).

  • nodes (int) – Number of nodes to use for Serpent2 run (-mpi flag in Serpent2).

sss_meta_zzz(nuc_code)[source]

Checks Serpent2-specific meta stable-flag for zzaaam. For instance, 47310 instead of 471101 for Ag-110m1. Metastable isotopes represented with aaa started with 3.

Parameters

nuc_code (str) – Name of nuclide in Serpent2 form. For instance, 47310.

Returns

nuc_zzaam – Name of nuclide in zzaaam form (471101).

Return type

int

write_depcode_input(temp_file, inp_file, reactor, dep_step, restart)[source]

Writes prepared data into the depletion code input file.

Parameters
  • template_file (str) – Path to Serpent2 template file.

  • input_file (str) – Path to input file for Serpent2 rerunning.

  • reactor (Reactor) – Contains information about power load curve and cumulative depletion time for the integration test.

  • dep_step (int) – Current depletion time step.

  • restart (bool) – Is the current simulation restarted?

write_mat_file(dep_dict, mat_file, dep_end_time)[source]

Writes the iteration input file containing the burnable materials composition used in Serpent2 runs and updated after each depletion step.

Parameters
  • dep_dict (dict of str to Materialflow) –

    Dictionary that contains Materialflow objects.

    key

    Name of burnable material.

    value

    Materialflow object holding composition and properties.

  • mat_file (str) – Path to file containing burnable materials composition.

  • dep_end_time (float) – Current time at the end of the depletion step (d).