void check_rates(size_t N, const std::string& X) { for (size_t i = 0; i < kin_ref.nReactions(); i++) { if (i >= N) { kin_ref.setMultiplier(i, 0); } else { kin_ref.setMultiplier(i, 1); } } p.setState_TPX(1200, 5*OneAtm, X); p_ref.setState_TPX(1200, 5*OneAtm, X); vector_fp k(kin.nReactions()), k_ref(kin_ref.nReactions()); vector_fp w(kin.nTotalSpecies()), w_ref(kin_ref.nTotalSpecies()); kin.getFwdRateConstants(k.data()); kin_ref.getFwdRateConstants(k_ref.data()); for (size_t i = 0; i < kin.nReactions(); i++) { EXPECT_DOUBLE_EQ(k_ref[i], k[i]) << "i = " << i << "; N = " << N; } kin.getFwdRatesOfProgress(k.data()); kin_ref.getFwdRatesOfProgress(k_ref.data()); for (size_t i = 0; i < kin.nReactions(); i++) { EXPECT_DOUBLE_EQ(k_ref[i], k[i]) << "i = " << i << "; N = " << N; } kin.getRevRateConstants(k.data()); kin_ref.getRevRateConstants(k_ref.data()); for (size_t i = 0; i < kin.nReactions(); i++) { EXPECT_DOUBLE_EQ(k_ref[i], k[i]) << "i = " << i << "; N = " << N; } kin.getRevRatesOfProgress(k.data()); kin_ref.getRevRatesOfProgress(k_ref.data()); for (size_t i = 0; i < kin.nReactions(); i++) { EXPECT_DOUBLE_EQ(k_ref[i], k[i]) << "i = " << i << "; N = " << N; } kin.getCreationRates(w.data()); kin_ref.getCreationRates(w_ref.data()); for (size_t i = 0; i < kin.nTotalSpecies(); i++) { size_t iref = p_ref.speciesIndex(p.speciesName(i)); EXPECT_DOUBLE_EQ(w_ref[iref], w[i]) << "sp = " << p.speciesName(i) << "; N = " << N; } }
TEST_F(ConstructFromScratch, throwUndefindElements) { IdealGasPhase p; p.throwUndefinedElements(); p.addElement("H"); p.addElement("O"); p.addSpecies(sH2O); p.addSpecies(sH2); ASSERT_EQ((size_t) 2, p.nSpecies()); p.addSpecies(sO2); p.addSpecies(sOH); ASSERT_EQ((size_t) 4, p.nSpecies()); ASSERT_EQ("H2", p.speciesName(1)); ASSERT_EQ(2, p.nAtoms(2, 1)); // O in O2 ASSERT_EQ(2, p.nAtoms(0, 0)); // H in H2O ASSERT_THROW(p.addSpecies(sCO), CanteraError); }