saltproc.depcode module

class saltproc.depcode.Depcode(codename, exec_path, template_inputfile_path, iter_inputfile, iter_matfile, geo_files=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_inputfile_path, iter_inputfile, iter_matfile, geo_files=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_inputfile_path (str) – Path to depletion code input file template.

  • iter_inputfile (str) – Name of depletion code 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_files (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(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

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 read_depcode_info()[source]

Parses initial depletion code info data from depletion code output and stores it in the Depcode object’s sim_info attribute.

abstract read_depcode_step_param()[source]

Parses data from depletion code output for each step and stores it in Depcode object’s param attributes.

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 switch_to_next_geometry()[source]

Inserts line with path to next depletion code geometry file at the beginning of the depletion code iteration input file.

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

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

Parameters
  • 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, 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.

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

class saltproc.depcode.DepcodeSerpent(exec_path='sss2', template_inputfile_path='reactor.serpent', iter_inputfile='data/saltproc_reactor', iter_matfile='data/saltproc_mat', geo_files=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_inputfile_path='reactor.serpent', iter_inputfile='data/saltproc_reactor', iter_matfile='data/saltproc_mat', geo_files=None, npop=50, active_cycles=20, inactive_cycles=20)[source]

Initializes the DepcodeSerpent object.

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

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

  • iter_inputfile (str) – Name of Serpent2 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_files (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

convert_nuclide_name_serpent_to_zam(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

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

create_nuclide_name_map_zam_to_serpent()[source]

Create a map that accepts nuclide names in zzaaam format and returns the Serpent2 nuclide code format. Uses Serpent2 *.out file with list of all nuclides in simulation.

Returns

nuclide_map – Contains mapping for nuclide names from zzaaam to Serpent2 format 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

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).

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(read_at_end=False)[source]

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

Parameters

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_plaintext_file(file_path)[source]

Reads the content of a plaintext file for use by other methods.

Parameters

file_path (str) – Path to file.

Returns

file_data – List of strings containing file lines.

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).

switch_to_next_geometry()[source]

Inserts line with path to next Serpent geometry file at the beginning of the Serpent iteration input file.

write_depcode_input(reactor, dep_step, restart)[source]

Writes prepared data into the depletion code input file.

Parameters
  • 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, 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.

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