From 5c783c708f0c08def6f6a3d8328b336d65842357 Mon Sep 17 00:00:00 2001 From: BangShiuh Date: Sat, 9 Jun 2018 22:47:17 -0400 Subject: [PATCH] [Transport/Test] Add tests for IonTransport properties --- interfaces/cython/cantera/test/test_onedim.py | 2 +- .../cython/cantera/test/test_transport.py | 42 +++++++++++++++++++ test/data/ch4_ion.cti | 19 +++++---- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/interfaces/cython/cantera/test/test_onedim.py b/interfaces/cython/cantera/test/test_onedim.py index 7b837efde0..b0c7f8d469 100644 --- a/interfaces/cython/cantera/test/test_onedim.py +++ b/interfaces/cython/cantera/test/test_onedim.py @@ -951,4 +951,4 @@ def test_ion_profile(self): self.sim.solve(loglevel=0, stage=2, enable_energy=True) # Regression test - self.assertNear(max(self.sim.E), 133.4795, 1e-3) + self.assertNear(max(self.sim.E), 131.9956, 1e-3) diff --git a/interfaces/cython/cantera/test/test_transport.py b/interfaces/cython/cantera/test/test_transport.py index 840636bc5d..6e43cba996 100644 --- a/interfaces/cython/cantera/test/test_transport.py +++ b/interfaces/cython/cantera/test/test_transport.py @@ -130,6 +130,29 @@ def test_species_visosities(self): visc) +class TestIonTransport(utilities.CanteraTest): + def setUp(self): + p = ct.one_atm + T = 2237 + self.gas = ct.Solution('ch4_ion.cti') + self.gas.X = 'O2:0.7010, H2O:0.1885, CO2:9.558e-2' + self.gas.TP = T, p + + def test_binary_diffusion(self): + ld = self.gas.n_species + i = self.gas.species_index("N2") + j = self.gas.species_index("H3O+") + bdiff = self.gas.binary_diff_coeffs[i][j] + # Regression test + self.assertNear(bdiff, 4.258e-4, 1e-4) + + def test_mixture_diffusion(self): + j = self.gas.species_index("H3O+") + mdiff = self.gas.mix_diff_coeffs[j] + # Regression test + self.assertNear(mdiff, 5.057e-4, 1e-4) + + class TestTransportGeometryFlags(utilities.CanteraTest): phase_data = """ units(length="cm", time="s", quantity="mol", act_energy="cal/mol") @@ -261,3 +284,22 @@ def test_set_customary_units(self): self.assertNear(tr1.dipole, tr2.dipole) self.assertNear(tr1.polarizability, tr2.polarizability) self.assertNear(tr1.rotational_relaxation, tr2.rotational_relaxation) + + +class TestIonGasTransportData(utilities.CanteraTest): + def setUp(self): + self.gas = ct.Solution('ch4_ion.cti') + + def test_read_ion(self): + tr = self.gas.species('N2').transport + self.assertNear(tr.dispersion_coefficient, 2.995e-50) + self.assertNear(tr.quadrupole_polarizability, 3.602e-50) + + def test_set_customary_units(self): + tr1 = ct.GasTransportData() + tr1.set_customary_units('linear', 3.62, 97.53, 1.76, + dispersion_coefficient = 2.995, + quadrupole_polarizability = 3.602) + tr2 = self.gas.species('N2').transport + self.assertNear(tr1.dispersion_coefficient, tr2.dispersion_coefficient) + self.assertNear(tr1.quadrupole_polarizability, tr2.quadrupole_polarizability) diff --git a/test/data/ch4_ion.cti b/test/data/ch4_ion.cti index fbbbdc0213..76368deb2b 100644 --- a/test/data/ch4_ion.cti +++ b/test/data/ch4_ion.cti @@ -144,7 +144,9 @@ species(name = "N2", diam = 3.62, well_depth = 97.53, polar = 1.76, - rot_relax = 4.00), + rot_relax = 4.00, + disp_coeff = 2.995, + quad_polar = 3.602), note = "121286" ) @@ -161,8 +163,9 @@ species(name = 'HCO+', transport=gas_transport(geom='linear', diam=3.59, well_depth=498.0, - polar=2.5, - rot_relax=0.0), + polar=1.356, + rot_relax=0.0, + disp_coeff = 0.416), note = 'J12/70') species(name = 'H3O+', @@ -176,11 +179,11 @@ species(name = 'H3O+', 7.097291130E+04, 7.458507790E+00] ) ), transport=gas_transport(geom='nonlinear', - diam=2.605, - well_depth=572.4, - dipole=1.844, - polar=1.5, - rot_relax=2.1), + diam=3.15, + well_depth=106.2, + dipole=1.417, + polar=0.897, + rot_relax=0.0), note = 'TPIS89') species(name = 'E',