@@ -1374,6 +1374,21 @@ def test_PVSystem_multi_scale_voltage_current_power(mocker):
13741374 system .scale_voltage_current_power (None )
13751375
13761376
1377+ def test_PVSystem_get_ac_sandia (cec_inverter_parameters , mocker ):
1378+ inv_fun = mocker .spy (inverter , 'sandia' )
1379+ system = pvsystem .PVSystem (
1380+ inverter = cec_inverter_parameters ['Name' ],
1381+ inverter_parameters = cec_inverter_parameters ,
1382+ )
1383+ vdcs = pd .Series (np .linspace (0 , 50 , 3 ))
1384+ idcs = pd .Series (np .linspace (0 , 11 , 3 ))
1385+ pdcs = idcs * vdcs
1386+ pacs = system .get_ac ('sandia' , vdcs , pdcs )
1387+ assert_series_equal (pacs , pd .Series ([- 0.020000 , 132.004308 , 250.000000 ]))
1388+ inv_fun .assert_called_once ()
1389+
1390+
1391+ # remove after deprecation period for PVSystem.snlinverter
13771392def test_PVSystem_snlinverter (cec_inverter_parameters ):
13781393 system = pvsystem .PVSystem (
13791394 inverter = cec_inverter_parameters ['Name' ],
@@ -1387,6 +1402,31 @@ def test_PVSystem_snlinverter(cec_inverter_parameters):
13871402 assert_series_equal (pacs , pd .Series ([- 0.020000 , 132.004308 , 250.000000 ]))
13881403
13891404
1405+ def test_PVSystem_get_ac_sandia_multi (cec_inverter_parameters , mocker ):
1406+ inv_fun = mocker .spy (inverter , 'sandia_multi' )
1407+ system = pvsystem .PVSystem (
1408+ arrays = [pvsystem .Array (), pvsystem .Array ()],
1409+ inverter = cec_inverter_parameters ['Name' ],
1410+ inverter_parameters = cec_inverter_parameters ,
1411+ )
1412+ vdcs = pd .Series (np .linspace (0 , 50 , 3 ))
1413+ idcs = pd .Series (np .linspace (0 , 11 , 3 )) / 2
1414+ pdcs = idcs * vdcs
1415+ pacs = system .get_ac ('sandia' , (vdcs , vdcs ), (pdcs , pdcs ))
1416+ assert_series_equal (pacs , pd .Series ([- 0.020000 , 132.004308 , 250.000000 ]))
1417+ inv_fun .assert_called_once ()
1418+ with pytest .raises (ValueError ,
1419+ match = "Length mismatch for per-array parameter" ):
1420+ system .get_ac ('sandia' , vdcs , (pdcs , pdcs ))
1421+ with pytest .raises (ValueError ,
1422+ match = "Length mismatch for per-array parameter" ):
1423+ system .get_ac ('sandia' , vdcs , (pdcs ,))
1424+ with pytest .raises (ValueError ,
1425+ match = "Length mismatch for per-array parameter" ):
1426+ system .get_ac ('sandia' , (vdcs , vdcs ), (pdcs , pdcs , pdcs ))
1427+
1428+
1429+ # remove after deprecation period for PVSystem.sandia_multi
13901430def test_PVSystem_sandia_multi (cec_inverter_parameters ):
13911431 system = pvsystem .PVSystem (
13921432 arrays = [pvsystem .Array (), pvsystem .Array ()],
@@ -1409,6 +1449,7 @@ def test_PVSystem_sandia_multi(cec_inverter_parameters):
14091449 system .sandia_multi ((vdcs , vdcs ), (pdcs , pdcs , pdcs ))
14101450
14111451
1452+ # remove after deprecation period for PVSystem.sandia_multi
14121453def test_PVSystem_sandia_multi_single_array (cec_inverter_parameters ):
14131454 system = pvsystem .PVSystem (
14141455 arrays = [pvsystem .Array ()],
@@ -1431,6 +1472,84 @@ def test_PVSystem_sandia_multi_single_array(cec_inverter_parameters):
14311472 system .sandia_multi ((vdcs ,), (pdcs , pdcs ))
14321473
14331474
1475+ def test_PVSystem_get_ac_pvwatts (pvwatts_system_defaults , mocker ):
1476+ mocker .spy (inverter , 'pvwatts' )
1477+ pdc = 50
1478+ out = pvwatts_system_defaults .get_ac ('pvwatts' , pdc )
1479+ inverter .pvwatts .assert_called_once_with (
1480+ pdc , ** pvwatts_system_defaults .inverter_parameters )
1481+ assert out < pdc
1482+
1483+
1484+ def test_PVSystem_get_ac_pvwatts_kwargs (pvwatts_system_kwargs , mocker ):
1485+ mocker .spy (inverter , 'pvwatts' )
1486+ pdc = 50
1487+ out = pvwatts_system_kwargs .get_ac ('pvwatts' , pdc )
1488+ inverter .pvwatts .assert_called_once_with (
1489+ pdc , ** pvwatts_system_kwargs .inverter_parameters )
1490+ assert out < pdc
1491+
1492+
1493+ def test_PVSystem_get_ac_pvwatts_multi (
1494+ pvwatts_system_defaults , pvwatts_system_kwargs , mocker ):
1495+ mocker .spy (inverter , 'pvwatts_multi' )
1496+ expected = [pd .Series ([0.0 , 48.123524 , 86.400000 ]),
1497+ pd .Series ([0.0 , 45.893550 , 85.500000 ])]
1498+ systems = [pvwatts_system_defaults , pvwatts_system_kwargs ]
1499+ for base_sys , exp in zip (systems , expected ):
1500+ system = pvsystem .PVSystem (
1501+ arrays = [pvsystem .Array (), pvsystem .Array ()],
1502+ inverter_parameters = base_sys .inverter_parameters ,
1503+ )
1504+ pdcs = pd .Series ([0. , 25. , 50. ])
1505+ pacs = system .get_ac ('pvwatts' , (pdcs , pdcs ))
1506+ assert_series_equal (pacs , exp )
1507+ assert inverter .pvwatts_multi .call_count == 2
1508+ with pytest .raises (ValueError ,
1509+ match = "Length mismatch for per-array parameter" ):
1510+ system .get_ac ('pvwatts' , (pdcs ,))
1511+ with pytest .raises (ValueError ,
1512+ match = "Length mismatch for per-array parameter" ):
1513+ system .get_ac ('pvwatts' , pdcs )
1514+ with pytest .raises (ValueError ,
1515+ match = "Length mismatch for per-array parameter" ):
1516+ system .get_ac ('pvwatts' , (pdcs , pdcs , pdcs ))
1517+
1518+
1519+ def test_PVSystem_get_ac_adr (adr_inverter_parameters , mocker ):
1520+ mocker .spy (inverter , 'adr' )
1521+ system = pvsystem .PVSystem (
1522+ inverter_parameters = adr_inverter_parameters ,
1523+ )
1524+ vdcs = pd .Series ([135 , 154 , 390 , 420 , 551 ])
1525+ pdcs = pd .Series ([135 , 1232 , 1170 , 420 , 551 ])
1526+ pacs = system .get_ac ('adr' , pdcs , vdcs )
1527+ assert_series_equal (pacs , pd .Series ([np .nan , 1161.5745 , 1116.4459 ,
1528+ 382.6679 , np .nan ]))
1529+ inverter .adr .assert_called_once_with (vdcs , pdcs ,
1530+ system .inverter_parameters )
1531+
1532+
1533+ def test_PVSystem_get_ac_adr_multi (adr_inverter_parameters ):
1534+ system = pvsystem .PVSystem (
1535+ arrays = [pvsystem .Array (), pvsystem .Array ()],
1536+ inverter_parameters = adr_inverter_parameters ,
1537+ )
1538+ pdcs = pd .Series ([135 , 1232 , 1170 , 420 , 551 ])
1539+ with pytest .raises (ValueError ,
1540+ match = "The adr inverter function cannot be used" ):
1541+ system .get_ac (model = 'adr' , p_dc = pdcs )
1542+
1543+
1544+ def test_PVSystem_get_ac_invalid (cec_inverter_parameters ):
1545+ system = pvsystem .PVSystem (
1546+ inverter_parameters = cec_inverter_parameters ,
1547+ )
1548+ pdcs = pd .Series (np .linspace (0 , 50 , 3 ))
1549+ with pytest .raises (ValueError , match = "is not a valid AC power model" ):
1550+ system .get_ac (model = 'not_a_model' , p_dc = pdcs )
1551+
1552+
14341553def test_PVSystem_creation ():
14351554 pv_system = pvsystem .PVSystem (module = 'blah' , inverter = 'blarg' )
14361555 # ensure that parameter attributes are dict-like. GH 294
@@ -1891,6 +2010,7 @@ def test_PVSystem_pvwatts_losses(pvwatts_system_defaults, mocker):
18912010 assert out < expected
18922011
18932012
2013+ # remove after deprecation period for PVSystem.pvwatts_ac
18942014def test_PVSystem_pvwatts_ac (pvwatts_system_defaults , mocker ):
18952015 mocker .spy (inverter , 'pvwatts' )
18962016 pdc = 50
@@ -1900,6 +2020,7 @@ def test_PVSystem_pvwatts_ac(pvwatts_system_defaults, mocker):
19002020 assert out < pdc
19012021
19022022
2023+ # remove after deprecation period for PVSystem.pvwatts_ac
19032024def test_PVSystem_pvwatts_ac_kwargs (pvwatts_system_kwargs , mocker ):
19042025 mocker .spy (inverter , 'pvwatts' )
19052026 pdc = 50
@@ -1909,6 +2030,7 @@ def test_PVSystem_pvwatts_ac_kwargs(pvwatts_system_kwargs, mocker):
19092030 assert out < pdc
19102031
19112032
2033+ # remove after deprecation period for PVSystem.pvwatts_ac
19122034def test_PVSystem_pvwatts_multi (pvwatts_system_defaults ,
19132035 pvwatts_system_kwargs ):
19142036 expected = [pd .Series ([0.0 , 48.123524 , 86.400000 ]),
0 commit comments