void SurfPhase::setParameters(int n, doublereal* const c) { if (n != 1) { throw CanteraError("SurfPhase::setParameters", "Bad value for number of parameter"); } setSiteDensity(c[0]); }
TEST(LatticeSolidPhase, fromScratch) { auto base = make_shared<StoichSubstance>(); base->setName("Li7Si3(S)"); base->setDensity(1390.0); auto sLi7Si3 = make_shomate2_species("Li7Si3(S)", "Li:7 Si:3", li7si3_shomate_coeffs); base->addSpecies(sLi7Si3); base->initThermo(); auto interstital = make_shared<LatticePhase>(); interstital->setName("Li7Si3_Interstitial"); auto sLii = make_const_cp_species("Li(i)", "Li:1", 298.15, 0, 2e4, 2e4); auto sVac = make_const_cp_species("V(i)", "", 298.15, 8.98e4, 0, 0); sLii->extra["molar_volume"] = 0.2; interstital->setSiteDensity(10.46344); interstital->addSpecies(sLii); interstital->addSpecies(sVac); interstital->initThermo(); interstital->setMoleFractionsByName("Li(i):0.01 V(i):0.99"); LatticeSolidPhase p; p.addLattice(base); p.addLattice(interstital); p.setLatticeStoichiometry(parseCompString("Li7Si3(S):1.0 Li7Si3_Interstitial:1.0")); p.initThermo(); p.setState_TP(725, 10 * OneAtm); // Regression test based on modified version of Li7Si3_ls.xml EXPECT_NEAR(p.enthalpy_mass(), -2077821.9295456698, 1e-6); double mu_ref[] = {-4.62717474e+08, -4.64248485e+07, 1.16370186e+05}; double vol_ref[] = {0.09557086, 0.2, 0.09557086}; vector_fp mu(p.nSpecies()); vector_fp vol(p.nSpecies()); p.getChemPotentials(mu.data()); p.getPartialMolarVolumes(vol.data()); for (size_t k = 0; k < p.nSpecies(); k++) { EXPECT_NEAR(mu[k], mu_ref[k], 1e-7*fabs(mu_ref[k])); EXPECT_NEAR(vol[k], vol_ref[k], 1e-7); } }