MCPcopy Create free account
hub / github.com/Cantera/cantera / initialize

Method initialize

src/zeroD/ReactorNet.cpp:105–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void ReactorNet::initialize()
106{
107 m_nv = 0;
108 debuglog("Initializing reactor network.\n", m_verbose);
109 if (m_reactors.empty()) {
110 throw CanteraError("ReactorNet::initialize",
111 "no reactors in network!");
112 }
113 m_start.assign(1, 0);
114 for (size_t n = 0; n < m_reactors.size(); n++) {
115 Reactor& r = *m_reactors[n];
116 r.initialize(m_time);
117 size_t nv = r.neq();
118 m_nv += nv;
119 m_start.push_back(m_nv);
120
121 if (m_verbose) {
122 writelog("Reactor {:d}: {:d} variables.\n", n, nv);
123 writelog(" {:d} sensitivity params.\n", r.nSensParams());
124 }
125 if (r.type() == "FlowReactor" && m_reactors.size() > 1) {
126 throw CanteraError("ReactorNet::initialize",
127 "FlowReactors must be used alone.");
128 }
129 }
130
131 m_ydot.resize(m_nv,0.0);
132 m_yest.resize(m_nv,0.0);
133 m_advancelimits.resize(m_nv,-1.0);
134 m_atol.resize(neq());
135 fill(m_atol.begin(), m_atol.end(), m_atols);
136 m_integ->setTolerances(m_rtol, neq(), m_atol.data());
137 m_integ->setSensitivityTolerances(m_rtolsens, m_atolsens);
138 if (!m_linearSolverType.empty()) {
139 m_integ->setLinearSolverType(m_linearSolverType);
140 }
141 if (m_precon) {
142 m_integ->setPreconditioner(m_precon);
143 }
144 m_integ->initialize(m_time, *this);
145 if (m_verbose) {
146 writelog("Number of equations: {:d}\n", neq());
147 writelog("Maximum time step: {:14.6g}\n", m_maxstep);
148 }
149 if (m_integ->preconditionerSide() != PreconditionerSide::NO_PRECONDITION) {
150 checkPreconditionerSupported();
151 }
152 m_integrator_init = true;
153 m_init = true;
154}
155
156void ReactorNet::reinitialize()
157{

Callers 6

integrate_reactorFunction · 0.95
test_gas_simpleMethod · 0.95
test_component_namesMethod · 0.95
test_jacobianMethod · 0.95

Calls 15

debuglogFunction · 0.85
CanteraErrorClass · 0.85
writelogFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
neqMethod · 0.45
nSensParamsMethod · 0.45
typeMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
setTolerancesMethod · 0.45

Tested by 5

test_gas_simpleMethod · 0.76
test_component_namesMethod · 0.76
test_jacobianMethod · 0.76