Helper Functions#
- F3_inventoryTracker(isovec, utype)#
Create a persistent inventory variable to track a block’s inventory.
- Parameters:
isovec (
array
) – An array of values that is used to update the persistent inventory variable.utype (
int
) – An interger used to describe what inventory update to perform. If utype is 1 then isovec is added to the inventory. Otherwise, isovec is subtracted from the inventory.
- Returns:
- y
The modified inventory after isovec has been added or subtracted.
- Return type:
array
- F3_ptableToGain(tab, sumtovalue)#
Converts a mask dialog table to gain array to be used with a continuous signal in F3M. Similar to F3_ptableToFlow but does not permit values outside the interval \(\in[0,1]\). Commonly used to calculate values for gain blocks representin process modifications, but can be used for a variety of purposes.
- Parameters:
tab (
cell array
) – Array containing entries that specify elements or isotopes to be modified. Column 1 specifies indicies of isovec to be modified whereas column 2 specifies the fracions to be applied.sumtovalue (
boolean
) – If true, then normalize the supplied fractions to 1
- Returns:
- y
The gain array which has shape [1677,1] that contains values \(\in[0,1]\).
- Return type:
array
- F3_ptableToArray(tab, sumtovalue)#
Convert a cell array from a mask dialog table into an array useable for downstream tasks. Typically used in loss and process blocks. Requires specified fractions in tab to be \(\in[0,1]\).
- Parameters:
tab (
cell array
) – Array containing entries that specify elements or isotopes to be modified. Column 1 specifies indicies of isovec to be modified whereas column 2 specifies the fracions to be applied.sumtovalue (
boolean
) – If true, then normalize the supplied fractions to 1
- Returns:
- y
The modification array which has shape [2,n]. Column 1 specifies indicies of isovec whereas column2 specifies the modification fractions.
- Return type:
array
- F3_getIsoIdx(x)#
Returns the index of isovec for the given isotope. Expects a string input with an element followed by the A number without any hyphenation. This function is not to be used for general purpose lookups, instead use the more flexible F3_getArrayPos function.
- Parameters:
x (
string
) – The isotope to find the array position of.- Returns:
- y
The location in the isovec array where the isotope is located.
- Return type:
array
- F3_fmtTableExpr(stin)#
Evaluates a string containing mathematical expressions that contain variables defined in the model workspace. This function is used to evaluate input from F3M mask dialogs for use in downstream processing tasks. This block is only designed for simple expressions with defined variables in the model workspace.
Important
This block is fairly simple and does not respect parenthetical ordering, instead it simply processes expressions in order from left to right.
- Parameters:
stin (
string
) – A string containing a mathematical expression.- Returns:
- y
The evaluated expression as a string.
- Return type:
string
model_workspace = get_param(bdroot,'ModelWorkspace'); x = 3; assignin(model_workspace,'x',3); y = 2; assignin(model_workspace,'y',2); z = 5; assignin(model_workspace,'z',5); stin = "x*y*z"; F3_fmtTableExpr(stin) ans = '30'
- F3_getElementSpan(x)#
Retrieves the array indicies of isovec that correspond to the given element. Multiple indicies are returned if multiple isotopes of that element are tracked. This function is not to be used for general purpose lookups, instead use the more flexible F3_getArrayPos function.
- Parameters:
x (
string
) – The element to find the array positions of.- Returns:
- y
The locations of isotopes tracked for the given element. The shape of the array is [n, 1] where n is the number of isotopes tracked.
- Return type:
array
- F3_calculateLossEntities(isovec, tab, etype)#
Calculate the removed entity component for use with various F3M process blocks.
Note
Fractions specified in row 2 of tab must be \(\in [0,1]\) otherwise an exception will be thrown.
- Parameters:
isovec (
array
) – A vector array with shape [1677, 1] that represents all isotopes tracked by F3M. This array is read from the attributes of the entity that is being modified by the F3M block.tab (
array
) – An array with shape [2, n] where n is the number of isotopes that are being modified. The first row, [1, :], contains the locations of isotopes that are being modified whereas the second row, [2, :] contains the corresponding fractions, \(\in [0,1]\) of the input, isovec, that should be removed.etype (
int
) – An integer used to indicate if the output corresponds to the removed component or the original component after modification. A value of 0 indicates that the modified component should be returned whereas any other value indicates the removed component should be returned.
- Returns:
- y
A vector with shape (1677,1) containing the 1675 isotopes tracked by F3M and two optional values at index 1676 and 1676. The specific details for the values of y depend on the value passed for etype.
- Return type:
array
- F3_getLossFilter(frac, lossOverrideTab)#
Generate an array of fractions from parameters specified in a mask dialog. By default, this function generates an array of identical values that has the same shape as isovec, but individual values can be overriden by the override table provided in the mask dialog.
This block does not account for any replacement material that might be specified in a replacement dialog table. The loss filter is “blind” to any replacement. Instead of calculating a net loss/replacement by considering both the loss and replacement specification together, they are considered separately as to differen terms. This is because it is more realistic to consider loss and replacement separately.
For example, suppose a species is specified as both a loss component and replacement component. Rather than considering the net change, both terms are carried out in their entirety (i.e., loss followed by replacement/gain).
- Parameters:
frac (
float
) – A float representing the fraction with which to reduce all species in isovec. Values should be \(\in [0,1]\) otherwise and exception will be thrown.lossOverrideTab (
array
) – A [N,2] shaped array where column 1 represents isovec array indicies and column 2 represents fractions. These entries override the provided frac. Values should be \(\in [0,1]\) otherwise an exception will be thrown.
- Returns:
- y
An array with shape [1677,1] containing fractions \(\in [0,1]\) with which to reduce isovec.
- Return type:
array
- F3_ptableToFlow(tab, sumtovalue)#
Converts a mask dialog table to flow array to be used with a continuous signal in F3M. Similar to F3_ptableToGain but does not permit values outside the interval \(\in[0,\infty]\) This function is commonly used for calculating flows which can be greater than zero, but can be used for a variety of purposes.
- Parameters:
tab (
cell array
) – Array containing entries that specify elements or isotopes to be placed into an array. Column 1 specifies indicies of isovec whereas column 2 specifies the values of the array.sumtovalue (
boolean
) – If true, then normalize the supplied fractions to 1
- Returns:
- y
The flow array which has shape [1677,1] that contains values \(\in[0,\infty]\).
- Return type:
array
- F3_getArrayPos(x)#
Returns the array position(s) for the specified element or isotope in the F3M isovec array/attribute that is tracked throughtout F3M blocks. Elements should be specified as a lowercase string whereas isotopes should be specified as a element followed by the A number.
F3_getArrayPos('c12') ans = 19 F3_getArrayPos('c') ans = 19 20 21 22
- Parameters:
x (
string
) – The isotope or element that should be found. Can also include keywords at1, at2, and all.- Returns:
- y
The location of the specified element, isotope, or keyword. For elements this is a [1,1] array whereas isotopes are [n, 1] where n is the number of tracked isotopes.
- Return type:
array
- F3_makeEntityIsos(fuelIdx, itemsize, fuel_params)#
Initalize a spent fuel entity to be used in the SNF generator block.
Warning
This function assumes the standard database organization described in the tutorial is followed. It must be modified if you use a non-standard database organization.
- Parameters:
fuelIdx (
int
) – Flag to indicate whether or not to randomize the fuel parameters. If 1, then chose a random combination of burnup, enrichment, and deacy. Otherwise, use the supplied values.itemsize (
float
) – Value to scale the database concentrations by. The database has values that are g/MTIHM so this must be scaled to units of kg using this user supplied valuefuel_params (
array
) –Array with shape [1, 5] that contains fuel parameter indicies. The indicies are as follows:
1: burnup index for array b
2: enrichment index for array e
3: decay index for array c
4: optional attribute for isovec(1676)
5: optional attribute for isovec(1677)
- Returns:
- y
A vector with shape (1677,1) containing the 1675 isotopes tracked by F3M and two optional values at index 1676 and 1676. Used as the isovec attribute of a SNF entity.
- Return type:
array