11 double R, std::size_t npoints,
double electric_field,
double T_wall,
13 double T_center_guess,
double rho_cp,
PropertyTable init_profile)
18 , m_Tcenter(T_center_guess)
20 , m_sigma(std::move(sigma))
21 , m_kappa(std::move(kappa))
22 , m_prad(std::move(p_rad))
23 , m_init(std::move(init_profile))
25 if (R <= 0.0 || npoints < 3) {
26 throw std::invalid_argument(
27 "ThermalPlasmaColumn1D: require R > 0 and at least 3 grid points "
28 "(got R=" + std::to_string(R) +
", n=" + std::to_string(npoints)
42 const std::string& name,
bool )
const
47 throw std::invalid_argument(
48 "ThermalPlasmaColumn1D: no component named '" + name +
"'.");
52 const std::string& name,
bool )
const
60 if (component !=
"T") {
61 throw std::invalid_argument(
62 "ThermalPlasmaColumn1D: no component named '" + component +
"'.");
65 throw std::runtime_error(
66 "ThermalPlasmaColumn1D::getValues: domain not installed in a container.");
69 for (std::size_t j = 0; j <
m_points; j++) {
77 if (!m_init.empty()) {
79 return m_init.eval(r);
83 return m_Twall + (m_Tcenter - m_Twall) * (1.0 - s * s);
88 auto x = xg.subspan(
loc(),
size());
91 for (std::size_t j = 0; j <
m_points; j++) {
92 double T = x[
index(0, j)];
93 x[
index(0, j)] = std::min(std::max(T, lo), hi);
111 auto x = xg.subspan(
loc(),
size());
112 auto rsd = rg.subspan(
loc(),
size());
113 auto diag = maskg.subspan(
loc(),
size());
116 std::size_t jmin, jmax;
121 std::size_t jpt = (jg == 0) ? 0 : jg -
firstPoint();
122 jmin = std::max<std::size_t>(jpt, 1) - 1;
123 jmax = std::min(jpt + 1,
m_points - 1);
126 const double E2 = m_E * m_E;
128 for (std::size_t j = jmin; j <= jmax; j++) {
129 const double Tj = x[
index(0, j)];
134 rsd[
index(0, j)] = Tj - m_Twall;
135 diag[
index(0, j)] = 0;
150 const double zj =
z(j);
151 const double re = 0.5 * (zj +
z(j + 1));
152 const double dre =
z(j + 1) - zj;
153 const double Tjp1 = x[
index(0, j + 1)];
154 const double kap_e = 0.5 * (m_kappa.eval(Tj) + m_kappa.eval(Tjp1));
155 const double flux_e = re * kap_e * (Tjp1 - Tj) / dre;
165 rw = 0.5 * (
z(j - 1) + zj);
166 const double Tjm1 = x[
index(0, j - 1)];
167 const double drw = zj -
z(j - 1);
168 const double kap_w = 0.5 * (m_kappa.eval(Tjm1) + m_kappa.eval(Tj));
169 flux_w = rw * kap_w * (Tj - Tjm1) / drw;
175 const double vol = 0.5 * (re * re - rw * rw);
176 const double div_flux = (flux_e - flux_w) / vol;
179 const double source = m_sigma.eval(Tj) * E2 - m_prad.eval(Tj);
185 rsd[
index(0, j)] = (div_flux + source) / m_rho_cp
187 diag[
index(0, j)] = 1;
void setTransientTolerances(double rtol, double atol, size_t n=npos)
void setComponentName(size_t n, const string &name)
void setupUniformGrid(size_t points, double length, double start=0.)
double lowerBound(size_t n) const
shared_ptr< vector< double > > m_state
vector< double > values(const string &component) const
double z(size_t jlocal) const
double upperBound(size_t n) const
void setSteadyTolerances(double rtol, double atol, size_t n=npos)
void setBounds(size_t n, double lower, double upper)
double prevSoln(size_t n, size_t j) const
size_t firstPoint() const
Domain1D(size_t nv=1, size_t points=1, double time=0.0)
size_t index(size_t n, size_t j) const
virtual size_t loc(size_t j=0) const
std::size_t componentIndex(const std::string &name, bool checkAlias=true) const override
double initialValue(std::size_t n, std::size_t j) override
Initial guess for component n at grid point j.
void getValues(const std::string &component, Cantera::span< double > values) const override
Copy converged temperatures from the shared global solution vector.
bool hasComponent(const std::string &name, bool checkAlias=true) const override
void eval(std::size_t jg, Cantera::span< const double > xg, Cantera::span< double > rg, Cantera::span< int > maskg, double rdt) override
Evaluate the residual function at point jg.
ThermalPlasmaColumn1D(double R, std::size_t npoints, double electric_field, double T_wall, PropertyTable sigma, PropertyTable kappa, PropertyTable p_rad, double T_center_guess, double rho_cp, PropertyTable init_profile=PropertyTable())
void resetBadValues(Cantera::span< double > xg) override
Clamp any out-of-bound temperatures after a failed Newton step to keep the solve from wandering into ...