rizer.cantera_ext
C++ Cantera 1-D plasma extension (custom Domain1D models and solvers)
Loading...
Searching...
No Matches
PlasmaColumnSolver.cpp
Go to the documentation of this file.
3
7
8#include <memory>
9
10namespace rizer {
11
12namespace { constexpr double kPi = 3.14159265358979323846; }
13
14ColumnResult solveColumn(double R, double electric_field, double T_wall,
15 const PropertyTable& sigma, const PropertyTable& kappa,
16 const PropertyTable& p_rad, const ColumnOptions& opts)
17{
18 using std::make_shared;
19
20 // Optional initial guess T(r), folded into the domain so it is applied at
21 // construction (via initialValue) without the deprecated Sim1D::setProfile.
22 PropertyTable init_profile;
23 if (opts.init_r.size() >= 2 && opts.init_r.size() == opts.init_T.size()) {
24 init_profile = PropertyTable(opts.init_r, opts.init_T);
25 }
26
27 auto column = make_shared<ThermalPlasmaColumn1D>(
28 R, opts.n_points, electric_field, T_wall,
29 sigma, kappa, p_rad, opts.T_center_guess, opts.rho_cp, init_profile);
30
31 // Dummy no-op terminators (no Solution required), matching the pattern of
32 // Cantera's BoundaryValueProblem sample. The column owns its own BCs.
33 auto left = make_shared<Cantera::Empty1D>();
34 auto right = make_shared<Cantera::Empty1D>();
35
36 std::vector<std::shared_ptr<Cantera::Domain1D>> domains{left, column, right};
37 Cantera::Sim1D sim(domains);
38
39 // Refinement applies to the column (domain index 1).
41 opts.refine_curve, opts.refine_prune);
42
43 sim.solve(opts.loglevel, opts.refine_grid);
44
45 // Extract the converged profile from the (possibly refined) grid.
46 const std::size_t np = column->nPoints();
47 ColumnResult res;
48 res.n_points = np;
49 res.electric_field = electric_field;
50 res.r.reserve(np);
51 res.T.reserve(np);
52 res.sigma.reserve(np);
53 res.kappa.reserve(np);
54
55 std::vector<double> Tvals = column->values("T");
56 for (std::size_t j = 0; j < np; j++) {
57 double r = column->z(j);
58 double T = Tvals[j];
59 res.r.push_back(r);
60 res.T.push_back(T);
61 res.sigma.push_back(column->sigmaAt(T));
62 res.kappa.push_back(column->kappaAt(T));
63 }
64
65 // Integrated current: I = int_0^R sigma(T) * E * 2*pi*r dr (trapezoidal).
66 double I = 0.0;
67 for (std::size_t j = 0; j + 1 < np; j++) {
68 // Trapezoidal rule: int_a^b f(r) dr ~ 0.5*(f(a)+f(b))*(b-a)
69 double f0 = res.sigma[j] * res.r[j];
70 double f1 = res.sigma[j + 1] * res.r[j + 1];
71 double dr = res.r[j + 1] - res.r[j];
72 I += 0.5 * (f0 + f1) * dr;
73 }
74 res.current = 2.0 * kPi * electric_field * I;
75
76 return res;
77}
78
79} // namespace rizer
void solve(int loglevel=0, bool refine_grid=true)
void setRefineCriteria(int dom=-1, double ratio=10.0, double slope=0.8, double curve=0.8, double prune=-0.1)
ColumnResult solveColumn(double R, double electric_field, double T_wall, const PropertyTable &sigma, const PropertyTable &kappa, const PropertyTable &p_rad, const ColumnOptions &opts)
Build, solve, and extract the radial Elenbaas-Heller column.
Solver configuration. All fields have defaults matching a typical H2 arc.
std::vector< double > init_r
Optional seed profile for the initial guess.
int loglevel
Sim1D verbosity (0 = silent, 1 = progress)
double refine_ratio
Refiner: max ratio of adjacent cell widths.
double refine_curve
Refiner: max fractional curvature per cell.
double rho_cp
rho*cp [J/m³/K] — scales the pseudo-transient term
double refine_slope
Refiner: max fractional slope change per cell.
double T_center_guess
parabolic-seed centerline temperature [K]
double refine_prune
Refiner: remove points below this threshold.
std::vector< double > init_T
seed temperatures [K] at init_r
std::size_t n_points
initial uniform grid count (refined during solve)
bool refine_grid
enable Cantera adaptive grid refinement
Output of a completed column solve.
double electric_field
E [V/m] used for this solve.
std::size_t n_points
number of grid points after adaptive refinement
std::vector< double > T
converged temperature [K] at each grid point
double current
I = 2π·E·∫sigma(T)·r dr [A], trapezoidal.
std::vector< double > sigma
electrical conductivity [S/m] evaluated at T
std::vector< double > kappa
thermal conductivity [W/m/K] evaluated at T
std::vector< double > r
radial grid [m] after refinement, r[0]=0, r[N-1]=R