3#ifdef REACTIONS_ENABLED
4#include "cantera/base/Solution.h"
5#include "cantera/thermo.h"
24 std::vector<std::shared_ptr<std::vector<double>>>
varData;
26#ifdef REACTIONS_ENABLED
27 std::shared_ptr<Cantera::ThermoPhase> gas;
28 std::shared_ptr<batchReactor> bRxr;
74 std::vector<double>
xc;
75 std::vector<double>
xh;
111 void set_tree(
int nLevels_,
double domainLength_,
double tau0_, std::vector<double> &ScHips_);
137 void set_tree(
double Re_,
double domainLength_,
double tau0_, std::vector<double> &ScHips_, std::string approach_ =
"rounding");
141 void set_varData(std::vector<double> &v, std::vector<double> &w,
const std::string &varN);
142 void set_varData(std::vector<double> &v, std::vector<double> &w,
const std::string &varN,
143 const std::vector<double> &rho);
155 std::vector<double>
projection(std::vector<double> &vcfd, std::vector<double> &weight);
157 std::pair<std::vector<double>, std::vector<double>>
projection(std::vector<double> &vcfd, std::vector<double> &weight,
158 const std::vector<double> &density);
161 std::vector<double>
setGridCfd(std::vector<double> &w);
164 std::vector<double> &rho_h);
171 void advanceHips(
const int iLevel,
const int iTree);
180 void writeData(
int real,
const int ifile,
const double outputTime);
214 std::shared_ptr<void> vcantSol =
nullptr,
216 int realization_ = 1);
250 double domainLength_,
255 std::vector<double> &ScHips_,
257 std::shared_ptr<void> vcantSol =
nullptr,
259 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?
std::pair< std::vector< double >, std::vector< double > > projection_back_with_density(std::vector< double > &vh, std::vector< double > &rho_h)
Projects HiPS parcel values and densities back onto the flow particles.
int getVariableIndex(const std::string &varName) const
Retrieves the index of a variable by its name in the varName list.
hips(double C_param_, int forceTurb_, int nVar_, 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::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
std::vector< std::pair< std::vector< double >, std::vector< double > > > get_varData_with_density()
Retrieves final simulation data, including both values and densities.
void forceProfile()
Adjusts the HiPS profile to enforce statistical stationarity.
std::vector< double > xh
vector containing physical domain of HiPS parcels
int nL
adjusted number of levels based on the Reynolds number
bool LrandSet
flag indicating new randomGen --> allow deletion
void resetForNewRealization()
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.
hips(int nLevels_, double domainLength_, double tau0_, double C_param_, int 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< 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.
double Afac
level lengthscale reduction factor (0.5)
double C_param
Eddy frequency parameter.
int forceTurb
forcing function for statistically stationary: -1 = none, 1 = source term, 2 = dir
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 > 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
void reactParcels_LevelTree(const int iLevel, const int iTree)
Simulates chemical reactions for parcels affected by a micromixing event.
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
std::vector< double > Temp
Vector containg temperature in each parcel;.
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
void set_tree(int nLevels_, double domainLength_, double tau0_, std::vector< double > &ScHips_)
Sets up the HiPS tree using explicitly specified tree parameters.
std::vector< double > ScHips
vector containing Schmidt numbers related to each variable