Skip to content

Commit 9f30788

Browse files
Test both exceptional cases
1 parent 1cca561 commit 9f30788

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

pvlib/tests/test_pvsystem.py

+31-7
Original file line numberDiff line numberDiff line change
@@ -2648,18 +2648,42 @@ def test_max_power_point_mismatched(inputs):
26482648
print(result)
26492649

26502650

2651-
def test_max_power_point_mismatched_exception():
2651+
@pytest.mark.parametrize(
2652+
'inputs',
2653+
[
2654+
{
2655+
"photocurrent": -6.2, # This is bad.
2656+
"saturation_current": 1.0e-8,
2657+
"n": 1.1,
2658+
"resistance_series": 0.0001,
2659+
"resistance_shunt": 5000.0,
2660+
"Ns": 60,
2661+
"T": 25.0,
2662+
},
2663+
{
2664+
"photocurrent": -6.2, # This is bad.
2665+
"saturation_current": 1.0e-8,
2666+
"n": 1.1,
2667+
"resistance_series": 0.0001,
2668+
"resistance_shunt": 5000.0,
2669+
"Ns": 60,
2670+
"T": 25.0,
2671+
"i_mp_ic": 5.6,
2672+
},
2673+
]
2674+
)
2675+
def test_max_power_point_mismatched_exception(inputs):
26522676
"""
26532677
Test errored max power point computation for mismatched devices in series.
26542678
"""
2655-
photocurrent = -6.2 # This is bad.
2656-
saturation_current = 1.0e-8
2657-
resistance_series = 0.0001
2658-
resistance_shunt = 5000.0
2679+
photocurrent = inputs["photocurrent"]
2680+
saturation_current = inputs["saturation_current"]
2681+
resistance_series = inputs["resistance_series"]
2682+
resistance_shunt = inputs["resistance_shunt"]
26592683
q_C = scipy.constants.value("elementary charge")
26602684
k_B_J_per_K = scipy.constants.value("Boltzmann constant")
2661-
T_K = scipy.constants.convert_temperature(25.0, "Celsius", "Kelvin")
2662-
nNsVth = 1.1 * 60 * k_B_J_per_K * T_K / q_C
2685+
T_K = scipy.constants.convert_temperature(inputs["T"], "Celsius", "Kelvin")
2686+
nNsVth = inputs["n"] * inputs["Ns"] * k_B_J_per_K * T_K / q_C
26632687

26642688
with pytest.raises(RuntimeError) as e_info:
26652689
pvsystem.max_power_point_mismatched(

0 commit comments

Comments
 (0)