Files
GridFire/docs/html/index.html

383 lines
30 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.13.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>GridFire: GridFire</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
<link href="doxygen-awesome-sidebar-only.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">GridFire<span id="projectnumber">&#160;0.0.1a</span>
</div>
<div id="projectbrief">General Purpose Nuclear Network</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.13.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){initNavTree('index.html',''); initResizable(true); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">GridFire </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md_docs_2static_2mainpage"></a></p>
<p><img src="../../assets/logo/GridFire.png" alt="GridFire Logo" class="inline"/></p>
2025-07-24 11:10:45 -04:00
<hr />
<p> GridFire is a C++ library designed to perform general nuclear network evolution using the Reaclib library. It is part of the larger SERiF project within the 4D-STAR collaboration. GridFire is primarily focused on modeling the most relevant burning stages for stellar evolution modeling. Currently, there is limited support for inverse reactions. Therefore, GridFire has a limited set of tools to evolves a fusing plasma in NSE; however, this is not the primary focus of the library and has therefor not had significant development. For those interested in modeling super nova, neutron star mergers, or other high-energy astrophysical phenomena, we <b>strongly</b> recomment using <a href="https://bitbucket.org/jlippuner/skynet/src/master/">SkyNet</a>.</p>
<p><b>Design Philosophy and Workflow:</b> GridFire is architected to balance physical fidelity, computational efficiency, and extensibility when simulating complex nuclear reaction networks. Users begin by defining a composition, which is used to construct a full GraphEngine representation of the reaction network. To manage the inherent stiffness and multiscale nature of these networks, GridFire employs a layered view strategy: partitioning algorithms isolate fast and slow processes, adaptive culling removes negligible reactions at runtime, and implicit solvers stably integrate the remaining stiff system. This modular pipeline allows researchers to tailor accuracy versus performance trade-offs, reuse common engine components, and extend screening or partitioning models without modifying core integration routines.</p>
<h2><a class="anchor" id="autotoc_md1"></a>
2025-07-24 11:10:45 -04:00
Funding</h2>
<p>GridFire is a part of the 4D-STAR collaboration.</p>
<p>4D-STAR is funded by European Research Council (ERC) under the Horizon Europe programme (Synergy Grant agreement No. 101071505: 4D-STAR) Work for this project is funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Council.</p>
<h2><a class="anchor" id="autotoc_md2"></a>
2025-07-24 11:10:45 -04:00
Build and Installation Instructions</h2>
<h3><a class="anchor" id="autotoc_md3"></a>
Prerequisites</h3>
<ul>
2025-07-24 11:10:45 -04:00
<li>C++ compiler supporting C++23 standard</li>
<li>Meson build system (&gt;= 1.5.0)</li>
<li>Python 3.10 or newer</li>
<li>Python packages: <code>meson-python&gt;=0.15.0</code></li>
<li>Boost libraries (&gt;= 1.75.0) installed system-wide</li>
</ul>
2025-07-24 11:10:45 -04:00
<blockquote class="doxtable">
<p><b>Note:</b> Boost is the only external library dependency; no additional libraries are required beyond a C++ compiler, Meson, Python, and Boost. </p>
</blockquote>
<blockquote class="doxtable">
<p><b>Note:</b> Windows is not supported at this time and <em>there are no plans to support it in the future</em>. Windows users are encouraged to use WSL2 or a Linux VM. </p>
2025-07-24 11:10:45 -04:00
</blockquote>
<h3><a class="anchor" id="autotoc_md4"></a>
Dependency Installation on Common Platforms</h3>
<ul>
<li><b>Ubuntu/Debian:</b> <div class="fragment"><div class="line">sudo apt-get update &amp;&amp; \</div>
<div class="line"> sudo apt-get install -y build-essential meson python3 python3-pip libboost-all-dev</div>
</div><!-- fragment --></li>
<li><b>Fedora/CentOS/RHEL:</b> <div class="fragment"><div class="line">sudo dnf install -y gcc-c++ meson python3 python3-pip boost-devel</div>
</div><!-- fragment --></li>
<li><b>macOS (Homebrew):</b> <div class="fragment"><div class="line">brew update &amp;&amp; \</div>
<div class="line"> brew install boost meson python</div>
</div><!-- fragment --></li>
</ul>
2025-07-24 11:10:45 -04:00
<h3><a class="anchor" id="autotoc_md5"></a>
Building the C++ Library</h3>
<div class="fragment"><div class="line">meson setup build</div>
<div class="line">meson compile -C build</div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md6"></a>
Installing the Library</h3>
<div class="fragment"><div class="line">meson install -C build</div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md7"></a>
Python Bindings and Installation</h3>
<p>The Python interface is provided via <code>meson-python</code> and <code>pybind11</code>. To install the Python package: </p><div class="fragment"><div class="line">pip install .</div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md8"></a>
Developer Workflow</h3>
<ol type="1">
<li>Clone the repository and install dependencies listed in <code>pyproject.toml</code>.</li>
<li>Configure and build with Meson: <div class="fragment"><div class="line">meson setup build</div>
<div class="line">meson compile -C build</div>
</div><!-- fragment --></li>
<li>Run the unit tests: <div class="fragment"><div class="line">meson test -C build</div>
</div><!-- fragment --></li>
<li>Iterate on code, rebuild, and rerun tests.</li>
</ol>
<h2><a class="anchor" id="autotoc_md9"></a>
Code Architecture and Logical Flow</h2>
<p>GridFire is organized into a series of composable modules, each responsible for a specific aspect of nuclear reaction network modeling. The core components include:</p>
<ul>
2025-07-24 11:10:45 -04:00
<li><b>Engine Module:</b> Core interfaces and implementations (e.g., <code>GraphEngine</code>) that evaluate reaction network rate equations and energy generation.</li>
<li><b>Screening Module:</b> Implements nuclear reaction screening corrections (<code>WeakScreening</code>, <code>BareScreening</code>, etc.) affecting reaction rates.</li>
<li><b>Reaction Module:</b> Parses and manages Reaclib reaction rate data, providing temperature- and density-dependent rate evaluations.</li>
<li><b>Partition Module:</b> Implements partition functions (e.g., <code>GroundStatePartitionFunction</code>, <code>RauscherThielemannPartitionFunction</code>) to weight reaction rates based on nuclear properties.</li>
<li><b>Solver Module:</b> Defines numerical integration strategies (e.g., <code>DirectNetworkSolver</code>) for solving the stiff ODE systems arising from reaction networks.</li>
<li><b>Python Interface:</b> Exposes <em>almost</em> all C++ functionality to Python, allowing users to define compositions, configure engines, and run simulations directly from Python scripts.</li>
2025-07-24 11:10:45 -04:00
</ul>
<p>Generally a user will start by selecting a base engine (currently we only offer <code>GraphEngine</code>), which constructs the full reaction network graph from a given composition. The user can then apply various engine views to adapt the network topology, such as partitioning fast and slow reactions, adaptively culling low-flow pathways, or priming the network with specific species. Finally, a numerical solver is selected to integrate the network over time, producing updated abundances and diagnostics.</p>
2025-07-24 11:10:45 -04:00
<h3><a class="anchor" id="autotoc_md10"></a>
GraphEngine Configuration Options</h3>
<p>GraphEngine exposes runtime configuration methods to tailor network construction and rate evaluations:</p>
<ul>
<li><b>Constructor Parameters:</b><ul>
<li><code>BuildDepthType</code> (<code>Full</code>/<code>Reduced</code>/<code>Minimal</code>): controls network build depth, trading startup time for network completeness.</li>
<li><code>partition::PartitionFunction</code>: custom functor for network partitioning based on <code>Z</code>, <code>A</code>, and <code>T9</code>.</li>
</ul>
</li>
2025-07-24 11:10:45 -04:00
<li><b>setPrecomputation(bool precompute):</b><ul>
<li>Enable/disable caching of reaction rates and stoichiometric data at initialization.</li>
<li><em>Effect:</em> Reduces per-step overhead; increases memory and setup time.</li>
</ul>
</li>
2025-07-24 11:10:45 -04:00
<li><b>setScreeningModel(ScreeningType type):</b><ul>
<li>Choose plasma screening (models: <code>BARE</code>, <code>WEAK</code>).</li>
<li><em>Effect:</em> Alters rate enhancement under dense/low-T conditions, impacting stiffness.</li>
</ul>
2025-07-24 11:10:45 -04:00
</li>
<li><b>setUseReverseReactions(bool useReverse):</b><ul>
<li>Toggle inclusion of reverse (detailed balance) reactions.</li>
<li><em>Effect:</em> Improves equilibrium fidelity; increases network size and stiffness.</li>
</ul>
</li>
</ul>
<h3><a class="anchor" id="autotoc_md11"></a>
Available Partition Functions</h3>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Function Name </th><th class="markdownTableHeadNone">Identifier </th><th class="markdownTableHeadNone">Description </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><code>GroundStatePartitionFunction</code> </td><td class="markdownTableBodyNone">"GroundState" </td><td class="markdownTableBodyNone">Weights using nuclear ground-state spin factors. </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><code>RauscherThielemannPartitionFunction</code> </td><td class="markdownTableBodyNone">"RauscherThielemann" </td><td class="markdownTableBodyNone">Interpolates normalized g-factors per Rauscher &amp; Thielemann. </td></tr>
</table>
<p>These functions implement: </p><div class="fragment"><div class="line"><span class="keywordtype">double</span> evaluate(<span class="keywordtype">int</span> Z, <span class="keywordtype">int</span> A, <span class="keywordtype">double</span> T9) <span class="keyword">const</span>;</div>
<div class="line"><span class="keywordtype">double</span> evaluateDerivative(<span class="keywordtype">int</span> Z, <span class="keywordtype">int</span> A, <span class="keywordtype">double</span> T9) <span class="keyword">const</span>;</div>
<div class="line"><span class="keywordtype">bool</span> supports(<span class="keywordtype">int</span> Z, <span class="keywordtype">int</span> A) <span class="keyword">const</span>;</div>
<div class="line">std::string type() <span class="keyword">const</span>;</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md12"></a>
Engine Views</h2>
<p>The GridFire engine supports multiple engine view strategies to adapt or restrict network topology. Each view implements a specific algorithm:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">View Name </th><th class="markdownTableHeadNone">Purpose </th><th class="markdownTableHeadNone">Algorithm / Reference </th><th class="markdownTableHeadNone">When to Use </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">AdaptiveEngineView </td><td class="markdownTableBodyNone">Dynamically culls low-flow species and reactions during runtime </td><td class="markdownTableBodyNone">Iterative flux thresholding to remove reactions below a flow threshold </td><td class="markdownTableBodyNone">Large networks to reduce computational cost </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">DefinedEngineView </td><td class="markdownTableBodyNone">Restricts the network to a user-specified subset of species and reactions </td><td class="markdownTableBodyNone">Static network masking based on user-provided species/reaction lists </td><td class="markdownTableBodyNone">Targeted pathway studies or code-to-code comparisons </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">MultiscalePartitioningEngineView </td><td class="markdownTableBodyNone">Partitions the network into fast and slow subsets based on reaction timescales </td><td class="markdownTableBodyNone">Network partitioning following Hix &amp; Thielemann Silicon Burning I &amp; II (DOI:10.1086/177016,10.1086/306692) </td><td class="markdownTableBodyNone">Stiff, multi-scale networks requiring tailored integration </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">NetworkPrimingEngineView </td><td class="markdownTableBodyNone">Primes the network with an initial species or set of species for ignition studies </td><td class="markdownTableBodyNone">Single-species injection with transient flow analysis </td><td class="markdownTableBodyNone">Investigations of ignition triggers or initial seed sensitivities </td></tr>
</table>
<p>These engine views implement the common Engine interface and may be composed in any order to build complex network pipelines. New view types can be added by deriving from the <code>EngineView</code> base class, and linked into the composition chain without modifying core engine code.</p>
<p><b>Python Extensibility:</b> Through the Python bindings, users can subclass engine view classes directly in Python, override methods like <code>evaluate</code> or <code>generateStoichiometryMatrix</code>, and pass instances back into C++ solvers. This enables rapid prototyping of custom view strategies without touching C++ sources.</p>
<h2><a class="anchor" id="autotoc_md13"></a>
Numerical Solver Strategies</h2>
<p>GridFire defines a flexible solver architecture through the <code>networkfire::solver::NetworkSolverStrategy</code> interface, enabling multiple ODE integration algorithms to be used interchangeably with any engine that implements the <code>Engine</code> or <code>DynamicEngine</code> contract.</p>
<ul>
2025-07-24 11:10:45 -04:00
<li><b>NetworkSolverStrategy&lt;EngineT&gt;</b>: Abstract strategy templated on an engine type. Requires implementation of: <div class="fragment"><div class="line">NetOut evaluate(<span class="keyword">const</span> NetIn&amp; netIn);</div>
</div><!-- fragment --> which integrates the network over one timestep and returns updated abundances, temperature, density, and diagnostics.</li>
</ul>
2025-07-24 11:10:45 -04:00
<h3><a class="anchor" id="autotoc_md14"></a>
DirectNetworkSolver (Implicit Rosenbrock Method)</h3>
<ul>
2025-07-24 11:10:45 -04:00
<li><b>Integrator:</b> Implicit Rosenbrock4 scheme (order 4) via Boost.Odeints <code>rosenbrock4&lt;double&gt;</code>, optimized for stiff reaction networks with adaptive step size control using configurable absolute and relative tolerances.</li>
<li><b>Jacobian Assembly:</b> Employs the <code>JacobianFunctor</code> to assemble the Jacobian matrix (∂f/∂Y) at each step, enabling stable implicit integration.</li>
<li><b>RHS Evaluation:</b> Continues to use the <code>RHSManager</code> to compute and cache derivative evaluations and specific energy rates, minimizing redundant computations.</li>
<li><b>Linear Algebra:</b> Utilizes Boost.uBLAS for state vectors and dense Jacobian matrices, with sparse access patterns supported via coordinate lists of nonzero entries.</li>
<li><b>Error Control and Logging:</b> Absolute and relative tolerance parameters (<code>absTol</code>, <code>relTol</code>) are read from configuration; Quill logger captures integration diagnostics and step statistics.</li>
</ul>
2025-07-24 11:10:45 -04:00
<h3><a class="anchor" id="autotoc_md15"></a>
Algorithmic Workflow in DirectNetworkSolver</h3>
<ol type="1">
<li><b>Initialization:</b> Convert input temperature to T9 units, retrieve tolerances, and initialize state vector <code>Y</code> from equilibrated composition.</li>
<li><b>Integrator Setup:</b> Construct the controlled Rosenbrock4 stepper and bind <code>RHSManager</code> and <code>JacobianFunctor</code>.</li>
<li><b>Adaptive Integration Loop:</b><ul>
<li>Perform <code>integrate_adaptive</code> advancing until <code>tMax</code>, catching any <code>StaleEngineTrigger</code> to repartition the network and update composition.</li>
<li>On each substep, observe states and log via <code>RHSManager::observe</code>.</li>
</ul>
</li>
<li><b>Finalization:</b> Assemble final mass fractions, compute accumulated energy, and populate <code>NetOut</code> with updated composition and diagnostics.</li>
</ol>
<h3><a class="anchor" id="autotoc_md16"></a>
Future Solver Implementations</h3>
<ul>
2025-07-24 11:10:45 -04:00
<li><b>Operator Splitting Solvers:</b> Strategies to decouple thermodynamics, screening, and reaction substeps for performance on stiff, multi-scale networks.</li>
<li><b>GPU-Accelerated Solvers:</b> Planned use of CUDA/OpenCL backends for large-scale network integration.</li>
</ul>
2025-07-24 11:10:45 -04:00
<p>These strategies can be developed by inheriting from <code>NetworkSolverStrategy</code> and registering against the same engine types without modifying existing engine code.</p>
<h2><a class="anchor" id="autotoc_md17"></a>
Usage Examples</h2>
<h3><a class="anchor" id="autotoc_md18"></a>
C++ Example: GraphEngine Initialization</h3>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="engine__graph_8h.html">gridfire/engine/engine_graph.h</a>&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;fourdst/composition/composition.h&quot;</span></div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment">// Define a composition and initialize the engine</span></div>
<div class="line">fourdst::composition::Composition comp;</div>
<div class="line"><a class="code hl_class" href="classgridfire_1_1_graph_engine.html">gridfire::GraphEngine</a> engine(comp);</div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html">gridfire::GraphEngine</a></div><div class="ttdoc">A reaction network engine that uses a graph-based representation.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8h_source.html#l00100">engine_graph.h:100</a></div></div>
2025-07-24 11:10:45 -04:00
<div class="ttc" id="aengine__graph_8h_html"><div class="ttname"><a href="engine__graph_8h.html">engine_graph.h</a></div></div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md19"></a>
C++ Example: Adaptive Network View</h3>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="engine__adaptive_8h.html">gridfire/engine/views/engine_adaptive.h</a>&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="engine__graph_8h.html">gridfire/engine/engine_graph.h</a>&quot;</span></div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line">fourdst::composition::Composition comp;</div>
<div class="line"><a class="code hl_class" href="classgridfire_1_1_graph_engine.html">gridfire::GraphEngine</a> baseEngine(comp);</div>
<div class="line"><span class="comment">// Dynamically adapt network topology based on reaction flows</span></div>
<div class="line"><a class="code hl_class" href="classgridfire_1_1_adaptive_engine_view.html">gridfire::AdaptiveEngineView</a> adaptiveView(baseEngine);</div>
<div class="ttc" id="aclassgridfire_1_1_adaptive_engine_view_html"><div class="ttname"><a href="classgridfire_1_1_adaptive_engine_view.html">gridfire::AdaptiveEngineView</a></div><div class="ttdoc">An engine view that dynamically adapts the reaction network based on runtime conditions.</div><div class="ttdef"><b>Definition</b> <a href="engine__adaptive_8h_source.html#l00050">engine_adaptive.h:50</a></div></div>
<div class="ttc" id="aengine__adaptive_8h_html"><div class="ttname"><a href="engine__adaptive_8h.html">engine_adaptive.h</a></div></div>
</div><!-- fragment --><h3><a class="anchor" id="autotoc_md20"></a>
Python Example</h3>
<div class="fragment"><div class="line"><span class="keyword">import</span> gridfire</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">from</span> fourdst.composition <span class="keyword">import</span> Composition</div>
<div class="line"> </div>
<div class="line">symbols = [<span class="stringliteral">&quot;H-1&quot;</span>, ...]</div>
<div class="line">X = [0.708, ...]</div>
<div class="line"> </div>
<div class="line">comp = Composition()</div>
<div class="line">comp.registerSymbols(symbols)</div>
<div class="line">comp.setMassFraction(X)</div>
<div class="line">comp.finalize(true)</div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment"># Initialize GraphEngine with predefined composition</span></div>
<div class="line">engine = <a class="code hl_class" href="classgridfire_1_1_graph_engine.html">gridfire.GraphEngine</a>(comp)</div>
<div class="line">netIn = gridfire.types.NetIn</div>
<div class="line">netIn.composition = comp</div>
<div class="line">netIn.tMax = 1e-3</div>
<div class="line">netIn.temperature = 1.5e7</div>
<div class="line">netIn.density = 1.6e2</div>
<div class="line">netIn.dt0 = 1e-12</div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment"># Perform one integration step</span></div>
<div class="line">netOut = engine.evaluate(netIn)</div>
<div class="line">print(netOut)</div>
</div><!-- fragment --><p>More detailed python usage can be found <a class="el" href="md_docs_2static_2usage.html">here</a></p>
<h2><a class="anchor" id="autotoc_md21"></a>
2025-07-24 11:10:45 -04:00
Common Workflow Example</h2>
<p>A representative workflow often composes multiple engine views to balance accuracy, stability, and performance when integrating stiff nuclear networks:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="engine__graph_8h.html">gridfire/engine/engine_graph.h</a>&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="engine__multiscale_8h.html">gridfire/engine/views/engine_multiscale.h</a>&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="engine__adaptive_8h.html">gridfire/engine/views/engine_adaptive.h</a>&quot;</span></div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="solver_8h.html">gridfire/solver/solver.h</a>&quot;</span></div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="preprocessor">#include &quot;fourdst/composition/composition.h&quot;</span></div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment">// 1. Define initial composition</span></div>
<div class="line">fourdst::composition::Composition comp;</div>
<div class="line"><span class="comment">// 2. Create base network engine (full reaction graph)</span></div>
<div class="line"><a class="code hl_class" href="classgridfire_1_1_graph_engine.html">gridfire::GraphEngine</a> baseEngine(comp);</div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment">// 3. Partition network into fast/slow subsets (reduces stiffness)</span></div>
<div class="line"><a class="code hl_class" href="classgridfire_1_1_multiscale_partitioning_engine_view.html">gridfire::MultiscalePartitioningEngineView</a> msView(baseEngine);</div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment">// 4. Adaptively cull negligible flux pathways (reduces dimension &amp; stiffness)</span></div>
<div class="line"><a class="code hl_class" href="classgridfire_1_1_adaptive_engine_view.html">gridfire::AdaptiveEngineView</a> adaptView(msView);</div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment">// 5. Construct implicit solver (handles remaining stiffness)</span></div>
<div class="line">gridfire::DirectNetworkSolver solver(adaptView);</div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment">// 6. Prepare input conditions</span></div>
<div class="line">NetIn input{</div>
<div class="line"> comp, <span class="comment">// composition</span></div>
<div class="line"> 1.5e7, <span class="comment">// temperature [K]</span></div>
<div class="line"> 1.5e2, <span class="comment">// density [g/cm^3]</span></div>
<div class="line"> 1e-12, <span class="comment">// initial timestep [s]</span></div>
<div class="line"> 3e17 <span class="comment">// integration end time [s]</span></div>
<div class="line">};</div>
<div class="line"> </div>
2025-07-24 11:10:45 -04:00
<div class="line"><span class="comment">// 7. Execute integration</span></div>
<div class="line">NetOut output = solver.evaluate(input);</div>
<div class="ttc" id="aclassgridfire_1_1_multiscale_partitioning_engine_view_html"><div class="ttname"><a href="classgridfire_1_1_multiscale_partitioning_engine_view.html">gridfire::MultiscalePartitioningEngineView</a></div><div class="ttdoc">An engine view that partitions the reaction network into multiple groups based on timescales.</div><div class="ttdef"><b>Definition</b> <a href="engine__multiscale_8h_source.html#l00174">engine_multiscale.h:174</a></div></div>
<div class="ttc" id="aengine__multiscale_8h_html"><div class="ttname"><a href="engine__multiscale_8h.html">engine_multiscale.h</a></div></div>
<div class="ttc" id="asolver_8h_html"><div class="ttname"><a href="solver_8h.html">solver.h</a></div></div>
</div><!-- fragment --><p><b>Workflow Components and Effects:</b></p><ul>
<li><b>GraphEngine</b> constructs the full reaction network, capturing all species and reactions.</li>
<li><b>MultiscalePartitioningEngineView</b> segregates reactions by characteristic timescales (Hix &amp; Thielemann), reducing the effective stiffness by treating fast processes separately.</li>
<li><b>AdaptiveEngineView</b> prunes low-flux species/reactions at runtime, decreasing dimensionality and improving computational efficiency.</li>
<li><b>DirectNetworkSolver</b> employs an implicit Rosenbrock method to stably integrate the remaining stiff system with adaptive step control.</li>
</ul>
<p>This layered approach enhances stability for stiff networks while maintaining accuracy and performance.</p>
<h2><a class="anchor" id="autotoc_md22"></a>
Related Projects</h2>
<p>GridFire integrates with and builds upon several key 4D-STAR libraries:</p>
<ul>
<li><a href="https://github.com/4D-STAR/fourdst">fourdst</a>: hub module managing versioning of <code>libcomposition</code>, <code>libconfig</code>, <code>liblogging</code>, and <code>libconstants</code></li>
<li><a href="https://github.com/4D-STAR/libcomposition">libcomposition</a> (<a href="https://4d-star.github.io/libcomposition/">docs</a>): Composition management toolkit.</li>
<li><a href="https://github.com/4D-STAR/libconfig">libconfig</a>: Configuration file parsing utilities.</li>
<li><a href="https://github.com/4D-STAR/liblogging">liblogging</a>: Flexible logging framework.</li>
<li><a href="https://github.com/4D-STAR/libconstants">libconstants</a>: Physical constants </li>
</ul>
</div></div><!-- PageDoc -->
<a href="doxygen_crawl.html"></a>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </li>
</ul>
</div>
</body>
</html>