Exemplo n.º 1
0
def test_V_at_I_implicit():

    # Implicit computation checks out when chaining with inverse function.
    I_A = np.array(0.1)
    I_ph_A = 0.125
    I_rs_A = 9.24e-7
    n = 1.5
    R_s_Ohm = 0.5625
    G_p_S = 0.001
    N_s = 1
    T_degC = T_degC_stc
    V_V_type_expected = np.float64
    I_A_expected = I_A

    V_V = equation.V_at_I(I_A=I_A,
                          N_s=N_s,
                          T_degC=T_degC,
                          I_ph_A=I_ph_A,
                          I_rs_A=I_rs_A,
                          n=n,
                          R_s_Ohm=R_s_Ohm,
                          G_p_S=G_p_S)['V_V']
    assert isinstance(V_V, V_V_type_expected)
    assert V_V.dtype == I_A.dtype

    I_A_inv_comp = equation.I_at_V(V_V=V_V,
                                   N_s=N_s,
                                   T_degC=T_degC,
                                   I_ph_A=I_ph_A,
                                   I_rs_A=I_rs_A,
                                   n=n,
                                   R_s_Ohm=R_s_Ohm,
                                   G_p_S=G_p_S)['I_A']

    np.testing.assert_array_almost_equal(I_A_inv_comp, I_A_expected)
Exemplo n.º 2
0
def test_I_at_V_explicit():

    # Can handle zero series resistance.
    V_V = 0.35
    I_ph_A = 0.125
    I_rs_A = 9.24e-7
    n = 1.5
    R_s_Ohm = 0.
    G_p_S = 0.001
    N_s = 1
    T_degC = T_degC_stc
    I_A_expected = I_ph_A - I_rs_A * np.expm1(
        q_C * V_V / (N_s * n * k_B_J_per_K * T_K_stc)) - G_p_S * V_V

    I_A = equation.I_at_V(V_V=V_V,
                          N_s=N_s,
                          T_degC=T_degC,
                          I_ph_A=I_ph_A,
                          I_rs_A=I_rs_A,
                          n=n,
                          R_s_Ohm=R_s_Ohm,
                          G_p_S=G_p_S)['I_A']
    assert isinstance(I_A, type(I_A_expected))
    assert I_A.dtype == I_A_expected.dtype
    np.testing.assert_array_almost_equal(I_A, I_A_expected)
Exemplo n.º 3
0
def I_at_V_F_T(*,
               V_V,
               F,
               T_degC,
               N_s,
               T_degC_0,
               I_sc_A_0,
               I_rs_A_0,
               n_0,
               R_s_Ohm_0,
               G_p_S_0,
               E_g_eV_0,
               newton_tol=newton_tol_default,
               newton_maxiter=newton_maxiter_default):
    """
    Compute terminal current at given terminal voltage, effective irradiance ratio, and effective diode-junction
    temperature.

    Inputs (any broadcast-compatible combination of python/numpy scalars and numpy arrays):
        Same as current_sum_at_diode_node(), but with removal of I_A and addition of:
            newton_tol (optional) tolerance for Newton solver
            newton_maxiter (optional) maximum number of iterations for Newton solver

    Outputs (device-level, at each combination of broadcast inputs, return type is np.float64 when all scalar inputs):
        dict containing the outputs of current_sum_at_diode_node() with the addition of:
            I_A terminal current
    """

    params = auxiliary_equations(F=F,
                                 T_degC=T_degC,
                                 N_s=N_s,
                                 T_degC_0=T_degC_0,
                                 I_sc_A_0=I_sc_A_0,
                                 I_rs_A_0=I_rs_A_0,
                                 n_0=n_0,
                                 R_s_Ohm_0=R_s_Ohm_0,
                                 G_p_S_0=G_p_S_0,
                                 E_g_eV_0=E_g_eV_0)

    return equation.I_at_V(V_V=V_V,
                           **params,
                           newton_tol=newton_tol,
                           newton_maxiter=newton_maxiter)
Exemplo n.º 4
0
I_mp_A = result['I_mp_A']
V_mp_V = result['V_mp_V']
V_oc_V = result['V_oc_V']

# Now we compute two additional points on the I-V curve that are normally
# provided by the Sandia Array Performance Model (SAPM). See
# https://pvpmc.sandia.gov/modeling-steps/2-dc-module-iv/point-value-models/sandia-pv-array-performance-model/
# Compute the voltages.
V_x_V = V_oc_V / 2
V_xx_V = (V_mp_V + V_oc_V) / 2

# Demonstrate a vectorized computation of currents from voltages.
V_V = numpy.array([V_x_V, V_xx_V])
# The API consistently returns a result dictionary, so that one must
# specifically choose the currents.
result = sde.I_at_V(V_V=V_V, **model_params_fit)
# There are extra computed results included that are occassionally useful.
print(f"result = {result}")
# Get the currents (a numpy array).
I_A = result['I_A']

# Unpack the computed currents.
I_x_A, I_xx_A = I_A[0], I_A[1]

# Now make a nice plot.
V_V = numpy.linspace(0., V_oc_V, num=100)
# Note the "shortcut" to getting only the currents from the result dictionary.
I_A = sde.I_at_V(V_V=V_V, **model_params_fit)['I_A']
fig, ax1 = plt.subplots(figsize=(8, 6))
ax1.plot(V_V_data, I_A_data, '.', label="I-V data <-")
ax1.plot(V_V, I_A, label="fit to data <-")