Skip to content

Commit

Permalink
Merge branch 'feature/floris_tuning' of github.com:paulf81/flasc into…
Browse files Browse the repository at this point in the history
… feature/floris_tuning
  • Loading branch information
paulf81 committed Oct 26, 2023
2 parents 87d15f1 + c4854fe commit 08d8c90
Show file tree
Hide file tree
Showing 4 changed files with 599 additions and 503 deletions.
1,041 changes: 553 additions & 488 deletions examples_artificial_data/04_floris_tuning/00_tune_emg_to_gch.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples_artificial_data/floris_input_artificial/emgauss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ wake:
empirical_gauss:
horizontal_deflection_gain_D: 3.0
vertical_deflection_gain_D: -1
deflection_rate: 15
deflection_rate: 30
mixing_gain_deflection: 0.0
yaw_added_mixing_gain: 0.0

Expand All @@ -186,8 +186,8 @@ wake:
we: 0.05
empirical_gauss:
wake_expansion_rates:
- 0.01
- 0.005
- 0.023
- 0.008
breakpoints_D:
- 10
sigma_0_D: 0.28
Expand Down
22 changes: 10 additions & 12 deletions flasc/model_tuning/floris_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See https://floris.readthedocs.io for documentation

# This is a preliminary implementation of tuning methods for FLORIS to SCADA.
# The code is focused on methods for the empirical guassian wake model and is
# The code is focused on methods for the Empirical Guassian wake model and is
# based on contributions from Elizabeth Eyeson, Paul Fleming (paul.fleming@nrel.gov)
# Misha Sinner (Michael.Sinner@nrel.gov) and Eric Simley at NREL,
# and Bart Doekemeijer of Shell. If interested to contribute to this work please
# reach out via github or email
# Misha Sinner (michael.sinner@nrel.gov) and Eric Simley at NREL, and Bart
# Doekemeijer at Shell, as well as discussions with Diederik van Binsbergen at
# NTNU. Please see readme.txt for more information.


import numpy as np
Expand All @@ -33,7 +33,6 @@
from flasc.energy_ratio.energy_ratio_utilities import add_power_ref, add_power_test
from flasc.energy_ratio.energy_ratio_input import EnergyRatioInput
from flasc.energy_ratio import energy_ratio as er
from sklearn.metrics import mean_squared_error
from flasc.model_tuning.tuner_utils import replicate_nan_values

from floris.tools import FlorisInterface, UncertaintyInterface
Expand Down Expand Up @@ -122,7 +121,7 @@ def sweep_velocity_model_parameter_for_overall_wake_losses(
# Return the error
return floris_wake_losses, scada_wake_loss

def select_best_velocity_parameter(floris_reults,
def select_best_velocity_parameter(floris_results,
scada_results,
value_candidates,
ax=None):
Expand All @@ -132,14 +131,14 @@ def select_best_velocity_parameter(floris_reults,
"""


error_values = (floris_reults - scada_results)**2
error_values = (floris_results - scada_results)**2

best_param = value_candidates[np.argmin(error_values)]
best_floris_result = floris_reults[np.argmin(error_values)]
best_floris_result = floris_results[np.argmin(error_values)]

if ax is not None:

ax.plot(value_candidates, floris_reults, 'b.-', label='FLORIS')
ax.plot(value_candidates, floris_results, 'b.-', label='FLORIS')
ax.scatter(best_param,best_floris_result,color='r',marker='o', label='Best Fit')
ax.axhline(scada_results,color='k', label='SCADA')
ax.grid(True)
Expand Down Expand Up @@ -251,9 +250,8 @@ def sweep_wd_std_for_er(
floris_vals = df_['FLORIS'].values
count_vals = df_['count_SCADA'].values

er_error[idx] = mean_squared_error(y_true=scada_vals,
y_pred=floris_vals,
sample_weight=count_vals)
er_error[idx] = (((scada_vals-floris_vals)**2 * count_vals).sum() /
count_vals.sum())

# Return the error
return er_error, df_list
Expand Down
33 changes: 33 additions & 0 deletions flasc/model_tuning/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Copyright 2023 NREL
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

See https://floris.readthedocs.io for documentation

____ model_tuning ____

This is a preliminary implementation of tuning methods for FLORIS to SCADA.
The code is focused on methods for the Empirical Guassian wake model and is
based on contributions from Elizabeth Eyeson, Paul Fleming (paul.fleming@nrel.gov)
Misha Sinner (michael.sinner@nrel.gov) and Eric Simley at NREL, and Bart
Doekemeijer at Shell, as well as discussions with Diederik van Binsbergen at
NTNU.

Please treat this module as a beta implementation.

We are planning to extend the capabilities of the model_tuning module in coming
version releases. If you are interested in contributing to this effort, please
reach out to Paul or Misha via email. Planned improvements include:
- Streamlining of processes and code
- Added flexibility for implementing other loss functions
- Consolidation and alignment with cosine power loss exponent fitting
(see estimate_cos_pp_fit method in turbine_analysis/yaw_pow_fitting.py)
- Possible accelerated model fitting by refinement of swept parameters
- Methods for fitting multiple parameters simultaneously

0 comments on commit 08d8c90

Please sign in to comment.