Skip to content

Add 1D Beer-Lambert photochemistry solver with Cantera integration - #10

Open
GalacticBobster with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-matrix-solver-instability
Open

Add 1D Beer-Lambert photochemistry solver with Cantera integration#10
GalacticBobster with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-matrix-solver-instability

Conversation

Copilot AI commented Nov 23, 2025

Copy link
Copy Markdown

Implements a one-dimensional photochemistry solver using Beer-Lambert law for actinic flux attenuation, leveraging Cantera's chemical kinetics framework.

Implementation

New directory: examples/BeerLambert1D/ (308 LOC solver + config + docs)

Core algorithm:

// Beer-Lambert attenuation: I(z) = I₀ * exp(-τ)
void computeActinicFlux() {
    for (int k = 0; k < nwavelengths_; k++) {
        double tau = 0.0;
        for (int j = nlevels_ - 1; j >= 0; j--) {
            actinic_flux_(j, k) = toa_flux_(k) * exp(-tau);
            tau += sigma(j, k) * num_density(j) * dz(j);
        }
    }
}

Features:

  • Vertical atmospheric grid with exponential pressure profile
  • Wavelength-dependent optical depth integration
  • Cantera ThermoPhase/Kinetics/Solution integration
  • Solar radiation input via existing C3M infrastructure
  • Test case: O₂ photolysis network (20 levels, 0-100 km)

Build:

  • Standalone CMake config (no modifications to existing build system)
  • Optional integration via TASK=BeerLambert
  • YAML configuration: beer_lambert_1d.yaml

Follows existing C3M patterns from src/actinic_flux.cpp and tests/1DPP.cpp.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Fixing instability in matrix solver</issue_title>
<issue_description>Make a one-dimensional solver for photochemistry using beer-lambert law and leverage the cantera structures to make a cpp file and also one yaml file to test it. Do not modify existing files please</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 23, 2025 21:10
Co-authored-by: GalacticBobster <85122891+GalacticBobster@users.noreply.github.com>
Co-authored-by: GalacticBobster <85122891+GalacticBobster@users.noreply.github.com>
Co-authored-by: GalacticBobster <85122891+GalacticBobster@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix instability in matrix solver for photochemistry Add 1D Beer-Lambert photochemistry solver with Cantera integration Nov 23, 2025
@GalacticBobster

Copy link
Copy Markdown
Owner

Extend it by writing an example to solve one dimensional photochemical equilibrium with parameterized eddy and binary diffusion and boundary conditions.

@GalacticBobster
GalacticBobster marked this pull request as ready for review November 24, 2025 05:26
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.

Fixing instability in matrix solver

2 participants