Core module
Core class
- class coreutils.core.Core(inpjson)
Define NE, TH and CZ core configurations.
- Parameters:
inpjson (string) – Path to the input file in .json format.
- AssemblyGeom
Object with assembly geometrical features.
- Map
Object mapping the core assemblies with the different numerations.
- Type:
coreutils.core.Map
- NE
Object for the NEutronic configuration.
- Type:
coreutils.core.NE
- TH
Object for the Thermo-Hydraulic configuration.
- Type:
- Tc
Array with coolant temperatures for NE data.
- Type:
np.array
- Tf
Array with fuel temperatures for NE data.
- Type:
np.array
- TfTc
Array with fuel and coolant temperatures for NE data.
- Type:
np.array
- getassemblytype :
Get type of a certain assembly.
- replace :
Replace assemblies with user-defined new or existing type.
- perturb :
Replace assemblies with user-defined new or existing type.
- translate :
Replace assemblies with user-defined new or existing type.
- perturbBC :
Spatially perturb cooling zone boundary conditions.
- writecentermap :
Write assembly number and x and y coordinates of centers to text file.
- getassemblylist :
Return assemblies belonging to a certain type.
- writecorelattice :
Write core lattice to txt file.
- from_json(inpjson)
Generate object from .json file.
- Parameters:
inpjson (string) – Path to .json input file
- Raises:
- getassemblylist(atype, config, match=True, isfren=False)
Return assemblies belonging to a certain type.
- Parameters:
atype (int) – Desired assembly type.
config (np.array) – Array defining the assembly arrangement with integers
match (bool, optional) – If
True, it takes the assemblies matching with atype. IfFalse, it takes all the others, by defaultTrue.isfren (bool, optional) – Flag for FRENETIC numeration, by default
False
- Returns:
matchedass – List of matching/non-matching assemblies.
- Return type:
- getassemblytype(assemblynumber, config, isfren=False)
Get type of a certain assembly.
- Parameters:
- Returns:
which – Type of assembly corresponding to
assemblynumber.- Return type:
- writecentermap(numbers=True, fren=True, fname='centermap.txt')
Write assembly number and x and y coordinates of centers to text file.
- Parameters:
- Return type:
None
- writecorelattice(flatten=False, fname='corelattice.txt', serpheader=False, string=True, whichconf='NE', numbers=False, fren=True, time=0)
Write core lattice to txt file.
- Parameters:
flatten (bool, optional) – Flag to print matrix or flattened array, by default
False.fname (str, optional) – File name, by default “corelattice.txt”.
serpheader (bool, optional) – Serpent 2 code instructions for core lattice geometry header, by default
False.string (bool) – Format of the file entries, by default
True.whichconf (string) – Type of configuration, by default
"NE".numbers (bool, optional) – Print assembly numbers instead of assembly names in the core lattice.
fren (bool, optional) – Flag for FRENETIC numeration, by default
Truetime (float) – Time instant of the desired configuration, in seconds
- Return type:
None
Geometry class
- class coreutils.core.Geometry.Geometry(GEargs=None, inpdict=None)
Define an object representing the geometry of the core.
- Parameters:
GEargs (dict, optional) – Dict containing info to build the object, by default
None.
- inpdict: dict, optional
Object stored as a dict, by default
None.
- compute_volume(self, height):
Compute volume of the assembly slice.
- class coreutils.core.Geometry.AssemblyGeometry(pitch=None, asstype=None, inpdict=None)
Define an assembly object in the x-y plane.
- Parameters:
pitch (float, optional) – Pitch of the assembly, by default
None. IfNone, it assumed that the object is parsed from a dictionary.asstype (string, optional) – It can be “H” (hexagonal) or “S” (squared), by default
None. IfNone, it assumed that the object is parsed from a dictionary.inpdict (dict, optional) – Object stored as a dict, by default
None.
- compute_volume(self, height):
Compute volume of the assembly slice.
- class coreutils.core.Geometry.LatticeGeometry(ass_pitch=None, n_pins=None, pin_radius=None, pin_pitch=None, lattype=None, wrap_width=0, wrap_mat=None, inter_ass_width=0, inpdict=None)
Define a regular lattice object in the x-y plane. Now only lattices with identical pins are supported.
- Parameters:
ass_pitch (float, optional) – Pitch of the lattice, by default
None. IfNone, it assumed that the object is parsed from a dictionary.n_pins (int, optional) – Number of pins composing the lattice, by default
None. IfNone, it assumed that the object is parsed from a dictionary.pin_radius (float, optional) – External radius of the pin (i.e., the surface in contact with the fluid), by default
None. IfNone, it assumed that the object is parsed from a dictionary.pin_pitch (float, optional) – Pin-to-Pin distance, by default
None. IfNone, it assumed that the object is parsed from a dictionary.lattype (string, optional) – It can be “H” (hexagonal) or “S” (squared), by default
None. IfNone, it assumed that the object is parsed from a dictionary.wrap_width (str, optional) – Thickness of the wrapper (box) enclosing the pins and the coolant, by default 0.
wrap_width – Constituting material of the wrapper (box) enclosing the pins and the coolant, by default
None.inter_ass_width (float, optional) – Thickness of the coolant layer between each lattice and its neighbour (inter-assembly clearance), by default 0.
inpdict (dict, optional) – Object stored as a dict, by default
None.
- interAssWidth
Thickness of the coolant layer between each lattice and its neighbour (inter-assembly clearance).
- Type:
- class coreutils.core.Geometry.PinGeometry(pindict=None, inpdict=None)
Define a pin object in the x-y plane.
- Parameters:
- radii
Array with pin radii in increasing order.
- Type:
np.array
- class coreutils.core.Geometry.AxialConfig(cuts=None, splitz=None, labels=None, NE_dim=3, inpdict=None, assemblynames=None)
Define the NE axial core configuration at a certain time instant.
- Parameters:
cuts (dict, optional) – Cuts defining different material regions, by default
Nonesplitz (list, optional) – List with the number of elements per axial region, by default
Nonelabels (list, optional) – List of region labels, by default
NoneNE_dim (int, optional) – Number of spatial dimensions of the model, by default 3
inpdict (_type_, optional) – Input dictionary with the object (if read outside this class), by default None
assemblynames (list, optional) – List with names of the various assembly type, by default None
- cuts
Dictionary with values
AxialCutsobjects assigned to assembly type- Type:
ordered dict
- cutsregions
Dict containing the regions composing the various cuts of each assembly type. It is useful to identify the regions involved in the the spatial homogenisation.
- Type:
ordered dict
- cutslabels
Dict containing the labels of the regions composing the various cuts of each assembly type. It is useful to identify the regions involved in the the spatial homogenisation.
- Type:
ordered dict
- cutsweights
Dict containing the weight of each regions composing the various cuts of each assembly type. It is useful to identify the percentage of each regions involved in the the spatial homogenisation.
- Type:
ordered dict
- regions
Dict mapping the number identifying each region (integer) with its name (string)
- Type:
ordered dict
- labels
Dict mapping the name of each region with its own label. More regions could share the same label.
- Type:
ordered dict
- config_str
Dict containing the axial regions (as string) inside each assembly type (dict keys).
- Type:
ordered dict
- config
Dict containing the number of axial regions inside each assembly type (dict keys).
- Type:
ordered dict
- splitz
Number of elements in each axial region. The array has length equal to the number of zcuts -1.
- Type:
np.array
- AxNodes
Axial coordinates. The array has length equal to the sum of all the numbers in splitz.
- Type:
np.array
- dz
Height of each axial element. The array has length equal to the sum of all the numbers in splitz.
- Type:
np.array
- nReg: returns the number of regions.
- mapFine2Coarse: returns the regions, labels and weights for
the axial regions involved in the spatial homogenisation.
- static mapFine2Coarse(cuts, zcuts)
Generate dictionaries with region names, labels and weights for homogenisation.
- class coreutils.core.Geometry.AxialCuts(up=None, lo=None, r=None, labels=None, inpdict=None)
Define the axial cuts for a certain type of assembly.
- Parameters:
up (list, optional) – Upper z-coordinate, by default
Nonelo (list, optional) – Lower z-coordinate, by default
Noner (list, optional) – String identifying the region within upz and lowz, by default
Nonelabels (list, optional) – Label for the region within upz and lowz, by default
Noneinpdict (dict, optional) – Input dictionary containing the object (if it comes from the outside), by default
None
- mesh1d: Compute nodes according to FRENETIC mesh1d.f90
- class coreutils.core.Geometry.GeometryError
Map class
- class coreutils.core.Map.Map(geinp=None, rotangle=None, Geom=None, regionsdict=None, inp=None, inpdict=None)
Build the nuclear reactor core geometry map defined in a file.
- Parameters:
geinp (str or np.array) – If
strit is the <Path/filename> of the input file containing the geometry arrangement of the core, ifnp.arraythe geometry arrangement is already defined by the user.rotangle (int) – rotation angle over which the arrangement is symmetrically rotated. The rotation angle should be passed in degree (only 0,60,45,90,180 values are allowed). With rotangle=0 no rotation occurs.
Geom (
Geometry) – Geometry object.regionsdict (dict) –
inp (np.array) – 2D array representing the reactor core sector defined in input. The entries represent the assembly types.
inpdict (dict) – Input dictionary, by default
False
- inp
2D array representing the reactor core sector defined in input. The entries represent the assembly types.
- Type:
np.array
- type
The geometry arrangement of the core.
- Type:
np.array
- fren2serp
Dictionary mapping the assemblies according to the FRENETIC numeration to the one employed by Serpent 2.
- Type:
- serp2fren
Dictionary mapping the assemblies according to the Serpent 2 numeration to the one employed by FRENETIC.
- Type:
- class coreutils.core.Map.MapError
MaterialData class
- class coreutils.core.MaterialData.NEMaterial(uniName=None, energygrid=None, datapath=None, egridname=None, h5file=None, reader='json', serpres=None, basename=False, temp=False, datacheck=True, init=False, P1consistent=False)
Create material regions with multi-group constants.
- Parameters:
uniName (str) – Universe name.
energygrid (iterable) – Energy group structure containing nE+1 group boundaries where nE is the number of energy groups.
datapath (str, optional) – Path to the file containing the data, by default
None. IfNone, data are taken from the local database.egridname (str, optional) – Name of the energy group structure, by default
None.h5file (object) – h5 group from .h5 files.
reader (str``) – Type or reader. It can be
'serpent','json'or'txt'.serpres (
serpentTools.ResultsReader) – Object created parsing the _res.m Serpent file withserpentToolsbasename (bool or str) – if not
False, base name is used to compose the filenames, which needs to be in the form <basename>_Tf_XXX_Tc_XXX.temp (tuple) – if
basenameis not None, directories in the form “Tf_{}_Tc_{}” are searched and “Tf_{}_Tc_{}” suffix is attached to the file namedatacheck (bool, optional) – Flag to check and ensure data consistency, by default
True.init (bool, optional) – Flag to initialise the object as empty, by default
False
- Tot
1D array of length
nEwith the total cross section in cm^-1.- Type:
np.array
- Abs
1D array of length
nEwith the absorption cross section in cm^-1.- Type:
np.array
- Capt
1D array of length
nEwith the capture cross section in cm^-1.- Type:
np.array
- Fiss
1D array of length
nEwith the fission cross section in cm^-1.- Type:
np.array
- Remxs
1D array of length
nEwith the removal cross section in cm^-1.- Type:
np.array
- Transpxs
1D array of length
nEwith the transport cross section in cm^-1.- Type:
np.array
- NuSf
1D array of length
nEwith the fission production cross section in cm^-1.- Type:
np.array
- Diffcoef
1D array of length
nEwith the diffusion coefficient in cm.- Type:
np.array
- Difflength
1D array of length
nEwith the diffusion length in cm.- Type:
np.array
- S0
2D array of size
(nE, nE)with the scattering matrix cross section in cm^-1.- Type:
np.array
- Chit
1D array of size
nEwith the total fission emission spectrum.- Type:
np.array
- Chip
1D array of size
nEwith the prompt fission emission spectrum.- Type:
np.array
- Chid
1D array of size
nEwith the delayed fission emission spectrum.- Type:
np.array
- Nubar
1D array of size
nEwith the number of neutrons emitted by fission.- Type:
np.array
- Invv
1D array of size
nEwith the inverse of the neutron velocity in s/cm.- Type:
np.array
- lambda
1D array of size
NPFwith the decay constants of the precursors.- Type:
np.array
- beta
1D array of size
NPFwith the delayed neutron fracitons.- Type:
np.array
- Flx
1D array of size
nEwith the flux energy spectrum in arbitrary units.- Type:
np.array
- collapse(fewgrp, spectrum=None, egridname=None)
Collapse in energy the multi-group data.
- Parameters:
fewgrp (iterable) – Few-group structure to perform the collapsing.
spectrum (array, optional) – Spectrum to perform the energy collapsing, by default
None. IfNone, theFlxattribute is used as a weighting spectrum.egridname (str, optional) – Name of the energy grid, by default
None.
- Raises:
OSError – Collapsing failed: weighting flux missing in {}.
- Return type:
None.
- datacheck()
Check data consistency and add missing data.
- Parameters:
None. –
- Return type:
None.
- getxs(key, pos1=None, pos2=None)
Get material data (for a certain energy group, if needed).
- Parameters:
key (str) – User selected nuclear data.
pos1 (int, optional) – Departure energy group for scattering matrix. If not provided, data over all the energy groups are returned. The default is
None.pos2 (int, optional) – Arrival energy group for scattering matrix. If not provided, data over all the energy groups are returned. The default is
None.
- Returns:
vals – 1-D
numpy.ndarraywith G/NPF (groups) rows.- Return type:
- isfiss()
Assess whether the material is fissile
- perturb(what, howmuch, depgro=None, sanitycheck=True)
Perturb material composition.
- Parameters:
what (str) – Type of perturbation. If
what="density", the density of the material is perturbed, otherwise the other data can be perturbed by indicating the data. For instance,what="Fiss"orwhat="Nubar".howmuch (list or float) – Magnitude of the perturbation. If list, its length must be equal to
nE, and the perturbation is applied to each group. If it is a float, the perturbation is applied to the material density.depgro (int, optional) – Departure energy group, by default
False. This argument is needed to perturb the scattering cross section.sanitycheck (bool, optional) – Flag to check and ensure data consistency, by default
True.
- Return type:
None.
- plot(what, depgro=False, family=1, ax=None, figname=None, normalise=True, **kwargs)
Plot multi-group data from the object.
- Parameters:
what (str) – Data to be plotted.
depgro (int, optional) – Departure energy group, by default
False. This argument is needed to plot the scattering cross section.family (int, optional) – Number of neutron precursor family, by default 1
ax (matplotlib.axes.Axes, optional) – Ax on which to plot the data, by default None. If not provided, a new figure is created.
figname (str, optional) – Figure name with its extension, by default
Nonenormalise (bool, optional) – Normalisation flag, by default
True
- Raises:
OSError – If the
depgroargument is not provided when the data to be plotted is the scattering matrix.
- class coreutils.core.MaterialData.CZdata(mflow, pressures, temperatures, CZassemblynames)
Assign Cooling Zones material data to the reactor core.
- Parameters:
mflow (list) – List with mass flow rates, one for each cooling zone.
pressures (list) – List with pressures, one for each cooling zone.
temperatures (list) – List with temperatures, one for each cooling zone.
CZassemblynames (list) – List with cooling zone names, sorted consistently with the physical parameter lists.
- class coreutils.core.MaterialData.THHexData(which, inpdict)
Assign TH material data to the reactor core.
- class coreutils.core.MaterialData.NEMaterialError
- class coreutils.core.MaterialData.THDataError
NE class
- class coreutils.core.NE.NE(NEargs=None, CI=None, inpdict=None, datacheck=True)
Define NE core configurations.
- Map
Object mapping the core assemblies with the different numerations.
- Type:
obj
- AxialConfig
Axial regions defined for NE purposes.
- Type:
obj
- data
NE data (multi-group constants) for each region defined in input. Neutronics configurations according to time.
- Type:
obj
- replace :
Replace assemblies with user-defined new or existing type.
- perturb :
Replace assemblies with user-defined new or existing type.
- translate :
Replace assemblies with user-defined new or existing type.
- critical(core, prt, time)
Enforce criticality, given the static keff of the system
- Parameters:
core (_type_) – _description_
- get_fissile_SA(core, t=0)
Return number of fissile types in a core configuration at time t.
- Parameters:
core (_type_) – _description_
- Returns:
_description_
- Return type:
_type_
- get_fissile_types(t=0)
Return fissile assembly types.
- Returns:
fissile_types – Return fissile assembly types.
- Return type:
- perturb(core, prt, time=0, sanitycheck=True, isfren=True, action='pert')
Perturb material composition.
- Parameters:
what (TYPE) – DESCRIPTION.
howmuch (TYPE) – DESCRIPTION.
- Return type:
None.
- replace(core, rpl, time, isfren=False, action='repl')
Replace full assemblies or axial regions.
This method is useful to replace axial regions in 1D or 3D models. Replacements can affect disjoint regions, but each replacement object should involve either the region subdivision (self.NE.AxialConfig.zcuts) or the xscuts subdivision (the one in self.NE.AxialConfig.cuts[AssType]). If the replacement affect this last axial grid, homogenised data are computed from scratch and added to the material regions. The methods
perturbandtranslaterely on this method to arrange the new regions.- Parameters:
isfren (bool, optional) – Flag for FRENETIC numeration, by default
False.- Return type:
None
- replaceSA(core, repl, time, isfren=False)
Replace full assemblies or axial regions.
- translate(core, transconfig, time, isfren=False, action='trans')
Replace assemblies with user-defined new or existing type.
- class coreutils.core.NE.NEError
TH class
- class coreutils.core.TH.TH(THargs=None, CI=None, inpdict=None)
Define TH core configurations.
- AxialConfig
Axial regions defined for NE purposes.
- Type:
obj
- data
NE data (multi-group constants) for each region defined in input. Neutronics configurations according to time.
- Type:
obj
- from_dict:
- replaceSA:
Replace full assemblies.
- perturbBC:
Spatially perturb cooling zone boundary conditions.
- perturbBC(core, pertconfig, time, isfren=False)
Spatially perturb cooling zone boundary conditions.
- coreutils.core.TH.meshTH1d(zmin, zmax, nvol, nvolref=None, zminref=None, zmaxref=None)
- provide baricenter of each nodes between zmin and zmax with optional refinement.
This method is based on the subroutine mesh.f90 of FRENETIC.
- Parameters:
zmin (float) – Minimum axial coordinate.
zmax (float) – Maximum axial coordinate.
nvol (integer) – Number of axial volumes.
nvolref (integer, optional) – Number of volumes to be used in the refined region.
zminref (float) – Minimum axial coordinate in the refined region.
zmaxref (float) – Maximum axial coordinate in the refined region.
- Returns:
centers – Centers of each axial cell
- Return type:
np.array
UnfoldCore class
- class coreutils.core.UnfoldCore.UnfoldCore(inpge, rotangle, regionsdict)
Set of methods to rotate the input reactor core geometry.
- coremap
2D array representing the whole reactor core. The entries represent the assembly types
- Type:
array[int]
- inp
2D array representing the reactor core sector defined in input. The entries represent the assembly types
- Type:
array[int]
- static rot180(coremap, N)
Perform a counterclockwise 180° rotation.
- static rot45(coremap, N)
Perform a counterclockwise 45° rotation.
- static rot60(coremap)
Perform a counterclockwise 60° rotation.