3#ifdef REACTIONS_ENABLED
4#include "cantera/base/Solution.h"
5#include "cantera/thermo.h"
23 std::vector<std::shared_ptr<std::vector<double>>>
varData;
29#ifdef REACTIONS_ENABLED
30 std::shared_ptr<Cantera::ThermoPhase> gas;
31 std::shared_ptr<batchReactor> bRxr;
74 std::vector<double>
xc;
75 std::vector<double>
xh;
139 void set_tree(
double Re_,
double domainLength_,
double tau0_, std::string ReApproach_ =
"rounding");
143 void set_varData(std::vector<double> &v, std::vector<double> &w,
const std::string &varN);
144 void set_varData(std::vector<double> &v, std::vector<double> &w,
const std::string &varN,
145 const std::vector<double> &rho);
155 void writeData(
int real,
const int ifile,
const double outputTime);
166 std::vector<double>
projection(std::vector<double> &vcfd, std::vector<double> &weight);
168 std::pair<std::vector<double>, std::vector<double>>
projection(std::vector<double> &vcfd, std::vector<double> &weight,
169 const std::vector<double> &density);
172 std::vector<double>
setGridCfd(std::vector<double> &w);
175 std::vector<double> &rho_h,
176 std::vector<double> &rho_c);
183 void advanceHips(
const int iLevel,
const int iTree);
224 std::vector<double> &ScHips_,
226 std::shared_ptr<void> vcantSol =
nullptr,
228 int realization_ = 1);
262 double domainLength_,
267 std::vector<double> &ScHips_,
269 std::shared_ptr<void> vcantSol =
nullptr,
271 int realization_ = 1);
std::vector< double > setGridHips(int N)
Generates a physical domain for HiPS parcels.
std::vector< double > parcelTimes
current times corresponding to the parcel states
const double DEFAULT_TIME_INTERVAL
Default: Write every 0.1s.
double lastOutputTime
Last time data was written.
int nVar
number of parcel variables (e.g., h, ysp)
int nLevels_
number of tree levels?
int getVariableIndex(const std::string &varName) const
Retrieves the index of a variable by its name in the varName list.
std::vector< double > xc
vector containing physical domain of flow particles
std::vector< int > pLoc
parcel index array for fast implementation of swaps
bool performReaction
flag indicating whether chemical reactions are performed in the simulation
void forceProfile()
Adjusts the HiPS profile to enforce statistical stationarity.
hips(int nLevels_, double domainLength_, double tau0_, double C_param_, bool forceTurb_, int nVar_, std::vector< double > &ScHips_, bool performReaction, std::shared_ptr< void > vcantSol=nullptr, int seed=10, int realization_=1)
Constructor for initializing the full HiPS tree at the time of object creation.
std::vector< double > xh
vector containing physical domain of HiPS parcels
void set_tree(int nLevels_, double domainLength_, double tau0_)
Sets up the HiPS tree using explicitly specified tree parameters.
std::vector< double > wPar
parcel volume fractions
int nL
adjusted number of levels based on the Reynolds number
bool forceTurb
forcing function for statistically stationary: -1 = none, 1 = source term, 2 = dir
std::vector< double > projection_back(std::vector< double > &vb)
Projects HiPS parcel values back onto the flow particles.
void setOutputIntervalEddy(int interval)
Sets the interval (in number of eddy events) for writing simulation data.
std::vector< std::vector< double > > get_varData()
Retrieves the final data from the simulation.
std::vector< int > i_plus
ceil(i_batchelor)
double outputIntervalTime
Default: write data every 0.1s.
const std::vector< std::shared_ptr< std::vector< double > > > & get_HipsVarData_ptr() const
double Afac
level lengthscale reduction factor (0.5)
double C_param
Eddy frequency parameter.
int realization
number of realizations
const int DEFAULT_EDDY_INTERVAL
Default: Write every 1000 eddies.
void selectAndSwapTwoSubtrees(const int iLevel, int &iTree)
Performs eddy events by swapping parcels within the HiPS tree.
void writeData(int real, const int ifile, const double outputTime)
Writes simulation data to a file for a specific realization, time, and file index.
double eddyRate_inertial
total rate of all eddies 0 through iEta (= eddyRate_total if Sc=1)
double Anew
adjusted level lengthscale reduction factor for dynamic adjustment of reduction factor
int currentIndex
member variable to keep track of current index of variables
std::vector< double > projection_back_with_density(std::vector< double > &vh, std::vector< double > &rho_h, std::vector< double > &rho_c)
Projects HiPS parcel values and densities back onto the flow particles (CFD cells).
std::vector< double > i_batchelor
Batchelor level for variable Sc scalars; NOTE: double, as in, between levels.
void calculateSolution(const double tRun, bool shouldWriteData=false)
Runs the HiPS simulation, advancing the solution using eddy events.
double time
current simulation time
void sample_hips_eddy(double &dt, int &iLevel)
Samples stochastic eddy events on the HiPS tree, determining the time increment and tree level.
void setOutputIntervalTime(double interval)
Sets the interval (in simulation time) for writing simulation data.
std::vector< double > varRho
density
void reactParcels_LevelTree(const int iLevel, const int iTree)
Simulates chemical reactions for parcels affected by a micromixing event.
hips(double C_param_, bool forceTurb_, int nVar_, std::vector< double > &ScHips_, bool performReaction, std::shared_ptr< void > vcantSol=nullptr, int seed=10, int realization_=1)
Constructor for initializing a HiPS object without building the tree immediately.
std::pair< std::vector< std::vector< double > >, std::vector< double > > get_varData_with_density()
Retrieves final simulation data, including both values and densities.
bool useTimeBasedWriting
Tracks if time writing is set.
std::vector< double > levelRates
list of eddy event rates at each level
std::vector< std::string > varName
vector containing the names of parcel variables
double Re
Reynolds number.
bool useEddyBasedWriting
Tracks if eddy writing is set.
void set_varData(std::vector< double > &v, std::vector< double > &w, const std::string &varN)
Assigns variables, their corresponding weights, and names to the parcels in the HiPS tree.
int nparcels
number of parcels
double Prob
probability value for probability-based solution
const std::vector< int > & get_pLoc() const
void mixAcrossLevelTree(int kVar, const int iMixLevel, const int iTree)
Uniformly mixes parcels at a specified level and subtree within the HiPS model.
double dtEE
time increment to next eddy event
int iEta
Kolmogorov level (needed for variable Sc scalars)
double eddyRate_total
total rate of all eddies 0 through nLevels-3
double domainLength
length of domain (m)
int eddyCounter
Counter for eddy events.
std::vector< std::shared_ptr< std::vector< double > > > varData
vector of pointers to vector
std::vector< double > projection(std::vector< double > &vcfd, std::vector< double > &weight)
Projects values from flow particles onto HiPS parcels assuming constant density.
std::vector< double > setGridCfd(std::vector< double > &w)
Generates a physical domain for flow particles based on their weights.
void advanceHips(const int iLevel, const int iTree)
Advances the HiPS model by simulating micromixing and reactions at a specific tree level.
double lStar
length of the level associated with the Reynolds number
int outputIntervalEddy
Default: write data every 10 eddy events.
double tau0
integral timescale
void saveAllParameters()
Saves all user-defined to a file.
int nLevels
number of tree levels
bool LScHips
hips schmidt number
std::vector< double > ScHips
vector containing Schmidt numbers related to each variable