Conversation
… fix zero-bound crash in ts1 Latin hypercube sampling. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…JPL19 chemical-activation formula pending a new MICM reaction type. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1044 +/- ##
=======================================
Coverage 72.12% 72.12%
=======================================
Files 147 147
Lines 12178 12185 +7
=======================================
+ Hits 8783 8789 +6
- Misses 3395 3396 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Notebook 11 and notebook 19 still loaded the old ts1.json mechanism. The initial conditions CSV lists SURF.het7 and other parameters that exist only in t1s2.json, so the solver raised a ValueError for these parameters. This change updates both notebooks to load t1s2.json, matching the CSV and the Python example. This change also adds underscores to k_inf in the t1s2.json usr_CO_OH description. Codespell read the word kinf as a misspelling of kind. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks @K20shores for sending this over. A few general chemistry notes that stood out to me then specifically for CAM-SIMA.
musica/configs/v1/ts1/t1s2.json Lines 3985 to 4013 in 10d504b I think the !-----------------------------------------------------------------
! ... so3 + 2*h2o --> h2so4 + h2o
! Note: this reaction proceeds by the 2 intermediate steps below
! so3 + h2o --> adduct
! adduct + h2o --> h2so4 + h2o
! (Lovejoy et al., JCP, pp. 19911-19916, 1996)
! The first order rate constant used here is recommended by JPL 2011.
! This rate involves the water vapor number density.
!-----------------------------------------------------------------
if ( usr_SO3_H2O_ndx > 0 ) then
call comp_exp( exp_fac, 6540.0_r8*tinv(:), ncol )
if( h2o_ndx > 0 ) then
fc(:) = 8.5e-21_r8 * m(:,k) * h2ovmr(:,k) * exp_fac(:)
else
fc(:) = 8.5e-21_r8 * invariants(:,k,inv_h2o_ndx) * exp_fac(:)
end if
rxt(:,k,usr_SO3_H2O_ndx) = 1.0e-20_r8 * fc(:)
end ifwhere SO3 + H2O <-> SO3.H2O (adduct fast pre-equilibrium) the steady state observed rate is
Either a new MICM type has to be made or fall back to the pre-JPL19 two-term representation. Zero will really mess up the mechanism...
More notes on SIMA forthcoming... |
|
For CAM-SIMA implementation... Right now the config has one SURFACE reaction per gas, so there's only one pair of (radius, number). This is at odds with what we agreed on for #1030 where we can't collapse per-mode SAD into one aggregate, so if you're not modifying MICM internals, per-mode duplicates of the same reactions needs to be made to match CAM. Thinking more about the het.. reactions I realize that the het1-3 being deferred might be problematic, since N2O5 hydrolysis is a dominant pathway to produce HNO3 globally. I think het1-17 would be better wired up as !-----------------------------------------------------------------------
! ... ClONO2 + HCl(liq) = Cl2 + HNO3 Sulfate Aerosol Reaction
!-----------------------------------------------------------------------
if( hclvmr > small_div .and. clono2vmr > small_div ) then
if ( hclvmr > clono2vmr ) then
rxt(i,k,rid_het4) = max( 0._r8,wrk*av_clono2*gprob_cnt_hcl(i,k) )*hcldeni
else
rxt(i,k,rid_het4) = max( 0._r8,wrk*av_clono2*gprob_cnt_hcl(i,k) )*cntdeni
end if
end ifFor het13, 14 I see it's implemented now but my hunch is that MICM's rates may be too slow for ice PSCs. MICM's SURFACE formula is the full resistor but for CAM stratospheric het13, 14, it is the free-molecular construction with no gas-diffusion term. This differs from the trop rates in TS1 (e.g., usr_N2O5_aer...) |
Ah, looks like the coefficient was dropped. Not sure how that happened, but fixing that bug will correct this rate |
|
I don't think we need Claude for this. This conversion is done using avogadro's number and I'm pretty sure it's just a bug somewhere in mechanism configuration that shouldn't be too hard to find. |
or I'm misunderstanding what you're saying entirely |
Ah, I found it. Not a bug in musica, but the old chemistry cafe. It wrote out this reaction {
"type": "ARRHENIUS",
"A": 3.082625243326537e-05,
"B": 0.0,
"C": 6539.99676963515,
"D": 300.0,
"E": 0.0,
"reactants": [
{
"name": "H2O",
"coefficient": 2.0
},
{
"name": "SO3",
"coefficient": 1.0
}
],
"products": [
{
"name": "H2SO4",
"coefficient": 1.0
},
{
"name": "H2O",
"coefficient": 1.0
}
],
"gas phase": "gas"
}which seems correct, i think |
Ah, neat, since it gets to |
Our conversion tool reads what Chemistry Cafe outputs with our mechanism configuration library. It converts from the old camp format to the newer format that uses SI units everywhere. It applies those conversions automatically. Louisa creates this information in Chemistry Cafe. This is likely a case where it's correct in Chemistry Cafe for CAM and potentially incorrect for the other output targets of Chemistry Cafe (kpp, box mox, music box, something else) because the main target is CAM, so it relies on Fortran code being correct in CAM rather than relying entirely on data, as we do for the mechanism in musica. |
Closes #1041
I converted the music box configuration listed in the issue with the musica-cli. To do so successfully, I had to add three species to the species list.
Then, I worked with claude to add in the 'unsupported reactions' section of the configuration file from chemistry cafe. I added those if they could have real values, or with types that let us set their rate to zero so we can figure out how to handle them later. Below lists what each reaction is, how it's handled, and what we might need to do
Correctly implemented, I think:
Deferred for later, but still included
AI usage: Claude helped me correctly set the names of photolysis rates and to either implement the het/user define rates or add stubs