@@ -172,42 +172,17 @@ void calculateAggregatePrimaryConcentrationsWrtLogC( PARAMS_DATA const & params,
172172 ARRAY_2D & dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations )
173173{
174174 constexpr int numSecondarySpecies = PARAMS_DATA::numSecondarySpecies ();
175- constexpr int numPrimarySpecies = PARAMS_DATA::numPrimarySpecies ();
176175
177176 REAL_TYPE logSecondarySpeciesConcentrations[numSecondarySpecies] = {0 };
178177
179- for ( INDEX_TYPE i = 0 ; i < numPrimarySpecies; ++i )
180- {
181- for ( INDEX_TYPE j = 0 ; j < numPrimarySpecies; ++j )
182- {
183- dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations[i][j] = 0.0 ;
184- }
185- }
186-
187- calculateLogSecondarySpeciesConcentration< REAL_TYPE,
188- INT_TYPE,
189- INDEX_TYPE >( params,
190- logPrimarySpeciesConcentrations,
191- logSecondarySpeciesConcentrations );
178+ calculateAggregatePrimaryConcentrationsWrtLogC< REAL_TYPE,
179+ INT_TYPE,
180+ INDEX_TYPE>( params,
181+ logPrimarySpeciesConcentrations,
182+ logSecondarySpeciesConcentrations,
183+ aggregatePrimarySpeciesConcentrations,
184+ dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations );
192185
193- for ( int i = 0 ; i < numPrimarySpecies; ++i )
194- {
195- REAL_TYPE const speciesConcentration_i = exp ( logPrimarySpeciesConcentrations[i] );
196- aggregatePrimarySpeciesConcentrations[i] = speciesConcentration_i;
197- dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations ( i, i ) = speciesConcentration_i;
198- for ( int j = 0 ; j < numSecondarySpecies; ++j )
199- {
200- REAL_TYPE const secondarySpeciesConcentrations_j = exp ( logSecondarySpeciesConcentrations[j] );
201- aggregatePrimarySpeciesConcentrations[i] += params.stoichiometricMatrix ( j, i+numSecondarySpecies ) * secondarySpeciesConcentrations_j;
202- for ( int k=0 ; k<numPrimarySpecies; ++k )
203- {
204- REAL_TYPE const dSecondarySpeciesConcentrations_dLogPrimarySpeciesConcentration = params.stoichiometricMatrix ( j, k+numSecondarySpecies ) * secondarySpeciesConcentrations_j;
205- dAggregatePrimarySpeciesConcentrationsDerivatives_dLogPrimarySpeciesConcentrations ( i, k ) += params.stoichiometricMatrix ( j,
206- i+numSecondarySpecies ) *
207- dSecondarySpeciesConcentrations_dLogPrimarySpeciesConcentration;
208- }
209- }
210- }
211186}
212187
213188template < typename REAL_TYPE,
0 commit comments