Skip to content

Commit

Permalink
Fix getCoverages for multi-site species
Browse files Browse the repository at this point in the history
  • Loading branch information
speth authored and ischoegl committed Aug 9, 2022
1 parent eedcbf9 commit 6e0028e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/thermo/SurfPhase.cpp
Expand Up @@ -250,9 +250,15 @@ void SurfPhase::setCoveragesNoNorm(const doublereal* theta)

void SurfPhase::getCoverages(doublereal* theta) const
{
getConcentrations(theta);
double sum_X = 0.0;
double sum_X_s = 0.0;
getMoleFractions(theta);
for (size_t k = 0; k < m_kk; k++) {
theta[k] *= size(k)/m_n0;
sum_X += theta[k];
sum_X_s += theta[k] * size(k);
}
for (size_t k = 0; k < m_kk; k++) {
theta[k] *= size(k) * sum_X / sum_X_s;
}
}

Expand Down
28 changes: 28 additions & 0 deletions test/data/surface-phases.yaml
Expand Up @@ -13,6 +13,18 @@ phases:
site-density: 2.7063e-9 mol/cm^2
state: {T: 900 K, P: 1 atm, coverages: {Pt(s): 0.5, H(s): 0.4, O(s): 0.1}}

- name: Pt-multi-sites
thermo: ideal-surface
adjacent-phases: [gas]
kinetics: surface
reactions: [Pt-reactions, Pt-multisite-reactions]
species: [{Pt-surf-species: all}, {multi-site-species: all}]
site-density: 2.7063e-9 mol/cm^2
state:
T: 900 K
P: 1 atm
coverages: {Pt(s): 0.35, H(s): 0.4, O(s): 0.1, O2(s): 0.15}

- name: TPB
thermo: edge
species: [{tpb-species: [(tpb)]}]
Expand Down Expand Up @@ -102,6 +114,19 @@ Pt-surf-species:
- [1.9454180E+00, 9.1761647E-04, -1.1226719E-07, -9.9099624E-11,
2.4307699E-14, -1.4005187E+04, -1.1531663E+01]

multi-site-species:
- name: O2(s)
composition: {O: 2, Pt: 2}
sites: 2
thermo:
model: NASA7
temperature-ranges: [300, 1000, 3000]
data:
- [-9.4986904E-01, 7.4042305E-03, -1.0451424E-06, -6.1120420E-09,
3.3787992E-12, -1.3209912E+04, 3.6137905E+00]
- [1.9454180E+00, 9.1761647E-04, -1.1226719E-07, -9.9099624E-11,
2.4307699E-14, -1.4005187E+04, -1.1531663E+01]


tpb-species:
- name: (tpb)
Expand All @@ -120,6 +145,9 @@ Pt-reactions:
- equation: H + Pt(s) => H(s)
sticking-coefficient: [1.0, 0.0, 0.0]

Pt-multisite-reactions:
- equation: 2 O(s) <=> O2(s)
rate-constant: {A: 3.1e9 cm^2/mol/s, b: 0.0, Ea: 0.0}

graphite-anode-species:
- name: EC(e)
Expand Down
26 changes: 26 additions & 0 deletions test/python/test_thermo.py
Expand Up @@ -1130,6 +1130,32 @@ def test_coverages_dict(self):
self.assertNear(C[self.interface.species_index('c6*M')], 0.75)


class TestInterfacePhase2(utilities.CanteraTest):
""" Test special cases of interface phases """
def test_multi_site_species(self):
surf = ct.Interface("surface-phases.yaml", "Pt-multi-sites")
# O2(s) consumes two surface sites
surf.coverages = {"Pt(s)": 0.5, "H(s)": 0.1, "O2(s)": 0.4}
X = surf.mole_fraction_dict()
moles = 0.5 + 0.1 + 0.4 / 2
assert np.isclose(X["Pt(s)"], 0.5 / moles)
assert np.isclose(X["H(s)"], 0.1 / moles)
assert np.isclose(X["O2(s)"], 0.2 / moles)

def test_multi_site_unnormalized(self):
surf = ct.Interface("surface-phases.yaml", "Pt-multi-sites")
theta = [0.5, 0.1, 0.1, 0.32]
surf.set_unnormalized_coverages(theta)
self.assertArrayNear(surf.coverages, theta)

X_unnormalized = surf.X
assert np.isclose(sum(theta), sum(surf.X))

surf.coverages = theta
X_normalized = surf.X
self.assertArrayNear(X_normalized * sum(theta), X_unnormalized)


class TestPlasmaPhase(utilities.CanteraTest):
def setUp(self):
self.phase = ct.Solution('oxygen-plasma.yaml',
Expand Down

0 comments on commit 6e0028e

Please sign in to comment.