<ahref="engine__graph_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aid="l00001"name="l00001"></a><spanclass="lineno"> 1</span><spanclass="preprocessor">#pragma once</span></div>
<divclass="line"><aid="l00023"name="l00023"></a><spanclass="lineno"> 23</span><spanclass="comment">// PERF: The function getNetReactionStoichiometry returns a map of species to their stoichiometric coefficients for a given reaction.</span></div>
<divclass="line"><aid="l00024"name="l00024"></a><spanclass="lineno"> 24</span><spanclass="comment">// this makes extra copies of the species, which is not ideal and could be optimized further.</span></div>
<divclass="line"><aid="l00025"name="l00025"></a><spanclass="lineno"> 25</span><spanclass="comment">// Even more relevant is the member m_reactionIDMap which makes copies of a REACLIBReaction for each reaction ID.</span></div>
<divclass="line"><aid="l00026"name="l00026"></a><spanclass="lineno"> 26</span><spanclass="comment">// REACLIBReactions are quite large data structures, so this could be a performance bottleneck.</span></div>
<divclass="line"><aid="l00456"name="l00456"></a><spanclass="lineno"> 456</span> T <aclass="code hl_function"href="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">calculateMolarReactionFlow</a>(</div>
<divclass="line"><aid="l00522"name="l00522"></a><spanclass="lineno"> 522</span><spanclass="keyword">const</span> std::vector<T>&Y_in, T T9, T rho)<spanclass="keyword"> const </span>{</div>
<divclass="line"><aid="l00535"name="l00535"></a><spanclass="lineno"> 535</span><spanclass="comment">// --- AD Pre-setup (flags to control conditionals in an AD safe / branch aware manner) ---</span></div>
<divclass="line"><aid="l00536"name="l00536"></a><spanclass="lineno"> 536</span><spanclass="comment">// ----- Constants for AD safe calculations ---</span></div>
<divclass="line"><aid="l00537"name="l00537"></a><spanclass="lineno"> 537</span><spanclass="keyword">const</span> T zero = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(0.0);</div>
<divclass="line"><aid="l00538"name="l00538"></a><spanclass="lineno"> 538</span><spanclass="keyword">const</span> T one = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(1.0);</div>
<divclass="line"><aid="l00540"name="l00540"></a><spanclass="lineno"> 540</span><spanclass="comment">// ----- Initialize variables for molar concentration product and thresholds ---</span></div>
<divclass="line"><aid="l00541"name="l00541"></a><spanclass="lineno"> 541</span><spanclass="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>
<divclass="line"><aid="l00542"name="l00542"></a><spanclass="lineno"> 542</span><spanclass="comment">// to zero so that the final returned reaction flow is 0. This is as opposed to standard if statements</span></div>
<divclass="line"><aid="l00543"name="l00543"></a><spanclass="lineno"> 543</span><spanclass="comment">// which create branches that break the AD tape.</span></div>
<divclass="line"><aid="l00544"name="l00544"></a><spanclass="lineno"> 544</span><spanclass="keyword">const</span> T rho_threshold = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(<aclass="code hl_variable"href="namespacegridfire.html#ada3c137c014ecd8d06200fea2d1a9f50">MIN_DENSITY_THRESHOLD</a>);</div>
<divclass="line"><aid="l00546"name="l00546"></a><spanclass="lineno"> 546</span><spanclass="comment">// --- Check if the density is below the threshold where we ignore reactions ---</span></div>
<divclass="line"><aid="l00547"name="l00547"></a><spanclass="lineno"> 547</span> T threshold_flag = CppAD::CondExpLt(rho, rho_threshold, zero, one); <spanclass="comment">// If rho < threshold, set flag to 0</span></div>
<divclass="line"><aid="l00549"name="l00549"></a><spanclass="lineno"> 549</span> std::vector<T> Y = Y_in;</div>
<divclass="line"><aid="l00550"name="l00550"></a><spanclass="lineno"> 550</span><spanclass="keywordflow">for</span> (<spanclass="keywordtype">size_t</span> i = 0; i <<aclass="code hl_variable"href="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc">m_networkSpecies</a>.size(); ++i) {</div>
<divclass="line"><aid="l00551"name="l00551"></a><spanclass="lineno"> 551</span><spanclass="comment">// We use CppAD::CondExpLt to handle AD taping and prevent branching</span></div>
<divclass="line"><aid="l00552"name="l00552"></a><spanclass="lineno"> 552</span><spanclass="comment">// Note that while this is syntactically more complex this is equivalent to</span></div>
<divclass="line"><aid="l00553"name="l00553"></a><spanclass="lineno"> 553</span><spanclass="comment">// if (Y[i] < 0) {Y[i] = 0;}</span></div>
<divclass="line"><aid="l00554"name="l00554"></a><spanclass="lineno"> 554</span><spanclass="comment">// The issue is that this would introduce a branch which would require the auto diff tape to be re-recorded</span></div>
<divclass="line"><aid="l00555"name="l00555"></a><spanclass="lineno"> 555</span><spanclass="comment">// each timestep, which is very inefficient.</span></div>
<divclass="line"><aid="l00559"name="l00559"></a><spanclass="lineno"> 559</span><spanclass="keyword">const</span> T u = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(<aclass="code hl_variable"href="classgridfire_1_1_graph_engine.html#a10c01bc20ae668c2857efb2a1783098e">m_constants</a>.u); <spanclass="comment">// Atomic mass unit in grams</span></div>
<divclass="line"><aid="l00560"name="l00560"></a><spanclass="lineno"> 560</span><spanclass="keyword">const</span> T N_A = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(<aclass="code hl_variable"href="classgridfire_1_1_graph_engine.html#a10c01bc20ae668c2857efb2a1783098e">m_constants</a>.Na); <spanclass="comment">// Avogadro's number in mol^-1</span></div>
<divclass="line"><aid="l00561"name="l00561"></a><spanclass="lineno"> 561</span><spanclass="keyword">const</span> T c = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(<aclass="code hl_variable"href="classgridfire_1_1_graph_engine.html#a10c01bc20ae668c2857efb2a1783098e">m_constants</a>.c); <spanclass="comment">// Speed of light in cm/s</span></div>
<divclass="line"><aid="l00563"name="l00563"></a><spanclass="lineno"> 563</span><spanclass="comment">// --- SINGLE LOOP OVER ALL REACTIONS ---</span></div>
<divclass="line"><aid="l00570"name="l00570"></a><spanclass="lineno"> 570</span><spanclass="comment">// 2. Use the rate to update all relevant species derivatives (dY/dt)</span></div>
<divclass="line"><aid="l00589"name="l00589"></a><spanclass="lineno"><aclass="line"href="classgridfire_1_1_graph_engine.html#a5e96b5a0b34c8932f0e14eabda57f1a4"> 589</a></span> T <aclass="code hl_function"href="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">GraphEngine::calculateMolarReactionFlow</a>(</div>
<divclass="line"><aid="l00596"name="l00596"></a><spanclass="lineno"> 596</span><spanclass="comment">// --- Pre-setup (flags to control conditionals in an AD safe / branch aware manner) ---</span></div>
<divclass="line"><aid="l00597"name="l00597"></a><spanclass="lineno"> 597</span><spanclass="comment">// ----- Constants for AD safe calculations ---</span></div>
<divclass="line"><aid="l00598"name="l00598"></a><spanclass="lineno"> 598</span><spanclass="keyword">const</span> T zero = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(0.0);</div>
<divclass="line"><aid="l00599"name="l00599"></a><spanclass="lineno"> 599</span><spanclass="keyword">const</span> T one = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(1.0);</div>
<divclass="line"><aid="l00601"name="l00601"></a><spanclass="lineno"> 601</span><spanclass="comment">// ----- Initialize variables for molar concentration product and thresholds ---</span></div>
<divclass="line"><aid="l00602"name="l00602"></a><spanclass="lineno"> 602</span><spanclass="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>
<divclass="line"><aid="l00603"name="l00603"></a><spanclass="lineno"> 603</span><spanclass="comment">// to zero so that the final returned reaction flow is 0. This is as opposed to standard if statements</span></div>
<divclass="line"><aid="l00604"name="l00604"></a><spanclass="lineno"> 604</span><spanclass="comment">// which create branches that break the AD tape.</span></div>
<divclass="line"><aid="l00605"name="l00605"></a><spanclass="lineno"> 605</span><spanclass="keyword">const</span> T Y_threshold = <spanclass="keyword">static_cast<</span>T<spanclass="keyword">></span>(<aclass="code hl_variable"href="namespacegridfire.html#a96c062f94713921e5d7568ecedcdcb06">MIN_ABUNDANCE_THRESHOLD</a>);</div>
<divclass="line"><aid="l00606"name="l00606"></a><spanclass="lineno"> 606</span> T threshold_flag = one;</div>
<divclass="line"><aid="l00608"name="l00608"></a><spanclass="lineno"> 608</span><spanclass="comment">// --- Calculate the molar reaction rate (in units of [s^-1][cm^3(N-1)][mol^(1-N)] for N reactants) ---</span></div>
<divclass="line"><aid="l00609"name="l00609"></a><spanclass="lineno"> 609</span><spanclass="keyword">const</span> T k_reaction = <aclass="code hl_namespace"href="namespacegridfire_1_1reaction.html">reaction</a>.calculate_rate(T9);</div>
<divclass="line"><aid="l00611"name="l00611"></a><spanclass="lineno"> 611</span><spanclass="comment">// --- Cound the number of each reactant species to account for species multiplicity ---</span></div>
<divclass="line"><aid="l00618"name="l00618"></a><spanclass="lineno"> 618</span><spanclass="comment">// --- Accumulator for the molar concentration ---</span></div>
<divclass="line"><aid="l00621"name="l00621"></a><spanclass="lineno"> 621</span><spanclass="comment">// --- Loop through each unique reactant species and calculate the molar concentration for that species then multiply that into the accumulator ---</span></div>
<divclass="line"><aid="l00623"name="l00623"></a><spanclass="lineno"> 623</span><spanclass="comment">// --- Resolve species to molar abundance ---</span></div>
<divclass="line"><aid="l00624"name="l00624"></a><spanclass="lineno"> 624</span><spanclass="comment">// PERF: Could probably optimize out this lookup</span></div>
<divclass="line"><aid="l00629"name="l00629"></a><spanclass="lineno"> 629</span><spanclass="comment">// --- Check if the species abundance is below the threshold where we ignore reactions ---</span></div>
<divclass="line"><aid="l00635"name="l00635"></a><spanclass="lineno"> 635</span><spanclass="comment">// --- If count is > 1 , we need to raise the molar concentration to the power of count since there are really count bodies in that reaction ---</span></div>
<divclass="line"><aid="l00643"name="l00643"></a><spanclass="lineno"> 643</span><spanclass="comment">// --- Final reaction flow calculation [mol][s^-1][cm^-3] ---</span></div>
<divclass="line"><aid="l00644"name="l00644"></a><spanclass="lineno"> 644</span><spanclass="comment">// Note: If the threshold flag ever gets set to zero this will return zero.</span></div>
<divclass="line"><aid="l00645"name="l00645"></a><spanclass="lineno"> 645</span><spanclass="comment">// This will result basically in multiple branches being written to the AD tape, which will make</span></div>
<divclass="line"><aid="l00646"name="l00646"></a><spanclass="lineno"> 646</span><spanclass="comment">// the tape more expensive to record, but it will also mean that we only need to record it once for</span></div>
<divclass="line"><aid="l00647"name="l00647"></a><spanclass="lineno"> 647</span><spanclass="comment">// the entire network.</span></div>
<divclass="ttc"id="aclassgridfire_1_1_dynamic_engine_html"><divclass="ttname"><ahref="classgridfire_1_1_dynamic_engine.html">gridfire::DynamicEngine</a></div><divclass="ttdoc">Abstract class for engines supporting Jacobian and stoichiometry operations.</div><divclass="ttdef"><b>Definition</b><ahref="engine__abstract_8h_source.html#l00121">engine_abstract.h:121</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a0ed390f3e598ebba4e245ac90bb78767"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a0ed390f3e598ebba4e245ac90bb78767">gridfire::GraphEngine::getNetworkSpecies</a></div><divclass="ttdeci">const std::vector< fourdst::atomic::Species >& getNetworkSpecies() const override</div><divclass="ttdoc">Gets the list of species in the network.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00128">engine_graph.cpp:128</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a191cff35402d3c97c82c5c966a39d0de"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a191cff35402d3c97c82c5c966a39d0de">gridfire::GraphEngine::m_usePrecomputation</a></div><divclass="ttdeci">bool m_usePrecomputation</div><divclass="ttdoc">Flag to enable or disable using precomputed reactions for efficiency. Mathematically,...</div><divclass="ttdef"><b>Definition</b><ahref="#l00347">engine_graph.h:347</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a26215593544c3a52597194602e4e25dd"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a26215593544c3a52597194602e4e25dd">gridfire::GraphEngine::getSpeciesTimescales</a></div><divclass="ttdeci">std::unordered_map< fourdst::atomic::Species, double > getSpeciesTimescales(const std::vector< double >&Y, double T9, double rho) const override</div><divclass="ttdoc">Computes timescales for all species in the network.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00538">engine_graph.cpp:538</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a26602e1b3c610780a47b5a6511d6d567"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a26602e1b3c610780a47b5a6511d6d567">gridfire::GraphEngine::populateReactionIDMap</a></div><divclass="ttdeci">void populateReactionIDMap()</div><divclass="ttdoc">Populates the reaction ID map.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00101">engine_graph.cpp:101</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a2e22b111f6d00ecc9e3804a71f1ce876"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a2e22b111f6d00ecc9e3804a71f1ce876">gridfire::GraphEngine::m_rhsADFun</a></div><divclass="ttdeci">CppAD::ADFun< double > m_rhsADFun</div><divclass="ttdoc">CppAD function for the right-hand side of the ODE.</div><divclass="ttdef"><b>Definition</b><ahref="#l00342">engine_graph.h:342</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a2f1718c89d4aaad028102724d18fa910"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a2f1718c89d4aaad028102724d18fa910">gridfire::GraphEngine::m_jacobianMatrix</a></div><divclass="ttdeci">boost::numeric::ublas::compressed_matrix< double > m_jacobianMatrix</div><divclass="ttdoc">Jacobian matrix (species x species).</div><divclass="ttdef"><b>Definition</b><ahref="#l00340">engine_graph.h:340</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a303e6093591cde91430f866a04a8be7c"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a303e6093591cde91430f866a04a8be7c">gridfire::GraphEngine::getJacobianMatrixEntry</a></div><divclass="ttdeci">double getJacobianMatrixEntry(const int i, const int j) const override</div><divclass="ttdoc">Gets an entry from the previously generated Jacobian matrix.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00419">engine_graph.cpp:419</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a30e09ed0bce6aa5fc89beaa316a7b827"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a30e09ed0bce6aa5fc89beaa316a7b827">gridfire::GraphEngine::m_networkSpeciesMap</a></div><divclass="ttdeci">std::unordered_map< std::string_view, fourdst::atomic::Species > m_networkSpeciesMap</div><divclass="ttdoc">Map from species name to Species object.</div><divclass="ttdef"><b>Definition</b><ahref="#l00336">engine_graph.h:336</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a3b17102b143435ddfdc015d7a50c4b18"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a3b17102b143435ddfdc015d7a50c4b18">gridfire::GraphEngine::m_config</a></div><divclass="ttdeci">Config & m_config</div><divclass="ttdef"><b>Definition</b><ahref="#l00327">engine_graph.h:327</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a47202c43342b96480070874bffce1391"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a47202c43342b96480070874bffce1391">gridfire::GraphEngine::populateSpeciesToIndexMap</a></div><divclass="ttdeci">void populateSpeciesToIndexMap()</div><divclass="ttdoc">Populates the species-to-index map.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00110">engine_graph.cpp:110</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a51b4cedf9b00de79fb6eef243631b04d"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a51b4cedf9b00de79fb6eef243631b04d">gridfire::GraphEngine::update</a></div><divclass="ttdeci">void update(const NetIn &netIn) override</div><divclass="ttdoc">Update the internal state of the engine.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00554">engine_graph.cpp:554</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a52edc3e88f1e8fc497e1e63972d63c80"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a52edc3e88f1e8fc497e1e63972d63c80">gridfire::GraphEngine::m_screeningType</a></div><divclass="ttdeci">screening::ScreeningType m_screeningType</div><divclass="ttdoc">Screening type for the reaction network. Default to no screening.</div><divclass="ttdef"><b>Definition</b><ahref="#l00344">engine_graph.h:344</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a5a5458ed01923124f2d7e1f04f32f138"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a5a5458ed01923124f2d7e1f04f32f138">gridfire::GraphEngine::reserveJacobianMatrix</a></div><divclass="ttdeci">void reserveJacobianMatrix()</div><divclass="ttdoc">Reserves space for the Jacobian matrix.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00117">engine_graph.cpp:117</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a5d431d5385b1219ba29689eb29601ea3"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a5d431d5385b1219ba29689eb29601ea3">gridfire::GraphEngine::m_precomputedReactions</a></div><divclass="ttdeci">std::vector< PrecomputedReaction > m_precomputedReactions</div><divclass="ttdoc">Precomputed reactions for efficiency.</div><divclass="ttdef"><b>Definition</b><ahref="#l00349">engine_graph.h:349</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a5d6cc63b99b467c2a976d1fbaaa1dfa3"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a5d6cc63b99b467c2a976d1fbaaa1dfa3">gridfire::GraphEngine::m_reactionIDMap</a></div><divclass="ttdeci">std::unordered_map< std::string_view, reaction::Reaction * > m_reactionIDMap</div><divclass="ttdoc">Map from reaction ID to REACLIBReaction. //PERF: This makes copies of REACLIBReaction and could be a ...</div><divclass="ttdef"><b>Definition</b><ahref="#l00333">engine_graph.h:333</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a697f2004e0d02c59e83c7890742d7c9a"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a697f2004e0d02c59e83c7890742d7c9a">gridfire::GraphEngine::getScreeningModel</a></div><divclass="ttdeci">screening::ScreeningType getScreeningModel() const override</div><divclass="ttdoc">Get the current electron screening model.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00365">engine_graph.cpp:365</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a6b5feaf788bade212b7c8df7ac8c8152"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a6b5feaf788bade212b7c8df7ac8c8152">gridfire::GraphEngine::getStoichiometryMatrixEntry</a></div><divclass="ttdeci">int getStoichiometryMatrixEntry(const int speciesIndex, const int reactionIndex) const override</div><divclass="ttdoc">Gets an entry from the stoichiometry matrix.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00429">engine_graph.cpp:429</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a8110e687844f921438bb517e1d8ce62f"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a8110e687844f921438bb517e1d8ce62f">gridfire::GraphEngine::setScreeningModel</a></div><divclass="ttdeci">void setScreeningModel(screening::ScreeningType) override</div><divclass="ttdoc">Set the electron screening model.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00360">engine_graph.cpp:360</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a832e2fe066381811a3e0464806ff5e95"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a832e2fe066381811a3e0464806ff5e95">gridfire::GraphEngine::exportToCSV</a></div><divclass="ttdeci">void exportToCSV(const std::string &filename) const</div><divclass="ttdoc">Exports the network to a CSV file for analysis.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00484">engine_graph.cpp:484</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a8b3baf29829c7ae0a61430ea70632bbf"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a8b3baf29829c7ae0a61430ea70632bbf">gridfire::GraphEngine::calculateRHSAndEnergy</a></div><divclass="ttdeci">StepDerivatives< double > calculateRHSAndEnergy(const std::vector< double >&Y, const double T9, const double rho) const override</div><divclass="ttdoc">Calculates the right-hand side (dY/dt) and energy generation rate.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00042">engine_graph.cpp:42</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a8c29d8bbde407e913be5eb77efb2c0c9"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a8c29d8bbde407e913be5eb77efb2c0c9">gridfire::GraphEngine::getNetReactionStoichiometry</a></div><divclass="ttdeci">static std::unordered_map< fourdst::atomic::Species, int > getNetReactionStoichiometry(const reaction::Reaction &reaction)</div><divclass="ttdoc">Gets the net stoichiometry for a given reaction.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00423">engine_graph.cpp:423</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a9245642b741f215e52861d00e756fb3f"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a9245642b741f215e52861d00e756fb3f">gridfire::GraphEngine::calculateMolarReactionFlow</a></div><divclass="ttdeci">double calculateMolarReactionFlow(const reaction::Reaction &reaction, const std::vector< double >&Y, const double T9, const double rho) const override</div><divclass="ttdoc">Calculates the molar reaction flow for a given reaction.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00377">engine_graph.cpp:377</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a92d26068ba139e47d335f5fe9e2814cc"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a92d26068ba139e47d335f5fe9e2814cc">gridfire::GraphEngine::m_networkSpecies</a></div><divclass="ttdeci">std::vector< fourdst::atomic::Species > m_networkSpecies</div><divclass="ttdoc">Vector of unique species in the network.</div><divclass="ttdef"><b>Definition</b><ahref="#l00335">engine_graph.h:335</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a95563f6bc86007d9ee053a0f1e15b889"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a95563f6bc86007d9ee053a0f1e15b889">gridfire::GraphEngine::recordADTape</a></div><divclass="ttdeci">void recordADTape()</div><divclass="ttdoc">Records the AD tape for the right-hand side of the ODE.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00558">engine_graph.cpp:558</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_a9f74786ff930ab72664b31f29d05a30c"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#a9f74786ff930ab72664b31f29d05a30c">gridfire::GraphEngine::GraphEngine</a></div><divclass="ttdeci">GraphEngine(const fourdst::composition::Composition &composition)</div><divclass="ttdoc">Constructs a GraphEngine from a composition.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00026">engine_graph.cpp:26</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_aa6202cee0c3c481eda77cc9a91bc126b"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#aa6202cee0c3c481eda77cc9a91bc126b">gridfire::GraphEngine::involvesSpecies</a></div><divclass="ttdeci">bool involvesSpecies(const fourdst::atomic::Species &species) const</div><divclass="ttdoc">Checks if a given species is involved in the network.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00140">engine_graph.cpp:140</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_acb7c4f5108b0efeae48ad15598e808c3"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#acb7c4f5108b0efeae48ad15598e808c3">gridfire::GraphEngine::m_reactions</a></div><divclass="ttdeci">reaction::LogicalReactionSet m_reactions</div><divclass="ttdoc">Set of REACLIB reactions in the network.</div><divclass="ttdef"><b>Definition</b><ahref="#l00332">engine_graph.h:332</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_acdce8d87e23a2cd1504bc9472e538c0f"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#acdce8d87e23a2cd1504bc9472e538c0f">gridfire::GraphEngine::syncInternalMaps</a></div><divclass="ttdeci">void syncInternalMaps()</div><divclass="ttdoc">Synchronizes the internal maps.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00062">engine_graph.cpp:62</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_acf4cfccea20f5cb31c9886bf233a28be"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#acf4cfccea20f5cb31c9886bf233a28be">gridfire::GraphEngine::validateConservation</a></div><divclass="ttdeci">bool validateConservation() const</div><divclass="ttdoc">Validates mass and charge conservation across all reactions.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00148">engine_graph.cpp:148</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_ad1cb5fd32efc37668e2d9ecf0c72ad24"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#ad1cb5fd32efc37668e2d9ecf0c72ad24">gridfire::GraphEngine::m_stoichiometryMatrix</a></div><divclass="ttdeci">boost::numeric::ublas::compressed_matrix< int > m_stoichiometryMatrix</div><divclass="ttdoc">Stoichiometry matrix (species x reactions).</div><divclass="ttdef"><b>Definition</b><ahref="#l00339">engine_graph.h:339</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_ad45650d10fc5dff1673ae3f806d067da"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#ad45650d10fc5dff1673ae3f806d067da">gridfire::GraphEngine::getNetworkReactions</a></div><divclass="ttdeci">const reaction::LogicalReactionSet & getNetworkReactions() const override</div><divclass="ttdoc">Gets the set of logical reactions in the network.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00134">engine_graph.cpp:134</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_ad8237c252145a75092202d00f5e1ddf7"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#ad8237c252145a75092202d00f5e1ddf7">gridfire::GraphEngine::m_speciesToIndexMap</a></div><divclass="ttdeci">std::unordered_map< fourdst::atomic::Species, size_t > m_speciesToIndexMap</div><divclass="ttdoc">Map from species to their index in the stoichiometry matrix.</div><divclass="ttdef"><b>Definition</b><ahref="#l00337">engine_graph.h:337</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_adac8c7d62bae76e17fc060e86dadd929"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#adac8c7d62bae76e17fc060e86dadd929">gridfire::GraphEngine::exportToDot</a></div><divclass="ttdeci">void exportToDot(const std::string &filename) const</div><divclass="ttdoc">Exports the network to a DOT file for visualization.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00436">engine_graph.cpp:436</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_ae347ff0316e532e0298ec8c913908105"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#ae347ff0316e532e0298ec8c913908105">gridfire::GraphEngine::generateJacobianMatrix</a></div><divclass="ttdeci">void generateJacobianMatrix(const std::vector< double >&Y, const double T9, const double rho) override</div><divclass="ttdoc">Generates the Jacobian matrix for the current state.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00386">engine_graph.cpp:386</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_aed726d36ee2b3796beff6067a1e4db38"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#aed726d36ee2b3796beff6067a1e4db38">gridfire::GraphEngine::generateStoichiometryMatrix</a></div><divclass="ttdeci">void generateStoichiometryMatrix() override</div><divclass="ttdoc">Generates the stoichiometry matrix for the network.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00303">engine_graph.cpp:303</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_aedf42d83bfcc28313b6b6454034d2efa"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#aedf42d83bfcc28313b6b6454034d2efa">gridfire::GraphEngine::collectNetworkSpecies</a></div><divclass="ttdeci">void collectNetworkSpecies()</div><divclass="ttdoc">Collects the unique species in the network.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00072">engine_graph.cpp:72</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_aeeafeab40a5f4dbfae78bdc87e25e93f"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#aeeafeab40a5f4dbfae78bdc87e25e93f">gridfire::GraphEngine::validateComposition</a></div><divclass="ttdeci">void validateComposition(const fourdst::composition::Composition &composition, double culling, double T9)</div><divclass="ttdoc">Validates the composition against the current reaction set.</div><divclass="ttdef"><b>Definition</b><ahref="engine__graph_8cpp_source.html#l00203">engine_graph.cpp:203</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1_graph_engine_html_af41df9ce979b6410e12642cb093916c9"><divclass="ttname"><ahref="classgridfire_1_1_graph_engine.html#af41df9ce979b6410e12642cb093916c9">gridfire::GraphEngine::calculateAllDerivatives</a></div><divclass="ttdeci">StepDerivatives< T > calculateAllDerivatives(const std::vector< T >&Y_in, T T9, T rho) const</div><divclass="ttdoc">Calculates all derivatives (dY/dt) and the energy generation rate.</div><divclass="ttdef"><b>Definition</b><ahref="#l00521">engine_graph.h:521</a></div></div>
<divclass="ttc"id="aclassgridfire_1_1reaction_1_1_reaction_html"><divclass="ttname"><ahref="classgridfire_1_1reaction_1_1_reaction.html">gridfire::reaction::Reaction</a></div><divclass="ttdoc">Represents a single nuclear reaction from a specific data source.</div><divclass="ttdef"><b>Definition</b><ahref="reaction_8h_source.html#l00072">reaction.h:72</a></div></div>
<divclass="ttc"id="aengine__abstract_8h_html"><divclass="ttname"><ahref="engine__abstract_8h.html">engine_abstract.h</a></div><divclass="ttdoc">Abstract interfaces for reaction network engines in GridFire.</div></div>
<divclass="ttc"id="anamespacegridfire_1_1reaction_html_aa86f08712565f278adacc7cd2361eb31"><divclass="ttname"><ahref="namespacegridfire_1_1reaction.html#aa86f08712565f278adacc7cd2361eb31">gridfire::reaction::LogicalReactionSet</a></div><divclass="ttdeci">TemplatedReactionSet< LogicalReaction > LogicalReactionSet</div><divclass="ttdoc">A set of logical reactions.</div><divclass="ttdef"><b>Definition</b><ahref="reaction_8h_source.html#l00557">reaction.h:557</a></div></div>
<divclass="ttc"id="anamespacegridfire_1_1screening_html_a6ca8556d27ac373e176f5b23437c416e"><divclass="ttname"><ahref="namespacegridfire_1_1screening.html#a6ca8556d27ac373e176f5b23437c416e">gridfire::screening::selectScreeningModel</a></div><divclass="ttdeci">std::unique_ptr< ScreeningModel > selectScreeningModel(ScreeningType type)</div><divclass="ttdoc">A factory function to select and create a screening model.</div><divclass="ttdef"><b>Definition</b><ahref="screening__types_8cpp_source.html#l00009">screening_types.cpp:9</a></div></div>
<divclass="ttc"id="anamespacegridfire_1_1screening_html_aa82aafbc4f8c28d0a75b60798e3a7d25"><divclass="ttname"><ahref="namespacegridfire_1_1screening.html#aa82aafbc4f8c28d0a75b60798e3a7d25">gridfire::screening::ScreeningType</a></div><divclass="ttdeci">ScreeningType</div><divclass="ttdoc">Enumerates the available plasma screening models.</div><divclass="ttdef"><b>Definition</b><ahref="screening__types_8h_source.html#l00015">screening_types.h:15</a></div></div>
<divclass="ttc"id="anamespacegridfire_1_1screening_html_aa82aafbc4f8c28d0a75b60798e3a7d25ad80b95b1abb9c8659fa4cc9d3d29bb71"><divclass="ttname"><ahref="namespacegridfire_1_1screening.html#aa82aafbc4f8c28d0a75b60798e3a7d25ad80b95b1abb9c8659fa4cc9d3d29bb71">gridfire::screening::ScreeningType::BARE</a></div><divclass="ttdeci">@ BARE</div><divclass="ttdoc">No screening applied. The screening factor is always 1.0.</div><divclass="ttdef"><b>Definition</b><ahref="screening__types_8h_source.html#l00016">screening_types.h:16</a></div></div>
<divclass="ttc"id="anamespacegridfire_html_a1121d0b2d005195333412559fa29d3cc"><divclass="ttname"><ahref="namespacegridfire.html#a1121d0b2d005195333412559fa29d3cc">gridfire::ADDouble</a></div><divclass="ttdeci">CppAD::AD< double > ADDouble</div><divclass="ttdoc">Alias for CppAD AD type for double precision.</div><divclass="ttdef"><b>Definition</b><ahref="#l00034">engine_graph.h:34</a></div></div>
<divclass="ttc"id="anamespacegridfire_html_a96c062f94713921e5d7568ecedcdcb06"><divclass="ttname"><ahref="namespacegridfire.html#a96c062f94713921e5d7568ecedcdcb06">gridfire::MIN_ABUNDANCE_THRESHOLD</a></div><divclass="ttdeci">static constexpr double MIN_ABUNDANCE_THRESHOLD</div><divclass="ttdoc">Minimum abundance threshold below which species are ignored.</div><divclass="ttdef"><b>Definition</b><ahref="#l00056">engine_graph.h:56</a></div></div>
<divclass="ttc"id="anamespacegridfire_html_ada3c137c014ecd8d06200fea2d1a9f50"><divclass="ttname"><ahref="namespacegridfire.html#ada3c137c014ecd8d06200fea2d1a9f50">gridfire::MIN_DENSITY_THRESHOLD</a></div><divclass="ttdeci">static constexpr double MIN_DENSITY_THRESHOLD</div><divclass="ttdoc">Minimum density threshold below which reactions are ignored.</div><divclass="ttdef"><b>Definition</b><ahref="#l00047">engine_graph.h:47</a></div></div>
<divclass="ttc"id="anamespacegridfire_html_ae01b1738df1921db565bcbd68dd6cf64"><divclass="ttname"><ahref="namespacegridfire.html#ae01b1738df1921db565bcbd68dd6cf64">gridfire::MIN_JACOBIAN_THRESHOLD</a></div><divclass="ttdeci">static constexpr double MIN_JACOBIAN_THRESHOLD</div><divclass="ttdoc">Minimum value for Jacobian matrix entries.</div><divclass="ttdef"><b>Definition</b><ahref="#l00064">engine_graph.h:64</a></div></div>
<divclass="ttc"id="areaction_8h_html"><divclass="ttname"><ahref="reaction_8h.html">reaction.h</a></div><divclass="ttdoc">Defines classes for representing and managing nuclear reactions.</div></div>
<divclass="ttc"id="astructgridfire_1_1_graph_engine_1_1_precomputed_reaction_html_a03d596c88289e21e7bd18711e3a1f275"><divclass="ttname"><ahref="structgridfire_1_1_graph_engine_1_1_precomputed_reaction.html#a03d596c88289e21e7bd18711e3a1f275">gridfire::GraphEngine::PrecomputedReaction::reactant_powers</a></div><divclass="ttdeci">std::vector< int > reactant_powers</div><divclass="ttdef"><b>Definition</b><ahref="#l00314">engine_graph.h:314</a></div></div>
<divclass="ttc"id="astructgridfire_1_1_graph_engine_1_1_precomputed_reaction_html_a7a7e9167b19e339e0d69544b9c00e79c"><divclass="ttname"><ahref="structgridfire_1_1_graph_engine_1_1_precomputed_reaction.html#a7a7e9167b19e339e0d69544b9c00e79c">gridfire::GraphEngine::PrecomputedReaction::stoichiometric_coefficients</a></div><divclass="ttdeci">std::vector< int > stoichiometric_coefficients</div><divclass="ttdef"><b>Definition</b><ahref="#l00317">engine_graph.h:317</a></div></div>
<divclass="ttc"id="astructgridfire_1_1_graph_engine_1_1constants_html_a3597bc632a5dd50aaa0044d8c18ca423"><divclass="ttname"><ahref="structgridfire_1_1_graph_engine_1_1constants.html#a3597bc632a5dd50aaa0044d8c18ca423">gridfire::GraphEngine::constants::u</a></div><divclass="ttdeci">const double u</div><divclass="ttdoc">Atomic mass unit in g.</div><divclass="ttdef"><b>Definition</b><ahref="#l00321">engine_graph.h:321</a></div></div>
<divclass="ttc"id="astructgridfire_1_1_graph_engine_1_1constants_html_a8bea6e348699c1aea93d17bb56739306"><divclass="ttname"><ahref="structgridfire_1_1_graph_engine_1_1constants.html#a8bea6e348699c1aea93d17bb56739306">gridfire::GraphEngine::constants::c</a></div><divclass="ttdeci">const double c</div><divclass="ttdoc">Speed of light in cm/s.</div><divclass="ttdef"><b>Definition</b><ahref="#l00323">engine_graph.h:323</a></div></div>
<divclass="ttc"id="astructgridfire_1_1_step_derivatives_html"><divclass="ttname"><ahref="structgridfire_1_1_step_derivatives.html">gridfire::StepDerivatives</a></div><divclass="ttdoc">Structure holding derivatives and energy generation for a network step.</div><divclass="ttdef"><b>Definition</b><ahref="engine__abstract_8h_source.html#l00053">engine_abstract.h:53</a></div></div>
<divclass="ttc"id="astructgridfire_1_1_step_derivatives_html_ab4aeb41be952c7b5844e1ee81fef9008"><divclass="ttname"><ahref="structgridfire_1_1_step_derivatives.html#ab4aeb41be952c7b5844e1ee81fef9008">gridfire::StepDerivatives::nuclearEnergyGenerationRate</a></div><divclass="ttdeci">T nuclearEnergyGenerationRate</div><divclass="ttdoc">Specific energy generation rate (e.g., erg/g/s).</div><divclass="ttdef"><b>Definition</b><ahref="engine__abstract_8h_source.html#l00055">engine_abstract.h:55</a></div></div>
<divclass="ttc"id="astructgridfire_1_1_step_derivatives_html_ae0de268b86c2404379409c4feae0b34d"><divclass="ttname"><ahref="structgridfire_1_1_step_derivatives.html#ae0de268b86c2404379409c4feae0b34d">gridfire::StepDerivatives::dydt</a></div><divclass="ttdeci">std::vector< T > dydt</div><divclass="ttdoc">Derivatives of abundances (dY/dt for each species).</div><divclass="ttdef"><b>Definition</b><ahref="engine__abstract_8h_source.html#l00054">engine_abstract.h:54</a></div></div>
<liclass="footer">Generated by <ahref="https://www.doxygen.org/index.html"><imgclass="footer"src="doxygen.svg"width="104"height="31"alt="doxygen"/></a> 1.13.2 </li>