src/slr_component.cpp
//------------------------------------------------------------------------------
/*! \brief compute sea-level rise
 * from Vermeer and Rahmstorf (2009)
 * computes the first derivative of the global atmospheric temperature cure
 * uses first derivative to compute slr based on thermal expansion and ice melt
 */
\brief compute sea-level rise
from Vermeer and Rahmstorf (2009)
computes the first derivative of the global atmospheric temperature cure
uses first derivative to compute slr based on thermal expansion and ice melt
\ brief compute sea - level rise from Vermeer and Rahmstorf ( 2009 ) computes the first derivative of the global atmospheric temperature cure uses first derivative to compute slr based on thermal expansion and ice melt
void slrComponent::compute_slr( const double date ) {
    unitval T = tgav.get( date ) - refperiod_tgav;      
    double dTdt_double = 0.0;
    if( tgav.size() > 2 ) {
        for( int i=tgav.firstdate(); i<=tgav.lastdate(); i++ ) {
            tgav_vals.set( i, tgav.get( i ).value( U_DEGC ) );
        }
        tgav_vals.allowInterp( true );		
        dTdt_double = tgav_vals.get_deriv( date );
    }
    const double a	= 0.56;		
    const double b	= -4.9 ;	
    unitval T0;
    T0.set( -0.41, U_DEGC );
    unitval dHdt;
    dHdt.set( a * ( T-T0 ).value( U_DEGC ) + b * dTdt_double, U_CM_YR );		
	sl_rc.set( date, dHdt );
    unitval dH;
    dH.set( dHdt.value( U_CM_YR ), U_CM );          
    unitval slr_to_date;
    slr_to_date.set( 0.0, U_CM );
    if( slr.exists( date-1 ) ) {
        slr_to_date.set( slr.get( date-1 ).value( U_CM ), U_CM );
    }
    slr.set( date, slr_to_date + dH );
    unitval X = slr.get( date );
    H_LOG( logger, Logger::DEBUG ) << date << " T=" << T << " dTdt=" << dTdt_double << " dHdt=" << dHdt << " slr=" << X << std::endl ;
    const double a_no_ice	= 0.08;		
    const double b_no_ice	= 2.5;		
    unitval T0_no_ice;
    T0_no_ice.set (-0.375, U_DEGC );	
    unitval dHdt_no_ice;
    dHdt_no_ice.set( a_no_ice * ( T-T0_no_ice ).value( U_DEGC ) + b_no_ice * dTdt_double, U_CM_YR );		
    sl_rc_no_ice.set( date, dHdt_no_ice );
    unitval dH_no_ice;
    dH_no_ice.set( dHdt_no_ice.value( U_CM_YR ), U_CM );          
    unitval slr_no_ice_to_date;
    slr_no_ice_to_date.set( 0.0, U_CM );
    if( slr_no_ice.exists( date-1 ) ) {
        slr_no_ice_to_date = slr_no_ice.get( date-1 );
    }
    slr_no_ice.set( date, slr_no_ice_to_date + dH_no_ice );
    unitval Y = slr_no_ice.get( date );
    H_LOG( logger, Logger::DEBUG ) << date << " T=" << T << " Dtdt=" << dTdt_double << " DHdt_no_ice=" << dHdt_no_ice << " slr_no_ice=" << Y << std::endl ;
}
void slrComponent :: compute_slr ( const double date ) { unitval T = tgav . get ( date ) - refperiod_tgav ; double dTdt_double = 0.0 ; if ( tgav . size ( ) > 2 ) { for ( int i = tgav . firstdate ( ) ; i <= tgav . lastdate ( ) ; i ++ ) { tgav_vals . set ( i , tgav . get ( i ) . value ( U_DEGC ) ) ; } tgav_vals . allowInterp ( true ) ; dTdt_double = tgav_vals . get_deriv ( date ) ; } const double a = 0.56 ; const double b = -4.9 ; unitval T0 ; T0 . set ( -0.41 , U_DEGC ) ; unitval dHdt ; dHdt . set ( a * ( T - T0 ) . value ( U_DEGC ) + b * dTdt_double , U_CM_YR ) ; sl_rc . set ( date , dHdt ) ; unitval dH ; dH . set ( dHdt . value ( U_CM_YR ) , U_CM ) ; unitval slr_to_date ; slr_to_date . set ( 0.0 , U_CM ) ; if ( slr . exists ( date - 1 ) ) { slr_to_date . set ( slr . get ( date - 1 ) . value ( U_CM ) , U_CM ) ; } slr . set ( date , slr_to_date + dH ) ; unitval X = slr . get ( date ) ; H_LOG ( logger , Logger :: DEBUG ) << date << " " << T << " " << dTdt_double << " " << dHdt << " " << X << std :: endl ; const double a_no_ice = 0.08 ; const double b_no_ice = 2.5 ; unitval T0_no_ice ; T0_no_ice . set ( -0.375 , U_DEGC ) ; unitval dHdt_no_ice ; dHdt_no_ice . set ( a_no_ice * ( T - T0_no_ice ) . value ( U_DEGC ) + b_no_ice * dTdt_double , U_CM_YR ) ; sl_rc_no_ice . set ( date , dHdt_no_ice ) ; unitval dH_no_ice ; dH_no_ice . set ( dHdt_no_ice . value ( U_CM_YR ) , U_CM ) ; unitval slr_no_ice_to_date ; slr_no_ice_to_date . set ( 0.0 , U_CM ) ; if ( slr_no_ice . exists ( date - 1 ) ) { slr_no_ice_to_date = slr_no_ice . get ( date - 1 ) ; } slr_no_ice . set ( date , slr_no_ice_to_date + dH_no_ice ) ; unitval Y = slr_no_ice . get ( date ) ; H_LOG ( logger , Logger :: DEBUG ) << date << " " << T << " " << dTdt_double << " " << dHdt_no_ice << " " << Y << std :: endl ; }
\brief compute sea-level rise
 from Vermeer and Rahmstorf (2009)
 computes the first derivative of the global atmospheric temperature cure
 uses first derivative to compute slr based on thermal expansion and ice melt
\ brief compute sea - level rise from Vermeer and Rahmstorf ( 2009 ) computes the first derivative of the global atmospheric temperature cure uses first derivative to compute slr based on thermal expansion and ice melt
// temperature relative to 1951-1980 mean // First need to compute dTdt, the first derivative of the temperature curve // deriv needs a continuous function // These values and formula below are from: // Vermeer, M. and S. Rahmstorf (2009). "Global sea level linked to global temperature." PNAS 106(51): 21527-21532. // This incorporates both thermal expansion and ice melt // cm / year / K // cm / K // cm/yr // integrating to 1 year // These values incorporate only thermal expansion // cm / year / degree C // cm / degree C // K // cm/yr // integrating to 1 year