-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from yardasol/separate-depcode
Separate `depcode.py` into three files
- Loading branch information
Showing
18 changed files
with
661 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
class Depcode(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. | ||
Attributes | ||
----------- | ||
param : dict of str to type | ||
Holds depletion step parameter information. Parameter names are keys | ||
and parameter values are values. | ||
sim_info : dict of str to type | ||
Holds simulation settings information. Setting names are keys | ||
and setting values are values. | ||
iter_inputfile : str | ||
Path to depletion code input file for depletion code rerunning. | ||
iter_matfile : str | ||
Path to iterative, rewritable material file for depletion code | ||
rerunning. This file is modified during the simulation. | ||
""" | ||
|
||
def __init__(self, | ||
codename, | ||
exec_path, | ||
template_input_file_path, | ||
geo_files=None, | ||
npop=50, | ||
active_cycles=20, | ||
inactive_cycles=20): | ||
"""Initializes the Depcode object. | ||
Parameters | ||
---------- | ||
codename : str | ||
Name of depletion code. | ||
exec_path : str | ||
Path to depletion code executable. | ||
template_input_file_path : str or dict of str to str | ||
Path(s) to depletion code input file(s), or a dictionary where | ||
the input type (e.g. material, geometry, settings, etc.) as a | ||
string are keys, and the path to the input file are values. | ||
Type depends on depletion code in use. | ||
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. | ||
""" | ||
self.codename = codename | ||
self.exec_path = exec_path | ||
self.template_input_file_path = template_input_file_path | ||
self.geo_files = geo_files | ||
self.npop = npop | ||
self.active_cycles = active_cycles | ||
self.inactive_cycles = inactive_cycles | ||
self.param = {} | ||
self.sim_info = {} | ||
self.iter_inputfile = './iter_input' | ||
self.iter_matfile = './iter_mat' | ||
|
||
@abstractmethod | ||
def read_depcode_info(self): | ||
"""Parses initial depletion code info data from depletion code | ||
output and stores it in the `Depcode` object's ``sim_info`` attribute. | ||
""" | ||
|
||
@abstractmethod | ||
def read_depcode_step_param(self): | ||
"""Parses data from depletion code output for each step and stores | ||
it in `Depcode` object's ``param`` attributes. | ||
""" | ||
|
||
@abstractmethod | ||
def read_dep_comp(self, read_at_end=False): | ||
"""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 : dict of str to Materialflow | ||
Dictionary that contains `Materialflow` objects. | ||
``key`` | ||
Name of burnable material. | ||
``value`` | ||
`Materialflow` object holding composition and properties. | ||
""" | ||
|
||
@abstractmethod | ||
def run_depcode(self, cores, nodes): | ||
"""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. | ||
""" | ||
|
||
@abstractmethod | ||
def switch_to_next_geometry(self): | ||
"""Changes the geometry used in the depletion code simulation to the | ||
next geometry file in ``geo_files`` | ||
""" | ||
|
||
@abstractmethod | ||
def write_depcode_input(self, reactor, dep_step, restart): | ||
""" 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? | ||
""" | ||
|
||
@abstractmethod | ||
def write_mat_file(self, dep_dict, dep_end_time): | ||
"""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). | ||
""" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.