@@ -1374,6 +1374,21 @@ def test_PVSystem_multi_scale_voltage_current_power(mocker):
1374
1374
system .scale_voltage_current_power (None )
1375
1375
1376
1376
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
1377
1392
def test_PVSystem_snlinverter (cec_inverter_parameters ):
1378
1393
system = pvsystem .PVSystem (
1379
1394
inverter = cec_inverter_parameters ['Name' ],
@@ -1387,6 +1402,31 @@ def test_PVSystem_snlinverter(cec_inverter_parameters):
1387
1402
assert_series_equal (pacs , pd .Series ([- 0.020000 , 132.004308 , 250.000000 ]))
1388
1403
1389
1404
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
1390
1430
def test_PVSystem_sandia_multi (cec_inverter_parameters ):
1391
1431
system = pvsystem .PVSystem (
1392
1432
arrays = [pvsystem .Array (), pvsystem .Array ()],
@@ -1409,6 +1449,7 @@ def test_PVSystem_sandia_multi(cec_inverter_parameters):
1409
1449
system .sandia_multi ((vdcs , vdcs ), (pdcs , pdcs , pdcs ))
1410
1450
1411
1451
1452
+ # remove after deprecation period for PVSystem.sandia_multi
1412
1453
def test_PVSystem_sandia_multi_single_array (cec_inverter_parameters ):
1413
1454
system = pvsystem .PVSystem (
1414
1455
arrays = [pvsystem .Array ()],
@@ -1431,6 +1472,84 @@ def test_PVSystem_sandia_multi_single_array(cec_inverter_parameters):
1431
1472
system .sandia_multi ((vdcs ,), (pdcs , pdcs ))
1432
1473
1433
1474
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
+
1434
1553
def test_PVSystem_creation ():
1435
1554
pv_system = pvsystem .PVSystem (module = 'blah' , inverter = 'blarg' )
1436
1555
# ensure that parameter attributes are dict-like. GH 294
@@ -1891,6 +2010,7 @@ def test_PVSystem_pvwatts_losses(pvwatts_system_defaults, mocker):
1891
2010
assert out < expected
1892
2011
1893
2012
2013
+ # remove after deprecation period for PVSystem.pvwatts_ac
1894
2014
def test_PVSystem_pvwatts_ac (pvwatts_system_defaults , mocker ):
1895
2015
mocker .spy (inverter , 'pvwatts' )
1896
2016
pdc = 50
@@ -1900,6 +2020,7 @@ def test_PVSystem_pvwatts_ac(pvwatts_system_defaults, mocker):
1900
2020
assert out < pdc
1901
2021
1902
2022
2023
+ # remove after deprecation period for PVSystem.pvwatts_ac
1903
2024
def test_PVSystem_pvwatts_ac_kwargs (pvwatts_system_kwargs , mocker ):
1904
2025
mocker .spy (inverter , 'pvwatts' )
1905
2026
pdc = 50
@@ -1909,6 +2030,7 @@ def test_PVSystem_pvwatts_ac_kwargs(pvwatts_system_kwargs, mocker):
1909
2030
assert out < pdc
1910
2031
1911
2032
2033
+ # remove after deprecation period for PVSystem.pvwatts_ac
1912
2034
def test_PVSystem_pvwatts_multi (pvwatts_system_defaults ,
1913
2035
pvwatts_system_kwargs ):
1914
2036
expected = [pd .Series ([0.0 , 48.123524 , 86.400000 ]),
0 commit comments