(self)
| 1488 | class TestReactorJacobians: |
| 1489 | |
| 1490 | def test_multi_surface_simple(self): |
| 1491 | # conditions for simulation |
| 1492 | yml = "simple_surface.yaml" |
| 1493 | fuel = "A:1.0, B:1.0" |
| 1494 | # gas kinetics |
| 1495 | gas = ct.Solution(yml, "gas") |
| 1496 | gas.TPX = 1000, 2e5, fuel |
| 1497 | gas.set_multiplier(0) |
| 1498 | # surface kinetics for the simulation |
| 1499 | surf = ct.Interface(yml, 'surf', [gas]) |
| 1500 | surf2 = ct.Interface(yml, 'surf', [gas]) |
| 1501 | surf.coverages = 'A(S):0.1, B(S):0.2, C(S):0.3, D(S):0.2, (S):0.2' |
| 1502 | surf2.coverages = 'A(S):0.1, D(S):0.2, (S):0.2' |
| 1503 | # create reactor |
| 1504 | r = ct.IdealGasMoleReactor(gas) |
| 1505 | r.volume = 3 |
| 1506 | # create surfaces |
| 1507 | rsurf1 = ct.ReactorSurface(surf, r, A=9e-4) |
| 1508 | rsurf2 = ct.ReactorSurface(surf2, r, A=5e-4) |
| 1509 | # create network |
| 1510 | net = ct.ReactorNet([r]) |
| 1511 | net.step() |
| 1512 | # get jacobians |
| 1513 | jacobian = r.jacobian |
| 1514 | fd_jacobian = r.finite_difference_jacobian |
| 1515 | # the volume row is not considered in comparisons because it is presently |
| 1516 | # not calculated. |
| 1517 | # check first row is near, terms which are generally on the order of 1e5 to 1e7 |
| 1518 | assert jacobian[0, 2:] == approx(fd_jacobian[0, 2:], rel=1e-1, abs=1e-2) |
| 1519 | # check first col is near, these are finite difference terms and should be close |
| 1520 | assert jacobian[2:, 0] == approx(fd_jacobian[2:, 0], rel=1e-3, abs=1e-4) |
| 1521 | # check all species are near, these terms are usually ~ 1e2 |
| 1522 | assert jacobian[2:, 2:] == approx(fd_jacobian[2:, 2:], rel=1e-3, abs=1e-4) |
| 1523 | |
| 1524 | def test_gas_simple(self): |
| 1525 | # conditions for simulation |
nothing calls this directly
no test coverage detected