Esempio n. 1
0
def test_fit_desoto_sandia(cec_params_cansol_cs5p_220p):
    # this test computes a set of IV curves for the input fixture, fits
    # the De Soto model to the calculated IV curves, and compares the fitted
    # parameters to the starting values
    params = cec_params_cansol_cs5p_220p['params']
    params.pop('Adjust')
    specs = cec_params_cansol_cs5p_220p['specs']
    effective_irradiance = np.array([400., 500., 600., 700., 800., 900.,
                                     1000.])
    temp_cell = np.array([15., 25., 35., 45.])
    ee = np.tile(effective_irradiance, len(temp_cell))
    tc = np.repeat(temp_cell, len(effective_irradiance))
    iph, io, rs, rsh, nnsvth = pvsystem.calcparams_desoto(
        ee, tc, alpha_sc=specs['alpha_sc'], **params)
    sim_ivcurves = pvsystem.singlediode(iph, io, rs, rsh, nnsvth, 300)
    sim_ivcurves['ee'] = ee
    sim_ivcurves['tc'] = tc

    result = sdm.fit_desoto_sandia(sim_ivcurves, specs)
    modeled = pd.Series(index=params.keys(), data=np.nan)
    modeled['a_ref'] = result['a_ref']
    modeled['I_L_ref'] = result['I_L_ref']
    modeled['I_o_ref'] = result['I_o_ref']
    modeled['R_s'] = result['R_s']
    modeled['R_sh_ref'] = result['R_sh_ref']
    expected = pd.Series(params)
    assert np.allclose(modeled[params.keys()].values,
                       expected[params.keys()].values, rtol=5e-2)
Esempio n. 2
0
for k in range(len(df)):
    # for k in range(1):
    current = np.array(df.iloc[k, 1:]).astype('float')

    is_current_finite = np.isfinite(current)

    if np.sum(is_current_finite) > 10 and np.nanmax(current) > 0.1:
        power = current * voltage
        power[np.logical_not(is_current_finite)] = 0
        mpp_idx = np.argmax(power)
        #         print(mpp_idx)
        ivcurves['timestamp'].append(df.loc[k, 'timestamps'])
        ivcurves['i_mp'].append(current[mpp_idx])
        ivcurves['v_mp'].append(voltage[mpp_idx])
        ivcurves['i_sc'].append(current[0])

        ivcurves['v_oc'].append(np.max(voltage[is_current_finite]))
        ivcurves['i'].append(current[is_current_finite])
        ivcurves['v'].append(voltage[is_current_finite])
        ivcurves['tm'].append(tm[k])
        ivcurves['tc'].append(tc[k])
        ivcurves['ee'].append(poa[k])
        ivcurves['idx'].append(poa[k])
        n = n + 1

for key in ['tc', 'ee', 'i_sc', 'v_oc', 'i_mp', 'v_mp']:
    ivcurves[key] = np.array(ivcurves[key])

desoto = fit_desoto_sandia(ivcurves, specs)

print(desoto.keys())