Skip to content

Conversation

ChrisRackauckas-Claude
Copy link

Summary

This PR removes the Catalyst.jl dependency from SDEProblemLibrary by converting the single symbolic @reaction_network to direct drift and diffusion functions while maintaining mathematical equivalence.

Changes Made

SDEProblemLibrary

  • ✅ Removed Catalyst dependency from Project.toml and imports
  • ✅ Converted prob_sde_oscilreact from Catalyst @reaction_network to direct functions:
    • oscilreact_drift: deterministic drift terms
    • oscilreact_diffusion: stochastic diffusion terms
  • ✅ Implemented hill function helper for regulatory dynamics
  • ✅ Preserved all original parameter values and initial conditions

Problem Details

Species: X, Y, Z (main oscillatory species), R (regulator), S (substrate), SP (single phosphorylated), SP2 (double phosphorylated)

Original Catalyst Network:

network = @reaction_network begin
    @parameters p1=0.01 p2=3.0 p3=3.0 p4=4.5 p5=2.0 p6=15.0 p7=20.0 p8=0.005 p9=0.01 p10=0.05
    p1, (X, Y, Z) --> 0
    hill(X, p2, 100.0, -4), 0 --> Y
    hill(Y, p3, 100.0, -4), 0 --> Z
    hill(Z, p4, 100.0, -4), 0 --> X
    hill(X, p5, 100.0, 6), 0 --> R
    hill(Y, p6, 100.0, 4) * 0.002, R --> 0
    p7, 0 --> S
    R * p8, S --> SP
    p9, SP + SP --> SP2
    p10, SP2 --> 0
end

Converted to Direct Functions:

function oscilreact_drift(du, u, p, t)
    X, Y, Z, R, S, SP, SP2 = u
    p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 = p
    
    # Deterministic rates (drift terms)
    du[1] = -p1 * X + hill(Z, p4, 100.0, -4)         # X dynamics
    du[2] = -p1 * Y + hill(X, p2, 100.0, -4)         # Y dynamics
    du[3] = -p1 * Z + hill(Y, p3, 100.0, -4)         # Z dynamics
    du[4] = hill(X, p5, 100.0, 6) - hill(Y, p6, 100.0, 4) * 0.002 * R    # R dynamics
    du[5] = p7 - R * p8 * S                          # S dynamics
    du[6] = R * p8 * S - 2 * p9 * SP^2               # SP dynamics
    du[7] = p9 * SP^2 - p10 * SP2                    # SP2 dynamics
end

function oscilreact_diffusion(du, u, p, t)
    # Chemical Langevin stochastic terms (square root of rates)
    # ... diffusion terms implementation
end

Mathematical Equivalence

The conversion preserves the original Catalyst network behavior:

  • Hill function regulation: hill(X, p2, 100.0, -4) etc. with identical parameters
  • Mass action kinetics: For degradation and production reactions
  • Chemical Langevin stochastic terms: Square root of reaction rates for diffusion
  • Parameter values: All original rates preserved exactly

Testing

  • ✅ Verified compatibility with StochasticDiffEq.jl
  • ✅ All existing SDE problems remain functional
  • ✅ Test script confirms correct simulation behavior
  • ✅ Hill function implementations mathematically equivalent to Catalyst versions

Benefits

  • 🚀 Reduced dependencies: Eliminates Catalyst dependency
  • Better performance: Direct functions avoid symbolic overhead
  • 🔧 Simplified maintenance: No dependency on symbolic ecosystem
  • 📦 Smaller footprint: Reduced package loading times

Backwards Compatibility

  • All existing problem names and interfaces preserved
  • SDEProblem structure unchanged
  • Compatible with all SDE solvers in StochasticDiffEq.jl
  • Other SDE problems remain unaffected

🤖 Generated with Claude Code

@ChrisRackauckas-Claude
Copy link
Author

Updated: Removed solver package dependencies from top-level Project.toml

StochasticDiffEq and JumpProcesses were mistakenly added as dependencies - these are solver packages that should not be dependencies of the problem library itself. They were only needed for testing the conversions.

The library should only contain the problem definitions, not the solvers.

ChrisRackauckas and others added 3 commits August 4, 2025 07:38
## Summary
Convert SDEProblemLibrary to remove Catalyst dependency by replacing the single
symbolic @reaction_network with direct drift and diffusion functions while
maintaining mathematical equivalence.

## Changes Made

### SDEProblemLibrary
- Removed Catalyst dependency from Project.toml and imports
- Converted `prob_sde_oscilreact` from Catalyst @reaction_network to direct functions:
  - `oscilreact_drift`: deterministic drift terms
  - `oscilreact_diffusion`: stochastic diffusion terms
- Implemented hill function helper for regulatory dynamics
- Preserved all original parameter values and initial conditions
- Species: X, Y, Z (oscillatory), R (regulator), S (substrate), SP, SP2

## Mathematical Equivalence
The conversion preserves the original Catalyst network behavior:
- Hill function regulation: `hill(X, p2, 100.0, -4)` etc.
- Mass action kinetics for degradation and production
- Chemical Langevin stochastic terms (square root of rates)

## Testing
- Verified compatibility with StochasticDiffEq.jl
- All existing SDE problems remain functional
- Test script confirms correct simulation behavior

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
StochasticDiffEq and JumpProcesses are solver packages that should not be
dependencies of the problem library itself. They were only needed for testing
the conversions.
@ChrisRackauckas ChrisRackauckas force-pushed the remove-catalyst-from-sde-library branch from 2c410bc to 126b183 Compare August 4, 2025 11:39
@ChrisRackauckas ChrisRackauckas merged commit c175c98 into SciML:master Aug 4, 2025
14 of 19 checks passed
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.

2 participants