Skip to content

Commit

Permalink
add notes about using constants in input files
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibbelink committed Aug 8, 2024
1 parent 6e0fd66 commit efa3412
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
19 changes: 19 additions & 0 deletions source/arche/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ the ``cyclus`` package is in your Python path:
my_small_value = CY_NEAR_ZERO
...
This holds true for |Cyclus| input files:

.. code-block:: python
from cyclus.system import CY_LARGE_DOUBLE
SIMULATION = { 'simulation':
...
'facility': [
{ 'config':
{ 'Source':
{ 'capacity': CY_LARGE_DOUBLE,
...
.. warning::
Only input files written in Python can access the constants in this way, since the variables are evaluated
prior to schema validation. Any attempt to use them in an XML input file will likely fail schema validation since
they will be evaluated as strings instead of the corresponding values in C++/Python.
Using constants with the Cyclus Preprocessor
--------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion source/user/writing_input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ contains all data for a simulation.
# dictionary with a single "simulation" key.
simulation = {"simulation": {...}}
# Alternitavely, the simualtion variable can also be a Python function or
# Alternatively, the simulation variable can also be a Python function or
# callable that returns a simulation dictionary. This function should not
# take any arguments.
def simulation():
return {"simulation": {...}}
.. note::
Some :ref:`constants <constants>` are provided by |Cyclus| and can be leveraged in Python input files.
Keep them in mind when defining near-zero values, or very large integer/double values. This
can help keep your simulation within the constraints of the program and avoid runtime errors.

Although not all sections are required, the following sections may appear in
any order in the input file:
Expand Down

0 comments on commit efa3412

Please sign in to comment.