Replies: 1 comment
-
|
Following today’s discussion, I’ve added a list of items we can consider to continue planning the configuration.
std::expected<Mechanism, Errors> validate(Mechanism); // by value
MIAM (Aerosol)
# Current
Henry's law constant:
HLC_ref [mol m-3 Pa-1]: 1.0e-5
C [K]: 2500.0
# Suggestion
Henry's law constant:
constant [mol m-3 Pa-1]: 1.0e-5
reference temperature [K]: 298.15
enthalpy [J mol-1]: 1000.0 (<- not yet divided by gas constant)
( or van't Hoff coefficient) [K]: 2500.0)MIEM (Emissions)
# Current
products:
- species name: Foo
coefficient: 1
# Suggestion
products:
- name: Foo
coefficient: 1
emissions:
data root: /path/to/emissions. <----- path
inventories:
my_anthro_inventory:
directory: cams/v6.2. <----- also path
file pattern: CAMS-GLOB-ANT_v6.2_{YYYY}-{MM}.nc
convention: eccad
species maps:
my_mechanism: <-- This name doesn't seem standardized. Is this needed?
This species map seems unnecessarily deeply nested
sources:
my_anthro_inventory: <-- This name doesn't seem standardized (name keyword could be used)
- inventory: FOO_EMIS.
mechanism: Foo
- inventory: BAR_EMIS
mechanism: Bar
sources:
- name: foo anthropogenic. <-- Ok, this is the same as `reactions.inventory name` defined in reactions.
but there is `inventory` keyword below, which is confusing.
mode: offline
type: anthropogenic
inventory: my_anthro_inventory. <-- here
species map: my_mechanism
temporal interpolation: linear
vertical injection: surface
scaling factor: 1.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
MechanismConfiguration: Versioning and API Redesign
Addressed #266
Proposing a stabilized public API (
parse/validate/writereturningstd::expected), an incremental tool integration roadmap (MIAM → MIEM → TUV-x), and a path to v2. Looking for feedback before opening implementation issues.Summary
Versioning strategy — each version parser translates directly to the
canonical
Mechanismtype. No chained migrations. Adding a new versionnever touches old translators.
Public API — replace
UniversalParser/ParserResultwith freefunctions
parse()andvalidate()returningstd::expected<Mechanism, Errors>.validate()takes by value soparse().map(...).map_error(...)chains withzero copies.
write(m, path)exports to YAML or JSON detected from suffix.Incremental roadmap — v1.x minor bumps add tools one at a time:
emissions:section,inventory name:on reactions)photolysis_calculator:path)mechanism:wrapper, field renames, flat namespaceEmissions linkage —
EMISSIONreactions carryinventory name:whichmatches a source in the
emissions:section by name. One source can feedmultiple reactions; the species map handles per-species routing; the
reaction's
scaling factor:adds per-reaction scaling on top.Development parser — repurposed. The
free functions
parse()andvalidate()are wired onto it directly. v1types remain the public return type (so
species_namestays; no break forcurrent callers); the
species_name→namerename is deferred to v2 withthe rest of the field renames.
01 — v1 Today
Gas-phase chemistry. Photolysis reactions describe stoichiometry; the rate is
provided externally by the host model. No photolysis calculator integration yet.
mechanism.yaml:02 — v1 Stabilized API
Same v1.0.0 chemistry, demonstrating the proposed stabilized public API.
From a config file:
Built from structs:
03 — v1.1: MIAM (aerosol + phase transfer)
Adds
aerosol representations:andaerosol processes:sections.New fields on
Mechanism:aerosol_representations,processes.henry_law_phase_transfer.04 — v1.2: MIEM (emissions inventory)
Adds
emissions:section.EMISSIONreactions gaininventory name:linking to a named source. Multiple reactions can share one source; per-reactionscaling factor:applies on top.Parser validates at load time: every
inventory name:has a matching source; every source species map entry references a species in the mechanism.05 — v1.3: TUV-x (photolysis calculator)
Adds a
photolysis_calculator:section — just a path to a TUV-x config file. The name-mapping between TUV-x cross-sections and mechanism photolysis reactions lives inside that config.New field on
Mechanism:std::optional<PhotolysisCalculator> photolysis_calculator.06 — v2 Aspirational
End-state:
mechanism:wrapper, flatmechanism_configuration::namespace,processes:key,transforms:co-located on photolysis reactions.07 — Versioning Design
Each version parser translates directly to the canonical
Mechanismtype — no migration chain.name = "",gas_phase = "GAS"; convertPhase.speciesfromvector<string>tovector<PhaseSpecies>mechanism:; renameprocesses:→ reactions structThe v1 → v2 config migration is handled offline by
mechanism-config migrate, not at runtime.08 — Implementation Plan
Suggested issues (each independently mergeable):
parse()+std::expected— replaceUniversalParserwith free function built ondevelopment::Parser;ConfigParseStatus→ErrorCode; v1 types remain the public return typevalidate(Mechanism)—validate.hppwrappingdevelopment::Parser::Validate(); checks species/phase refs; enables in-code construction patternSingleMomentMode,TwoMomentMode,HenryLawPhaseTransfer, etc. inv1/types.hppaerosol representations:andaerosol processes:; validate mode phases and speciesinventory_nameonEmission— parseinventory name:YAML key; empty string if absentEmissionsConfigstruct; validate everyinventory name:has a matching sourcephotolysis_calculator:parser —std::optional<PhotolysisCalculator>onMechanism; parse singleconfig:pathwrite()—exporter.hpp; format from suffix; AC: round-trip parse → write → parse produces equalMechanismmechanism-config migrateCLI —mechanism:wrapper, flat namespace,species_name→nameand other renames;developmentbecomes the v2 parserBeta Was this translation helpful? Give feedback.
All reactions