|
1 | 1 | import numpy as np |
| 2 | +from numpy import nan |
2 | 3 | import pandas as pd |
3 | 4 | from numpy.testing import assert_allclose |
4 | 5 | from .conftest import assert_series_equal |
@@ -114,3 +115,40 @@ def test_huld_errors(): |
114 | 115 | pvarray.huld( |
115 | 116 | eff_irr, temp_mod, pdc0, cell_type='csi', k_version='2021' |
116 | 117 | ) |
| 118 | + |
| 119 | + |
| 120 | +def test_batzelis(): |
| 121 | + params = {'isc0': 15.98, 'voc0': 50.26, 'imp0': 15.27, 'vmp0': 42.57, |
| 122 | + 'alpha_sc': 0.00046, 'beta_voc': -0.0024} |
| 123 | + g = np.array([1000, 500, 1200, 500, 1200, 0, nan, 1000]) |
| 124 | + t = np.array([25, 20, 20, 50, 50, 25, 0, nan]) |
| 125 | + expected = { # these values were computed using the function itself |
| 126 | + 'p_mp': [650.044, 328.599, 789.136, 300.079, 723.401, 0, nan, nan], |
| 127 | + 'i_mp': [ 15.270, 7.626, 18.302, 7.680, 18.433, 0, nan, nan], |
| 128 | + 'v_mp': [ 42.570, 43.090, 43.117, 39.071, 39.246, 0, nan, nan], |
| 129 | + 'i_sc': [ 15.980, 7.972, 19.132, 8.082, 19.397, 0, nan, nan], |
| 130 | + 'v_oc': [ 50.260, 49.687, 51.172, 45.948, 47.585, 0, nan, nan], |
| 131 | + } |
| 132 | + |
| 133 | + # numpy array |
| 134 | + actual = pvarray.batzelis(g, t, **params) |
| 135 | + for key, exp in expected.items(): |
| 136 | + np.testing.assert_allclose(actual[key], exp, atol=1e-3) |
| 137 | + |
| 138 | + # pandas series |
| 139 | + actual = pvarray.batzelis(pd.Series(g), pd.Series(t), **params) |
| 140 | + for key, exp in expected.items(): |
| 141 | + pd.testing.assert_series_equal(actual[key], pd.Series(exp), atol=1e-3) |
| 142 | + |
| 143 | + # scalar |
| 144 | + actual = pvarray.batzelis(g[1], t[1], **params) |
| 145 | + for key, exp in expected.items(): |
| 146 | + assert pytest.approx(exp[1], abs=1e-3) == actual[key] |
| 147 | + |
| 148 | + |
| 149 | +def test_batzelis_negative_voltage(): |
| 150 | + params = {'isc0': 15.98, 'voc0': 50.26, 'imp0': 15.27, 'vmp0': 42.57, |
| 151 | + 'alpha_sc': 0.00046, 'beta_voc': -0.0024} |
| 152 | + actual = pvarray.batzelis(1e-10, 25, **params) |
| 153 | + assert actual['v_mp'] == 0 |
| 154 | + assert actual['v_oc'] == 0 |
0 commit comments