[Reactor] Fix sensitivity parameter order for constant pressure reactors
This matches the behavior of Reactor, where the parameter order is determined by the order of the reactions in the mechanism.
This commit is contained in:
parent
8724bc9f04
commit
615c3124fb
3 changed files with 10 additions and 2 deletions
|
|
@ -886,7 +886,7 @@ class TestReactorSensitivities(utilities.CanteraTest):
|
|||
self.assertNear(np.linalg.norm(S[Ns:K2,1]), 0.0, atol=1e-5)
|
||||
self.assertNear(np.linalg.norm(S[K2+Ns:,0]), 0.0, atol=1e-5)
|
||||
|
||||
def test_parameter_order1(self):
|
||||
def _test_parameter_order1(self, reactorClass):
|
||||
# Single reactor, changing the order in which parameters are added
|
||||
gas = ct.Solution('h2o2.xml')
|
||||
|
||||
|
|
@ -894,7 +894,7 @@ class TestReactorSensitivities(utilities.CanteraTest):
|
|||
net = ct.ReactorNet()
|
||||
gas.TPX = 900, 101325, 'H2:0.1, OH:1e-7, O2:0.1, AR:1e-5'
|
||||
|
||||
r = ct.IdealGasReactor(gas)
|
||||
r = reactorClass(gas)
|
||||
net.add_reactor(r)
|
||||
return r, net
|
||||
|
||||
|
|
@ -925,6 +925,12 @@ class TestReactorSensitivities(utilities.CanteraTest):
|
|||
for i,j in enumerate((2,1,3,0)):
|
||||
self.assertArrayNear(S1[:,i], S2[:,j])
|
||||
|
||||
def test_parameter_order1a(self):
|
||||
self._test_parameter_order1(ct.IdealGasReactor)
|
||||
|
||||
def test_parameter_order1b(self):
|
||||
self._test_parameter_order1(ct.IdealGasConstPressureReactor)
|
||||
|
||||
def test_parameter_order2(self):
|
||||
# Multiple reactors, changing the order in which parameters are added
|
||||
gas = ct.Solution('h2o2.xml')
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ void ConstPressureReactor::initialize(doublereal t0)
|
|||
}
|
||||
}
|
||||
m_work.resize(maxnt);
|
||||
std::sort(m_pnum.begin(), m_pnum.end());
|
||||
m_init = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ void IdealGasConstPressureReactor::initialize(doublereal t0)
|
|||
}
|
||||
}
|
||||
m_work.resize(maxnt);
|
||||
std::sort(m_pnum.begin(), m_pnum.end());
|
||||
m_init = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue