Skip to content

Commit

Permalink
Merge pull request #465 from NREL/pp/fix_vanilla_gen_with_layout
Browse files Browse the repository at this point in the history
Fix vanilla wind gen with layout
  • Loading branch information
ppinchuk authored Sep 12, 2024
2 parents 7d4a339 + 534bb71 commit 5873cfd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 62 deletions.
10 changes: 10 additions & 0 deletions reV/SAM/SAM.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ def _make_res_kwargs(
# make precip rate available for curtailment analysis
kwargs["precip_rate"] = True

sam_configs = project_points.sam_inputs.values()
needs_wd = any(_sam_config_contains_turbine_layout(sam_config)
for sam_config in sam_configs)
kwargs["require_wind_dir"] = needs_wd

elif res_handler == GeothermalResource:
args += (project_points.d,)

Expand Down Expand Up @@ -954,3 +959,8 @@ def _add_sys_capacity(sam_inputs):
cap = sam_inputs.get("nameplate")

sam_inputs["system_capacity"] = cap


def _sam_config_contains_turbine_layout(sam_config):
"""Detect wether SAM config contains multiple turbines in layout. """
return len(sam_config.get("wind_farm_xCoordinates", ())) > 1
22 changes: 22 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ def test_clearsky():
RevPySam.get_sam_res(res_file, pp, pp.tech)


def test_no_wind_direction():
"""Test getting resource without wind direction (no layout specified)"""

res_file = os.path.join(TESTDATADIR, 'wtk/ri_100_wtk_2012.h5')
sam_file = os.path.join(TESTDATADIR, 'SAM/wind_gen_standard_losses_0.json')
pp = ProjectPoints(slice(0, 1), sam_file, "windpower", res_file=res_file)
out = RevPySam.get_sam_res(res_file, pp, pp.tech)
assert "winddirection" not in out.var_list
assert (out._get_res_df(0)[0]["winddirection"] == 0).all()


def test_wind_direction():
"""Test getting resource with wind direction (layout was specified)"""
res_file = os.path.join(TESTDATADIR, 'wtk/ri_100_wtk_2012.h5')
sam_file = os.path.join(TESTDATADIR, 'SAM/i_windpower_lcoe.json')
pp = ProjectPoints(slice(0, 1), sam_file, "windpower", res_file=res_file)

out = RevPySam.get_sam_res(res_file, pp, pp.tech)
assert "winddirection" in out.var_list
assert (out._get_res_df(0)[0]["winddirection"] != 0).any()


@pytest.mark.parametrize(
("start", "interval"), [[0, 1], [13, 1], [10, 2], [13, 3]]
)
Expand Down
78 changes: 16 additions & 62 deletions tests/test_econ_windbos.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,62 +67,18 @@

# baseline single owner + windbos results using 2012 RI WTK data.
BASELINE = {
"project_return_aftertax_npv": np.array(
[
7876459.5,
7875551.5,
7874505.0,
7875270.0,
7875349.5,
7872819.5,
7871078.5,
7871352.5,
7871153.5,
7869134.5,
]
),
"lcoe_real": np.array(
[
71.007614,
69.21741,
67.24552,
68.67675,
68.829605,
64.257965,
61.39551,
61.83265,
61.51415,
58.43599,
]
),
"lcoe_nom": np.array(
[
89.433525,
87.17878,
84.6952,
86.497826,
86.69034,
80.932396,
77.327156,
77.87773,
77.476585,
73.59966,
]
),
"flip_actual_irr": np.array(
[
10.999977,
10.999978,
10.999978,
10.999978,
10.999978,
10.999978,
10.999979,
10.999979,
10.999979,
10.99998,
]
),
"project_return_aftertax_npv": np.array([7876966.0, 7876048.0, 7875001.5,
7875783.5, 7875860.5, 7873335.5,
7871586.5, 7871840.5, 7871639.0,
7869647.0]),
"lcoe_real": np.array([72.039345, 70.18582, 68.16827, 69.666306, 69.81716,
65.14765, 62.207253, 62.621048, 62.29249,
59.192535]),
"lcoe_nom": np.array([90.73299, 88.39848, 85.85738, 87.744156, 87.93416,
82.05295, 78.34954, 78.87071, 78.456894, 74.55253]),
"flip_actual_irr": np.array([10.999977, 10.999978, 10.999978, 10.999978,
10.999978, 10.999978, 10.999979, 10.999979,
10.999979, 10.999979]),
"total_installed_cost": np.array(10 * [88892234.91311586]),
"turbine_cost": np.array(10 * [52512000.0]),
"sales_tax_cost": np.array(10 * [0.0]),
Expand All @@ -132,13 +88,11 @@

# baseline single owner + windbos results when sweeping sales tax basis
BASELINE_SITE_BOS = {
"total_installed_cost": np.array(
[88892230.0, 88936680.0, 88981130.0, 89025576.0, 89070020.0]
),
"total_installed_cost": np.array([88892230.0, 88936680.0, 88981130.0,
89025576.0, 89070020.0]),
"turbine_cost": np.array(5 * [52512000.0]),
"sales_tax_cost": np.array(
[0.0, 44446.117, 88892.234, 133338.36, 177784.47]
),
"sales_tax_cost": np.array([0.0, 44446.117, 88892.234, 133338.36,
177784.47]),
"bos_cost": np.array(5 * [36380234.91311585]),
}

Expand Down

0 comments on commit 5873cfd

Please sign in to comment.