Skip to content

Commit

Permalink
Merge branch 'master' into pysam_update_capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
dguittet committed Aug 21, 2023
2 parents 8755736 + 1051727 commit 0562a63
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 50 deletions.
1 change: 1 addition & 0 deletions hybrid/detailed_pv_plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from hybrid.dispatch.power_sources.pv_dispatch import PvDispatch
from hybrid.layout.pv_module import get_module_attribs, set_module_attribs
from hybrid.layout.pv_inverter import set_inverter_attribs
from tools.utils import flatten_dict


class DetailedPVPlant(PowerSource):
Expand Down
60 changes: 30 additions & 30 deletions tests/analysis/test_custom_financial.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ def test_custom_financial():

def test_detailed_pv(site):
# Run detailed PV model (pvsamv1) using a custom financial model
annual_energy_expected = 108829776
npv_expected = -39094719
annual_energy_expected = 108239401
npv_expected = -39144853

pvsamv1_defaults_file = Path(__file__).absolute().parent.parent / "hybrid/pvsamv1_basic_params.json"
with open(pvsamv1_defaults_file, 'r') as f:
Expand Down Expand Up @@ -132,12 +132,12 @@ def test_detailed_pv(site):

def test_hybrid_simple_pv_with_wind(site):
# Run wind + simple PV (pvwattsv8) hybrid plant with custom financial model
annual_energy_expected_pv = 98792572
annual_energy_expected_wind = 32492414
annual_energy_expected_hybrid = 131284986
npv_expected_pv = -39914031
npv_expected_wind = -11880595
npv_expected_hybrid = -51794626
annual_energy_expected_pv = 98821626
annual_energy_expected_wind = 33637984
annual_energy_expected_hybrid = 132459610
npv_expected_pv = -39911660
npv_expected_wind = -11786833
npv_expected_hybrid = -51698493

interconnect_kw = 150e6
pv_kw = 50000
Expand Down Expand Up @@ -194,12 +194,12 @@ def test_hybrid_simple_pv_with_wind(site):

def test_hybrid_detailed_pv_with_wind(site):
# Test wind + detailed PV (pvsamv1) hybrid plant with custom financial model
annual_energy_expected_pv = 21590086
annual_energy_expected_wind = 32492414
annual_energy_expected_hybrid = 54082500
npv_expected_pv = -7833348
npv_expected_wind = -11880595
npv_expected_hybrid = -19713943
annual_energy_expected_pv = 21500708
annual_energy_expected_wind = 33637984
annual_energy_expected_hybrid = 55138692
npv_expected_pv = -7840663
npv_expected_wind = -11786833
npv_expected_hybrid = -19627496

interconnect_kw = 150e6
wind_kw = 10000
Expand Down Expand Up @@ -276,14 +276,14 @@ def test_hybrid_detailed_pv_with_wind(site):

def test_hybrid_simple_pv_with_wind_storage_dispatch(site):
# Test wind + simple PV (pvwattsv8) + storage with dispatch hybrid plant with custom financial model
annual_energy_expected_pv = 9879371
annual_energy_expected_wind = 32492414
annual_energy_expected_battery = -31197
annual_energy_expected_hybrid = 42340587
npv_expected_pv = -1899148
npv_expected_wind = -5000659
npv_expected_battery = -8163411
npv_expected_hybrid = -15063967
annual_energy_expected_pv = 9882421
annual_energy_expected_wind = 33637983
annual_energy_expected_battery = -31287
annual_energy_expected_hybrid = 43489117
npv_expected_pv = -1898253
npv_expected_wind = -4664335
npv_expected_battery = -8163435
npv_expected_hybrid = -14726773

interconnect_kw = 15000
pv_kw = 5000
Expand Down Expand Up @@ -346,14 +346,14 @@ def test_hybrid_simple_pv_with_wind_storage_dispatch(site):

def test_hybrid_detailed_pv_with_wind_storage_dispatch(site):
# Test wind + detailed PV (pvsamv1) + storage with dispatch hybrid plant with custom financial model
annual_energy_expected_pv = 20463359
annual_energy_expected_wind = 32492414
annual_energy_expected_battery = -30558
annual_energy_expected_hybrid = 52924846
npv_expected_pv = -3592661
npv_expected_wind = -5000659
npv_expected_battery = -8163239
npv_expected_hybrid = -16757400
annual_energy_expected_pv = 20413333
annual_energy_expected_wind = 33637984
annual_energy_expected_battery = -30147
annual_energy_expected_hybrid = 54020819
npv_expected_pv = -3607348
npv_expected_wind = -4664335
npv_expected_battery = -8163128
npv_expected_hybrid = -16435636

interconnect_kw = 15000
wind_kw = 10000
Expand Down
37 changes: 17 additions & 20 deletions tests/hybrid/test_hybrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,23 @@ def test_detailed_pv_system_capacity(site):

def test_hybrid_detailed_pv_only(site):
# Run standalone detailed PV model (pvsamv1) using defaults
annual_energy_expected = 9874145
annual_energy_expected = 11236852
solar_only = detailed_pv
pv_plant = DetailedPVPlant(site=site, pv_config=solar_only)
assert pv_plant.system_capacity_kw == approx(50002.2, 1e-2)
assert pv_plant.system_capacity_kw == approx(pv_kw, 1e-2)
pv_plant.simulate_power(1, False)
assert pv_plant.system_capacity_kw == approx(pv_kw, 1e-2)
assert pv_plant._system_model.Outputs.annual_energy == approx(annual_energy_expected, 1e-2)
assert pv_plant._system_model.Outputs.capacity_factor == approx(22.55, 1e-2)

# Run detailed PV model (pvsamv1) using defaults
npv_expected = -2546876
npv_expected = -2566581
solar_only = {
'pv': detailed_pv,
'grid': technologies['grid']
}
solar_only['pv']['use_pvwatts'] = False # specify detailed PV model but don't change any defaults
solar_only['grid']['interconnect_kw'] = 150e3
solar_only['pv'].pop('system_capacity_kw') # use default system capacity instead
hybrid_plant = HybridSimulation(solar_only, site)
hybrid_plant.layout.plot()
hybrid_plant.ppa_price = (0.01, )
Expand All @@ -225,7 +224,7 @@ def test_hybrid_detailed_pv_only(site):
solar_only['pv']['use_pvwatts'] = False # specify detailed PV model
solar_only['pv']['tech_config'] = tech_config # specify parameters
solar_only['grid']['interconnect_kw'] = 150e3
solar_only['pv'].pop('system_capacity_kw') # use default system capacity instead
solar_only['pv']['system_capacity_kw'] = 50000 # use another system capacity
hybrid_plant = HybridSimulation(solar_only, site)
hybrid_plant.layout.plot()
hybrid_plant.ppa_price = (0.01, )
Expand Down Expand Up @@ -308,8 +307,8 @@ def test_hybrid_detailed_pv_only(site):

def test_hybrid_user_instantiated(site):
# Run detailed PV model (pvsamv1) using defaults and user-instantiated financial models
annual_energy_expected = 9874145
npv_expected = -2546876
annual_energy_expected = 11236852
npv_expected = -2566581
system_capacity_kw = 5000
system_capacity_kw_expected = 4998
layout_params = PVGridParameters(x_position=0.5,
Expand Down Expand Up @@ -341,11 +340,11 @@ def test_hybrid_user_instantiated(site):
hybrid_plant.simulate()
aeps = hybrid_plant.annual_energies
npvs = hybrid_plant.net_present_values
assert hybrid_plant.pv.system_capacity_kw == approx(system_capacity_kw, 1e-3)
assert aeps.pv == approx(annual_energy_expected, 1e-3)
assert aeps.hybrid == approx(annual_energy_expected, 1e-3)
assert npvs.pv == approx(npv_expected, 1e-3)
assert npvs.hybrid == approx(npv_expected, 1e-3)
assert hybrid_plant.pv.system_capacity_kw == approx(system_capacity_kw, 1e-2)
assert aeps.pv == approx(annual_energy_expected, 1e-2)
assert aeps.hybrid == approx(annual_energy_expected, 1e-2)
assert npvs.pv == approx(npv_expected, 1e-2)
assert npvs.hybrid == approx(npv_expected, 1e-2)


with open("financial.json", 'w') as f:
Expand Down Expand Up @@ -397,8 +396,8 @@ def test_hybrid_user_instantiated(site):

def test_custom_layout(site):
# Run detailed (pvsamv1) and simple (PVWattsv8) PV models using a custom layout model
annual_energy_expected = 7945627
npv_expected = -2712860
annual_energy_expected = 7996844
npv_expected = -2848449
interconnect_kw = 150e3

design_vec = DetailedPVParameters(
Expand Down Expand Up @@ -458,12 +457,10 @@ def test_custom_layout(site):
hybrid_plant.simulate()
aeps = hybrid_plant.annual_energies
npvs = hybrid_plant.net_present_values
assert hybrid_plant.pv.system_capacity_kw == approx(4998.4, 1e-3) # changed via size_electrical_parameters()
assert hybrid_plant.pv.capacity_factor == approx(18.25, 1e-2)
assert aeps.pv == approx(annual_energy_expected, 1e-3)
assert aeps.hybrid == approx(annual_energy_expected, 1e-3)
assert npvs.pv == approx(npv_expected, 1e-3)
assert npvs.hybrid == approx(npv_expected, 1e-3)
assert aeps.pv == approx(annual_energy_expected, 1e-2)
assert aeps.hybrid == approx(annual_energy_expected, 1e-2)
assert npvs.pv == approx(npv_expected, 1e-2)
assert npvs.hybrid == approx(npv_expected, 1e-2)

# Use simple plant (PVWattsv8) with detailed layout
annual_energy_expected = 10425444
Expand Down

0 comments on commit 0562a63

Please sign in to comment.