Loading...
Searching...
No Matches
/Users/tboudreaux/Programming/4DSTAR/GridFire/src/network/include/gridfire/engine/engine_approx8.h

Multiplies two arrays and sums the resulting elements.

Multiplies two arrays and sums the resulting elements.

Parameters

  a | First array.
  b | Second array.

Returns
  Sum of the product of the arrays.

vec7 a = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0};
vec7 b = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
double result = sum_product(a, b);
gridfire::approx8::sum_product
double sum_product(const vec7 &a, const vec7 &b)
Definition engine_approx8.cpp:82
/* ***********************************************************************
//
// Copyright (C) 2025 -- The 4D-STAR Collaboration
// File Author: Emily Boudreaux
// Last Modified: March 21, 2025
//
// 4DSSE is free software; you can use it and/or modify
// it under the terms and restrictions the GNU General Library Public
// License version 3 (GPLv3) as published by the Free Software Foundation.
//
// 4DSSE is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with this software; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// *********************************************************************** */
#pragma once
#include <array>
#include <boost/numeric/odeint.hpp>
#include "gridfire/network.h"
namespace gridfire::approx8{
typedef boost::numeric::ublas::vector< double > vector_type;
typedef boost::numeric::ublas::matrix< double > matrix_type;
typedef std::array<double,7> vec7;
struct Approx8Net{
static constexpr int ih1=0;
static constexpr int ihe3=1;
static constexpr int ihe4=2;
static constexpr int ic12=3;
static constexpr int in14=4;
static constexpr int io16=5;
static constexpr int ine20=6;
static constexpr int img24=7;
static constexpr int iTemp=img24+1;
static constexpr int iDensity =iTemp+1;
static constexpr int iEnergy=iDensity+1;
static constexpr int nIso=img24+1; // number of isotopes
static constexpr int nVar=iEnergy+1; // number of variables
static constexpr std::array<int,nIso> aIon = {
1,
3,
4,
12,
14,
16,
20,
24
};
static constexpr std::array<double,nIso> mIon = {
1.67262164e-24,
5.00641157e-24,
6.64465545e-24,
1.99209977e-23,
2.32462686e-23,
2.65528858e-23,
3.31891077e-23,
3.98171594e-23
};
};
double sum_product( const vec7 &a, const vec7 &b);
vec7 get_T9_array(const double &T);
double rate_fit(const vec7 &T9, const vec7 &coef);
double pp_rate(const vec7 &T9);
double dp_rate(const vec7 &T9);
double he3he3_rate(const vec7 &T9);
double he3he4_rate(const vec7 &T9);
double triple_alpha_rate(const vec7 &T9);
double c12p_rate(const vec7 &T9);
double c12a_rate(const vec7 &T9);
double n14p_rate(const vec7 &T9);
double n14a_rate(const vec7 &T9);
double n15pa_rate(const vec7 &T9);
double n15pg_rate(const vec7 &T9);
double n15pg_frac(const vec7 &T9);
double o16p_rate(const vec7 &T9);
double o16a_rate(const vec7 &T9);
double ne20a_rate(const vec7 &T9);
double c12c12_rate(const vec7 &T9);
double c12o16_rate(const vec7 &T9);
struct Jacobian {
void operator() ( const vector_type &y, matrix_type &J, double /* t */, vector_type &dfdt ) const;
};
struct ODE {
void operator() ( const vector_type &y, vector_type &dydt, double /* t */) const;
};
class Approx8Network final : public Network {
public:
Approx8Network();
NetOut evaluate(const NetIn &netIn) override;
void setStiff(bool stiff) override;
bool isStiff() const override { return m_stiff; }
private:
vector_type m_y;
double m_tMax = 0;
double m_dt0 = 0;
bool m_stiff = false;
static vector_type convert_netIn(const NetIn &netIn);
};
} // namespace nnApprox8
gridfire::approx8::Approx8Network::convert_netIn
static vector_type convert_netIn(const NetIn &netIn)
Converts the input parameters to the internal state vector.
Definition engine_approx8.cpp:509
gridfire::approx8::Approx8Network::isStiff
bool isStiff() const override
Checks if the solver is using a stiff method.
Definition engine_approx8.h:315
gridfire::approx8::Approx8Network::Approx8Network
Approx8Network()
Definition engine_approx8.cpp:443
gridfire::approx8::Approx8Network::m_stiff
bool m_stiff
Definition engine_approx8.h:320
gridfire::approx8::Approx8Network::m_dt0
double m_dt0
Definition engine_approx8.h:319
gridfire::approx8::Approx8Network::m_tMax
double m_tMax
Definition engine_approx8.h:318
gridfire::approx8::Approx8Network::evaluate
NetOut evaluate(const NetIn &netIn) override
Evaluates the nuclear network.
Definition engine_approx8.cpp:445
gridfire::approx8::Approx8Network::m_y
vector_type m_y
Definition engine_approx8.h:317
gridfire::approx8::Approx8Network::setStiff
void setStiff(bool stiff) override
Sets whether the solver should use a stiff method.
Definition engine_approx8.cpp:505
gridfire::approx8
Definition engine_approx8.h:39
gridfire::approx8::he3he3_rate
double he3he3_rate(const vec7 &T9)
Calculates the rate for the reaction he3 + he3 -> he4 + 2p.
Definition engine_approx8.cpp:129
gridfire::approx8::pp_rate
double pp_rate(const vec7 &T9)
Calculates the rate for the reaction p + p -> d.
Definition engine_approx8.cpp:115
gridfire::approx8::get_T9_array
vec7 get_T9_array(const double &T)
Definition engine_approx8.cpp:93
gridfire::approx8::triple_alpha_rate
double triple_alpha_rate(const vec7 &T9)
Calculates the rate for the reaction he4 + he4 + he4 -> c12.
Definition engine_approx8.cpp:142
gridfire::approx8::matrix_type
boost::numeric::ublas::matrix< double > matrix_type
Alias for a matrix of doubles using Boost uBLAS.
Definition engine_approx8.h:51
gridfire::approx8::n14p_rate
double n14p_rate(const vec7 &T9)
Calculates the rate for the reaction n14(p,g)o15 - o15 + p -> c12 + he4.
Definition engine_approx8.cpp:164
gridfire::approx8::n14a_rate
double n14a_rate(const vec7 &T9)
Calculates the rate for the reaction n14(a,g)f18 assumed to go on to ne20.
Definition engine_approx8.cpp:173
gridfire::approx8::dp_rate
double dp_rate(const vec7 &T9)
Calculates the rate for the reaction p + d -> he3.
Definition engine_approx8.cpp:122
gridfire::approx8::he3he4_rate
double he3he4_rate(const vec7 &T9)
Calculates the rate for the reaction he3(he3,2p)he4.
Definition engine_approx8.cpp:135
gridfire::approx8::o16p_rate
double o16p_rate(const vec7 &T9)
Calculates the rate for the reaction o16(p,g)f17 then f17 -> o17(p,a)n14.
Definition engine_approx8.cpp:204
gridfire::approx8::c12c12_rate
double c12c12_rate(const vec7 &T9)
Calculates the rate for the reaction c12(c12,a)ne20.
Definition engine_approx8.cpp:227
gridfire::approx8::o16a_rate
double o16a_rate(const vec7 &T9)
Calculates the rate for the reaction o16(a,g)ne20.
Definition engine_approx8.cpp:210
gridfire::approx8::c12p_rate
double c12p_rate(const vec7 &T9)
Calculates the rate for the reaction c12 + p -> n13.
Definition engine_approx8.cpp:150
gridfire::approx8::c12o16_rate
double c12o16_rate(const vec7 &T9)
Calculates the rate for the reaction c12(o16,a)mg24.
Definition engine_approx8.cpp:233
gridfire::approx8::n15pa_rate
double n15pa_rate(const vec7 &T9)
Calculates the rate for the reaction n15(p,a)c12 (CNO I).
Definition engine_approx8.cpp:181
gridfire::approx8::vector_type
boost::numeric::ublas::vector< double > vector_type
Alias for a vector of doubles using Boost uBLAS.
Definition engine_approx8.h:45
gridfire::approx8::vec7
std::array< double, 7 > vec7
Alias for a std::array of 7 doubles.
Definition engine_approx8.h:57
gridfire::approx8::n15pg_frac
double n15pg_frac(const vec7 &T9)
Calculates the fraction for the reaction n15(p,g)o16.
Definition engine_approx8.cpp:197
gridfire::approx8::n15pg_rate
double n15pg_rate(const vec7 &T9)
Calculates the rate for the reaction n15(p,g)o16 (CNO II).
Definition engine_approx8.cpp:190
gridfire::approx8::ne20a_rate
double ne20a_rate(const vec7 &T9)
Calculates the rate for the reaction ne20(a,g)mg24.
Definition engine_approx8.cpp:218
gridfire::approx8::rate_fit
double rate_fit(const vec7 &T9, const vec7 &coef)
Definition engine_approx8.cpp:110
gridfire::approx8::c12a_rate
double c12a_rate(const vec7 &T9)
Calculates the rate for the reaction c12 + he4 -> o16.
Definition engine_approx8.cpp:157
network.h
gridfire::approx8::Approx8Net::iTemp
static constexpr int iTemp
Definition engine_approx8.h:73
gridfire::approx8::Approx8Net::iEnergy
static constexpr int iEnergy
Definition engine_approx8.h:75
gridfire::approx8::Approx8Net::in14
static constexpr int in14
Definition engine_approx8.h:68
gridfire::approx8::Approx8Net::aIon
static constexpr std::array< int, nIso > aIon
Definition engine_approx8.h:80
gridfire::approx8::Approx8Net::nIso
static constexpr int nIso
Definition engine_approx8.h:77
gridfire::approx8::Approx8Net::iDensity
static constexpr int iDensity
Definition engine_approx8.h:74
gridfire::approx8::Approx8Net::nVar
static constexpr int nVar
Definition engine_approx8.h:78
gridfire::approx8::Approx8Net::ihe4
static constexpr int ihe4
Definition engine_approx8.h:66
gridfire::approx8::Approx8Net::mIon
static constexpr std::array< double, nIso > mIon
Definition engine_approx8.h:91
gridfire::approx8::Approx8Net::ic12
static constexpr int ic12
Definition engine_approx8.h:67
gridfire::approx8::Approx8Net::img24
static constexpr int img24
Definition engine_approx8.h:71
gridfire::approx8::Approx8Net::ihe3
static constexpr int ihe3
Definition engine_approx8.h:65
gridfire::approx8::Approx8Net::io16
static constexpr int io16
Definition engine_approx8.h:69
gridfire::approx8::Approx8Net::ih1
static constexpr int ih1
Definition engine_approx8.h:64
gridfire::approx8::Approx8Net::ine20
static constexpr int ine20
Definition engine_approx8.h:70
gridfire::approx8::Jacobian::operator()
void operator()(const vector_type &y, matrix_type &J, double, vector_type &dfdt) const
Calculates the Jacobian matrix.
Definition engine_approx8.cpp:243
gridfire::approx8::ODE::operator()
void operator()(const vector_type &y, vector_type &dydt, double) const
Calculates the derivatives of the state vector.
Definition engine_approx8.cpp:348