• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NREL / flasc / 8619096729

09 Apr 2024 04:25PM UTC coverage: 94.184% (+1.2%) from 92.968%
8619096729

Pull #181

github

web-flow
Merge 9de9bf000 into f79762152
Pull Request #181: Use FLORIS tools for layout visualizations

1 of 9 new or added lines in 1 file covered. (11.11%)

3190 of 3387 relevant lines covered (94.18%)

2.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.94
/flasc/utilities/utilities_examples.py
1
import copy
3✔
2
from pathlib import Path
3✔
3
from time import perf_counter as timerpc
3✔
4

5
import floris.layout_visualization as layoutviz
3✔
6
import matplotlib.pyplot as plt
3✔
7
import numpy as np
3✔
8
from floris import FlorisModel, UncertainFlorisModel
3✔
9

10

11
def load_floris_smarteole(wake_model="gch", wd_std=0.0):
3✔
12
    """Load a FlorisModel object for the wind farm at hand.
13

14
    Args:
15
        wake_model (str, optional): The wake model that FLORIS should use. Common
16
          options are 'cc', 'gch', 'jensen', 'turbopark' and 'emgauss'
17
           . Defaults to "gch".
18
        operation_modes (array, optional): Array or list of integers denoting each
19
          turbine's operation mode. When None is specified, will assume each turbine
20
          is in its first operation mode (0). Defaults to None.
21
        wd_std (float, optional): Uncertainty; standard deviation in the inflow
22
          wind direction in degrees. Defaults to 0.0 deg meaning no uncertainty.
23

24
    Returns:
25
        FlorisModel: Floris object.
26
    """
27

28
    # Use the local FLORIS GCH/CC model for the wake model settings
29
    root_path = (
30
        Path(__file__).resolve().parents[2] / "examples_smarteole" / "floris_input_smarteole"
31
    )
32
    fn = root_path / "{:s}.yaml".format(wake_model)
×
33

34
    # Initialize FLORIS model and format appropriately
35
    fm = FlorisModel(fn)
×
36

37
    # Add uncertainty
38
    if wd_std > 0.01:
×
39
        unc_options = {
40
            "std_wd": wd_std,  # Standard deviation for inflow wind direction (deg)
41
            "pmf_res": 1.0,  # Resolution over which to calculate angles (deg)
42
            "pdf_cutoff": 0.995,  # Probability density function cut-off (-)
43
        }
44
        fm = UncertainFlorisModel(fm, unc_options=unc_options)
×
45

46
    # Add turbine weighing terms. These are typically used to distinguish
47
    # between turbines of interest and neighboring farms. This is particularly
48
    # helpful when you have information about surrounding wind farms.
49
    turbine_weights = np.ones(len(fm.layout_x), dtype=float)
×
50

51
    return (fm, turbine_weights)
×
52

53

54
def load_floris_artificial(wake_model="gch", wd_std=0.0, cosine_exponent=None):
3✔
55
    """Load a FlorisModel object for the wind farm at hand.
56

57
    Args:
58
        wake_model (str, optional): The wake model that FLORIS should use. Common
59
          options are 'cc', 'gch', 'jensen',  'turbopark' and 'emgauss'
60
          . Defaults to "gch".
61
        operation_modes (array, optional): Array or list of integers denoting each
62
          turbine's operation mode. When None is specified, will assume each turbine
63
          is in its first operation mode (0). Defaults to None.
64
        wd_std (float, optional): Uncertainty; standard deviation in the inflow
65
          wind direction in degrees. Defaults to 0.0 deg meaning no uncertainty.
66

67
    Returns:
68
        FlorisModel: Floris object.
69
    """
70

71
    # Use the local FLORIS GCH/CC model for the wake model settings
72
    root_path = (
3✔
73
        Path(__file__).resolve().parents[2] / "examples_artificial_data" / "floris_input_artificial"
3✔
74
    )
75
    fn = root_path / "{:s}.yaml".format(wake_model)
3✔
76

77
    # Now assign the turbine locations and information
78
    layout_x = [1630.222, 1176.733, 816.389, 755.938, 0.0, 1142.24, 1553.102]
3✔
79
    layout_y = [0.0, 297.357, 123.431, 575.544, 647.779, 772.262, 504.711]
3✔
80

81
    # Initialize FLORIS model and format appropriately
82
    fm = FlorisModel(fn)
3✔
83
    fm.set(
3✔
84
        layout_x=layout_x,
3✔
85
        layout_y=layout_y,
3✔
86
    )
87

88
    # Update Pp if specified
89
    if cosine_exponent is not None:
3✔
90
        tdefs = [copy.deepcopy(t) for t in fm.core.farm.turbine_definitions]
×
91
        for ii in range(len(tdefs)):
×
92
            tdefs[ii]["power_thrust_table"]["cosine_loss_exponent_yaw"] = cosine_exponent
×
93

94
        fm.set(turbine_type=tdefs)
×
95

96
    # Add uncertainty
97
    if wd_std > 0.01:
3✔
98
        unc_options = {
99
            "std_wd": wd_std,  # Standard deviation for inflow wind direction (deg)
100
            "pmf_res": 1.0,  # Resolution over which to calculate angles (deg)
101
            "pdf_cutoff": 0.995,  # Probability density function cut-off (-)
102
        }
103
        fm = UncertainFlorisModel(fm, unc_options=unc_options)
×
104

105
    # Add turbine weighing terms. These are typically used to distinguish
106
    # between turbines of interest and neighboring farms. This is particularly
107
    # helpful when you have information about surrounding wind farms.
108
    turbine_weights = np.ones(len(layout_x), dtype=float)
3✔
109

110
    return (fm, turbine_weights)
3✔
111

112

113
if __name__ == "__main__":
3✔
114
    # Load and time the artificial FLORIS model
115
    t0 = timerpc()
×
NEW
116
    fm, turbine_weights = load_floris_artificial()
×
117
    print("Time spent to load the FLORIS model (artificial): {:.2f} s.".format(timerpc() - t0))
×
NEW
118
    ax = layoutviz.plot_turbine_points(fm)
×
NEW
119
    layoutviz.plot_turbine_labels(fm, ax=ax)
×
NEW
120
    ax.grid()
×
121

122
    # Load and time the Smarteole FLORIS model
123
    t0 = timerpc()
×
NEW
124
    fm, turbine_weights = load_floris_smarteole()
×
125
    print("Time spent to load the FLORIS model (smarteole): {:.2f} s.".format(timerpc() - t0))
×
NEW
126
    ax = layoutviz.plot_turbine_points(fm)
×
NEW
127
    layoutviz.plot_turbine_labels(fm, ax=ax)
×
NEW
128
    ax.grid()
×
129

130
    plt.show()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc