From 7f78aac0b81fbe673f54ae0889f04fd570bc8c91 Mon Sep 17 00:00:00 2001 From: Sandoval Date: Mon, 30 Nov 2026 13:22:25 -0700 Subject: [PATCH 1/9] Add CliffSim companion tests for series mismatch --- tests/test_mismatch.py | 69 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index c43a6863af..f2a7a6083f 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -1,6 +1,7 @@ import numpy as np from pvlib import singlediode as _singlediode -from pvlib.mismatch import _setup_currents, _singlediode_mismatch +from pvlib.mismatch import (_setup_currents, _singlediode_mismatch, + _v_from_i_mismatch) def test__setup_currents(): @@ -35,3 +36,69 @@ def test__singlediode_mismatch_isc_voc(): IL, Io, Rs, Rsh, nNsVth, neg_v_limit=neg_v_limit) assert np.isclose(isc[0], expected_isc) assert np.isclose(voc[0], expected_voc.sum()) + + +def test__singlediode_mismatch_cliffsim(): + # Reference values transcribed from CliffSim-1-compare.xlsx. + # The expected values are from the non-Cliff spreadsheet column. + IL = np.array([[6.], [4.]]) + Io = np.array([[1e-9], [5e-8]]) + Rs = np.array([[0.5], [0.7]]) + Rsh = np.array([[2000.], [1200.]]) + nNsVth = np.array([[2.5], [2.9]]) + neg_v_limit = -5. + + expected = { + 'isc': np.array([5.9960000000000004]), + 'voc': np.array([109.01309999999999]), + 'imp': np.array([3.8311999999999999]), + 'vmp': np.array([92.014600000000002]), + 'pmp': np.array([352.52499999999998]), + 'ff': np.array([0.53932586979593367]), + } + + isc, voc, imp, vmp = _singlediode_mismatch( + IL, Io, Rs, Rsh, nNsVth, neg_v_limit=neg_v_limit) + pmp = imp * vmp + ff = pmp / (isc * voc) + + np.testing.assert_allclose(isc, expected['isc'], atol=1e-3, rtol=0.) + np.testing.assert_allclose(voc, expected['voc'], atol=5e-3, rtol=0.) + np.testing.assert_allclose(imp, expected['imp'], atol=2e-3, rtol=0.) + np.testing.assert_allclose(vmp, expected['vmp'], atol=5e-2, rtol=0.) + np.testing.assert_allclose(pmp, expected['pmp'], atol=2e-2, rtol=0.) + np.testing.assert_allclose(ff, expected['ff'], atol=1e-5, rtol=0.) + + +def test__v_from_i_mismatch_cliffsim(): + # Reference values transcribed from CliffSim-1-compare.xlsx and + # points_of_interest_1_to_6A.csv. The Keith and Norman solutions are + # compared against the same pvlib calculation. For Norman's solution, + # use columns A (current) and B (string voltage); ignore columns C-E. + IL = np.array([[6.], [4.]]) + Io = np.array([[1e-9], [5e-8]]) + Rs = np.array([[0.5], [0.7]]) + Rsh = np.array([[2000.], [1200.]]) + nNsVth = np.array([[2.5], [2.9]]) + neg_v_limit = -5. + + currents = np.array([[1., 1.5, 2., 2.5, 3., 3.5, + 4., 4.5, 5., 5.5, 6.]]) + keith_voltages = np.array([[106.51, 105.10899999999999, 103.554, + 101.76300000000001, 99.56, + 96.376000000000005, 48.706000000000003, + 45.524999999999999, 44.24, + 42.194000000000003]]) + norman_voltages = np.array([[106.53001420000001, 105.1284256, + 103.57315919999999, 101.7831631, + 99.5802625, 96.3959485, + 48.7152532, 45.5353417, + 44.2505189, 42.2050763, -8.]]) + + voltages = _v_from_i_mismatch( + currents, IL, Io, Rs, Rsh, nNsVth, neg_v_limit=neg_v_limit) + + np.testing.assert_allclose( + voltages[:, :keith_voltages.shape[1]], keith_voltages, + atol=5e-3, rtol=0.) + np.testing.assert_allclose(voltages, norman_voltages, atol=2e-2, rtol=0.) From efc7cb2cb27a78a91f7f8899dd61a2499c26006c Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:08:12 -0700 Subject: [PATCH 2/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index f2a7a6083f..387731639d 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -38,7 +38,7 @@ def test__singlediode_mismatch_isc_voc(): assert np.isclose(voc[0], expected_voc.sum()) -def test__singlediode_mismatch_cliffsim(): +def test__singlediode_mismatch_five_points(): # Reference values transcribed from CliffSim-1-compare.xlsx. # The expected values are from the non-Cliff spreadsheet column. IL = np.array([[6.], [4.]]) From f3c890fe972b31f689521d1586206f552e47c38a Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:08:44 -0700 Subject: [PATCH 3/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index 387731639d..238abda9bd 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -39,8 +39,9 @@ def test__singlediode_mismatch_isc_voc(): def test__singlediode_mismatch_five_points(): - # Reference values transcribed from CliffSim-1-compare.xlsx. - # The expected values are from the non-Cliff spreadsheet column. + # Expected values from SunSolve (K. McIntosh, private communcication, + # Sept. 2026). pvlib calculations are corroborated by comparison with + # the SunSolve calculations. IL = np.array([[6.], [4.]]) Io = np.array([[1e-9], [5e-8]]) Rs = np.array([[0.5], [0.7]]) From df23018ac7eab70658c0029850333d62b8a01cec Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:09:00 -0700 Subject: [PATCH 4/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index 238abda9bd..900d46bc9a 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -72,10 +72,8 @@ def test__singlediode_mismatch_five_points(): def test__v_from_i_mismatch_cliffsim(): - # Reference values transcribed from CliffSim-1-compare.xlsx and - # points_of_interest_1_to_6A.csv. The Keith and Norman solutions are - # compared against the same pvlib calculation. For Norman's solution, - # use columns A (current) and B (string voltage); ignore columns C-E. + # Expected values from SunSolve (K. McIntosh, private communication, + # Sept. 2026) and from Xyce (N. Jost, private communication, Sept. 2026). IL = np.array([[6.], [4.]]) Io = np.array([[1e-9], [5e-8]]) Rs = np.array([[0.5], [0.7]]) From dd262aa2986e60c11dcd6d1ef250658a9973226f Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:09:16 -0700 Subject: [PATCH 5/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index 900d46bc9a..5b5ecd407e 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -81,8 +81,8 @@ def test__v_from_i_mismatch_cliffsim(): nNsVth = np.array([[2.5], [2.9]]) neg_v_limit = -5. - currents = np.array([[1., 1.5, 2., 2.5, 3., 3.5, - 4., 4.5, 5., 5.5, 6.]]) + currents = np.array([1., 1.5, 2., 2.5, 3., 3.5, + 4., 4.5, 5., 5.5, 6.]) keith_voltages = np.array([[106.51, 105.10899999999999, 103.554, 101.76300000000001, 99.56, 96.376000000000005, 48.706000000000003, From 5decb97faab56ff754a8ee54f2aae9cbe7f64d36 Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:09:34 -0700 Subject: [PATCH 6/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index 5b5ecd407e..b03ec7393a 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -83,16 +83,18 @@ def test__v_from_i_mismatch_cliffsim(): currents = np.array([1., 1.5, 2., 2.5, 3., 3.5, 4., 4.5, 5., 5.5, 6.]) - keith_voltages = np.array([[106.51, 105.10899999999999, 103.554, - 101.76300000000001, 99.56, - 96.376000000000005, 48.706000000000003, - 45.524999999999999, 44.24, - 42.194000000000003]]) - norman_voltages = np.array([[106.53001420000001, 105.1284256, - 103.57315919999999, 101.7831631, - 99.5802625, 96.3959485, - 48.7152532, 45.5353417, - 44.2505189, 42.2050763, -8.]]) + sunsolve_voltages = np.array([ + 106.51, 105.10899999999999, 103.554, + 101.76300000000001, 99.56, + 96.376000000000005, 48.706000000000003, + 45.524999999999999, 44.24, + 42.194000000000003]) + xyce_voltages = np.array([ + 106.53001420000001, 105.1284256, + 103.57315919999999, 101.7831631, + 99.5802625, 96.3959485, + 48.7152532, 45.5353417, + 44.2505189, 42.2050763, -8.]) voltages = _v_from_i_mismatch( currents, IL, Io, Rs, Rsh, nNsVth, neg_v_limit=neg_v_limit) From 54906fca055c7ce445aeafae70393a84c6abe250 Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:10:26 -0700 Subject: [PATCH 7/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index b03ec7393a..8ce6b5923e 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -100,6 +100,6 @@ def test__v_from_i_mismatch_cliffsim(): currents, IL, Io, Rs, Rsh, nNsVth, neg_v_limit=neg_v_limit) np.testing.assert_allclose( - voltages[:, :keith_voltages.shape[1]], keith_voltages, + voltages[:, sunsolve_voltages.shape[1]], keith_voltages, atol=5e-3, rtol=0.) np.testing.assert_allclose(voltages, norman_voltages, atol=2e-2, rtol=0.) From d5996c03e79ae638353a8cdf307bc7062bab9e10 Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:10:36 -0700 Subject: [PATCH 8/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index 8ce6b5923e..c192d10a32 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -71,7 +71,7 @@ def test__singlediode_mismatch_five_points(): np.testing.assert_allclose(ff, expected['ff'], atol=1e-5, rtol=0.) -def test__v_from_i_mismatch_cliffsim(): +def test__v_from_i_mismatch_corroboration(): # Expected values from SunSolve (K. McIntosh, private communication, # Sept. 2026) and from Xyce (N. Jost, private communication, Sept. 2026). IL = np.array([[6.], [4.]]) From 4324e90a28e6d30d6dbc7a3b685b2ebc5214c932 Mon Sep 17 00:00:00 2001 From: HunterSandoval Date: Mon, 30 Nov 2026 16:10:46 -0700 Subject: [PATCH 9/9] Apply suggestion from @cwhanse Co-authored-by: Cliff Hansen --- tests/test_mismatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mismatch.py b/tests/test_mismatch.py index c192d10a32..6fb8268f0a 100644 --- a/tests/test_mismatch.py +++ b/tests/test_mismatch.py @@ -102,4 +102,4 @@ def test__v_from_i_mismatch_corroboration(): np.testing.assert_allclose( voltages[:, sunsolve_voltages.shape[1]], keith_voltages, atol=5e-3, rtol=0.) - np.testing.assert_allclose(voltages, norman_voltages, atol=2e-2, rtol=0.) + np.testing.assert_allclose(voltages, xyce_voltages, atol=2e-2, rtol=0.)