Files
GridFire/docs/engine__graph_8h_source.html

463 lines
84 KiB
HTML

<!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: src/network/include/gridfire/engine/engine_graph.h Source File</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('engine__graph_8h_source.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 class="header">
<div class="headertitle"><div class="title">engine_graph.h</div></div>
</div><!--header-->
<div class="contents">
<a href="engine__graph_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno"> 2</span> </div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno"> 3</span><span class="preprocessor">#include &quot;fourdst/composition/atomicSpecies.h&quot;</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno"> 4</span><span class="preprocessor">#include &quot;fourdst/composition/composition.h&quot;</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="preprocessor">#include &quot;fourdst/logging/logging.h&quot;</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span><span class="preprocessor">#include &quot;fourdst/config/config.h&quot;</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno"> 7</span> </div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno"> 8</span><span class="preprocessor">#include &quot;<a class="code" href="network_8h.html">gridfire/network.h</a>&quot;</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno"> 9</span><span class="preprocessor">#include &quot;<a class="code" href="reaction_8h.html">gridfire/reaction/reaction.h</a>&quot;</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"> 10</span><span class="preprocessor">#include &quot;<a class="code" href="engine__abstract_8h.html">gridfire/engine/engine_abstract.h</a>&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> </div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="preprocessor">#include &lt;unordered_map&gt;</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> </div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span><span class="preprocessor">#include &lt;boost/numeric/ublas/matrix_sparse.hpp&gt;</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span><span class="preprocessor">#include &quot;cppad/cppad.hpp&quot;</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> </div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="comment">// PERF: The function getNetReactionStoichiometry returns a map of species to their stoichiometric coefficients for a given reaction.</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="comment">// this makes extra copies of the species, which is not ideal and could be optimized further.</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="comment">// Even more relevant is the member m_reactionIDMap which makes copies of a REACLIBReaction for each reaction ID.</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span><span class="comment">// REACLIBReactions are quite large data structures, so this could be a performance bottleneck.</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespacegridfire.html">gridfire</a> {</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="namespacegridfire.html#a1121d0b2d005195333412559fa29d3cc"> 31</a></span> <span class="keyword">typedef</span> CppAD::AD&lt;double&gt; <a class="code hl_typedef" href="namespacegridfire.html#a1121d0b2d005195333412559fa29d3cc">ADDouble</a>;</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> </div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> <span class="keyword">using </span>fourdst::config::Config;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> <span class="keyword">using </span>fourdst::logging::LogManager;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> <span class="keyword">using </span>fourdst::constant::Constants;</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"><a class="line" href="namespacegridfire.html#ada3c137c014ecd8d06200fea2d1a9f50"> 44</a></span> <span class="keyword">static</span> <span class="keyword">constexpr</span> <span class="keywordtype">double</span> <a class="code hl_variable" href="namespacegridfire.html#ada3c137c014ecd8d06200fea2d1a9f50">MIN_DENSITY_THRESHOLD</a> = 1e-18;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span></div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"><a class="line" href="namespacegridfire.html#a96c062f94713921e5d7568ecedcdcb06"> 53</a></span> <span class="keyword">static</span> <span class="keyword">constexpr</span> <span class="keywordtype">double</span> <a class="code hl_variable" href="namespacegridfire.html#a96c062f94713921e5d7568ecedcdcb06">MIN_ABUNDANCE_THRESHOLD</a> = 1e-18;</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"><a class="line" href="namespacegridfire.html#ae01b1738df1921db565bcbd68dd6cf64"> 61</a></span> <span class="keyword">static</span> <span class="keyword">constexpr</span> <span class="keywordtype">double</span> <a class="code hl_variable" href="namespacegridfire.html#ae01b1738df1921db565bcbd68dd6cf64">MIN_JACOBIAN_THRESHOLD</a> = 1e-24;</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span></div>
<div class="foldopen" id="foldopen00086" data-start="{" data-end="};">
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html"> 86</a></span> <span class="keyword">class </span><a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a9f74786ff930ab72664b31f29d05a30c">GraphEngine</a> final : <span class="keyword">public</span> <a class="code hl_class" href="classgridfire_1_1_dynamic_engine.html">DynamicEngine</a>{</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> <span class="keyword">public</span>:</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> <span class="keyword">explicit</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a9f74786ff930ab72664b31f29d05a30c">GraphEngine</a>(<span class="keyword">const</span> fourdst::composition::Composition &amp;composition);</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> <span class="keyword">explicit</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a9f74786ff930ab72664b31f29d05a30c">GraphEngine</a>(<a class="code hl_class" href="classgridfire_1_1reaction_1_1_logical_reaction_set.html">reaction::LogicalReactionSet</a> reactions);</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span></div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span> <a class="code hl_struct" href="structgridfire_1_1_step_derivatives.html">StepDerivatives&lt;double&gt;</a> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a8b3baf29829c7ae0a61430ea70632bbf">calculateRHSAndEnergy</a>(</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno"> 124</span> <span class="keyword">const</span> std::vector&lt;double&gt;&amp; Y,</div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno"> 125</span> <span class="keyword">const</span> <span class="keywordtype">double</span> T9,</div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno"> 126</span> <span class="keyword">const</span> <span class="keywordtype">double</span> rho</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> ) <span class="keyword">const override</span>;</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span></div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno"> 142</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#ae347ff0316e532e0298ec8c913908105">generateJacobianMatrix</a>(</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"> 143</span> <span class="keyword">const</span> std::vector&lt;double&gt;&amp; Y,</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno"> 144</span> <span class="keyword">const</span> <span class="keywordtype">double</span> T9,</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno"> 145</span> <span class="keyword">const</span> <span class="keywordtype">double</span> rho</div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno"> 146</span> ) <span class="keyword">override</span>;</div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span></div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#aed726d36ee2b3796beff6067a1e4db38">generateStoichiometryMatrix</a>() <span class="keyword">override</span>;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span></div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> <span class="keywordtype">double</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">calculateMolarReactionFlow</a>(</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> <span class="keyword">const</span> <a class="code hl_class" href="classgridfire_1_1reaction_1_1_reaction.html">reaction::Reaction</a>&amp; <a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a>,</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> <span class="keyword">const</span> std::vector&lt;double&gt;&amp;Y,</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> <span class="keyword">const</span> <span class="keywordtype">double</span> T9,</div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> <span class="keyword">const</span> <span class="keywordtype">double</span> rho</div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno"> 173</span> ) <span class="keyword">const override</span>;</div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno"> 174</span></div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno"> 179</span> [[nodiscard]] <span class="keyword">const</span> std::vector&lt;fourdst::atomic::Species&gt;&amp; <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a0ed390f3e598ebba4e245ac90bb78767">getNetworkSpecies</a>() <span class="keyword">const override</span>;</div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno"> 180</span></div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno"> 185</span> [[nodiscard]] <span class="keyword">const</span> <a class="code hl_class" href="classgridfire_1_1reaction_1_1_logical_reaction_set.html">reaction::LogicalReactionSet</a>&amp; <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#ad45650d10fc5dff1673ae3f806d067da">getNetworkReactions</a>() <span class="keyword">const override</span>;</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno"> 186</span></div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno"> 198</span> [[nodiscard]] <span class="keywordtype">double</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a303e6093591cde91430f866a04a8be7c">getJacobianMatrixEntry</a>(</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno"> 199</span> <span class="keyword">const</span> <span class="keywordtype">int</span> i,</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno"> 200</span> <span class="keyword">const</span> <span class="keywordtype">int</span> j</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno"> 201</span> ) <span class="keyword">const override</span>;</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno"> 202</span></div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno"> 209</span> [[nodiscard]] <span class="keyword">static</span> std::unordered_map&lt;fourdst::atomic::Species, int&gt; <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a8c29d8bbde407e913be5eb77efb2c0c9">getNetReactionStoichiometry</a>(</div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno"> 210</span> <span class="keyword">const</span> <a class="code hl_class" href="classgridfire_1_1reaction_1_1_reaction.html">reaction::Reaction</a>&amp; <a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a></div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno"> 211</span> );</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno"> 212</span></div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno"> 224</span> [[nodiscard]] <span class="keywordtype">int</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a6b5feaf788bade212b7c8df7ac8c8152">getStoichiometryMatrixEntry</a>(</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno"> 225</span> <span class="keyword">const</span> <span class="keywordtype">int</span> speciesIndex,</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno"> 226</span> <span class="keyword">const</span> <span class="keywordtype">int</span> reactionIndex</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno"> 227</span> ) <span class="keyword">const override</span>;</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno"> 228</span></div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno"> 240</span> [[nodiscard]] std::unordered_map&lt;fourdst::atomic::Species, double&gt; <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a26215593544c3a52597194602e4e25dd">getSpeciesTimescales</a>(</div>
<div class="line"><a id="l00241" name="l00241"></a><span class="lineno"> 241</span> <span class="keyword">const</span> std::vector&lt;double&gt;&amp; Y,</div>
<div class="line"><a id="l00242" name="l00242"></a><span class="lineno"> 242</span> <span class="keywordtype">double</span> T9,</div>
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno"> 243</span> <span class="keywordtype">double</span> rho</div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno"> 244</span> ) <span class="keyword">const override</span>;</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno"> 245</span></div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno"> 252</span> [[nodiscard]] <span class="keywordtype">bool</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#aa6202cee0c3c481eda77cc9a91bc126b">involvesSpecies</a>(</div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno"> 253</span> <span class="keyword">const</span> fourdst::atomic::Species&amp; species</div>
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno"> 254</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno"> 255</span></div>
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno"> 272</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#adac8c7d62bae76e17fc060e86dadd929">exportToDot</a>(</div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno"> 273</span> <span class="keyword">const</span> std::string&amp; filename</div>
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno"> 274</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno"> 275</span></div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno"> 292</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a832e2fe066381811a3e0464806ff5e95">exportToCSV</a>(</div>
<div class="line"><a id="l00293" name="l00293"></a><span class="lineno"> 293</span> <span class="keyword">const</span> std::string&amp; filename</div>
<div class="line"><a id="l00294" name="l00294"></a><span class="lineno"> 294</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno"> 295</span> </div>
<div class="line"><a id="l00296" name="l00296"></a><span class="lineno"> 296</span> </div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno"> 297</span> <span class="keyword">private</span>:</div>
<div class="line"><a id="l00298" name="l00298"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#acb7c4f5108b0efeae48ad15598e808c3"> 298</a></span> <a class="code hl_class" href="classgridfire_1_1reaction_1_1_logical_reaction_set.html">reaction::LogicalReactionSet</a> <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#acb7c4f5108b0efeae48ad15598e808c3">m_reactions</a>; </div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a5d6cc63b99b467c2a976d1fbaaa1dfa3"> 299</a></span> std::unordered_map&lt;std::string_view, reaction::Reaction*&gt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a5d6cc63b99b467c2a976d1fbaaa1dfa3">m_reactionIDMap</a>; </div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno"> 300</span> </div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc"> 301</a></span> std::vector&lt;fourdst::atomic::Species&gt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc">m_networkSpecies</a>; </div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a30e09ed0bce6aa5fc89beaa316a7b827"> 302</a></span> std::unordered_map&lt;std::string_view, fourdst::atomic::Species&gt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a30e09ed0bce6aa5fc89beaa316a7b827">m_networkSpeciesMap</a>; </div>
<div class="line"><a id="l00303" name="l00303"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#ad8237c252145a75092202d00f5e1ddf7"> 303</a></span> std::unordered_map&lt;fourdst::atomic::Species, size_t&gt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#ad8237c252145a75092202d00f5e1ddf7">m_speciesToIndexMap</a>; </div>
<div class="line"><a id="l00304" name="l00304"></a><span class="lineno"> 304</span> </div>
<div class="line"><a id="l00305" name="l00305"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#ad1cb5fd32efc37668e2d9ecf0c72ad24"> 305</a></span> boost::numeric::ublas::compressed_matrix&lt;int&gt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#ad1cb5fd32efc37668e2d9ecf0c72ad24">m_stoichiometryMatrix</a>; </div>
<div class="line"><a id="l00306" name="l00306"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a2f1718c89d4aaad028102724d18fa910"> 306</a></span> boost::numeric::ublas::compressed_matrix&lt;double&gt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a2f1718c89d4aaad028102724d18fa910">m_jacobianMatrix</a>; </div>
<div class="line"><a id="l00307" name="l00307"></a><span class="lineno"> 307</span> </div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a2e22b111f6d00ecc9e3804a71f1ce876"> 308</a></span> CppAD::ADFun&lt;double&gt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a2e22b111f6d00ecc9e3804a71f1ce876">m_rhsADFun</a>; </div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno"> 309</span> </div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a3b17102b143435ddfdc015d7a50c4b18"> 310</a></span> Config&amp; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a3b17102b143435ddfdc015d7a50c4b18">m_config</a> = Config::getInstance();</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a0837bab6dcd111d9075c9343b90d64f1"> 311</a></span> Constants&amp; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a0837bab6dcd111d9075c9343b90d64f1">m_constants</a> = Constants::getInstance(); </div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a483979fc154adc88d029b3b672066d53"> 312</a></span> quill::Logger* <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a483979fc154adc88d029b3b672066d53">m_logger</a> = LogManager::getInstance().getLogger(<span class="stringliteral">&quot;log&quot;</span>);</div>
<div class="line"><a id="l00313" name="l00313"></a><span class="lineno"> 313</span> </div>
<div class="line"><a id="l00314" name="l00314"></a><span class="lineno"> 314</span> <span class="keyword">private</span>:</div>
<div class="line"><a id="l00322" name="l00322"></a><span class="lineno"> 322</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#acdce8d87e23a2cd1504bc9472e538c0f">syncInternalMaps</a>();</div>
<div class="line"><a id="l00323" name="l00323"></a><span class="lineno"> 323</span></div>
<div class="line"><a id="l00330" name="l00330"></a><span class="lineno"> 330</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#aedf42d83bfcc28313b6b6454034d2efa">collectNetworkSpecies</a>();</div>
<div class="line"><a id="l00331" name="l00331"></a><span class="lineno"> 331</span></div>
<div class="line"><a id="l00338" name="l00338"></a><span class="lineno"> 338</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a26602e1b3c610780a47b5a6511d6d567">populateReactionIDMap</a>();</div>
<div class="line"><a id="l00339" name="l00339"></a><span class="lineno"> 339</span></div>
<div class="line"><a id="l00346" name="l00346"></a><span class="lineno"> 346</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a47202c43342b96480070874bffce1391">populateSpeciesToIndexMap</a>();</div>
<div class="line"><a id="l00347" name="l00347"></a><span class="lineno"> 347</span></div>
<div class="line"><a id="l00355" name="l00355"></a><span class="lineno"> 355</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a5a5458ed01923124f2d7e1f04f32f138">reserveJacobianMatrix</a>();</div>
<div class="line"><a id="l00356" name="l00356"></a><span class="lineno"> 356</span></div>
<div class="line"><a id="l00366" name="l00366"></a><span class="lineno"> 366</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a95563f6bc86007d9ee053a0f1e15b889">recordADTape</a>();</div>
<div class="line"><a id="l00367" name="l00367"></a><span class="lineno"> 367</span></div>
<div class="line"><a id="l00377" name="l00377"></a><span class="lineno"> 377</span> [[nodiscard]] <span class="keywordtype">bool</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#acf4cfccea20f5cb31c9886bf233a28be">validateConservation</a>() <span class="keyword">const</span>;</div>
<div class="line"><a id="l00378" name="l00378"></a><span class="lineno"> 378</span></div>
<div class="line"><a id="l00390" name="l00390"></a><span class="lineno"> 390</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#aeeafeab40a5f4dbfae78bdc87e25e93f">validateComposition</a>(</div>
<div class="line"><a id="l00391" name="l00391"></a><span class="lineno"> 391</span> <span class="keyword">const</span> fourdst::composition::Composition &amp;composition,</div>
<div class="line"><a id="l00392" name="l00392"></a><span class="lineno"> 392</span> <span class="keywordtype">double</span> culling,</div>
<div class="line"><a id="l00393" name="l00393"></a><span class="lineno"> 393</span> <span class="keywordtype">double</span> T9</div>
<div class="line"><a id="l00394" name="l00394"></a><span class="lineno"> 394</span> );</div>
<div class="line"><a id="l00395" name="l00395"></a><span class="lineno"> 395</span></div>
<div class="line"><a id="l00409" name="l00409"></a><span class="lineno"> 409</span> <span class="keyword">template</span> &lt;IsArithmeticOrAD T&gt;</div>
<div class="line"><a id="l00410" name="l00410"></a><span class="lineno"> 410</span> T <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">calculateMolarReactionFlow</a>(</div>
<div class="line"><a id="l00411" name="l00411"></a><span class="lineno"> 411</span> <span class="keyword">const</span> <a class="code hl_class" href="classgridfire_1_1reaction_1_1_reaction.html">reaction::Reaction</a> &amp;<a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a>,</div>
<div class="line"><a id="l00412" name="l00412"></a><span class="lineno"> 412</span> <span class="keyword">const</span> std::vector&lt;T&gt; &amp;Y,</div>
<div class="line"><a id="l00413" name="l00413"></a><span class="lineno"> 413</span> <span class="keyword">const</span> T T9,</div>
<div class="line"><a id="l00414" name="l00414"></a><span class="lineno"> 414</span> <span class="keyword">const</span> T rho</div>
<div class="line"><a id="l00415" name="l00415"></a><span class="lineno"> 415</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00416" name="l00416"></a><span class="lineno"> 416</span></div>
<div class="line"><a id="l00429" name="l00429"></a><span class="lineno"> 429</span> <span class="keyword">template</span>&lt;IsArithmeticOrAD T&gt;</div>
<div class="line"><a id="l00430" name="l00430"></a><span class="lineno"> 430</span> <a class="code hl_struct" href="structgridfire_1_1_step_derivatives.html">StepDerivatives&lt;T&gt;</a> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#af41df9ce979b6410e12642cb093916c9">calculateAllDerivatives</a>(</div>
<div class="line"><a id="l00431" name="l00431"></a><span class="lineno"> 431</span> <span class="keyword">const</span> std::vector&lt;T&gt; &amp;Y_in,</div>
<div class="line"><a id="l00432" name="l00432"></a><span class="lineno"> 432</span> T T9,</div>
<div class="line"><a id="l00433" name="l00433"></a><span class="lineno"> 433</span> T rho</div>
<div class="line"><a id="l00434" name="l00434"></a><span class="lineno"> 434</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00435" name="l00435"></a><span class="lineno"> 435</span></div>
<div class="line"><a id="l00448" name="l00448"></a><span class="lineno"> 448</span> <a class="code hl_struct" href="structgridfire_1_1_step_derivatives.html">StepDerivatives&lt;double&gt;</a> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#af41df9ce979b6410e12642cb093916c9">calculateAllDerivatives</a>(</div>
<div class="line"><a id="l00449" name="l00449"></a><span class="lineno"> 449</span> <span class="keyword">const</span> std::vector&lt;double&gt;&amp; Y_in,</div>
<div class="line"><a id="l00450" name="l00450"></a><span class="lineno"> 450</span> <span class="keyword">const</span> <span class="keywordtype">double</span> T9,</div>
<div class="line"><a id="l00451" name="l00451"></a><span class="lineno"> 451</span> <span class="keyword">const</span> <span class="keywordtype">double</span> rho</div>
<div class="line"><a id="l00452" name="l00452"></a><span class="lineno"> 452</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00453" name="l00453"></a><span class="lineno"> 453</span></div>
<div class="line"><a id="l00466" name="l00466"></a><span class="lineno"> 466</span> <a class="code hl_struct" href="structgridfire_1_1_step_derivatives.html">StepDerivatives&lt;ADDouble&gt;</a> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#af41df9ce979b6410e12642cb093916c9">calculateAllDerivatives</a>(</div>
<div class="line"><a id="l00467" name="l00467"></a><span class="lineno"> 467</span> <span class="keyword">const</span> std::vector&lt;ADDouble&gt;&amp; Y_in,</div>
<div class="line"><a id="l00468" name="l00468"></a><span class="lineno"> 468</span> <span class="keyword">const</span> <a class="code hl_typedef" href="namespacegridfire.html#a1121d0b2d005195333412559fa29d3cc">ADDouble</a> &amp;T9,</div>
<div class="line"><a id="l00469" name="l00469"></a><span class="lineno"> 469</span> <span class="keyword">const</span> <a class="code hl_typedef" href="namespacegridfire.html#a1121d0b2d005195333412559fa29d3cc">ADDouble</a> &amp;rho</div>
<div class="line"><a id="l00470" name="l00470"></a><span class="lineno"> 470</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a id="l00471" name="l00471"></a><span class="lineno"> 471</span> };</div>
</div>
<div class="line"><a id="l00472" name="l00472"></a><span class="lineno"> 472</span> </div>
<div class="line"><a id="l00473" name="l00473"></a><span class="lineno"> 473</span> </div>
<div class="line"><a id="l00474" name="l00474"></a><span class="lineno"> 474</span> <span class="keyword">template</span>&lt;IsArithmeticOrAD T&gt;</div>
<div class="foldopen" id="foldopen00475" data-start="{" data-end="}">
<div class="line"><a id="l00475" name="l00475"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#af41df9ce979b6410e12642cb093916c9"> 475</a></span> <a class="code hl_struct" href="structgridfire_1_1_step_derivatives.html">StepDerivatives&lt;T&gt;</a> <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#af41df9ce979b6410e12642cb093916c9">GraphEngine::calculateAllDerivatives</a>(</div>
<div class="line"><a id="l00476" name="l00476"></a><span class="lineno"> 476</span> <span class="keyword">const</span> std::vector&lt;T&gt; &amp;Y_in, T T9, T rho)<span class="keyword"> const </span>{</div>
<div class="line"><a id="l00477" name="l00477"></a><span class="lineno"> 477</span> </div>
<div class="line"><a id="l00478" name="l00478"></a><span class="lineno"> 478</span> <span class="comment">// --- Setup output derivatives structure ---</span></div>
<div class="line"><a id="l00479" name="l00479"></a><span class="lineno"> 479</span> <a class="code hl_struct" href="structgridfire_1_1_step_derivatives.html">StepDerivatives&lt;T&gt;</a> result;</div>
<div class="line"><a id="l00480" name="l00480"></a><span class="lineno"> 480</span> result.<a class="code hl_variable" href="structgridfire_1_1_step_derivatives.html#ae0de268b86c2404379409c4feae0b34d">dydt</a>.resize(<a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc">m_networkSpecies</a>.size(), <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(0.0));</div>
<div class="line"><a id="l00481" name="l00481"></a><span class="lineno"> 481</span> </div>
<div class="line"><a id="l00482" name="l00482"></a><span class="lineno"> 482</span> <span class="comment">// --- AD Pre-setup (flags to control conditionals in an AD safe / branch aware manner) ---</span></div>
<div class="line"><a id="l00483" name="l00483"></a><span class="lineno"> 483</span> <span class="comment">// ----- Constants for AD safe calculations ---</span></div>
<div class="line"><a id="l00484" name="l00484"></a><span class="lineno"> 484</span> <span class="keyword">const</span> T zero = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(0.0);</div>
<div class="line"><a id="l00485" name="l00485"></a><span class="lineno"> 485</span> <span class="keyword">const</span> T one = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(1.0);</div>
<div class="line"><a id="l00486" name="l00486"></a><span class="lineno"> 486</span> </div>
<div class="line"><a id="l00487" name="l00487"></a><span class="lineno"> 487</span> <span class="comment">// ----- Initialize variables for molar concentration product and thresholds ---</span></div>
<div class="line"><a id="l00488" name="l00488"></a><span class="lineno"> 488</span> <span class="comment">// Note: the logic here is that we use CppAD::CondExprLt to test thresholds and if they are less we set the flag</span></div>
<div class="line"><a id="l00489" name="l00489"></a><span class="lineno"> 489</span> <span class="comment">// to zero so that the final returned reaction flow is 0. This is as opposed to standard if statements</span></div>
<div class="line"><a id="l00490" name="l00490"></a><span class="lineno"> 490</span> <span class="comment">// which create branches that break the AD tape.</span></div>
<div class="line"><a id="l00491" name="l00491"></a><span class="lineno"> 491</span> <span class="keyword">const</span> T rho_threshold = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(<a class="code hl_variable" href="namespacegridfire.html#ada3c137c014ecd8d06200fea2d1a9f50">MIN_DENSITY_THRESHOLD</a>);</div>
<div class="line"><a id="l00492" name="l00492"></a><span class="lineno"> 492</span> </div>
<div class="line"><a id="l00493" name="l00493"></a><span class="lineno"> 493</span> <span class="comment">// --- Check if the density is below the threshold where we ignore reactions ---</span></div>
<div class="line"><a id="l00494" name="l00494"></a><span class="lineno"> 494</span> T threshold_flag = CppAD::CondExpLt(rho, rho_threshold, zero, one); <span class="comment">// If rho &lt; threshold, set flag to 0</span></div>
<div class="line"><a id="l00495" name="l00495"></a><span class="lineno"> 495</span> </div>
<div class="line"><a id="l00496" name="l00496"></a><span class="lineno"> 496</span> std::vector&lt;T&gt; Y = Y_in;</div>
<div class="line"><a id="l00497" name="l00497"></a><span class="lineno"> 497</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc">m_networkSpecies</a>.size(); ++i) {</div>
<div class="line"><a id="l00498" name="l00498"></a><span class="lineno"> 498</span> <span class="comment">// We use CppAD::CondExpLt to handle AD taping and prevent branching</span></div>
<div class="line"><a id="l00499" name="l00499"></a><span class="lineno"> 499</span> <span class="comment">// Note that while this is syntactically more complex this is equivalent to</span></div>
<div class="line"><a id="l00500" name="l00500"></a><span class="lineno"> 500</span> <span class="comment">// if (Y[i] &lt; 0) {Y[i] = 0;}</span></div>
<div class="line"><a id="l00501" name="l00501"></a><span class="lineno"> 501</span> <span class="comment">// The issue is that this would introduce a branch which would require the auto diff tape to be re-recorded</span></div>
<div class="line"><a id="l00502" name="l00502"></a><span class="lineno"> 502</span> <span class="comment">// each timestep, which is very inefficient.</span></div>
<div class="line"><a id="l00503" name="l00503"></a><span class="lineno"> 503</span> Y[i] = CppAD::CondExpLt(Y[i], zero, zero, Y[i]); <span class="comment">// Ensure no negative abundances</span></div>
<div class="line"><a id="l00504" name="l00504"></a><span class="lineno"> 504</span> }</div>
<div class="line"><a id="l00505" name="l00505"></a><span class="lineno"> 505</span> </div>
<div class="line"><a id="l00506" name="l00506"></a><span class="lineno"> 506</span> <span class="keyword">const</span> T u = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(<a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a0837bab6dcd111d9075c9343b90d64f1">m_constants</a>.get(<span class="stringliteral">&quot;u&quot;</span>).value); <span class="comment">// Atomic mass unit in grams</span></div>
<div class="line"><a id="l00507" name="l00507"></a><span class="lineno"> 507</span> <span class="keyword">const</span> T N_A = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(<a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a0837bab6dcd111d9075c9343b90d64f1">m_constants</a>.get(<span class="stringliteral">&quot;N_a&quot;</span>).value); <span class="comment">// Avogadro&#39;s number in mol^-1</span></div>
<div class="line"><a id="l00508" name="l00508"></a><span class="lineno"> 508</span> <span class="keyword">const</span> T c = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(<a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a0837bab6dcd111d9075c9343b90d64f1">m_constants</a>.get(<span class="stringliteral">&quot;c&quot;</span>).value); <span class="comment">// Speed of light in cm/s</span></div>
<div class="line"><a id="l00509" name="l00509"></a><span class="lineno"> 509</span> </div>
<div class="line"><a id="l00510" name="l00510"></a><span class="lineno"> 510</span> <span class="comment">// --- SINGLE LOOP OVER ALL REACTIONS ---</span></div>
<div class="line"><a id="l00511" name="l00511"></a><span class="lineno"> 511</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> reactionIndex = 0; reactionIndex &lt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#acb7c4f5108b0efeae48ad15598e808c3">m_reactions</a>.size(); ++reactionIndex) {</div>
<div class="line"><a id="l00512" name="l00512"></a><span class="lineno"> 512</span> <span class="keyword">const</span> <span class="keyword">auto</span>&amp; <a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a> = <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#acb7c4f5108b0efeae48ad15598e808c3">m_reactions</a>[reactionIndex];</div>
<div class="line"><a id="l00513" name="l00513"></a><span class="lineno"> 513</span> </div>
<div class="line"><a id="l00514" name="l00514"></a><span class="lineno"> 514</span> <span class="comment">// 1. Calculate reaction rate</span></div>
<div class="line"><a id="l00515" name="l00515"></a><span class="lineno"> 515</span> <span class="keyword">const</span> T molarReactionFlow = <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">calculateMolarReactionFlow&lt;T&gt;</a>(<a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a>, Y, T9, rho);</div>
<div class="line"><a id="l00516" name="l00516"></a><span class="lineno"> 516</span> </div>
<div class="line"><a id="l00517" name="l00517"></a><span class="lineno"> 517</span> <span class="comment">// 2. Use the rate to update all relevant species derivatives (dY/dt)</span></div>
<div class="line"><a id="l00518" name="l00518"></a><span class="lineno"> 518</span> <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> speciesIndex = 0; speciesIndex &lt; <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc">m_networkSpecies</a>.size(); ++speciesIndex) {</div>
<div class="line"><a id="l00519" name="l00519"></a><span class="lineno"> 519</span> <span class="keyword">const</span> T nu_ij = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(<a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#ad1cb5fd32efc37668e2d9ecf0c72ad24">m_stoichiometryMatrix</a>(speciesIndex, reactionIndex));</div>
<div class="line"><a id="l00520" name="l00520"></a><span class="lineno"> 520</span> result.<a class="code hl_variable" href="structgridfire_1_1_step_derivatives.html#ae0de268b86c2404379409c4feae0b34d">dydt</a>[speciesIndex] += threshold_flag * nu_ij * molarReactionFlow / rho;</div>
<div class="line"><a id="l00521" name="l00521"></a><span class="lineno"> 521</span> }</div>
<div class="line"><a id="l00522" name="l00522"></a><span class="lineno"> 522</span> }</div>
<div class="line"><a id="l00523" name="l00523"></a><span class="lineno"> 523</span> </div>
<div class="line"><a id="l00524" name="l00524"></a><span class="lineno"> 524</span> T massProductionRate = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(0.0); <span class="comment">// [mol][s^-1]</span></div>
<div class="line"><a id="l00525" name="l00525"></a><span class="lineno"> 525</span> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span>&amp; [species, index] : <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#ad8237c252145a75092202d00f5e1ddf7">m_speciesToIndexMap</a>) {</div>
<div class="line"><a id="l00526" name="l00526"></a><span class="lineno"> 526</span> massProductionRate += result.<a class="code hl_variable" href="structgridfire_1_1_step_derivatives.html#ae0de268b86c2404379409c4feae0b34d">dydt</a>[index] * species.mass() * u;</div>
<div class="line"><a id="l00527" name="l00527"></a><span class="lineno"> 527</span> }</div>
<div class="line"><a id="l00528" name="l00528"></a><span class="lineno"> 528</span> </div>
<div class="line"><a id="l00529" name="l00529"></a><span class="lineno"> 529</span> result.<a class="code hl_variable" href="structgridfire_1_1_step_derivatives.html#ab4aeb41be952c7b5844e1ee81fef9008">nuclearEnergyGenerationRate</a> = -massProductionRate * N_A * c * c; <span class="comment">// [cm^2][s^-3] = [erg][s^-1][g^-1]</span></div>
<div class="line"><a id="l00530" name="l00530"></a><span class="lineno"> 530</span> </div>
<div class="line"><a id="l00531" name="l00531"></a><span class="lineno"> 531</span> <span class="keywordflow">return</span> result;</div>
<div class="line"><a id="l00532" name="l00532"></a><span class="lineno"> 532</span> }</div>
</div>
<div class="line"><a id="l00533" name="l00533"></a><span class="lineno"> 533</span> </div>
<div class="line"><a id="l00534" name="l00534"></a><span class="lineno"> 534</span> </div>
<div class="line"><a id="l00535" name="l00535"></a><span class="lineno"> 535</span> <span class="keyword">template</span> &lt;IsArithmeticOrAD T&gt;</div>
<div class="foldopen" id="foldopen00536" data-start="{" data-end="}">
<div class="line"><a id="l00536" name="l00536"></a><span class="lineno"><a class="line" href="classgridfire_1_1_graph_engine.html#a5e96b5a0b34c8932f0e14eabda57f1a4"> 536</a></span> T <a class="code hl_function" href="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">GraphEngine::calculateMolarReactionFlow</a>(</div>
<div class="line"><a id="l00537" name="l00537"></a><span class="lineno"> 537</span> <span class="keyword">const</span> <a class="code hl_class" href="classgridfire_1_1reaction_1_1_reaction.html">reaction::Reaction</a> &amp;<a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a>,</div>
<div class="line"><a id="l00538" name="l00538"></a><span class="lineno"> 538</span> <span class="keyword">const</span> std::vector&lt;T&gt; &amp;Y,</div>
<div class="line"><a id="l00539" name="l00539"></a><span class="lineno"> 539</span> <span class="keyword">const</span> T T9,</div>
<div class="line"><a id="l00540" name="l00540"></a><span class="lineno"> 540</span> <span class="keyword">const</span> T rho</div>
<div class="line"><a id="l00541" name="l00541"></a><span class="lineno"> 541</span> )<span class="keyword"> const </span>{</div>
<div class="line"><a id="l00542" name="l00542"></a><span class="lineno"> 542</span> </div>
<div class="line"><a id="l00543" name="l00543"></a><span class="lineno"> 543</span> <span class="comment">// --- Pre-setup (flags to control conditionals in an AD safe / branch aware manner) ---</span></div>
<div class="line"><a id="l00544" name="l00544"></a><span class="lineno"> 544</span> <span class="comment">// ----- Constants for AD safe calculations ---</span></div>
<div class="line"><a id="l00545" name="l00545"></a><span class="lineno"> 545</span> <span class="keyword">const</span> T zero = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(0.0);</div>
<div class="line"><a id="l00546" name="l00546"></a><span class="lineno"> 546</span> <span class="keyword">const</span> T one = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(1.0);</div>
<div class="line"><a id="l00547" name="l00547"></a><span class="lineno"> 547</span> </div>
<div class="line"><a id="l00548" name="l00548"></a><span class="lineno"> 548</span> <span class="comment">// ----- Initialize variables for molar concentration product and thresholds ---</span></div>
<div class="line"><a id="l00549" name="l00549"></a><span class="lineno"> 549</span> <span class="comment">// Note: the logic here is that we use CppAD::CondExprLt to test thresholds and if they are less we set the flag</span></div>
<div class="line"><a id="l00550" name="l00550"></a><span class="lineno"> 550</span> <span class="comment">// to zero so that the final returned reaction flow is 0. This is as opposed to standard if statements</span></div>
<div class="line"><a id="l00551" name="l00551"></a><span class="lineno"> 551</span> <span class="comment">// which create branches that break the AD tape.</span></div>
<div class="line"><a id="l00552" name="l00552"></a><span class="lineno"> 552</span> <span class="keyword">const</span> T Y_threshold = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(<a class="code hl_variable" href="namespacegridfire.html#a96c062f94713921e5d7568ecedcdcb06">MIN_ABUNDANCE_THRESHOLD</a>);</div>
<div class="line"><a id="l00553" name="l00553"></a><span class="lineno"> 553</span> T threshold_flag = one;</div>
<div class="line"><a id="l00554" name="l00554"></a><span class="lineno"> 554</span> </div>
<div class="line"><a id="l00555" name="l00555"></a><span class="lineno"> 555</span> <span class="comment">// --- Calculate the molar reaction rate (in units of [s^-1][cm^3(N-1)][mol^(1-N)] for N reactants) ---</span></div>
<div class="line"><a id="l00556" name="l00556"></a><span class="lineno"> 556</span> <span class="keyword">const</span> T k_reaction = <a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a>.calculate_rate(T9);</div>
<div class="line"><a id="l00557" name="l00557"></a><span class="lineno"> 557</span> </div>
<div class="line"><a id="l00558" name="l00558"></a><span class="lineno"> 558</span> <span class="comment">// --- Cound the number of each reactant species to account for species multiplicity ---</span></div>
<div class="line"><a id="l00559" name="l00559"></a><span class="lineno"> 559</span> std::unordered_map&lt;std::string, int&gt; reactant_counts;</div>
<div class="line"><a id="l00560" name="l00560"></a><span class="lineno"> 560</span> reactant_counts.reserve(<a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a>.reactants().size());</div>
<div class="line"><a id="l00561" name="l00561"></a><span class="lineno"> 561</span> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span>&amp; reactant : <a class="code hl_namespace" href="namespacegridfire_1_1reaction.html">reaction</a>.reactants()) {</div>
<div class="line"><a id="l00562" name="l00562"></a><span class="lineno"> 562</span> reactant_counts[std::string(reactant.name())]++;</div>
<div class="line"><a id="l00563" name="l00563"></a><span class="lineno"> 563</span> }</div>
<div class="line"><a id="l00564" name="l00564"></a><span class="lineno"> 564</span> </div>
<div class="line"><a id="l00565" name="l00565"></a><span class="lineno"> 565</span> <span class="comment">// --- Accumulator for the molar concentration ---</span></div>
<div class="line"><a id="l00566" name="l00566"></a><span class="lineno"> 566</span> <span class="keyword">auto</span> molar_concentration_product = <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(1.0);</div>
<div class="line"><a id="l00567" name="l00567"></a><span class="lineno"> 567</span> </div>
<div class="line"><a id="l00568" name="l00568"></a><span class="lineno"> 568</span> <span class="comment">// --- Loop through each unique reactant species and calculate the molar concentration for that species then multiply that into the accumulator ---</span></div>
<div class="line"><a id="l00569" name="l00569"></a><span class="lineno"> 569</span> <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span>&amp; [species_name, count] : reactant_counts) {</div>
<div class="line"><a id="l00570" name="l00570"></a><span class="lineno"> 570</span> <span class="comment">// --- Resolve species to molar abundance ---</span></div>
<div class="line"><a id="l00571" name="l00571"></a><span class="lineno"> 571</span> <span class="comment">// PERF: Could probably optimize out this lookup</span></div>
<div class="line"><a id="l00572" name="l00572"></a><span class="lineno"> 572</span> <span class="keyword">const</span> <span class="keyword">auto</span> species_it = <a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#ad8237c252145a75092202d00f5e1ddf7">m_speciesToIndexMap</a>.find(<a class="code hl_variable" href="classgridfire_1_1_graph_engine.html#a30e09ed0bce6aa5fc89beaa316a7b827">m_networkSpeciesMap</a>.at(species_name));</div>
<div class="line"><a id="l00573" name="l00573"></a><span class="lineno"> 573</span> <span class="keyword">const</span> <span class="keywordtype">size_t</span> species_index = species_it-&gt;second;</div>
<div class="line"><a id="l00574" name="l00574"></a><span class="lineno"> 574</span> <span class="keyword">const</span> T Yi = Y[species_index];</div>
<div class="line"><a id="l00575" name="l00575"></a><span class="lineno"> 575</span> </div>
<div class="line"><a id="l00576" name="l00576"></a><span class="lineno"> 576</span> <span class="comment">// --- Check if the species abundance is below the threshold where we ignore reactions ---</span></div>
<div class="line"><a id="l00577" name="l00577"></a><span class="lineno"> 577</span> threshold_flag *= CppAD::CondExpLt(Yi, Y_threshold, zero, one);</div>
<div class="line"><a id="l00578" name="l00578"></a><span class="lineno"> 578</span> </div>
<div class="line"><a id="l00579" name="l00579"></a><span class="lineno"> 579</span> <span class="comment">// --- Convert from molar abundance to molar concentration ---</span></div>
<div class="line"><a id="l00580" name="l00580"></a><span class="lineno"> 580</span> T molar_concentration = Yi * rho;</div>
<div class="line"><a id="l00581" name="l00581"></a><span class="lineno"> 581</span> </div>
<div class="line"><a id="l00582" name="l00582"></a><span class="lineno"> 582</span> <span class="comment">// --- If count is &gt; 1 , we need to raise the molar concentration to the power of count since there are really count bodies in that reaction ---</span></div>
<div class="line"><a id="l00583" name="l00583"></a><span class="lineno"> 583</span> molar_concentration_product *= CppAD::pow(molar_concentration, <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(count)); <span class="comment">// ni^count</span></div>
<div class="line"><a id="l00584" name="l00584"></a><span class="lineno"> 584</span> </div>
<div class="line"><a id="l00585" name="l00585"></a><span class="lineno"> 585</span> <span class="comment">// --- Apply factorial correction for identical reactions ---</span></div>
<div class="line"><a id="l00586" name="l00586"></a><span class="lineno"> 586</span> <span class="keywordflow">if</span> (count &gt; 1) {</div>
<div class="line"><a id="l00587" name="l00587"></a><span class="lineno"> 587</span> molar_concentration_product /= <span class="keyword">static_cast&lt;</span>T<span class="keyword">&gt;</span>(std::tgamma(<span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(count + 1))); <span class="comment">// Gamma function for factorial</span></div>
<div class="line"><a id="l00588" name="l00588"></a><span class="lineno"> 588</span> }</div>
<div class="line"><a id="l00589" name="l00589"></a><span class="lineno"> 589</span> }</div>
<div class="line"><a id="l00590" name="l00590"></a><span class="lineno"> 590</span> <span class="comment">// --- Final reaction flow calculation [mol][s^-1][cm^-3] ---</span></div>
<div class="line"><a id="l00591" name="l00591"></a><span class="lineno"> 591</span> <span class="comment">// Note: If the threshold flag ever gets set to zero this will return zero.</span></div>
<div class="line"><a id="l00592" name="l00592"></a><span class="lineno"> 592</span> <span class="comment">// This will result basically in multiple branches being written to the AD tape, which will make</span></div>
<div class="line"><a id="l00593" name="l00593"></a><span class="lineno"> 593</span> <span class="comment">// the tape more expensive to record, but it will also mean that we only need to record it once for</span></div>
<div class="line"><a id="l00594" name="l00594"></a><span class="lineno"> 594</span> <span class="comment">// the entire network.</span></div>
<div class="line"><a id="l00595" name="l00595"></a><span class="lineno"> 595</span> <span class="keywordflow">return</span> molar_concentration_product * k_reaction * threshold_flag;</div>
<div class="line"><a id="l00596" name="l00596"></a><span class="lineno"> 596</span> }</div>
</div>
<div class="line"><a id="l00597" name="l00597"></a><span class="lineno"> 597</span>};</div>
<div class="ttc" id="aclassgridfire_1_1_dynamic_engine_html"><div class="ttname"><a href="classgridfire_1_1_dynamic_engine.html">gridfire::DynamicEngine</a></div><div class="ttdoc">Abstract class for engines supporting Jacobian and stoichiometry operations.</div><div class="ttdef"><b>Definition</b> <a href="engine__abstract_8h_source.html#l00118">engine_abstract.h:118</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a0837bab6dcd111d9075c9343b90d64f1"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a0837bab6dcd111d9075c9343b90d64f1">gridfire::GraphEngine::m_constants</a></div><div class="ttdeci">Constants &amp; m_constants</div><div class="ttdoc">Access to physical constants.</div><div class="ttdef"><b>Definition</b> <a href="#l00311">engine_graph.h:311</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a0ed390f3e598ebba4e245ac90bb78767"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a0ed390f3e598ebba4e245ac90bb78767">gridfire::GraphEngine::getNetworkSpecies</a></div><div class="ttdeci">const std::vector&lt; fourdst::atomic::Species &gt; &amp; getNetworkSpecies() const override</div><div class="ttdoc">Gets the list of species in the network.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00112">engine_graph.cpp:112</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a26215593544c3a52597194602e4e25dd"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a26215593544c3a52597194602e4e25dd">gridfire::GraphEngine::getSpeciesTimescales</a></div><div class="ttdeci">std::unordered_map&lt; fourdst::atomic::Species, double &gt; getSpeciesTimescales(const std::vector&lt; double &gt; &amp;Y, double T9, double rho) const override</div><div class="ttdoc">Computes timescales for all species in the network.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00426">engine_graph.cpp:426</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a26602e1b3c610780a47b5a6511d6d567"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a26602e1b3c610780a47b5a6511d6d567">gridfire::GraphEngine::populateReactionIDMap</a></div><div class="ttdeci">void populateReactionIDMap()</div><div class="ttdoc">Populates the reaction ID map.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00085">engine_graph.cpp:85</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a2e22b111f6d00ecc9e3804a71f1ce876"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a2e22b111f6d00ecc9e3804a71f1ce876">gridfire::GraphEngine::m_rhsADFun</a></div><div class="ttdeci">CppAD::ADFun&lt; double &gt; m_rhsADFun</div><div class="ttdoc">CppAD function for the right-hand side of the ODE.</div><div class="ttdef"><b>Definition</b> <a href="#l00308">engine_graph.h:308</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a2f1718c89d4aaad028102724d18fa910"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a2f1718c89d4aaad028102724d18fa910">gridfire::GraphEngine::m_jacobianMatrix</a></div><div class="ttdeci">boost::numeric::ublas::compressed_matrix&lt; double &gt; m_jacobianMatrix</div><div class="ttdoc">Jacobian matrix (species x species).</div><div class="ttdef"><b>Definition</b> <a href="#l00306">engine_graph.h:306</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a303e6093591cde91430f866a04a8be7c"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a303e6093591cde91430f866a04a8be7c">gridfire::GraphEngine::getJacobianMatrixEntry</a></div><div class="ttdeci">double getJacobianMatrixEntry(const int i, const int j) const override</div><div class="ttdoc">Gets an entry from the previously generated Jacobian matrix.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00307">engine_graph.cpp:307</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a30e09ed0bce6aa5fc89beaa316a7b827"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a30e09ed0bce6aa5fc89beaa316a7b827">gridfire::GraphEngine::m_networkSpeciesMap</a></div><div class="ttdeci">std::unordered_map&lt; std::string_view, fourdst::atomic::Species &gt; m_networkSpeciesMap</div><div class="ttdoc">Map from species name to Species object.</div><div class="ttdef"><b>Definition</b> <a href="#l00302">engine_graph.h:302</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a3b17102b143435ddfdc015d7a50c4b18"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a3b17102b143435ddfdc015d7a50c4b18">gridfire::GraphEngine::m_config</a></div><div class="ttdeci">Config &amp; m_config</div><div class="ttdef"><b>Definition</b> <a href="#l00310">engine_graph.h:310</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a47202c43342b96480070874bffce1391"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a47202c43342b96480070874bffce1391">gridfire::GraphEngine::populateSpeciesToIndexMap</a></div><div class="ttdeci">void populateSpeciesToIndexMap()</div><div class="ttdoc">Populates the species-to-index map.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00094">engine_graph.cpp:94</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a483979fc154adc88d029b3b672066d53"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a483979fc154adc88d029b3b672066d53">gridfire::GraphEngine::m_logger</a></div><div class="ttdeci">quill::Logger * m_logger</div><div class="ttdef"><b>Definition</b> <a href="#l00312">engine_graph.h:312</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a5a5458ed01923124f2d7e1f04f32f138"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a5a5458ed01923124f2d7e1f04f32f138">gridfire::GraphEngine::reserveJacobianMatrix</a></div><div class="ttdeci">void reserveJacobianMatrix()</div><div class="ttdoc">Reserves space for the Jacobian matrix.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00101">engine_graph.cpp:101</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a5d6cc63b99b467c2a976d1fbaaa1dfa3"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a5d6cc63b99b467c2a976d1fbaaa1dfa3">gridfire::GraphEngine::m_reactionIDMap</a></div><div class="ttdeci">std::unordered_map&lt; std::string_view, reaction::Reaction * &gt; m_reactionIDMap</div><div class="ttdoc">Map from reaction ID to REACLIBReaction. //PERF: This makes copies of REACLIBReaction and could be a ...</div><div class="ttdef"><b>Definition</b> <a href="#l00299">engine_graph.h:299</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a6b5feaf788bade212b7c8df7ac8c8152"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a6b5feaf788bade212b7c8df7ac8c8152">gridfire::GraphEngine::getStoichiometryMatrixEntry</a></div><div class="ttdeci">int getStoichiometryMatrixEntry(const int speciesIndex, const int reactionIndex) const override</div><div class="ttdoc">Gets an entry from the stoichiometry matrix.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00317">engine_graph.cpp:317</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a832e2fe066381811a3e0464806ff5e95"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a832e2fe066381811a3e0464806ff5e95">gridfire::GraphEngine::exportToCSV</a></div><div class="ttdeci">void exportToCSV(const std::string &amp;filename) const</div><div class="ttdoc">Exports the network to a CSV file for analysis.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00372">engine_graph.cpp:372</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a8b3baf29829c7ae0a61430ea70632bbf"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a8b3baf29829c7ae0a61430ea70632bbf">gridfire::GraphEngine::calculateRHSAndEnergy</a></div><div class="ttdeci">StepDerivatives&lt; double &gt; calculateRHSAndEnergy(const std::vector&lt; double &gt; &amp;Y, const double T9, const double rho) const override</div><div class="ttdoc">Calculates the right-hand side (dY/dt) and energy generation rate.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00037">engine_graph.cpp:37</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a8c29d8bbde407e913be5eb77efb2c0c9"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a8c29d8bbde407e913be5eb77efb2c0c9">gridfire::GraphEngine::getNetReactionStoichiometry</a></div><div class="ttdeci">static std::unordered_map&lt; fourdst::atomic::Species, int &gt; getNetReactionStoichiometry(const reaction::Reaction &amp;reaction)</div><div class="ttdoc">Gets the net stoichiometry for a given reaction.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00311">engine_graph.cpp:311</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a9245642b741f215e52861d00e756fb3f"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">gridfire::GraphEngine::calculateMolarReactionFlow</a></div><div class="ttdeci">double calculateMolarReactionFlow(const reaction::Reaction &amp;reaction, const std::vector&lt; double &gt; &amp;Y, const double T9, const double rho) const override</div><div class="ttdoc">Calculates the molar reaction flow for a given reaction.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00265">engine_graph.cpp:265</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a92d26068ba139e47d335f5fe9e2814cc"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc">gridfire::GraphEngine::m_networkSpecies</a></div><div class="ttdeci">std::vector&lt; fourdst::atomic::Species &gt; m_networkSpecies</div><div class="ttdoc">Vector of unique species in the network.</div><div class="ttdef"><b>Definition</b> <a href="#l00301">engine_graph.h:301</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a95563f6bc86007d9ee053a0f1e15b889"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a95563f6bc86007d9ee053a0f1e15b889">gridfire::GraphEngine::recordADTape</a></div><div class="ttdeci">void recordADTape()</div><div class="ttdoc">Records the AD tape for the right-hand side of the ODE.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00442">engine_graph.cpp:442</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_a9f74786ff930ab72664b31f29d05a30c"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#a9f74786ff930ab72664b31f29d05a30c">gridfire::GraphEngine::GraphEngine</a></div><div class="ttdeci">GraphEngine(const fourdst::composition::Composition &amp;composition)</div><div class="ttdoc">Constructs a GraphEngine from a composition.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00025">engine_graph.cpp:25</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_aa6202cee0c3c481eda77cc9a91bc126b"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#aa6202cee0c3c481eda77cc9a91bc126b">gridfire::GraphEngine::involvesSpecies</a></div><div class="ttdeci">bool involvesSpecies(const fourdst::atomic::Species &amp;species) const</div><div class="ttdoc">Checks if a given species is involved in the network.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00124">engine_graph.cpp:124</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_acb7c4f5108b0efeae48ad15598e808c3"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#acb7c4f5108b0efeae48ad15598e808c3">gridfire::GraphEngine::m_reactions</a></div><div class="ttdeci">reaction::LogicalReactionSet m_reactions</div><div class="ttdoc">Set of REACLIB reactions in the network.</div><div class="ttdef"><b>Definition</b> <a href="#l00298">engine_graph.h:298</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_acdce8d87e23a2cd1504bc9472e538c0f"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#acdce8d87e23a2cd1504bc9472e538c0f">gridfire::GraphEngine::syncInternalMaps</a></div><div class="ttdeci">void syncInternalMaps()</div><div class="ttdoc">Synchronizes the internal maps.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00046">engine_graph.cpp:46</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_acf4cfccea20f5cb31c9886bf233a28be"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#acf4cfccea20f5cb31c9886bf233a28be">gridfire::GraphEngine::validateConservation</a></div><div class="ttdeci">bool validateConservation() const</div><div class="ttdoc">Validates mass and charge conservation across all reactions.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00132">engine_graph.cpp:132</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_ad1cb5fd32efc37668e2d9ecf0c72ad24"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#ad1cb5fd32efc37668e2d9ecf0c72ad24">gridfire::GraphEngine::m_stoichiometryMatrix</a></div><div class="ttdeci">boost::numeric::ublas::compressed_matrix&lt; int &gt; m_stoichiometryMatrix</div><div class="ttdoc">Stoichiometry matrix (species x reactions).</div><div class="ttdef"><b>Definition</b> <a href="#l00305">engine_graph.h:305</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_ad45650d10fc5dff1673ae3f806d067da"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#ad45650d10fc5dff1673ae3f806d067da">gridfire::GraphEngine::getNetworkReactions</a></div><div class="ttdeci">const reaction::LogicalReactionSet &amp; getNetworkReactions() const override</div><div class="ttdoc">Gets the set of logical reactions in the network.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00118">engine_graph.cpp:118</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_ad8237c252145a75092202d00f5e1ddf7"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#ad8237c252145a75092202d00f5e1ddf7">gridfire::GraphEngine::m_speciesToIndexMap</a></div><div class="ttdeci">std::unordered_map&lt; fourdst::atomic::Species, size_t &gt; m_speciesToIndexMap</div><div class="ttdoc">Map from species to their index in the stoichiometry matrix.</div><div class="ttdef"><b>Definition</b> <a href="#l00303">engine_graph.h:303</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_adac8c7d62bae76e17fc060e86dadd929"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#adac8c7d62bae76e17fc060e86dadd929">gridfire::GraphEngine::exportToDot</a></div><div class="ttdeci">void exportToDot(const std::string &amp;filename) const</div><div class="ttdoc">Exports the network to a DOT file for visualization.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00324">engine_graph.cpp:324</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_ae347ff0316e532e0298ec8c913908105"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#ae347ff0316e532e0298ec8c913908105">gridfire::GraphEngine::generateJacobianMatrix</a></div><div class="ttdeci">void generateJacobianMatrix(const std::vector&lt; double &gt; &amp;Y, const double T9, const double rho) override</div><div class="ttdoc">Generates the Jacobian matrix for the current state.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00274">engine_graph.cpp:274</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_aed726d36ee2b3796beff6067a1e4db38"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#aed726d36ee2b3796beff6067a1e4db38">gridfire::GraphEngine::generateStoichiometryMatrix</a></div><div class="ttdeci">void generateStoichiometryMatrix() override</div><div class="ttdoc">Generates the stoichiometry matrix for the network.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00208">engine_graph.cpp:208</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_aedf42d83bfcc28313b6b6454034d2efa"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#aedf42d83bfcc28313b6b6454034d2efa">gridfire::GraphEngine::collectNetworkSpecies</a></div><div class="ttdeci">void collectNetworkSpecies()</div><div class="ttdoc">Collects the unique species in the network.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00056">engine_graph.cpp:56</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_aeeafeab40a5f4dbfae78bdc87e25e93f"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#aeeafeab40a5f4dbfae78bdc87e25e93f">gridfire::GraphEngine::validateComposition</a></div><div class="ttdeci">void validateComposition(const fourdst::composition::Composition &amp;composition, double culling, double T9)</div><div class="ttdoc">Validates the composition against the current reaction set.</div><div class="ttdef"><b>Definition</b> <a href="engine__graph_8cpp_source.html#l00187">engine_graph.cpp:187</a></div></div>
<div class="ttc" id="aclassgridfire_1_1_graph_engine_html_af41df9ce979b6410e12642cb093916c9"><div class="ttname"><a href="classgridfire_1_1_graph_engine.html#af41df9ce979b6410e12642cb093916c9">gridfire::GraphEngine::calculateAllDerivatives</a></div><div class="ttdeci">StepDerivatives&lt; T &gt; calculateAllDerivatives(const std::vector&lt; T &gt; &amp;Y_in, T T9, T rho) const</div><div class="ttdoc">Calculates all derivatives (dY/dt) and the energy generation rate.</div><div class="ttdef"><b>Definition</b> <a href="#l00475">engine_graph.h:475</a></div></div>
<div class="ttc" id="aclassgridfire_1_1reaction_1_1_logical_reaction_set_html"><div class="ttname"><a href="classgridfire_1_1reaction_1_1_logical_reaction_set.html">gridfire::reaction::LogicalReactionSet</a></div><div class="ttdoc">A collection of LogicalReaction objects.</div><div class="ttdef"><b>Definition</b> <a href="reaction_8h_source.html#l00554">reaction.h:554</a></div></div>
<div class="ttc" id="aclassgridfire_1_1reaction_1_1_reaction_html"><div class="ttname"><a href="classgridfire_1_1reaction_1_1_reaction.html">gridfire::reaction::Reaction</a></div><div class="ttdoc">Represents a single nuclear reaction from a specific data source.</div><div class="ttdef"><b>Definition</b> <a href="reaction_8h_source.html#l00071">reaction.h:71</a></div></div>
<div class="ttc" id="aengine__abstract_8h_html"><div class="ttname"><a href="engine__abstract_8h.html">engine_abstract.h</a></div><div class="ttdoc">Abstract interfaces for reaction network engines in GridFire.</div></div>
<div class="ttc" id="anamespacegridfire_1_1reaction_html"><div class="ttname"><a href="namespacegridfire_1_1reaction.html">gridfire::reaction</a></div><div class="ttdef"><b>Definition</b> <a href="reaction_8h_source.html#l00024">reaction.h:24</a></div></div>
<div class="ttc" id="anamespacegridfire_html"><div class="ttname"><a href="namespacegridfire.html">gridfire</a></div><div class="ttdef"><b>Definition</b> <a href="engine__abstract_8h_source.html#l00021">engine_abstract.h:21</a></div></div>
<div class="ttc" id="anamespacegridfire_html_a1121d0b2d005195333412559fa29d3cc"><div class="ttname"><a href="namespacegridfire.html#a1121d0b2d005195333412559fa29d3cc">gridfire::ADDouble</a></div><div class="ttdeci">CppAD::AD&lt; double &gt; ADDouble</div><div class="ttdoc">Alias for CppAD AD type for double precision.</div><div class="ttdef"><b>Definition</b> <a href="#l00031">engine_graph.h:31</a></div></div>
<div class="ttc" id="anamespacegridfire_html_a96c062f94713921e5d7568ecedcdcb06"><div class="ttname"><a href="namespacegridfire.html#a96c062f94713921e5d7568ecedcdcb06">gridfire::MIN_ABUNDANCE_THRESHOLD</a></div><div class="ttdeci">static constexpr double MIN_ABUNDANCE_THRESHOLD</div><div class="ttdoc">Minimum abundance threshold below which species are ignored.</div><div class="ttdef"><b>Definition</b> <a href="#l00053">engine_graph.h:53</a></div></div>
<div class="ttc" id="anamespacegridfire_html_ada3c137c014ecd8d06200fea2d1a9f50"><div class="ttname"><a href="namespacegridfire.html#ada3c137c014ecd8d06200fea2d1a9f50">gridfire::MIN_DENSITY_THRESHOLD</a></div><div class="ttdeci">static constexpr double MIN_DENSITY_THRESHOLD</div><div class="ttdoc">Minimum density threshold below which reactions are ignored.</div><div class="ttdef"><b>Definition</b> <a href="#l00044">engine_graph.h:44</a></div></div>
<div class="ttc" id="anamespacegridfire_html_ae01b1738df1921db565bcbd68dd6cf64"><div class="ttname"><a href="namespacegridfire.html#ae01b1738df1921db565bcbd68dd6cf64">gridfire::MIN_JACOBIAN_THRESHOLD</a></div><div class="ttdeci">static constexpr double MIN_JACOBIAN_THRESHOLD</div><div class="ttdoc">Minimum value for Jacobian matrix entries.</div><div class="ttdef"><b>Definition</b> <a href="#l00061">engine_graph.h:61</a></div></div>
<div class="ttc" id="anetwork_8h_html"><div class="ttname"><a href="network_8h.html">network.h</a></div></div>
<div class="ttc" id="areaction_8h_html"><div class="ttname"><a href="reaction_8h.html">reaction.h</a></div><div class="ttdoc">Defines classes for representing and managing nuclear reactions.</div></div>
<div class="ttc" id="astructgridfire_1_1_step_derivatives_html"><div class="ttname"><a href="structgridfire_1_1_step_derivatives.html">gridfire::StepDerivatives</a></div><div class="ttdoc">Structure holding derivatives and energy generation for a network step.</div><div class="ttdef"><b>Definition</b> <a href="engine__abstract_8h_source.html#l00050">engine_abstract.h:50</a></div></div>
<div class="ttc" id="astructgridfire_1_1_step_derivatives_html_ab4aeb41be952c7b5844e1ee81fef9008"><div class="ttname"><a href="structgridfire_1_1_step_derivatives.html#ab4aeb41be952c7b5844e1ee81fef9008">gridfire::StepDerivatives::nuclearEnergyGenerationRate</a></div><div class="ttdeci">T nuclearEnergyGenerationRate</div><div class="ttdoc">Specific energy generation rate (e.g., erg/g/s).</div><div class="ttdef"><b>Definition</b> <a href="engine__abstract_8h_source.html#l00052">engine_abstract.h:52</a></div></div>
<div class="ttc" id="astructgridfire_1_1_step_derivatives_html_ae0de268b86c2404379409c4feae0b34d"><div class="ttname"><a href="structgridfire_1_1_step_derivatives.html#ae0de268b86c2404379409c4feae0b34d">gridfire::StepDerivatives::dydt</a></div><div class="ttdeci">std::vector&lt; T &gt; dydt</div><div class="ttdoc">Derivatives of abundances (dY/dt for each species).</div><div class="ttdef"><b>Definition</b> <a href="engine__abstract_8h_source.html#l00051">engine_abstract.h:51</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_fc4c7f03e1a69a98c370fae55a743828.html">network</a></li><li class="navelem"><a class="el" href="dir_5cccfa813acdf3744b542715860d37b2.html">include</a></li><li class="navelem"><a class="el" href="dir_2a1262ef5950eb718393488a3eb5aa9f.html">gridfire</a></li><li class="navelem"><a class="el" href="dir_6b2e1e22dfdea3280d50981209bf7529.html">engine</a></li><li class="navelem"><a class="el" href="engine__graph_8h.html">engine_graph.h</a></li>
<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>