From 6e0fd66bf6224fcf83d938aa2a72c44bb55a92ad Mon Sep 17 00:00:00 2001 From: Ben Nibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Sat, 3 Aug 2024 17:44:05 -0400 Subject: [PATCH] cosmetic changes and content edits --- source/arche/constants.rst | 73 +++++++++++++------------ source/arche/tutorial_cpp/state_var.rst | 2 +- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/source/arche/constants.rst b/source/arche/constants.rst index f5f91939..e98e955a 100644 --- a/source/arche/constants.rst +++ b/source/arche/constants.rst @@ -1,55 +1,59 @@ .. _constants: -Using standard constants in |Cyclus| +|Cyclus| Defined Constants ====================================== Cyclus defines a set of constants to help standardize archetype properties and prevent unexpected simulation failures. These constants are determined at build time and may -depend on your system's architecture (e.g. for maximum integer size). This set is -defined twice, with identical values existing in the C++ namespace and Python library. +depend on your system's architecture (specifically the size of an ``int`` type, in bytes). +This set is defined twice, with identical values existing in the C++ namespace and Python library. The numeric values are as follows: -.. list-table:: Cyclus constant values - :widths: 25 25 25 - :header-rows: 1 +.. list-table:: + :width: 100% + :widths: 25 75 + :header-rows: 1 - * - Name - - Value - * - CY_LARGE_INT - - 2147483647 (on most 64-bit machines; this should be equal to std::numeric_limits::max()) - * - CY_LARGE_DOUBLE - - 1e299 - * - CY_NEAR_ZERO - - 1e-08 + * - Name + - Value + * - CY_LARGE_INT + - | 2147483647 on most 64-bit machines. + | This should be equal to ``std::numeric_limits::max()``. + * - CY_LARGE_DOUBLE + - 1e299 + * - CY_NEAR_ZERO + - 1e-08 Accessing constants in C++ -------------------------- The constants are defined in ``cyclus/cyc_limits.h`` and exist in the ``cyclus::`` namespace. They can be -included and used as so: +used in this way: .. code-block:: cpp - #include "cyclus.h" - ... - double my_large_double = cyclus::CY_LARGE_DOUBLE; - ... + + #include "cyclus.h" + ... + int my_large_int = cyclus::CY_LARGE_INT; + ... Accessing constants in Python ----------------------------- The constants are defined in the ``cyclus.system`` module and can be imported and used as long as -the cyclus package is in your Python path: +the ``cyclus`` package is in your Python path: .. code-block:: python - from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO - ... - my_small_value = CY_NEAR_ZERO - ... + + from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO + ... + my_small_value = CY_NEAR_ZERO + ... Using constants with the Cyclus Preprocessor -------------------------------------------- -Many archetype developers utilize the Cyclus Preprocessor and ``#pragma cyclus`` to +Many archetype developers utilize the :ref:`Cyclus Preprocessor ` and ``#pragma cyclus`` to define state variables within an archetype. The preprocessor allows any arbitrary Python code to be executed via ``#pragma cyclus exec``. Thus one can import the set of Python constants into the global namespace that agent annotations are processed, @@ -58,14 +62,15 @@ following ``#pragma cyclus var`` is evaluated by the Python interpreter, so you treat it as if it were Python code. .. code-block:: cpp - #pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE - ... + #pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE + + ... - #pragma cyclus var {"default": CY_LARGE_DOUBLE, \ - "tooltip": "sink maximum inventory size", \ - "uilabel": "Maximum Inventory", \ - "uitype": "range", \ - "range": [0.0, CY_LARGE_DOUBLE], \ - "doc": "total maximum inventory size of sink facility"} - double max_inv_size; + #pragma cyclus var {"default": CY_LARGE_DOUBLE, \ + "tooltip": "sink maximum inventory size", \ + "uilabel": "Maximum Inventory", \ + "uitype": "range", \ + "range": [0.0, CY_LARGE_DOUBLE], \ + "doc": "total maximum inventory size of sink facility"} + double max_inv_size; diff --git a/source/arche/tutorial_cpp/state_var.rst b/source/arche/tutorial_cpp/state_var.rst index 3ca2b0d3..531178a7 100644 --- a/source/arche/tutorial_cpp/state_var.rst +++ b/source/arche/tutorial_cpp/state_var.rst @@ -61,7 +61,7 @@ stored and the input/output commodity names. .. note:: Sometimes you may wish to include numeric values in your state variable definitions, such as a default value or range of possible values. Cyclus provides a set of constants - that might be of use, see :ref:`constants` for more information. + that might be of use, see :ref:`documentation on standard constants ` for more information. Build and Install the Modified Module ---------------------------------------