### Nodal Writer Example Initialization Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/BranchToNodalDiffusion.rst Import and print the docstring of the Writer class from the nodal_writer module, demonstrating the basic setup for a nodal diffusion writer. ```python >>> from nodal_writer import Writer >>> print(Writer.__doc__.strip()) ``` -------------------------------- ### Install development version of serpentTools Source: https://github.com/core-gatech-group/serpent-tools/wiki/9th-Annual-Serpent-Users-Group-Meeting-Workshop Clone the source code from GitHub and install the development version of serpentTools. This involves cloning the repository, navigating into the directory, and running the setup script. ```bash git clone https://www.github.com/CORE-GATECH-GROUP/serpent-tools.git cd serpent-tools python setup.py install ``` -------------------------------- ### Install serpentTools from Release Archive Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/install.rst Install serpentTools by first downloading and extracting a release archive, then using pip. ```bash $ cd path/to/release ``` ```bash $ pip install . ``` -------------------------------- ### Install serpentTools with Extras Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/install.rst Install serpentTools along with optional "extras" dependencies for enhanced functionality. ```bash $ pip install "serpentTools[extras]" ``` -------------------------------- ### Install Numpy with Apt Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/install.rst Install the numpy package on Ubuntu using the apt package manager. ```bash # ubuntu $ sudo apt-get install python-numpy ``` -------------------------------- ### Install serpentTools with Pip Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/install.rst Install the latest release of serpentTools from the Python Package Index. ```bash $ pip install serpentTools ``` -------------------------------- ### Install serpentTools via Git Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/install.rst Install serpentTools directly from a git repository, including development and testing dependencies. ```bash $ git clone https://github.com/CORE-GATECH-GROUP/serpent-tools.git $ cd serpent-tools $ git checkout main ``` ```bash $ pip install -e ".[extras,test]" ``` ```bash $ pytest tests ``` -------------------------------- ### Install Core Python Packages with Conda Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/install.rst Install essential Python packages like setuptools, numpy, matplotlib, and pyyaml using conda in an Anaconda Prompt. ```bash $ conda install setuptools numpy matplotlib pyyaml ``` -------------------------------- ### Get Reaction Descriptions Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/XSPlot.rst The `MT` and `MTdescrip` attributes of an XSData object provide the reaction type codes and their corresponding descriptions. This example shows how to create a dictionary of these mappings. ```python o16 = xsreader["i8016_03c"] # Make a quick dictionary to show descriptions dict(zip(o16.MT, o16.MTdescrip)) ``` -------------------------------- ### Install stable release of serpentTools Source: https://github.com/core-gatech-group/serpent-tools/wiki/9th-Annual-Serpent-Users-Group-Meeting-Workshop Use this command to install the stable release of the serpentTools package using pip. The --user flag may be necessary for users without administrative privileges. ```bash pip install serpentTools ``` -------------------------------- ### Install serpentTools with conda Source: https://github.com/core-gatech-group/serpent-tools/blob/main/README.rst Use conda to install the serpentTools package from the conda-forge channel. ```bash conda install -c conda-forge serpentTools ``` -------------------------------- ### Inspecting Homogenized Universe Data After Configuration Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Branching.rst After configuring the BranchingReader settings, this example shows how to retrieve a specific homogenized universe and inspect its infExp attribute, demonstrating that only the explicitly requested variables are present. ```python >>> univ4 = b1.getUniv("0", 0) >>> univ4.infExp ``` -------------------------------- ### Access Detector Grids Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Detector.rst Access the grid data for detectors that include spatial or energy meshes. This example shows the first 5 rows of the 'E' grid. ```python >>> spectrum = bwr.detectors['spectrum'] >>> print(spectrum.grids['E'][:5]) [[1.00002e-11 4.13994e-07 2.07002e-07] [4.13994e-07 5.31579e-07 4.72786e-07] [5.31579e-07 6.25062e-07 5.78320e-07] [6.25062e-07 6.82560e-07 6.53811e-07] [6.82560e-07 8.33681e-07 7.58121e-07]] ``` -------------------------------- ### Import Libraries for Sensitivity Analysis Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Sensitivity.ipynb Imports necessary libraries for plotting and reading SERPENT data files. Ensure these are installed before use. ```python %matplotlib inline from matplotlib import pyplot import serpentTools ``` -------------------------------- ### Get Group Cross-Sections with MicroXSReader Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/MicroXSReader.ipynb Obtains group-wise cross-sections and their uncertainties for a specified universe, isotope, and reaction. ```python # Obtain the group cross-sections vals, unc = mdx.getXS(universe='0', isotope=10010, reaction=102) ``` -------------------------------- ### Configure DepletionReader Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/DepletionReader.ipynb Customize the `DepletionReader` to store specific data by modifying settings like `materialVariables`, `materials`, and `metadataKeys`. This example configures the reader to store only burnup days and atomic density for materials matching a regex. ```python rc['depletion.processTotal'] = False rc['depletion.metadataKeys'] = ['BU'] rc['depletion.materialVariables'] = ['ADENS'] rc['depletion.materials'] = [r'bglass\d+'] bgReader= serpentTools.readDataFile(depFile) bgReader.read() ``` -------------------------------- ### Export to MATLAB .mat file Source: https://context7.com/core-gatech-group/serpent-tools/llms.txt Exports results to a MATLAB .mat file. Requires the scipy library to be installed. ```python res.toMatlab('assembly_res.mat', reconvert=True) ``` -------------------------------- ### Plot Initial Concentrations Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/DepletionMatrix.ipynb Generate a basic plot of initial concentrations using the `plotDensity` method. This provides a visual overview of the starting isotopic composition. ```python reader.plotDensity() ``` -------------------------------- ### Python Code Block Example Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/documentation.rst A simple Python print statement example, often found within Jupyter notebooks and converted to RST. This shows the basic structure. ```python print('hello world!') ``` -------------------------------- ### Configuring DepletionReader Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/DepletionReader.rst Control which data is stored by the DepletionReader by modifying global settings. This example configures the reader to store only burnup days and atomic density for specific materials, and to not process totals. ```python >>> rc['depletion.processTotal'] = False >>> rc['depletion.metadataKeys'] = ['BU'] >>> rc['depletion.materialVariables'] = ['ADENS'] ``` -------------------------------- ### Expand variables based on settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Settings.ipynb Configure 'xs.variableGroups' and 'xs.variableExtras' and then use rc.expandVariables() to get a set of all variables to be extracted. This relies on the 'serpentVersion' setting. ```python rc['xs.variableGroups'] = ['kinetics', 'xs', 'diffusion'] rc['xs.variableExtras'] = ['XS_DATA_FILE_PATH'] varSet = rc.expandVariables() print(sorted(varSet)) ``` -------------------------------- ### Numpydoc Style Docstring Example Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/documentation.rst Illustrates the structure of a numpydoc-style docstring, including parameters, returns, and other sections. This format is used for Python objects. ```python def foo(a, b=None): """Simple one line docstring Parameters ---------- a : float Some value b : bool, optional A flag Returns ------- returnType Description of the return type """ ``` -------------------------------- ### Access Specific Detector Bins Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Detector.rst Retrieve a slice of bin data from a multi-dimensional detector. This example shows the first 5 values from a specific subset of bins. ```python >>> print(xy.bins[:5, 10]) [8.19312e+17 7.18519e+17 6.90079e+17 6.22241e+17 5.97257e+17] ``` -------------------------------- ### Build Documentation Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/documentation.rst Command to clean and build HTML documentation. Navigate to the build directory to verify rendering. ```bash make clean html ``` -------------------------------- ### Import serpentTools Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/DepletionMatrix.ipynb Import the necessary serpentTools library to begin. ```python import serpentTools ``` -------------------------------- ### Detector Plotting with Steps and Sigma Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Detector.ipynb Customize detector plots by enabling step-wise representation of tally values and overlaying confidence intervals (sigma). This example plots steps and then adds sigma with specific markers and transparency. ```python ax = nodeFlx.plot(steps=True, label='steps') ax = nodeFlx.plot(sigma=100, ax=ax, c='k', alpha=0.6, marker='x', label='sigma') ``` -------------------------------- ### Import Libraries and Configure Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/ResultsReader.ipynb Imports necessary libraries and sets the Serpent version for the reader. Ensure the 'serpentVersion' matches your Serpent output. ```python import numpy as np import serpentTools from serpentTools.settings import rc rc['serpentVersion'] = '2.1.30' ``` -------------------------------- ### Initialize MicroXSReader Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/MicroXSReader.rst Import the library and initialize the MicroXSReader by providing the path to the micro depletion file. Ensure the 'mdep' option is set in your SERPENT input file to generate this file. ```python import serpentTools mdxFile = 'ref_mdx0.m' mdx = serpentTools.readDataFile(mdxFile) ``` -------------------------------- ### Display YAML Configuration Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Settings.ipynb Use the `%cat` magic command to display the contents of a YAML configuration file. ```python %cat myConfig.yaml ``` -------------------------------- ### Configuring Branching Reader Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Branching.rst Control which variables are stored as state data and which extra data is included on HomogUniv objects by modifying serpentTools.settings.rc. This example sets floatVariables to 'BOR', intVariables to 'TFU', disables B1XS, and includes specific extra variables. ```python >>> from serpentTools.settings import rc >>> rc['branching.floatVariables'] = ['BOR'] >>> rc['branching.intVariables'] = ['TFU'] >>> rc['xs.getB1XS'] = False >>> rc['xs.variableExtras'] = ['INF_TOT', 'INF_SCATT0'] >>> r1 = serpentTools.readDataFile(branchFile) >>> b1 = r1.branches['B1000', 'FT600'] >>> b1.stateData {'BOR': 1000.0, 'DATE': '17/12/19', 'TFU': 600, 'TIME': '09:48:54', 'VERSION': '2.1.29'} >>> assert isinstance(b1.stateData['BOR'], float) >>> assert isinstance(b1.stateData['TFU'], int) ``` -------------------------------- ### Python Code Block Example (No Lexer) Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/documentation.rst An example of a Python code block in RST format without a specific lexer specified, used when the 'ipython3' lexer is problematic. ```rst .. code:: print('hello world!') ``` -------------------------------- ### Import serpentTools and rc Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Settings.rst Import the necessary serpentTools package and the rc object for accessing settings. ```python import serpentTools from serpentTools.settings import rc ``` -------------------------------- ### Import necessary libraries Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/BranchToNodalDiffusion.ipynb Import numpy, serpentTools, and BranchCollector for handling branching calculations. ```python import numpy import serpentTools from serpentTools.xs import BranchCollector ``` -------------------------------- ### Get current serpentVersion Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Settings.ipynb Retrieve the current SERPENT version setting. ```python rc['serpentVersion'] ``` -------------------------------- ### Generate Python Distributions Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/git.rst Use this command to create source distributions and wheels for uploading to PyPI. Ensure the version is correctly formatted. ```sh python setup.py sdist bdist_wheel ``` -------------------------------- ### Get SerpentTools Logger Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/logging.rst Obtain the internal 'serpentTools' logger instance. ```python >>> import logging >>> logging.getLogger("serpentTools") ``` -------------------------------- ### Display First 10 Energy Grid Points Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Sensitivity.ipynb Shows the first 10 energy values in the energy grid. These represent the lower bounds of the energy bins. ```python print(sens.energies[:10]) ``` -------------------------------- ### Access Depletion Matrix Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/DepletionMatrix.ipynb Access the depletion matrix itself. If `scipy` is installed, it will be a `csc_matrix` by default; otherwise, it will be a full numpy array. ```python reader.depmtx ``` -------------------------------- ### Initialize ResultsReader Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/ResultsReader.rst Demonstrates how to initialize the ResultsReader to read a Serpent output file. The preferred method is to use the readDataFile function. ```python import numpy as np import serpentTools from serpentTools.settings import rc resFile = 'InnerAssembly_res.m' res = serpentTools.readDataFile(resFile) ``` -------------------------------- ### Access serpentTools CLI Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/command-line.rst Execute this command from the terminal to access the serpentTools command line interface. Ensure serpentTools is installed. ```bash python -m serpentTools ``` -------------------------------- ### Extraneous Whitespace Example Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/codestyle.rst Avoid extraneous whitespace within parentheses and brackets. Consistent spacing improves code readability. ```python spam(ham[1], {eggs: 2}) ``` ```python spam( ham[ 1 ], { eggs: 2 } ) ``` -------------------------------- ### Get BranchedUniv Object for a Universe Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/BranchToNodalDiffusion.ipynb Retrieve a 'BranchedUniv' object for a specific universe, such as '0', to analyze its cross-section data independently. ```python u0 = collector.universes['0'] ``` -------------------------------- ### Configure Basic Logging Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/logging.rst Configure the Python logging system to display messages with a basic format. This is a prerequisite for seeing log output. ```python >>> import logging >>> logging.basicConfig(format="%(levelname)-s: %(message)-s") # Display a basic warning >>> logging.warning("This is a warning") WARNING: This is a warning ``` -------------------------------- ### Expand Group Constant Variables Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Settings.rst Configure settings for 'xs.variableGroups' and 'xs.variableExtras' and then use expandVariables() to get a set of all variables to be extracted. ```python rc['serpentVersion'] rc['xs.variableGroups'] = ['kinetics', 'xs', 'diffusion'] rc['xs.variableExtras'] = ['XS_DATA_FILE_PATH'] varSet = rc.expandVariables() print(sorted(varSet)) ``` -------------------------------- ### Import serpentTools and Define Branch File Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Branching.ipynb Imports the serpentTools library and defines the path to the branching coefficient file. This is a prerequisite for reading the file. ```python %matplotlib inline import serpentTools branchFile = 'demo.coe' ``` -------------------------------- ### Basic Detector Plot Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Detector.rst Generates a basic plot of the detector data. No specific setup is required beyond having a Detector object. ```python >>> nodeFlx.plot() ``` -------------------------------- ### Access Material Keys After Configuration Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/DepletionReader.ipynb After configuring and reading data with a `DepletionReader`, you can access the keys of the stored materials to verify the configuration. ```python bgReader.materials.keys() ``` -------------------------------- ### Upload Python Distributions to PyPI Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/git.rst After a successful check, upload the generated distributions to the Python Package Index using Twine. Replace with the actual package version. ```sh twine upload dist/serpentTools-* ``` -------------------------------- ### Check Python Distributions with Twine Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/git.rst Before uploading to PyPI, use Twine to check package compatibility. Replace with the actual package version. ```sh twine check dist/serpentTools-* ``` -------------------------------- ### Parsed Literal Example Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/documentation.rst Represents a block of text that should be displayed literally, often used in conjunction with code blocks to show output. ```rst .. parsed-literal:: hello world! ``` -------------------------------- ### Parent Class Initialization Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/codestyle.rst Directly call the `__init__` method from a parent class. This ensures proper initialization of inherited attributes and methods. ```python class MyQueue(list): def __init__(self, items): list.__init__(self) self.extend(items) ``` -------------------------------- ### Get First 10 Infinite Exponential Values Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/ResultsReader.ipynb Retrieves and sorts the first 10 keys from the 'infExp' dictionary of a HomogUniv object. ```python sorted(univ0.infExp)[:10] ``` -------------------------------- ### Accessing Materials by Indexing Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/DepletionReader.ipynb Demonstrates that materials can be accessed directly from the DepletionReader using dictionary-like indexing, similar to accessing them via the .materials attribute or .get() method. ```python assert dep["fuel0"] is dep.materials["fuel0"] is dep.get("fuel0") ``` -------------------------------- ### Get Group Cross-Sections with Isomeric Flag Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/MicroXSReader.ipynb Retrieves group cross-sections, optionally specifying the isomeric state using the 'isomeric' flag. ```python # Example of how to use the isomeric flag vals, unc = mdx.getXS(universe='0', isotope=10010, reaction=102, isomeric=0) ``` -------------------------------- ### Accessing Group Constants Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/BranchToNodalDiffusion.rst Access specific group constants from the 'infS1' scattering table. The scattering matrices are not reshaped from vectors to matrices in this example. ```python >>> infT[1, 0, 2, 2] array([0.324746, 0.864346]) ``` -------------------------------- ### Import and access settings from serpentTools.settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/ResultsReader.ipynb Import the rc object from serpentTools.settings to access and modify simulation settings. Use rc.keys() to view available settings. ```python from serpentTools.settings import rc ``` ```python rc.keys() ``` -------------------------------- ### Get Hexagonal Detector Indexing Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Detector.ipynb Retrieve the indexing order for the hexagonal detector's tally array. This indicates the order of spatial dimensions. ```python hex2.indexes ``` -------------------------------- ### Accessing and viewing ResultsReader settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/ResultsReader.rst Import the rc object from serpentTools.settings to view available configuration keys. ```python >>> from serpentTools.settings import rc >>> rc.keys() dict_keys(['branching.areUncsPresent', 'branching.intVariables', 'branching.floatVariables', 'depletion.metadataKeys', 'depletion.materialVariables', 'depletion.materials', 'depletion.processTotal', 'detector.names', 'verbosity', 'sampler.allExist', 'sampler.freeAll', 'sampler.raiseErrors', 'sampler.skipPrecheck', 'serpentVersion', 'xs.getInfXS', 'xs.getB1XS', 'xs.reshapeScatter', 'xs.variableGroups', 'xs.variableExtras']) ``` -------------------------------- ### Access Detector by Indexing Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Detector.ipynb Demonstrates accessing detector objects using dictionary-like indexing on the reader object. ```python pin['nodeFlx'] ``` ```python bwr.get('spectrum') ``` -------------------------------- ### Get Single MT Description Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/XSPlot.ipynb Retrieves the description for a specific Material Type (MT) number using direct indexing into the MTdescrip attribute. ```python o16.MTdescrip[0] ``` -------------------------------- ### View First 10 Universes Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/ResultsReader.ipynb Displays the first 10 universe entries from the results. This shows the structure of the UnivTuple objects. ```python sorted(res.universes)[:10] ``` -------------------------------- ### Accessing Reaction Descriptions Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/XSPlot.rst Use MTdescrip to get the description of a reaction by its MT number, or use the describe method for a specific reaction object. ```python >>> o16.MTdescrip[0] 'Total' >>> o16.describe(1) 'Total' ``` -------------------------------- ### Check Depletion Matrix Storage Format Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/DepletionMatrix.rst Determine if the depletion matrix is stored in a sparse or dense format. The reader defaults to sparse if SciPy is installed. ```python reader.sparse ``` ```python reader.depmtx ``` -------------------------------- ### Run Basic Python Command Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/install.rst Execute a simple Python command directly from the terminal. ```bash $ python -m "print('hello world')" ``` ```python >>> print('hello world') ``` -------------------------------- ### Run Pytest with Coverage Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/checklist.rst View code coverage by running pytest with the pytest-cov package installed. This helps identify parts of the project not touched by tests. ```bash $ pytest --cov=serpentTools ``` -------------------------------- ### Read Detector Data Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Detector.rst Reads SERPENT detector files using serpentTools.readDataFile. This function is preferred for reproducing examples. It loads detectors into the 'detectors' dictionary. ```python from matplotlib import pyplot import serpentTools pinFile = 'fuelPin_det0.m' bwrFile = 'bwr_det0.m' pin = serpentTools.readDataFile(pinFile) bwr = serpentTools.readDataFile(bwrFile) print(pin.detectors) print(bwr.detectors) ``` -------------------------------- ### Get First 5 Grouped Constants Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/ResultsReader.ipynb Retrieves and sorts the first 5 keys from the 'gc' dictionary, which stores variables not included in 'inf' or 'b1'. ```python sorted(univ0.gc)[:5] ``` -------------------------------- ### Inspect infinite medium experiment keys Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/ResultsReader.ipynb View the available keys for infinite medium experiments within a filtered universe object using the .infExp.keys() method. ```python univ0Filt.infExp.keys() ``` -------------------------------- ### Settings Configuration Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/MicroXSReader.ipynb Allows users to configure which data is stored within the MicroXSReader object to optimize memory usage. ```APIDOC ## Settings ### Description Control which data is stored by the `MicroXSReader` object. By default, all data is stored. Modifying these settings can reduce memory footprint. ### Configuration Options - `rc['microxs.getFY'] = True/False`: Controls whether fission yields are stored. - `rc['microxs.getXS'] = True/False`: Controls whether group cross-sections and uncertainties are stored. - `rc['microxs.getFlx'] = True/False`: Controls whether flux ratios and uncertainties are stored. ### Example ```python # Disable storing fission yields rc['microxs.getFY'] = False # Enable storing group cross-sections rc['microxs.getXS'] = True ``` ``` -------------------------------- ### Retrieve Specific Group Constant Value Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Branching.ipynb Use the get method on a HomogUniv object to retrieve the expected value for a specific group constant, such as 'infFiss'. ```python univ0.get('infFiss') ``` -------------------------------- ### Class Method for File Parsing Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/datamodel.rst Demonstrates how file classes can emulate previous reader behavior using a class method for parsing. This allows for creating file instances directly from Serpent files. ```python class DemoFile: @classmethod def fromSerpent(cls, fp, *args, **kwargs): # process # return an instance of DemoFile or cls() ``` -------------------------------- ### Get Keys for Available Cross-Sections Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/XSPlot.ipynb The 'keys()' method returns a view object that displays a list of all the keys (isotope and material names) in the 'xsections' dictionary. ```python xsreader.keys() ``` -------------------------------- ### Load Serpent-Tools Settings from YAML Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/changelog.rst The `loadYaml` function in `serpentTools.settings.rc` now uses `safe_load` for improved security when loading YAML configuration files. ```python serpentTools.settings.rc.loadYaml ``` -------------------------------- ### Access Specific Detector Tallies Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Detector.rst Retrieve a slice of tally data from a multi-dimensional detector. This example shows the first 5 values from a specific subset of tallies. ```python >>> print(xy.tallies[0, 0, :5]) [8.19312e+17 7.18519e+17 6.90079e+17 6.22241e+17 5.97257e+17] ``` -------------------------------- ### Generate Seeded Input Files with seedFiles Source: https://context7.com/core-gatech-group/serpent-tools/llms.txt Create multiple copies of a SERPENT input file, each with a unique random seed, for ensemble Monte Carlo studies. Use generateSeed to create individual seeds. ```python from serpentTools.seed import seedFiles, generateSeed # Generate a single random seed with 10 digits seed = generateSeed(10) print(seed) # e.g. 4831927650 # Create 5 independent copies of an input file with unique seeds created_files = seedFiles( inputFile='reactor.inp', numSeeds=5, seed=42, # optional: seed the RNG for reproducibility outputDir='runs', # optional: write copies into this subdirectory link=False, # False = full copy; True = include-directive only length=10, # number of digits in each generated seed ) print(created_files) # ['runs/reactor_0.inp', 'runs/reactor_1.inp', ..., 'runs/reactor_4.inp'] ``` -------------------------------- ### Load Settings from YAML File Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Settings.rst Use the `rc.loadYaml` method to load settings from a specified YAML file. This method parses the YAML and updates the `rc` settings object. Ensure the YAML file is correctly formatted. ```yaml xs.getInfXS: False xs.getB1XS: True xs.variableGroups: [gc-meta, kinetics, xs] branching: floatVariables: [Fhi, Blo] depletion: materials: [fuel*] metadataKeys: [NAMES, BU] materialVariables: [ADENS, MDENS, VOLUME] serpentVersion: 2.1.29 ``` ```python >>> %cat myConfig.yaml xs.getInfXS: False xs.getB1XS: True xs.variableGroups: [gc-meta, kinetics, xs] branching: floatVariables: [Fhi, Blo] depletion: materials: [fuel*] metadataKeys: [NAMES, BU] materialVariables: [ADENS, MDENS, VOLUME] serpentVersion: 2.1.29 ``` ```python >>> myConf = 'myConfig.yaml' >>> rc.loadYaml(myConf) INFO : serpentTools: Done ``` ```python >>> rc['xs.getInfXS'] False ``` -------------------------------- ### Get a filtered universe object Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/ResultsReader.ipynb Retrieve a specific universe object from the filtered results using the getUniv method, specifying the universe name and optionally an index. ```python univ0Filt = resFilt.getUniv('0', index=1) ``` -------------------------------- ### Configure MicroXSReader Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/MicroXSReader.ipynb Sets configuration options for the MicroXSReader to control which data is stored, such as fission yields, cross-sections, and flux ratios. ```python rc['microxs.getFY'] = False # True/False only rc['microxs.getXS'] = True # True/False only rc['microxs.getFlx'] = True # True/False only ``` -------------------------------- ### Get Fission Yields at Exact Energy with MicroXSReader Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/MicroXSReader.ipynb Retrieves fission yields at a specific energy, disabling the default behavior of using the closest available energy. ```python indYield, cumYield = mdx.getFY(parent=922350, energy=2.53e-08, daughter=541350, flagEnergy=False ) ``` -------------------------------- ### To-MATLAB Sub-command Help Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/command-line.rst Use the -h flag with the 'to-matlab' sub-command to view its specific options for converting SERPENT output files to MATLAB .mat files. ```bash python -m serpentTools to-matlab -h ``` -------------------------------- ### Get Fission Yields with MicroXSReader Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/MicroXSReader.ipynb Retrieves independent and cumulative fission yields for a given parent, energy, and daughter. By default, it uses the closest available energy. ```python indYield, cumYield = mdx.getFY(parent=922350, energy=2.53e-08, daughter=541350 ) print('Independent yield = {}'.format(indYield)) print('Cumulative yield = {}'.format(cumYield)) ``` -------------------------------- ### Display Writer Method Documentation Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/BranchToNodalDiffusion.ipynb Prints the docstring for the 'write' method of the 'Writer' class, detailing its parameters and how to use it for writing data. ```python print(writer.write.__doc__.strip()) ``` -------------------------------- ### Read Serpent Data File Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/BranchToNodalDiffusion.ipynb Use serpentTools.readDataFile to load Serpent output files. This is the primary method for reading data unless you are following along with specific examples. ```python coe = serpentTools.readDataFile('demo.coe') ``` -------------------------------- ### Access Available Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Settings.rst The rc object can be queried like a dictionary to view all available settings. ```python rc.keys() ``` -------------------------------- ### Initialize Depletion Matrix Reader Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/DepletionMatrix.rst Instantiate the DepmtxReader to read data from a depletion matrix file. The preferred method for reading output files is `serpentTools.readDataFile`. ```python import serpentTools reader = serpentTools.readDataFile('depmtx_ref.m') ``` -------------------------------- ### Example of Shared Variable Groups using YAML Anchors Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/serpentVersions.rst YAML anchors (&) and aliases (*) can be used to share variable groups between different SERPENT versions when they are similar but not identical. ```yaml parentV: parentG: !!set &parentG {vx0, vx1, ...} childV: childG: *parentG ``` -------------------------------- ### Access Detector by Index Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Detector.rst Demonstrates accessing Detector objects from a DetectorReader using dictionary-like indexing and the .get() method. This is an alternative to accessing the 'detectors' attribute directly. ```python pin["nodeFlx"] is pin.detectors["nodeFlx"] bwr.get("spectrum") is bwr.detectors["spectrum"] ``` -------------------------------- ### Sphinx Python Object Reference - Class Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/develop/documentation.rst Example of using Sphinx's reStructuredText directive to link to a Python class. This creates a clickable link to the class documentation. ```rst :class:`serpentTools.DepletionReader` ``` -------------------------------- ### Read Branching Coefficient File Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Branching.rst Demonstrates the basic operation of reading a branching coefficient file using serpentTools. The preferred method is `readDataFile`. ```python import serpentTools branchFile = 'demo.coe' r0 = serpentTools.readDataFile(branchFile) ``` -------------------------------- ### Retrieve Specific Cross Section Value Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/BranchToNodalDiffusion.ipynb Index into the cross-section table using the order defined by 'axis', 'univIndex', 'states', and 'burnups' to get a specific cross-section value. ```python infT[1, 0, 2, 2] ``` -------------------------------- ### Load YAML Configuration and Access Settings Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Settings.ipynb Load settings from a YAML file into the `rc` object and access specific settings using dictionary-like syntax. The `loadYaml` method processes the configuration file. ```python myConf = 'myConfig.yaml' rc.loadYaml(myConf) rc['xs.getInfXS'] ``` -------------------------------- ### Get Shape of Energy-Integrated Keff Sensitivity Array Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Sensitivity.ipynb Prints the shape of the energy-integrated 'keff' sensitivity array. This provides a summarized sensitivity value across all energy groups. ```python print(sens.energyIntegratedSens['keff'].shape) ``` -------------------------------- ### SerpentTools CLI: Version, List, Seed, and To-Matlab Source: https://context7.com/core-gatech-group/serpent-tools/llms.txt Utilize the serpentTools command-line interface for managing settings, generating seeded input files, and converting SERPENT output to MATLAB format. Supports verbosity flags and configuration file loading. ```bash # Display version python -m serpentTools --version # List all settings and their defaults python -m serpentTools list python -m serpentTools list --pattern "depletion.*" # Generate seeded input copies python -m serpentTools seed reactor.inp 10 --output-dir runs/ --link --length 12 # Convert a SERPENT output file to a MATLAB .mat file python -m serpentTools to-matlab reactor_dep.m -o reactor_dep.mat python -m serpentTools to-matlab reactor_dep.m --append --format 5 --longNames # Verbosity flags (mutually exclusive) python -m serpentTools -v list # info-level messages python -m serpentTools -vv list # debug-level messages python -m serpentTools -q to-matlab reactor_res.m # suppress warnings # Load a YAML config file before executing a subcommand python -m serpentTools -c myConfig.yaml to-matlab reactor_dep.m ``` -------------------------------- ### Retrieve Specific Group Constants Source: https://github.com/core-gatech-group/serpent-tools/blob/main/docs/examples/Branching.rst Use the get method on HomogUniv objects to retrieve specific group constants. A KeyError is raised if uncertainties are requested but not available for a variable. ```python >>> univ0.get('infFiss') array([ 0.00271604, 0.059773 ]) >>> try: ... univ0.get('infS0', uncertainty=True) >>> except KeyError as ke: # no uncertainties here ... print(str(ke)) 'Variable infS0 absent from uncertainty dictionary' ``` -------------------------------- ### Display First 10 Lethargy Widths Source: https://github.com/core-gatech-group/serpent-tools/blob/main/examples/Sensitivity.ipynb Shows the first 10 lethargy widths. These values indicate the relative size of each energy bin on a logarithmic scale. ```python print(sens.lethargyWidths[:10]) ```