20 const std::function<
double(
double,
double)> &plasma_voltage,
21 std::size_t channel_offset, std::size_t n_vars)
22 : m_channel(&channel), m_gap(gap),
23 m_plasma_voltage(&plasma_voltage),
24 m_channel_offset(channel_offset), m_n_vars(n_vars),
25 m_n_points(channel.nPoints()),
26 m_Rp(std::numeric_limits<double>::infinity())
34 throw std::runtime_error(
35 "ChannelCircuit: the circuit closes on "
36 "R_p = gap / integral(sigma dA) and sets the field to "
37 "V_p / gap, so gap must be positive; got " +
38 std::to_string(m_gap) +
" m.");
45 throw std::runtime_error(
46 "ChannelCircuit: a circuit closes on integral(sigma dA) over "
47 "the cross-section, which needs at least 2 radial nodes to "
48 "have an area; got " +
49 std::to_string(m_n_points) +
".");
56 m_cell_area.resize(m_n_points);
57 for (std::size_t j = 0; j < m_n_points; j++)
60 const double outer = channel.
faceRadius(j + 1);
61 m_cell_area[j] =
Cantera::Pi * (outer * outer - inner * inner);
75 m_Rp = resistanceFrom(conductance(x));
79 const std::vector<double> &x)
85 m_Rp = resistanceFrom(conductance(x));
88 m_Vp0 = (*m_plasma_voltage)(t0, m_Rp);
89 m_Vp1 = (*m_plasma_voltage)(t1, m_Rp);
97 const double fraction =
98 (m_dt > 0.0) ? std::min(std::max((t - m_t0) / m_dt, 0.0), 1.0) : 0.0;
99 return (m_Vp0 + (m_Vp1 - m_Vp0) * fraction) / m_gap;
106 out.
Rp_state = resistanceFrom(conductance(x));
108 out.
current = (m_Rp > 0.0 && std::isfinite(m_Rp)) ? m_Vp1 / m_Rp : 0.0;
117 double ChannelCircuit::conductance(
const std::vector<double> &x)
const
120 for (std::size_t j = 0; j < m_n_points; j++)
123 x[m_channel_offset + m_n_vars * j + 0],
124 x[m_channel_offset + m_n_vars * j + 1],
125 &x[m_channel_offset + m_n_vars * j + 2], j) *
131 double ChannelCircuit::resistanceFrom(
double conductance_value)
const
133 return (conductance_value > 0.0)
134 ? m_gap / conductance_value
135 : std::numeric_limits<double>::infinity();
Closes an external electrical circuit on the channel's own resistance.
void seedResistance(const std::vector< double > &x)
Set the resistance from the current state without asking the circuit for a voltage.
double electricField(double t) const
Applied field over the step closeOver() last covered [V/m].
ChannelCircuit(const PlasmaChannel1D &channel, double gap, const std::function< double(double, double)> &plasma_voltage, std::size_t channel_offset, std::size_t n_vars)
Build the coupling, or an inactive one when no callback is given.
CircuitSample sample(const std::vector< double > &x) const
void closeOver(double t0, double t1, const std::vector< double > &x)
Close the circuit over one step: freeze at the state the step starts from and ask the callback for ...
Transient, two-temperature (Te != Tg), finite-rate reacting 1-D radial plasma channel (custom Cantera...
double nodeElectricalConductivity(double Tg, double Te, const double *Y, std::size_t j) const
Electrical conductivity [S/m] at one node's state, from the same composition-resolved closure the sou...
double faceRadius(std::size_t j) const
Radius of face j, the single definition of where a cell boundary sits (NUMERICS.md section 2).
The circuit columns of one recorded frame.
double current
Total current [A].
double Vp
Plasma terminal voltage at the end of the step [V].
double electric_field
Applied field [V/m].
double Rp_state
Resistance OF this frame's own recorded fields, which is what a reader recomputing it from Tg,...
double Rp
Resistance the circuit was DRIVEN with over the step ending at this frame, which is what current was ...