Skip to content

Conversation

@rrsettgast
Copy link
Member

@rrsettgast rrsettgast commented Dec 17, 2025

  • remove non-log(c) option
  • create aliases for log/exp
  • use aliases everywhere in the code
  • correct derivatives wrt log by multiplying by ln(10) when using base10, and 1 when using base_e

REAL_TYPE const speciesConcentration_i = exp( logPrimarySpeciesConcentrations[i] );
REAL_TYPE const speciesConcentration_i = logmath::exp( logPrimarySpeciesConcentrations[i] );
aggregatePrimarySpeciesConcentrations[i] = speciesConcentration_i;
dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations( i, i ) = speciesConcentration_i;

Choose a reason for hiding this comment

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

Should it be?
dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations( i, i ) = logmath::dWrtLogConst() * speciesConcentration_i;

Copy link

@azibitsker azibitsker left a comment

Choose a reason for hiding this comment

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

I went went through the changes and based on my current understanding of the framework, I think there is only one type of correction that I see in the derivative of aggregate wrt to log(C^primary) that should have a ln(10) factor in front of C_i.

aggregatePrimarySpeciesConcentrations[i] = speciesConcentration_i;
mobileAggregatePrimarySpeciesConcentrations[i] = speciesConcentration_i;
dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations( i, i ) = speciesConcentration_i;
dMobileAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations( i, i ) = speciesConcentration_i;

Choose a reason for hiding this comment

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

Similarly, should it be?
dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations( i, i ) = logmath::dWrtLogConst() * speciesConcentration_i;
dMobileAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations( i, i ) = logmath::dWrtLogConst() * speciesConcentration_i;

@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (97a1fb1) to head (0f6cc11).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #19   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        26    +1     
  Lines          830       743   -87     
=========================================
- Hits           830       743   -87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@frankfeifan frankfeifan left a comment

Choose a reason for hiding this comment

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

There are a few places missing logmath::dWrtLogConst< RealType >() but multiplied back somewhere else, so the unit tests don't complain. I've left my comments in some places and will check all other places.

data.reactionRatesDerivatives( r, i ) = data.reactionRatesDerivatives( r, i ) * exp( -data.speciesConcentration[i] );
}

data.reactionRatesDerivatives( r, i ) = data.reactionRatesDerivatives( r, i ) * logmath::exp( -data.speciesConcentration[i] );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
data.reactionRatesDerivatives( r, i ) = data.reactionRatesDerivatives( r, i ) * logmath::exp( -data.speciesConcentration[i] );
data.reactionRatesDerivatives( r, i ) = data.reactionRatesDerivatives( r, i ) * logmath::exp( -data.speciesConcentration[i] ) / logmath::dWrtLogConst< double >();

for( IntType j = 0; j < numPrimarySpecies; ++j )
{
dReactionRates_dLogPrimarySpeciesConcentrations( i, j ) = reactionRatesDerivatives( i, j + numSecondarySpecies );
dReactionRates_dLogPrimarySpeciesConcentrations( i, j ) = logmath::dWrtLogConst< REAL_TYPE >() * reactionRatesDerivatives( i, j + numSecondarySpecies );
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is better to account for logmath::dWrtLogConst< REAL_TYPE >() when we calculate reactionRatesDerivatives in kineticReactions::computeReactionRates instead of here.

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.

4 participants