src/oceanbox.cpp
//------------------------------------------------------------------------------
/*! \brief              Function that chem_equilibrate tries to minimize
 *  \param[in] alk      alkalinity value to try
 *  \param[in] *params  pointer to other parameters (just f_target currently)
 *  \returns            double, difference between flux and target flux
 *
 *  The gsl minimization algorithm calls this function, which slots alk
 *  into the csys chemistry input, runs csys, and reports back the difference
 *  between csys's computed ocean-atmosphere flux and the target flux.
 */
\brief              Function that chem_equilibrate tries to minimize
\param[in] alk      alkalinity value to try
\param[in] *params  pointer to other parameters (just f_target currently)
\returns            double, difference between flux and target flux

The gsl minimization algorithm calls this function, which slots alk
into the csys chemistry input, runs csys, and reports back the difference
between csys's computed ocean-atmosphere flux and the target flux.
\ brief Function that chem_equilibrate tries to minimize \ param [ in ] alk alkalinity value to try \ param [ in ] * params pointer to other parameters ( just f_target currently ) \ returns double difference between flux and target flux The gsl minimization algorithm calls this function which slots alk into the csys chemistry input runs csys and reports back the difference between csys ' s computed ocean - atmosphere flux and the target flux .
double oceanbox::fmin( double alk, void *params ) {
	mychemistry.set_alk( alk );
	mychemistry.ocean_csys_run( Tbox, carbon );
	double f_target = *( double * )params;
	double diff = fabs( mychemistry.calc_annual_surface_flux( Ca ).value( U_PGC_YR ) - f_target );
	return diff;
}
double oceanbox :: fmin ( double alk , void * params ) { mychemistry . set_alk ( alk ) ; mychemistry . ocean_csys_run ( Tbox , carbon ) ; double f_target = * ( double * ) params ; double diff = fabs ( mychemistry . calc_annual_surface_flux ( Ca ) . value ( U_PGC_YR ) - f_target ) ; return diff ; }
\brief              Function that chem_equilibrate tries to minimize
  \param[in] alk      alkalinity value to try
  \param[in] *params  pointer to other parameters (just f_target currently)
  \returns            double, difference between flux and target flux
\ brief Function that chem_equilibrate tries to minimize \ param [ in ] alk alkalinity value to try \ param [ in ] * params pointer to other parameters ( just f_target currently ) \ returns double difference between flux and target flux
// Call the chemistry model with new value for alk //    OB_LOG( logger, Logger::DEBUG) << "fmin at " << alk << ", f_target=" << f_target << ", returning " << diff << endl;