foxes 0.8.2__py3-none-any.whl → 1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of foxes might be problematic. Click here for more details.
- docs/source/conf.py +353 -0
- examples/abl_states/run.py +160 -0
- examples/compare_rotors_pwakes/run.py +217 -0
- examples/compare_wakes/run.py +241 -0
- examples/dyn_wakes/run.py +311 -0
- examples/field_data_nc/run.py +121 -0
- examples/induction_RHB/run.py +201 -0
- examples/multi_height/run.py +113 -0
- examples/power_mask/run.py +249 -0
- examples/random_timeseries/run.py +210 -0
- examples/scan_row/run.py +193 -0
- examples/sector_management/run.py +162 -0
- examples/sequential/run.py +209 -0
- examples/single_state/run.py +201 -0
- examples/states_lookup_table/run.py +137 -0
- examples/streamline_wakes/run.py +138 -0
- examples/tab_file/run.py +142 -0
- examples/timelines/run.py +267 -0
- examples/timeseries/run.py +183 -0
- examples/timeseries_slurm/run.py +185 -0
- examples/wind_rose/run.py +141 -0
- examples/windio/run.py +29 -0
- examples/yawed_wake/run.py +196 -0
- foxes/__init__.py +4 -8
- foxes/algorithms/__init__.py +1 -1
- foxes/algorithms/downwind/downwind.py +232 -101
- foxes/algorithms/downwind/models/farm_wakes_calc.py +11 -6
- foxes/algorithms/downwind/models/init_farm_data.py +1 -1
- foxes/algorithms/downwind/models/point_wakes_calc.py +5 -6
- foxes/algorithms/downwind/models/reorder_farm_output.py +0 -1
- foxes/algorithms/downwind/models/set_amb_point_results.py +4 -2
- foxes/algorithms/iterative/iterative.py +73 -33
- foxes/algorithms/iterative/models/farm_wakes_calc.py +11 -6
- foxes/algorithms/sequential/models/plugin.py +1 -1
- foxes/algorithms/sequential/sequential.py +126 -255
- foxes/constants.py +17 -2
- foxes/core/__init__.py +1 -0
- foxes/core/algorithm.py +631 -146
- foxes/core/data.py +252 -20
- foxes/core/data_calc_model.py +13 -289
- foxes/core/engine.py +630 -0
- foxes/core/farm_controller.py +37 -9
- foxes/core/farm_data_model.py +15 -0
- foxes/core/model.py +133 -80
- foxes/core/point_data_model.py +15 -0
- foxes/core/rotor_model.py +27 -21
- foxes/core/states.py +16 -0
- foxes/core/turbine_type.py +28 -0
- foxes/core/wake_frame.py +22 -4
- foxes/core/wake_model.py +2 -3
- foxes/data/windio/windio_5turbines_timeseries.yaml +23 -1
- foxes/engines/__init__.py +16 -0
- foxes/engines/dask.py +975 -0
- foxes/engines/default.py +75 -0
- foxes/engines/futures.py +72 -0
- foxes/engines/mpi.py +38 -0
- foxes/engines/multiprocess.py +74 -0
- foxes/engines/numpy.py +185 -0
- foxes/engines/pool.py +263 -0
- foxes/engines/single.py +139 -0
- foxes/input/farm_layout/__init__.py +1 -0
- foxes/input/farm_layout/from_csv.py +4 -0
- foxes/input/farm_layout/from_json.py +1 -1
- foxes/input/farm_layout/grid.py +2 -2
- foxes/input/farm_layout/ring.py +65 -0
- foxes/input/farm_layout/row.py +2 -2
- foxes/input/states/__init__.py +6 -0
- foxes/input/states/create/random_abl_states.py +1 -1
- foxes/input/states/field_data_nc.py +157 -32
- foxes/input/states/multi_height.py +127 -13
- foxes/input/states/one_point_flow.py +577 -0
- foxes/input/states/scan_ws.py +73 -2
- foxes/input/states/states_table.py +204 -35
- foxes/input/windio/__init__.py +1 -1
- foxes/input/windio/get_states.py +44 -23
- foxes/input/windio/read_attributes.py +41 -16
- foxes/input/windio/read_farm.py +116 -102
- foxes/input/windio/read_fields.py +13 -6
- foxes/input/windio/read_outputs.py +63 -22
- foxes/input/windio/runner.py +31 -17
- foxes/input/windio/windio.py +36 -22
- foxes/models/ground_models/wake_mirror.py +8 -4
- foxes/models/model_book.py +29 -18
- foxes/models/partial_wakes/rotor_points.py +3 -3
- foxes/models/rotor_models/centre.py +4 -0
- foxes/models/rotor_models/grid.py +22 -23
- foxes/models/rotor_models/levels.py +4 -5
- foxes/models/turbine_models/calculator.py +0 -2
- foxes/models/turbine_models/lookup_table.py +27 -2
- foxes/models/turbine_models/rotor_centre_calc.py +4 -3
- foxes/models/turbine_models/set_farm_vars.py +103 -34
- foxes/models/turbine_types/PCt_file.py +24 -0
- foxes/models/turbine_types/PCt_from_two.py +24 -0
- foxes/models/turbine_types/__init__.py +1 -0
- foxes/models/turbine_types/lookup.py +316 -0
- foxes/models/turbine_types/null_type.py +50 -0
- foxes/models/turbine_types/wsrho2PCt_from_two.py +24 -0
- foxes/models/turbine_types/wsti2PCt_from_two.py +24 -0
- foxes/models/vertical_profiles/data_profile.py +1 -1
- foxes/models/wake_frames/__init__.py +1 -0
- foxes/models/wake_frames/dynamic_wakes.py +424 -0
- foxes/models/wake_frames/farm_order.py +23 -3
- foxes/models/wake_frames/rotor_wd.py +4 -2
- foxes/models/wake_frames/seq_dynamic_wakes.py +56 -63
- foxes/models/wake_frames/streamlines.py +19 -20
- foxes/models/wake_frames/timelines.py +328 -127
- foxes/models/wake_frames/yawed_wakes.py +4 -1
- foxes/models/wake_models/dist_sliced.py +1 -3
- foxes/models/wake_models/induction/rankine_half_body.py +4 -4
- foxes/models/wake_models/induction/rathmann.py +2 -2
- foxes/models/wake_models/induction/self_similar.py +2 -2
- foxes/models/wake_models/induction/vortex_sheet.py +2 -2
- foxes/models/wake_models/ti/iec_ti.py +34 -17
- foxes/models/wake_models/top_hat.py +1 -1
- foxes/models/wake_models/wind/bastankhah14.py +2 -2
- foxes/models/wake_models/wind/bastankhah16.py +8 -7
- foxes/models/wake_models/wind/jensen.py +1 -1
- foxes/models/wake_models/wind/turbopark.py +2 -2
- foxes/output/__init__.py +4 -1
- foxes/output/farm_layout.py +2 -2
- foxes/output/flow_plots_2d/__init__.py +0 -1
- foxes/output/flow_plots_2d/flow_plots.py +70 -30
- foxes/output/grids.py +91 -21
- foxes/output/seq_plugins/__init__.py +2 -0
- foxes/output/{flow_plots_2d → seq_plugins}/seq_flow_ani_plugin.py +62 -20
- foxes/output/seq_plugins/seq_wake_debug_plugin.py +145 -0
- foxes/output/slice_data.py +131 -111
- foxes/output/state_turbine_map.py +18 -13
- foxes/output/state_turbine_table.py +19 -19
- foxes/utils/__init__.py +1 -1
- foxes/utils/dev_utils.py +42 -0
- foxes/utils/dict.py +1 -1
- foxes/utils/factory.py +147 -52
- foxes/utils/pandas_helpers.py +4 -3
- foxes/utils/wind_dir.py +0 -2
- foxes/utils/xarray_utils.py +23 -13
- foxes/variables.py +37 -0
- {foxes-0.8.2.dist-info → foxes-1.0.dist-info}/METADATA +71 -33
- foxes-1.0.dist-info/RECORD +307 -0
- {foxes-0.8.2.dist-info → foxes-1.0.dist-info}/WHEEL +1 -1
- foxes-1.0.dist-info/top_level.txt +4 -0
- tests/0_consistency/iterative/test_iterative.py +92 -0
- tests/0_consistency/partial_wakes/test_partial_wakes.py +90 -0
- tests/1_verification/flappy_0_6/PCt_files/flappy/run.py +85 -0
- tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +103 -0
- tests/1_verification/flappy_0_6/abl_states/flappy/run.py +85 -0
- tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +87 -0
- tests/1_verification/flappy_0_6/partial_top_hat/flappy/run.py +82 -0
- tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +82 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_centre/flappy/run.py +92 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +93 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/flappy/run.py +92 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +96 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/flappy/run.py +94 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +122 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/flappy/run.py +94 -0
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +122 -0
- tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/flappy/run.py +92 -0
- tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +93 -0
- tests/1_verification/flappy_0_6_2/grid_rotors/flappy/run.py +85 -0
- tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +130 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/flappy/run.py +96 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +116 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/flappy/run.py +93 -0
- tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +99 -0
- tests/3_examples/test_examples.py +34 -0
- foxes/VERSION +0 -1
- foxes/output/flow_plots_2d.py +0 -0
- foxes/utils/runners/__init__.py +0 -1
- foxes/utils/runners/runners.py +0 -280
- foxes-0.8.2.dist-info/RECORD +0 -247
- foxes-0.8.2.dist-info/top_level.txt +0 -1
- foxes-0.8.2.dist-info/zip-safe +0 -1
- {foxes-0.8.2.dist-info → foxes-1.0.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import argparse
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
|
|
5
|
+
import foxes
|
|
6
|
+
import foxes.variables as FV
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
# define arguments and options:
|
|
10
|
+
parser = argparse.ArgumentParser()
|
|
11
|
+
parser.add_argument(
|
|
12
|
+
"-nt", "--n_t", help="The number of turbines", type=int, default=5
|
|
13
|
+
)
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"-l",
|
|
16
|
+
"--layout",
|
|
17
|
+
help="The wind farm layout file (path or static)",
|
|
18
|
+
default=None,
|
|
19
|
+
)
|
|
20
|
+
parser.add_argument("--ws", help="The wind speed", type=float, default=9.0)
|
|
21
|
+
parser.add_argument("--wd", help="The wind direction", type=float, default=270.0)
|
|
22
|
+
parser.add_argument("--ti", help="The TI value", type=float, default=0.08)
|
|
23
|
+
parser.add_argument("--rho", help="The air density", type=float, default=1.225)
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"-dx", "--deltax", help="The turbine distance in x", type=float, default=800.0
|
|
26
|
+
)
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"-dy", "--deltay", help="Turbine layout y step", type=float, default=0.0
|
|
29
|
+
)
|
|
30
|
+
parser.add_argument(
|
|
31
|
+
"-t",
|
|
32
|
+
"--turbine_file",
|
|
33
|
+
help="The P-ct-curve csv file (path or static)",
|
|
34
|
+
default="NREL-5MW-D126-H90.csv",
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
"-m",
|
|
38
|
+
"--tmodels",
|
|
39
|
+
help="The turbine models",
|
|
40
|
+
default=[],
|
|
41
|
+
nargs="+",
|
|
42
|
+
)
|
|
43
|
+
parser.add_argument(
|
|
44
|
+
"-w",
|
|
45
|
+
"--wakes",
|
|
46
|
+
help="The wake models",
|
|
47
|
+
default=["Bastankhah2014_linear_k004", "CrespoHernandez_quadratic_ambka04"],
|
|
48
|
+
nargs="+",
|
|
49
|
+
)
|
|
50
|
+
parser.add_argument("-r", "--rotor", help="The rotor model", default="centre")
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"-p", "--pwakes", help="The partial wakes models", default=None, nargs="+"
|
|
53
|
+
)
|
|
54
|
+
parser.add_argument(
|
|
55
|
+
"-g", "--grounds", help="The ground models", default=None, nargs="+"
|
|
56
|
+
)
|
|
57
|
+
parser.add_argument("-f", "--frame", help="The wake frame", default="rotor_wd")
|
|
58
|
+
parser.add_argument("-v", "--var", help="The plot variable", default=FV.WS)
|
|
59
|
+
parser.add_argument("-e", "--engine", help="The engine", default=None)
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
"-n", "--n_cpus", help="The number of cpus", default=None, type=int
|
|
62
|
+
)
|
|
63
|
+
parser.add_argument(
|
|
64
|
+
"-C",
|
|
65
|
+
"--chunksize_points",
|
|
66
|
+
help="The chunk size for points",
|
|
67
|
+
default=None,
|
|
68
|
+
type=int,
|
|
69
|
+
)
|
|
70
|
+
parser.add_argument(
|
|
71
|
+
"-it", "--iterative", help="Use iterative algorithm", action="store_true"
|
|
72
|
+
)
|
|
73
|
+
parser.add_argument(
|
|
74
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
75
|
+
)
|
|
76
|
+
args = parser.parse_args()
|
|
77
|
+
|
|
78
|
+
# create model book
|
|
79
|
+
mbook = foxes.ModelBook()
|
|
80
|
+
ttype = foxes.models.turbine_types.PCtFile(args.turbine_file)
|
|
81
|
+
mbook.turbine_types[ttype.name] = ttype
|
|
82
|
+
|
|
83
|
+
# create states
|
|
84
|
+
states = foxes.input.states.SingleStateStates(
|
|
85
|
+
ws=args.ws,
|
|
86
|
+
wd=args.wd,
|
|
87
|
+
ti=args.ti,
|
|
88
|
+
rho=args.rho,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
# create wind farm
|
|
92
|
+
print("\nCreating wind farm")
|
|
93
|
+
farm = foxes.WindFarm()
|
|
94
|
+
if args.layout is None:
|
|
95
|
+
foxes.input.farm_layout.add_row(
|
|
96
|
+
farm=farm,
|
|
97
|
+
xy_base=np.array([0.0, 0.0]),
|
|
98
|
+
xy_step=np.array([args.deltax, args.deltay]),
|
|
99
|
+
n_turbines=args.n_t,
|
|
100
|
+
turbine_models=args.tmodels + [ttype.name],
|
|
101
|
+
)
|
|
102
|
+
else:
|
|
103
|
+
foxes.input.farm_layout.add_from_file(
|
|
104
|
+
farm, args.layout, turbine_models=args.tmodels + [ttype.name]
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
# create algorithm
|
|
108
|
+
Algo = foxes.algorithms.Iterative if args.iterative else foxes.algorithms.Downwind
|
|
109
|
+
algo = Algo(
|
|
110
|
+
farm,
|
|
111
|
+
states,
|
|
112
|
+
rotor_model=args.rotor,
|
|
113
|
+
wake_models=args.wakes,
|
|
114
|
+
wake_frame=args.frame,
|
|
115
|
+
partial_wakes=args.pwakes,
|
|
116
|
+
ground_models=args.grounds,
|
|
117
|
+
mbook=mbook,
|
|
118
|
+
engine=args.engine,
|
|
119
|
+
n_procs=args.n_cpus,
|
|
120
|
+
chunk_size_points=args.chunksize_points,
|
|
121
|
+
verbosity=1,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
farm_results = algo.calc_farm()
|
|
125
|
+
print("\nResults data:\n", farm_results)
|
|
126
|
+
|
|
127
|
+
# add capacity and efficiency to farm results
|
|
128
|
+
o = foxes.output.FarmResultsEval(farm_results)
|
|
129
|
+
o.add_capacity(algo)
|
|
130
|
+
o.add_capacity(algo, ambient=True)
|
|
131
|
+
o.add_efficiency()
|
|
132
|
+
|
|
133
|
+
# state-turbine results
|
|
134
|
+
farm_df = farm_results.to_dataframe()
|
|
135
|
+
print("\nFarm results data:\n")
|
|
136
|
+
print(
|
|
137
|
+
farm_df[
|
|
138
|
+
[
|
|
139
|
+
FV.X,
|
|
140
|
+
FV.ORDER,
|
|
141
|
+
FV.WD,
|
|
142
|
+
FV.AMB_REWS,
|
|
143
|
+
FV.REWS,
|
|
144
|
+
FV.AMB_TI,
|
|
145
|
+
FV.TI,
|
|
146
|
+
FV.AMB_P,
|
|
147
|
+
FV.P,
|
|
148
|
+
FV.CT,
|
|
149
|
+
FV.EFF,
|
|
150
|
+
]
|
|
151
|
+
]
|
|
152
|
+
)
|
|
153
|
+
print()
|
|
154
|
+
|
|
155
|
+
# results by turbine
|
|
156
|
+
turbine_results = o.reduce_states(
|
|
157
|
+
{
|
|
158
|
+
FV.AMB_P: "mean",
|
|
159
|
+
FV.P: "mean",
|
|
160
|
+
FV.AMB_CAP: "mean",
|
|
161
|
+
FV.CAP: "mean",
|
|
162
|
+
FV.EFF: "mean",
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
turbine_results[FV.AMB_YLD] = o.calc_turbine_yield(
|
|
166
|
+
algo=algo, annual=True, ambient=True
|
|
167
|
+
)
|
|
168
|
+
turbine_results[FV.YLD] = o.calc_turbine_yield(algo=algo, annual=True)
|
|
169
|
+
print("\nResults by turbine:\n")
|
|
170
|
+
print(turbine_results)
|
|
171
|
+
|
|
172
|
+
# power results
|
|
173
|
+
P0 = o.calc_mean_farm_power(ambient=True)
|
|
174
|
+
P = o.calc_mean_farm_power()
|
|
175
|
+
print(f"\nFarm power : {P/1000:.1f} MW")
|
|
176
|
+
print(f"Farm ambient power: {P0/1000:.1f} MW")
|
|
177
|
+
print(f"Farm efficiency : {o.calc_farm_efficiency()*100:.2f} %")
|
|
178
|
+
print(f"Annual farm yield : {turbine_results[FV.YLD].sum():.2f} GWh.")
|
|
179
|
+
|
|
180
|
+
if not args.nofig:
|
|
181
|
+
|
|
182
|
+
# horizontal flow plot
|
|
183
|
+
o = foxes.output.FlowPlots2D(algo, farm_results)
|
|
184
|
+
g = o.gen_states_fig_xy(
|
|
185
|
+
args.var, resolution=10, rotor_color="red", figsize=(10, 3)
|
|
186
|
+
)
|
|
187
|
+
fig = next(g)
|
|
188
|
+
plt.show()
|
|
189
|
+
plt.close(fig)
|
|
190
|
+
|
|
191
|
+
# vertical flow plot
|
|
192
|
+
o = foxes.output.FlowPlots2D(algo, farm_results)
|
|
193
|
+
g = o.gen_states_fig_xz(
|
|
194
|
+
args.var,
|
|
195
|
+
resolution=10,
|
|
196
|
+
x_direction=np.mod(args.wd, 360.0),
|
|
197
|
+
rotor_color="red",
|
|
198
|
+
figsize=(10, 3),
|
|
199
|
+
)
|
|
200
|
+
fig = next(g)
|
|
201
|
+
plt.show()
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
import foxes
|
|
4
|
+
import foxes.variables as FV
|
|
5
|
+
|
|
6
|
+
if __name__ == "__main__":
|
|
7
|
+
# define arguments:
|
|
8
|
+
parser = argparse.ArgumentParser()
|
|
9
|
+
parser.add_argument(
|
|
10
|
+
"-P",
|
|
11
|
+
"--P_percent",
|
|
12
|
+
help="Power percent choice, applied to all states",
|
|
13
|
+
type=float,
|
|
14
|
+
default=55.0,
|
|
15
|
+
)
|
|
16
|
+
parser.add_argument(
|
|
17
|
+
"-s",
|
|
18
|
+
"--states",
|
|
19
|
+
help="The states input file (path or static)",
|
|
20
|
+
default="wind_rose_bremen.csv",
|
|
21
|
+
)
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"-l",
|
|
24
|
+
"--layout",
|
|
25
|
+
help="The wind farm layout file (path or static)",
|
|
26
|
+
default="test_farm_67.csv",
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"-D",
|
|
30
|
+
help="The rotor diameter",
|
|
31
|
+
default=126.0,
|
|
32
|
+
type=float,
|
|
33
|
+
)
|
|
34
|
+
parser.add_argument(
|
|
35
|
+
"-H",
|
|
36
|
+
help="The hub height",
|
|
37
|
+
default=90.0,
|
|
38
|
+
type=float,
|
|
39
|
+
)
|
|
40
|
+
parser.add_argument("-r", "--rotor", help="The rotor model", default="centre")
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"-p", "--pwakes", help="The partial wakes models", default=None, nargs="+"
|
|
43
|
+
)
|
|
44
|
+
parser.add_argument(
|
|
45
|
+
"-w",
|
|
46
|
+
"--wakes",
|
|
47
|
+
help="The wake models",
|
|
48
|
+
default=["Bastankhah2014_linear_lim_k004"],
|
|
49
|
+
nargs="+",
|
|
50
|
+
)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"-m", "--tmodels", help="The turbine models", default=[], nargs="+"
|
|
53
|
+
)
|
|
54
|
+
parser.add_argument("-e", "--engine", help="The engine", default=None)
|
|
55
|
+
parser.add_argument(
|
|
56
|
+
"-n", "--n_cpus", help="The number of cpus", default=None, type=int
|
|
57
|
+
)
|
|
58
|
+
parser.add_argument(
|
|
59
|
+
"-c",
|
|
60
|
+
"--chunksize_states",
|
|
61
|
+
help="The chunk size for states",
|
|
62
|
+
default=None,
|
|
63
|
+
type=int,
|
|
64
|
+
)
|
|
65
|
+
parser.add_argument(
|
|
66
|
+
"-C",
|
|
67
|
+
"--chunksize_points",
|
|
68
|
+
help="The chunk size for points",
|
|
69
|
+
default=None,
|
|
70
|
+
type=int,
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
74
|
+
)
|
|
75
|
+
args = parser.parse_args()
|
|
76
|
+
|
|
77
|
+
mbook = foxes.models.ModelBook()
|
|
78
|
+
mbook.turbine_types["ttypeDH"] = foxes.models.turbine_types.NullType(
|
|
79
|
+
D=args.D, H=args.H
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
mbook.turbine_models["lookup"] = foxes.models.turbine_models.LookupTable(
|
|
83
|
+
"curtail_to_power.csv",
|
|
84
|
+
input_vars=[FV.REWS, "P_percent"],
|
|
85
|
+
output_vars=[FV.P, FV.CT],
|
|
86
|
+
varmap={
|
|
87
|
+
FV.REWS: "wind",
|
|
88
|
+
"P_percent": "powerPercent",
|
|
89
|
+
FV.P: "GenPower",
|
|
90
|
+
FV.CT: "ct",
|
|
91
|
+
},
|
|
92
|
+
P_percent=args.P_percent,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
states = foxes.input.states.StatesTable(
|
|
96
|
+
data_source=args.states,
|
|
97
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
|
|
98
|
+
var2col={FV.WS: "ws", FV.WD: "wd", FV.WEIGHT: "weight"},
|
|
99
|
+
fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
farm = foxes.WindFarm()
|
|
103
|
+
foxes.input.farm_layout.add_from_file(
|
|
104
|
+
farm,
|
|
105
|
+
args.layout,
|
|
106
|
+
col_x="x",
|
|
107
|
+
col_y="y",
|
|
108
|
+
col_H="H",
|
|
109
|
+
turbine_models=["ttypeDH", "lookup"] + args.tmodels,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
algo = foxes.algorithms.Downwind(
|
|
113
|
+
farm,
|
|
114
|
+
states,
|
|
115
|
+
rotor_model=args.rotor,
|
|
116
|
+
wake_models=args.wakes,
|
|
117
|
+
wake_frame="rotor_wd",
|
|
118
|
+
partial_wakes=args.pwakes,
|
|
119
|
+
mbook=mbook,
|
|
120
|
+
engine=args.engine,
|
|
121
|
+
n_procs=args.n_cpus,
|
|
122
|
+
chunk_size_states=args.chunksize_states,
|
|
123
|
+
chunk_size_points=args.chunksize_points,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
farm_results = algo.calc_farm()
|
|
127
|
+
|
|
128
|
+
fr = farm_results.to_dataframe()
|
|
129
|
+
print(fr[[FV.WD, FV.H, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P, FV.CT, FV.WEIGHT]])
|
|
130
|
+
|
|
131
|
+
o = foxes.output.FarmResultsEval(farm_results)
|
|
132
|
+
P0 = o.calc_mean_farm_power(ambient=True)
|
|
133
|
+
P = o.calc_mean_farm_power()
|
|
134
|
+
print(f"\nFarm power : {P/1000:.1f} MW")
|
|
135
|
+
print(f"Farm ambient power: {P0/1000:.1f} MW")
|
|
136
|
+
print(f"Farm efficiency : {o.calc_farm_efficiency()*100:.2f} %")
|
|
137
|
+
print(f"Annual farm yield : {o.calc_farm_yield(algo=algo):.2f} GWh")
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import argparse
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
import foxes
|
|
7
|
+
import foxes.variables as FV
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
parser = argparse.ArgumentParser()
|
|
12
|
+
parser.add_argument(
|
|
13
|
+
"-f",
|
|
14
|
+
"--file_pattern",
|
|
15
|
+
help="The search pattern for input *.nc files",
|
|
16
|
+
default="wind_rotation.nc",
|
|
17
|
+
)
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"-t",
|
|
20
|
+
"--turbine_file",
|
|
21
|
+
help="The P-ct-curve csv file (path or static)",
|
|
22
|
+
default="NREL-5MW-D126-H90.csv",
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument("-r", "--rotor", help="The rotor model", default="centre")
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"-p", "--pwakes", help="The partial wakes models", default="centre", nargs="+"
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument("-sc", "--scheduler", help="The scheduler choice", default=None)
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"-w",
|
|
31
|
+
"--wakes",
|
|
32
|
+
help="The wake models",
|
|
33
|
+
default=["Jensen_linear_k007"],
|
|
34
|
+
nargs="+",
|
|
35
|
+
)
|
|
36
|
+
parser.add_argument(
|
|
37
|
+
"-wf", "--wake_frame", help="The wake frame choice", default="streamlines_100"
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"-m", "--tmodels", help="The turbine models", default=[], nargs="+"
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"-nt", "--n_turbines", help="The number of turbines", default=9, type=int
|
|
44
|
+
)
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"-npl", "--no_pre_load", help="Pre-load the nc data", action="store_true"
|
|
47
|
+
)
|
|
48
|
+
parser.add_argument("-e", "--engine", help="The engine", default=None)
|
|
49
|
+
parser.add_argument(
|
|
50
|
+
"-n", "--n_cpus", help="The number of cpus", default=None, type=int
|
|
51
|
+
)
|
|
52
|
+
parser.add_argument(
|
|
53
|
+
"-c",
|
|
54
|
+
"--chunksize_states",
|
|
55
|
+
help="The chunk size for states",
|
|
56
|
+
default=None,
|
|
57
|
+
type=int,
|
|
58
|
+
)
|
|
59
|
+
parser.add_argument(
|
|
60
|
+
"-C",
|
|
61
|
+
"--chunksize_points",
|
|
62
|
+
help="The chunk size for points",
|
|
63
|
+
default=None,
|
|
64
|
+
type=int,
|
|
65
|
+
)
|
|
66
|
+
parser.add_argument(
|
|
67
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
68
|
+
)
|
|
69
|
+
args = parser.parse_args()
|
|
70
|
+
|
|
71
|
+
mbook = foxes.models.ModelBook()
|
|
72
|
+
ttype = foxes.models.turbine_types.PCtFile(args.turbine_file)
|
|
73
|
+
mbook.turbine_types[ttype.name] = ttype
|
|
74
|
+
|
|
75
|
+
states = foxes.input.states.FieldDataNC(
|
|
76
|
+
args.file_pattern,
|
|
77
|
+
states_coord="state",
|
|
78
|
+
x_coord="x",
|
|
79
|
+
y_coord="y",
|
|
80
|
+
h_coord="h",
|
|
81
|
+
time_format=None,
|
|
82
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
|
|
83
|
+
var2ncvar={FV.WS: "ws", FV.WD: "wd"},
|
|
84
|
+
fixed_vars={FV.RHO: 1.225, FV.TI: 0.1},
|
|
85
|
+
pre_load=not args.no_pre_load,
|
|
86
|
+
bounds_error=False,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
farm = foxes.WindFarm()
|
|
90
|
+
N = int(args.n_turbines**0.5)
|
|
91
|
+
foxes.input.farm_layout.add_grid(
|
|
92
|
+
farm,
|
|
93
|
+
xy_base=np.array([500.0, 500.0]),
|
|
94
|
+
step_vectors=np.array([[500.0, 0], [0, 500.0]]),
|
|
95
|
+
steps=(N, N),
|
|
96
|
+
turbine_models=args.tmodels + [ttype.name],
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
algo = foxes.algorithms.Downwind(
|
|
100
|
+
farm,
|
|
101
|
+
states,
|
|
102
|
+
rotor_model=args.rotor,
|
|
103
|
+
wake_models=args.wakes,
|
|
104
|
+
wake_frame=args.wake_frame,
|
|
105
|
+
partial_wakes=args.pwakes,
|
|
106
|
+
mbook=mbook,
|
|
107
|
+
engine=args.engine,
|
|
108
|
+
n_procs=args.n_cpus,
|
|
109
|
+
chunk_size_states=args.chunksize_states,
|
|
110
|
+
chunk_size_points=args.chunksize_points,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
time0 = time.time()
|
|
114
|
+
farm_results = algo.calc_farm()
|
|
115
|
+
time1 = time.time()
|
|
116
|
+
|
|
117
|
+
print("\nCalc time =", time1 - time0, "\n")
|
|
118
|
+
|
|
119
|
+
print(farm_results, "\n")
|
|
120
|
+
|
|
121
|
+
fr = farm_results.to_dataframe()
|
|
122
|
+
print(fr[[FV.X, FV.Y, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]])
|
|
123
|
+
|
|
124
|
+
if not args.nofig:
|
|
125
|
+
o = foxes.output.FlowPlots2D(algo, farm_results)
|
|
126
|
+
for fig in o.gen_states_fig_xy(
|
|
127
|
+
FV.WS,
|
|
128
|
+
resolution=10,
|
|
129
|
+
figsize=(8, 8),
|
|
130
|
+
quiver_pars=dict(angles="xy", scale_units="xy", scale=0.07),
|
|
131
|
+
quiver_n=15,
|
|
132
|
+
xmin=0,
|
|
133
|
+
xmax=2500,
|
|
134
|
+
ymin=0,
|
|
135
|
+
ymax=2500,
|
|
136
|
+
):
|
|
137
|
+
plt.show()
|
|
138
|
+
plt.close(fig)
|
examples/tab_file/run.py
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import argparse
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
|
|
5
|
+
import foxes
|
|
6
|
+
import foxes.variables as FV
|
|
7
|
+
|
|
8
|
+
if __name__ == "__main__":
|
|
9
|
+
parser = argparse.ArgumentParser()
|
|
10
|
+
parser.add_argument(
|
|
11
|
+
"-l",
|
|
12
|
+
"--layout",
|
|
13
|
+
help="The wind farm layout file (path or static)",
|
|
14
|
+
default="test_farm_67.csv",
|
|
15
|
+
)
|
|
16
|
+
parser.add_argument(
|
|
17
|
+
"-s",
|
|
18
|
+
"--states",
|
|
19
|
+
help="The states input file (path or static)",
|
|
20
|
+
default="winds100.tab",
|
|
21
|
+
)
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"-t",
|
|
24
|
+
"--turbine_file",
|
|
25
|
+
help="The P-ct-curve csv file (path or static)",
|
|
26
|
+
default="NREL-5MW-D126-H90.csv",
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument("-r", "--rotor", help="The rotor model", default="centre")
|
|
29
|
+
parser.add_argument(
|
|
30
|
+
"-p", "--pwakes", help="The partial wakes models", default={}, nargs="+"
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"-w",
|
|
34
|
+
"--wakes",
|
|
35
|
+
help="The wake models",
|
|
36
|
+
default=["CrespoHernandez_quadratic", "Bastankhah2014_linear"],
|
|
37
|
+
nargs="+",
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"-m", "--tmodels", help="The turbine models", default=[], nargs="+"
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"-sl",
|
|
44
|
+
"--show_layout",
|
|
45
|
+
help="Flag for showing layout figure",
|
|
46
|
+
action="store_true",
|
|
47
|
+
)
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
"-cm", "--calc_mean", help="Calculate states mean", action="store_true"
|
|
50
|
+
)
|
|
51
|
+
parser.add_argument("-e", "--engine", help="The engine", default="process")
|
|
52
|
+
parser.add_argument(
|
|
53
|
+
"-n", "--n_cpus", help="The number of cpus", default=None, type=int
|
|
54
|
+
)
|
|
55
|
+
parser.add_argument(
|
|
56
|
+
"-c",
|
|
57
|
+
"--chunksize_states",
|
|
58
|
+
help="The chunk size for states",
|
|
59
|
+
default=None,
|
|
60
|
+
type=int,
|
|
61
|
+
)
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
"-C",
|
|
64
|
+
"--chunksize_points",
|
|
65
|
+
help="The chunk size for points",
|
|
66
|
+
default=5000,
|
|
67
|
+
type=int,
|
|
68
|
+
)
|
|
69
|
+
parser.add_argument(
|
|
70
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
71
|
+
)
|
|
72
|
+
args = parser.parse_args()
|
|
73
|
+
|
|
74
|
+
mbook = foxes.models.ModelBook()
|
|
75
|
+
ttype = foxes.models.turbine_types.PCtFile(args.turbine_file)
|
|
76
|
+
mbook.turbine_types[ttype.name] = ttype
|
|
77
|
+
|
|
78
|
+
states = foxes.input.states.TabStates(
|
|
79
|
+
data_source=args.states,
|
|
80
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
|
|
81
|
+
fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
with foxes.Engine.new(
|
|
85
|
+
engine_type=args.engine,
|
|
86
|
+
n_procs=args.n_cpus,
|
|
87
|
+
chunk_size_states=args.chunksize_states,
|
|
88
|
+
chunk_size_points=args.chunksize_points,
|
|
89
|
+
):
|
|
90
|
+
if not args.nofig:
|
|
91
|
+
o = foxes.output.StatesRosePlotOutput(states, point=[0.0, 0.0, 100.0])
|
|
92
|
+
fig = o.get_figure(12, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20])
|
|
93
|
+
plt.show()
|
|
94
|
+
|
|
95
|
+
farm = foxes.WindFarm()
|
|
96
|
+
foxes.input.farm_layout.add_from_file(
|
|
97
|
+
farm,
|
|
98
|
+
args.layout,
|
|
99
|
+
col_x="x",
|
|
100
|
+
col_y="y",
|
|
101
|
+
col_H="H",
|
|
102
|
+
turbine_models=[ttype.name, "kTI_02"] + args.tmodels,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if not args.nofig and args.show_layout:
|
|
106
|
+
ax = foxes.output.FarmLayoutOutput(farm).get_figure()
|
|
107
|
+
plt.show()
|
|
108
|
+
plt.close(ax.get_figure())
|
|
109
|
+
|
|
110
|
+
algo = foxes.algorithms.Downwind(
|
|
111
|
+
farm,
|
|
112
|
+
states,
|
|
113
|
+
mbook=mbook,
|
|
114
|
+
rotor_model=args.rotor,
|
|
115
|
+
wake_models=args.wakes,
|
|
116
|
+
wake_frame="rotor_wd",
|
|
117
|
+
partial_wakes=args.pwakes,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
time0 = time.time()
|
|
121
|
+
farm_results = algo.calc_farm()
|
|
122
|
+
time1 = time.time()
|
|
123
|
+
|
|
124
|
+
print("\nCalc time =", time1 - time0, "\n")
|
|
125
|
+
|
|
126
|
+
print(farm_results)
|
|
127
|
+
|
|
128
|
+
fr = farm_results.to_dataframe()
|
|
129
|
+
print(fr[[FV.WD, FV.H, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P, FV.WEIGHT]])
|
|
130
|
+
|
|
131
|
+
o = foxes.output.FarmResultsEval(farm_results)
|
|
132
|
+
P0 = o.calc_mean_farm_power(ambient=True)
|
|
133
|
+
P = o.calc_mean_farm_power()
|
|
134
|
+
print(f"\nFarm power : {P/1000:.1f} MW")
|
|
135
|
+
print(f"Farm ambient power: {P0/1000:.1f} MW")
|
|
136
|
+
print(f"Farm efficiency : {o.calc_farm_efficiency()*100:.2f} %")
|
|
137
|
+
print(f"Annual farm yield : {o.calc_farm_yield(algo=algo):.2f} GWh")
|
|
138
|
+
|
|
139
|
+
if not args.nofig and args.calc_mean:
|
|
140
|
+
o = foxes.output.FlowPlots2D(algo, farm_results)
|
|
141
|
+
fig = o.get_mean_fig_xy(FV.WS, resolution=30)
|
|
142
|
+
plt.show()
|