Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/v0/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ namespace mechanism_configuration::v0
{
types::PhaseSpecies phase_species;
phase_species.name = species.name;
// Carry the species-level diffusion coefficient onto the phase species so it survives
// into MICM, which reads the coefficient from the phase species (e.g. for surface
// reactions) rather than from the species definition.
phase_species.diffusion_coefficient = species.diffusion_coefficient;
gas_phase.species.push_back(phase_species);
}
mechanism.phases.push_back(gas_phase);
Expand Down
20 changes: 20 additions & 0 deletions test/unit/v0/test_species_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,25 @@ TEST(SpeciesConfig, ValidSpeciesConfig)
EXPECT_FALSE(species_vector[3].diffusion_coefficient.has_value());
EXPECT_FALSE(species_vector[3].absolute_tolerance.has_value());
}

// In v0 all species are placed in the gas phase. The species-level diffusion
// coefficient must be carried onto the phase species, since MICM reads the
// coefficient from the phase species (e.g. for surface reactions).
ASSERT_EQ(mechanism.phases.size(), 1);
auto& gas_phase = mechanism.phases[0];
EXPECT_EQ(gas_phase.name, "gas");
ASSERT_EQ(gas_phase.species.size(), 4);

EXPECT_EQ(gas_phase.species[0].name, "foo");
EXPECT_EQ(gas_phase.species[0].diffusion_coefficient, 2.3e-4);

EXPECT_EQ(gas_phase.species[1].name, "bar");
EXPECT_EQ(gas_phase.species[1].diffusion_coefficient, 0.4e-5);

EXPECT_EQ(gas_phase.species[2].name, "baz");
EXPECT_FALSE(gas_phase.species[2].diffusion_coefficient.has_value());

EXPECT_EQ(gas_phase.species[3].name, "quz");
EXPECT_FALSE(gas_phase.species[3].diffusion_coefficient.has_value());
}
}
Loading