Skip to content

Introduce aerosol chemistry validation and parser support#282

Merged
boulderdaze merged 26 commits into
mainfrom
271-add-miam-parser
Jul 6, 2026
Merged

Introduce aerosol chemistry validation and parser support#282
boulderdaze merged 26 commits into
mainfrom
271-add-miam-parser

Conversation

@boulderdaze

@boulderdaze boulderdaze commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

This PR:

  • Adds aerosol representations and processes functions
  • Adds check schema, validation function for aerosol
  • Adds an integration test for the CAM cloud chemistry
  • Makes reactions an optional key, since an aerosol configuration does not always require reactions. See the code and comments for details.
  • Part of Add MIAM types to canonical Mechanism #271

Notes:

  • I noticed that the emissions PR creates its own directory, which I think is a good approach for keeping things clean and organized. I considered doing the same for the aerosol model, but decided against it. Gas-phase chemistry and aerosol processes can be used together within a single chemistry system, and their configurations are often closely related.
  • More unit tests will be added in a follow up PR.
  • I restructured the Validate function into ValidateGasModel and introduced a separate ValidateAerosolModel.
Errors ValidateGasModel(const Mechanism& mechanism);
Errors ValidateAerosolModel(const Mechanism& mechanism);

During aerosol validation, the relationship between phases and species(eg. condensed phase and species, gas phase and species, solvent, molecular weight, density ) cannot be expressed in the current semantics::Input because the required relationship information is lost during flattening. It does not preserve which species belongs to which phase.

The intermediate type that I tried to introduced AerosolProcessRef also loses the structure by dropping the association between a specific species and its phase context.

The current aerosol validation cannot preserve the error locations for the reasons above. This will be addressed in #284

@boulderdaze boulderdaze changed the title Add aerosol parser Add aerosol chemistry parser Jun 26, 2026
@codecov-commenter

codecov-commenter commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.11688% with 91 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.65%. Comparing base (a8c7c0d) to head (8f0fe4e).

Files with missing lines Patch % Lines
src/v1/aerosol_type_schema.cpp 76.43% 41 Missing ⚠️
src/v1/aerosol_type_parsers.cpp 85.00% 27 Missing ⚠️
src/v1/parser.cpp 70.00% 12 Missing ⚠️
src/validate.cpp 95.00% 6 Missing ⚠️
src/v1/utils.cpp 80.95% 4 Missing ⚠️
src/errors.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #282      +/-   ##
==========================================
- Coverage   88.96%   87.65%   -1.32%     
==========================================
  Files          39       41       +2     
  Lines        1949     2478     +529     
==========================================
+ Hits         1734     2172     +438     
- Misses        215      306      +91     
Files with missing lines Coverage Δ
include/mechanism_configuration/errors.hpp 57.14% <ø> (ø)
include/mechanism_configuration/mechanism.hpp 100.00% <ø> (ø)
src/v1/type_parsers.cpp 85.88% <100.00%> (+0.34%) ⬆️
src/v1/type_schema.cpp 83.09% <100.00%> (ø)
src/errors.cpp 34.21% <0.00%> (-0.93%) ⬇️
src/v1/utils.cpp 92.72% <80.95%> (-7.28%) ⬇️
src/validate.cpp 91.45% <95.00%> (+2.11%) ⬆️
src/v1/parser.cpp 84.22% <70.00%> (-2.82%) ⬇️
src/v1/aerosol_type_parsers.cpp 85.00% <85.00%> (ø)
src/v1/aerosol_type_schema.cpp 76.43% <76.43%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@boulderdaze boulderdaze self-assigned this Jun 26, 2026
@boulderdaze boulderdaze added this to the Cloud Chemistry milestone Jun 26, 2026
@boulderdaze boulderdaze requested a review from K20shores June 26, 2026 04:45
@boulderdaze boulderdaze marked this pull request as ready for review June 26, 2026 04:45

@K20shores K20shores left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to divorce the validation and parsing so that in-code mechanism can be validated. That means we need to update Validate to include aerosol validation

Comment thread src/detail/v1/aerosol_type_parsers.hpp Outdated
Comment thread src/v1/aerosol_type_schema.cpp
Comment thread src/v1/aerosol_type_schema.cpp Outdated
Comment thread src/v1/parser.cpp Outdated
@boulderdaze boulderdaze requested a review from K20shores June 27, 2026 02:25
@boulderdaze boulderdaze changed the title Add aerosol chemistry parser Introduce aerosol chemistry validation and parser support Jun 27, 2026

@K20shores K20shores left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments, but nothing that should hold up a merge. There's only one comment that wouldn't be addressed by a future issue anyway. If you like the way things look now, I'm happy to accept it

Comment thread include/mechanism_configuration/types.hpp
Comment thread include/mechanism_configuration/validate.hpp
Comment thread src/v1/aerosol_type_schema.cpp
Comment thread src/v1/aerosol_type_schema.cpp
Comment thread src/v1/parser.cpp
Comment on lines +383 to +384
// Uses the same ValidateSemantics engine as ValidateGasModel, but with
// YAML-derived input so errors include source locations.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValidateGasModel also includes line information because we have the semantic reference inputs, which I feel we should also add for aerosols

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gas model can store them in a flat array without relationship information unlike aerosol.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow what you mean here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its the discussion we had previously. Aerosol validation requires relationship information to determine which species/solvent belong to which phases, and so on, in order to perform the validation checks.
Gas-phase model can find this information in a flat array, which is implemented in semantic structs to locate where the errors are.

Comment thread src/v1/parser.cpp
@boulderdaze

Copy link
Copy Markdown
Contributor Author

Hi @smeechncar, @vweeks,
I pulled the emissions PR that has been recently merged and while working on resolving the conflicts, I noticed a few areas where for emissions implementation could be improved. Some of these are related to the changes by this aerosol PR. I'd appreciate your thoughts on whether these changes make sense.

@boulderdaze boulderdaze merged commit c669ff8 into main Jul 6, 2026
27 of 28 checks passed
@boulderdaze boulderdaze deleted the 271-add-miam-parser branch July 6, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants