ssc/common.cpp
//adjustment factors changed from derates to percentages jmf 1/9/15
adjustment factors changed from derates to percentages jmf 1/9/15
adjustment factors changed from derates to percentages jmf 1 / 9 / 15
bool adjustment_factors::setup(int nsteps) 
{
	ssc_number_t f = m_cm->as_number( m_prefix + ":constant" );
	f = 1.0 - f / 100.0; 
	m_factors.resize( nsteps, f );
	if ( m_cm->is_assigned(m_prefix + ":hourly") )
	{
		size_t n;
		ssc_number_t *p = m_cm->as_array( m_prefix + ":hourly", &n );
		if ( p != 0 && n == (size_t)nsteps )
		{
			for( int i=0;i<nsteps;i++ )
				m_factors[i] *= (1.0 - p[i]/100.0); 
		}
	}
	if ( m_cm->is_assigned(m_prefix + ":periods") )
	{
		size_t nr, nc;
		ssc_number_t *mat = m_cm->as_matrix(m_prefix + ":periods", &nr, &nc);
		if ( mat != 0 && nc == 3 )
		{
			for( size_t r=0;r<nr;r++ )
			{
				int start = (int) mat[ nc*r ];
				int end = (int) mat[ nc*r + 1 ];
				ssc_number_t factor =  mat[ nc*r + 2 ];
				if ( start < 0 || start >= nsteps || end < start )
				{
					m_error = util::format( "period %d is invalid ( start: %d, end %d )", (int)r, start, end );
					continue;
				}
				if ( end >= nsteps ) end = nsteps-1;
				for( int i=start;i<=end;i++ )
					m_factors[i] *= (1.0 - factor/100.0); 
			}
		}
	}
	return m_error.length() == 0;
}
bool adjustment_factors :: setup ( int nsteps ) { ssc_number_t f = m_cm -> as_number ( m_prefix + " " ) ; f = 1.0 - f / 100.0 ; m_factors . resize ( nsteps , f ) ; if ( m_cm -> is_assigned ( m_prefix + " " ) ) { size_t n ; ssc_number_t * p = m_cm -> as_array ( m_prefix + " " , & n ) ; if ( p != 0 && n == ( size_t ) nsteps ) { for ( int i = 0 ; i < nsteps ; i ++ ) m_factors [ i ] *= ( 1.0 - p [ i ] / 100.0 ) ; } } if ( m_cm -> is_assigned ( m_prefix + " " ) ) { size_t nr , nc ; ssc_number_t * mat = m_cm -> as_matrix ( m_prefix + " " , & nr , & nc ) ; if ( mat != 0 && nc == 3 ) { for ( size_t r = 0 ; r < nr ; r ++ ) { int start = ( int ) mat [ nc * r ] ; int end = ( int ) mat [ nc * r + 1 ] ; ssc_number_t factor = mat [ nc * r + 2 ] ; if ( start < 0 || start >= nsteps || end < start ) { m_error = util :: format ( " " , ( int ) r , start , end ) ; continue ; } if ( end >= nsteps ) end = nsteps - 1 ; for ( int i = start ; i <= end ; i ++ ) m_factors [ i ] *= ( 1.0 - factor / 100.0 ) ; } } } return m_error . length ( ) == 0 ; }
adjustment factors changed from derates to percentages jmf 1/9/15
adjustment factors changed from derates to percentages jmf 1 / 9 / 15
//nsteps is set to 8760 in this declaration function in common.h //convert from percentage to factor //convert from percentages to factors //convert from percentages to factors