Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dguittet committed Aug 14, 2023
1 parent 933c1d3 commit 1b89d7a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
26 changes: 13 additions & 13 deletions tests/analysis/test_custom_financial.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_custom_financial():
def test_detailed_pv(site):
# Run detailed PV model (pvsamv1) using a custom financial model
annual_energy_expected = 108239401
npv_expected = -40021910
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 @@ -135,9 +135,9 @@ def test_hybrid_simple_pv_with_wind(site):
annual_energy_expected_pv = 98821626
annual_energy_expected_wind = 33637984
annual_energy_expected_hybrid = 132459610
npv_expected_pv = -40714053
npv_expected_wind = -12059963
npv_expected_hybrid = -52774017
npv_expected_pv = -39911660
npv_expected_wind = -11786833
npv_expected_hybrid = -51698493

interconnect_kw = 150e6
pv_kw = 50000
Expand Down Expand Up @@ -197,9 +197,9 @@ def test_hybrid_detailed_pv_with_wind(site):
annual_energy_expected_pv = 21500708
annual_energy_expected_wind = 33637984
annual_energy_expected_hybrid = 55138692
npv_expected_pv = -8015242
npv_expected_wind = -12059963
npv_expected_hybrid = -20075205
npv_expected_pv = -7840663
npv_expected_wind = -11786833
npv_expected_hybrid = -19627496

interconnect_kw = 150e6
wind_kw = 10000
Expand Down Expand Up @@ -280,10 +280,10 @@ def test_hybrid_simple_pv_with_wind_storage_dispatch(site):
annual_energy_expected_wind = 33637983
annual_energy_expected_battery = -31287
annual_energy_expected_hybrid = 43489117
npv_expected_pv = -2138980
npv_expected_wind = -5483725
npv_expected_pv = -1898253
npv_expected_wind = -4664335
npv_expected_battery = -8163435
npv_expected_hybrid = -15786128
npv_expected_hybrid = -14726773

interconnect_kw = 15000
pv_kw = 5000
Expand Down Expand Up @@ -350,10 +350,10 @@ def test_hybrid_detailed_pv_with_wind_storage_dispatch(site):
annual_energy_expected_wind = 33637984
annual_energy_expected_battery = -30147
annual_energy_expected_hybrid = 54020819
npv_expected_pv = -4104598
npv_expected_wind = -5483725
npv_expected_pv = -3607348
npv_expected_wind = -4664335
npv_expected_battery = -8163128
npv_expected_hybrid = -17751533
npv_expected_hybrid = -16435636

interconnect_kw = 15000
wind_kw = 10000
Expand Down
35 changes: 17 additions & 18 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(25.66, 1e-2)

# Run detailed PV model (pvsamv1) using defaults
npv_expected = -25676157
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 = 112401677
npv_expected = -25676141
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)


# Run user-instantiated detailed PV plant, grid and respective financial models
Expand Down Expand Up @@ -394,8 +393,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 = 80145550
npv_expected = -28481459
annual_energy_expected = 7996844
npv_expected = -2848449
interconnect_kw = 150e3

design_vec = DetailedPVParameters(
Expand Down Expand Up @@ -455,10 +454,10 @@ def test_custom_layout(site):
hybrid_plant.simulate()
aeps = hybrid_plant.annual_energies
npvs = hybrid_plant.net_present_values
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 = 10405832
Expand Down

0 comments on commit 1b89d7a

Please sign in to comment.