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

Method test_replace_equations

test/python/test_reactor.py:2835–2858  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2833 assert r.component_name(2) == 'temperature'
2834
2835 def test_replace_equations(self):
2836 nsp = self.gas.n_species
2837 tau = np.linspace(0.5, 2, nsp + 3)
2838 class DummyReactor(ct.ExtensibleReactor):
2839 def __init__(self, *args, **kwargs):
2840 super().__init__(*args, **kwargs)
2841 self.y = np.ones(nsp + 3)
2842
2843 def replace_get_state(self, y):
2844 y[:] = self.y
2845
2846 def replace_update_state(self, y):
2847 self.y[:] = y
2848
2849 def replace_eval(self, t, LHS, RHS):
2850 RHS[:] = - self.y / tau
2851
2852 r = DummyReactor(self.gas)
2853 net = ct.ReactorNet([r])
2854 net.rtol *= 0.1
2855
2856 while(net.time < 1):
2857 net.step()
2858 assert r.get_state() == approx(np.exp(- net.time / tau))
2859
2860 def test_error_handling(self):
2861 class DummyReactor1(ct.ExtensibleReactor):

Callers

nothing calls this directly

Calls 3

stepMethod · 0.95
DummyReactorClass · 0.85
ReactorNetMethod · 0.45

Tested by

no test coverage detected