foxes 1.1.0.2__py3-none-any.whl → 1.2__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 +3 -2
- examples/dyn_wakes/run.py +2 -2
- examples/timelines/run.py +1 -1
- foxes/__init__.py +13 -2
- foxes/algorithms/downwind/downwind.py +6 -1
- foxes/algorithms/downwind/models/init_farm_data.py +5 -2
- foxes/algorithms/downwind/models/point_wakes_calc.py +0 -1
- foxes/algorithms/iterative/iterative.py +1 -1
- foxes/algorithms/sequential/sequential.py +4 -3
- foxes/config/__init__.py +1 -0
- foxes/config/config.py +134 -0
- foxes/constants.py +15 -6
- foxes/core/algorithm.py +22 -10
- foxes/core/data.py +2 -1
- foxes/core/engine.py +40 -34
- foxes/core/farm_controller.py +4 -3
- foxes/core/farm_data_model.py +6 -2
- foxes/core/model.py +2 -1
- foxes/core/point_data_model.py +4 -2
- foxes/core/rotor_model.py +8 -4
- foxes/core/turbine_type.py +1 -1
- foxes/core/wake_frame.py +7 -5
- foxes/core/wake_model.py +6 -1
- foxes/data/__init__.py +1 -1
- foxes/data/static_data.py +0 -7
- foxes/engines/dask.py +4 -3
- foxes/engines/single.py +1 -1
- foxes/input/__init__.py +1 -1
- foxes/input/farm_layout/from_csv.py +3 -1
- foxes/input/farm_layout/from_file.py +10 -10
- foxes/input/farm_layout/from_json.py +4 -3
- foxes/input/farm_layout/grid.py +3 -3
- foxes/input/states/create/random_abl_states.py +5 -3
- foxes/input/states/field_data_nc.py +22 -14
- foxes/input/states/multi_height.py +26 -15
- foxes/input/states/one_point_flow.py +6 -5
- foxes/input/states/scan_ws.py +4 -1
- foxes/input/states/single.py +15 -6
- foxes/input/states/slice_data_nc.py +18 -12
- foxes/input/states/states_table.py +17 -10
- foxes/input/yaml/__init__.py +3 -0
- foxes/input/yaml/dict.py +210 -0
- foxes/input/yaml/windio/__init__.py +4 -0
- foxes/input/{windio → yaml/windio}/get_states.py +7 -7
- foxes/input/{windio → yaml/windio}/read_attributes.py +61 -40
- foxes/input/{windio → yaml/windio}/read_farm.py +34 -43
- foxes/input/{windio → yaml/windio}/read_fields.py +11 -10
- foxes/input/yaml/windio/read_outputs.py +147 -0
- foxes/input/yaml/windio/windio.py +269 -0
- foxes/input/yaml/yaml.py +103 -0
- foxes/models/partial_wakes/axiwake.py +7 -6
- foxes/models/partial_wakes/centre.py +3 -2
- foxes/models/partial_wakes/segregated.py +5 -2
- foxes/models/point_models/set_uniform_data.py +5 -3
- foxes/models/rotor_models/centre.py +2 -2
- foxes/models/rotor_models/grid.py +5 -5
- foxes/models/rotor_models/levels.py +6 -6
- foxes/models/turbine_models/kTI_model.py +3 -1
- foxes/models/turbine_models/lookup_table.py +7 -4
- foxes/models/turbine_models/power_mask.py +14 -8
- foxes/models/turbine_models/sector_management.py +4 -2
- foxes/models/turbine_models/set_farm_vars.py +53 -23
- foxes/models/turbine_models/table_factors.py +8 -7
- foxes/models/turbine_models/yaw2yawm.py +0 -1
- foxes/models/turbine_models/yawm2yaw.py +0 -1
- foxes/models/turbine_types/CpCt_file.py +6 -3
- foxes/models/turbine_types/CpCt_from_two.py +6 -3
- foxes/models/turbine_types/PCt_file.py +7 -6
- foxes/models/turbine_types/PCt_from_two.py +11 -2
- foxes/models/turbine_types/TBL_file.py +3 -4
- foxes/models/turbine_types/wsrho2PCt_from_two.py +19 -11
- foxes/models/turbine_types/wsti2PCt_from_two.py +19 -11
- foxes/models/vertical_profiles/abl_log_neutral_ws.py +1 -1
- foxes/models/vertical_profiles/abl_log_stable_ws.py +1 -1
- foxes/models/vertical_profiles/abl_log_unstable_ws.py +1 -1
- foxes/models/vertical_profiles/abl_log_ws.py +1 -1
- foxes/models/wake_frames/dynamic_wakes.py +17 -9
- foxes/models/wake_frames/farm_order.py +4 -3
- foxes/models/wake_frames/rotor_wd.py +3 -1
- foxes/models/wake_frames/seq_dynamic_wakes.py +14 -7
- foxes/models/wake_frames/streamlines.py +9 -6
- foxes/models/wake_frames/timelines.py +21 -14
- foxes/models/wake_frames/yawed_wakes.py +3 -1
- foxes/models/wake_models/induction/vortex_sheet.py +0 -1
- foxes/models/wake_models/ti/crespo_hernandez.py +2 -1
- foxes/models/wake_models/wind/bastankhah14.py +3 -2
- foxes/models/wake_models/wind/bastankhah16.py +2 -1
- foxes/models/wake_models/wind/turbopark.py +9 -7
- foxes/models/wake_superpositions/ws_product.py +0 -1
- foxes/output/calc_points.py +7 -4
- foxes/output/farm_layout.py +30 -18
- foxes/output/farm_results_eval.py +4 -3
- foxes/output/grids.py +8 -7
- foxes/output/output.py +7 -2
- foxes/output/results_writer.py +10 -11
- foxes/output/rose_plot.py +38 -20
- foxes/output/rotor_point_plots.py +7 -3
- foxes/output/slice_data.py +1 -1
- foxes/output/state_turbine_map.py +5 -1
- foxes/output/state_turbine_table.py +7 -3
- foxes/output/turbine_type_curves.py +7 -2
- foxes/utils/dict.py +107 -3
- foxes/utils/geopandas_utils.py +3 -2
- {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/METADATA +20 -21
- {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/RECORD +122 -122
- {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/WHEEL +1 -1
- foxes-1.2.dist-info/entry_points.txt +3 -0
- tests/0_consistency/iterative/test_iterative.py +65 -67
- tests/0_consistency/partial_wakes/test_partial_wakes.py +58 -61
- tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +56 -53
- tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +41 -41
- tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +34 -34
- tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +50 -50
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +51 -52
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +73 -74
- tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +73 -74
- tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +51 -49
- tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +101 -103
- tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +61 -62
- tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +51 -52
- examples/windio/run.py +0 -29
- foxes/data/states/windio_timeseries_5000.nc +0 -0
- foxes/data/windio/DTU_10MW_turbine.yaml +0 -10
- foxes/data/windio/__init__.py +0 -0
- foxes/data/windio/windio_5turbines_timeseries.yaml +0 -79
- foxes/input/windio/__init__.py +0 -11
- foxes/input/windio/read_outputs.py +0 -172
- foxes/input/windio/runner.py +0 -183
- foxes/input/windio/windio.py +0 -193
- {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/LICENSE +0 -0
- {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from foxes.core import WindFarm
|
|
5
|
+
from foxes.models import ModelBook
|
|
6
|
+
from foxes.utils import import_module, Dict
|
|
7
|
+
|
|
8
|
+
from .read_fields import read_wind_resource_field
|
|
9
|
+
from .get_states import get_states
|
|
10
|
+
from .read_farm import read_layout, read_turbine_types
|
|
11
|
+
from .read_attributes import read_attributes
|
|
12
|
+
from ..dict import run_dict
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _read_site(wio_dict, verbosity):
|
|
16
|
+
"""Reads the site information"""
|
|
17
|
+
|
|
18
|
+
def _print(*args, level=1, **kwargs):
|
|
19
|
+
if verbosity >= level:
|
|
20
|
+
print(*args, **kwargs)
|
|
21
|
+
|
|
22
|
+
wio_site = Dict(wio_dict["site"], name=wio_dict.name + ".site")
|
|
23
|
+
_print("Reading site")
|
|
24
|
+
_print(" Name:", wio_site.pop("name", None))
|
|
25
|
+
_print(" Contents:", [k for k in wio_site.keys()])
|
|
26
|
+
_print(" Ignoring boundaries", level=2)
|
|
27
|
+
|
|
28
|
+
# read energy_resource:
|
|
29
|
+
energy_resource = Dict(
|
|
30
|
+
wio_site["energy_resource"], name=wio_site.name + ".energy_resource"
|
|
31
|
+
)
|
|
32
|
+
_print(" Reading energy_resource", level=2)
|
|
33
|
+
_print(" Name:", energy_resource.pop("name", None), level=2)
|
|
34
|
+
_print(" Contents:", [k for k in energy_resource.keys()], level=2)
|
|
35
|
+
|
|
36
|
+
# read wind_resource:
|
|
37
|
+
wind_resource = Dict(
|
|
38
|
+
energy_resource["wind_resource"], name=energy_resource.name + ".wind_resource"
|
|
39
|
+
)
|
|
40
|
+
_print(" Reading wind_resource", level=3)
|
|
41
|
+
_print(" Name:", wind_resource.pop("name", None), level=3)
|
|
42
|
+
_print(" Contents:", [k for k in wind_resource.keys()], level=3)
|
|
43
|
+
|
|
44
|
+
# read fields
|
|
45
|
+
coords = Dict(name="coords")
|
|
46
|
+
fields = Dict(name="fields")
|
|
47
|
+
dims = Dict(name="dims")
|
|
48
|
+
for n, d in wind_resource.items():
|
|
49
|
+
read_wind_resource_field(n, d, coords, fields, dims, verbosity)
|
|
50
|
+
if verbosity > 2:
|
|
51
|
+
print(" Coords:")
|
|
52
|
+
for c, d in coords.items():
|
|
53
|
+
print(f" {c}: Shape {d.shape}")
|
|
54
|
+
print(" Fields:")
|
|
55
|
+
for f, d in dims.items():
|
|
56
|
+
if len(d):
|
|
57
|
+
print(f" {f}: Dims {d}, shape {fields[f].shape}")
|
|
58
|
+
else:
|
|
59
|
+
print(f" {f} = {fields[f]}")
|
|
60
|
+
|
|
61
|
+
return get_states(coords, fields, dims, verbosity)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _read_farm(wio_dict, mbook, verbosity):
|
|
65
|
+
"""Reads the wind farm information"""
|
|
66
|
+
wio_farm = Dict(wio_dict["wind_farm"], name=wio_dict.name + ".wind_farm")
|
|
67
|
+
if verbosity > 1:
|
|
68
|
+
print("Reading wind farm")
|
|
69
|
+
print(" Name:", wio_farm.pop("name", None))
|
|
70
|
+
print(" Contents:", [k for k in wio_farm.keys()])
|
|
71
|
+
|
|
72
|
+
# find REWS exponents:
|
|
73
|
+
try:
|
|
74
|
+
rotor_averaging = wio_dict["attributes"]["analysis"]["rotor_averaging"]
|
|
75
|
+
ws_exp_P = rotor_averaging["wind_speed_exponent_for_power"]
|
|
76
|
+
ws_exp_ct = rotor_averaging["wind_speed_exponent_for_ct"]
|
|
77
|
+
except KeyError:
|
|
78
|
+
ws_exp_P = 1
|
|
79
|
+
ws_exp_ct = 1
|
|
80
|
+
|
|
81
|
+
# read turbine type:
|
|
82
|
+
ttypes = read_turbine_types(wio_farm, mbook, ws_exp_P, ws_exp_ct, verbosity)
|
|
83
|
+
|
|
84
|
+
# read layouts and create wind farm:
|
|
85
|
+
farm = WindFarm()
|
|
86
|
+
wfarm = wio_farm["layouts"]
|
|
87
|
+
if isinstance(wfarm, dict):
|
|
88
|
+
layouts = Dict(wfarm, name=wio_farm.name + ".layouts")
|
|
89
|
+
else:
|
|
90
|
+
layouts = {str(i): l for i, l in enumerate(wfarm)}
|
|
91
|
+
layouts = Dict(layouts, name=wio_farm.name + ".layouts")
|
|
92
|
+
if verbosity > 2:
|
|
93
|
+
print(" Reading layouts")
|
|
94
|
+
print(" Contents:", [k for k in layouts.keys()])
|
|
95
|
+
for lname, ldict in layouts.items():
|
|
96
|
+
read_layout(lname, ldict, farm, ttypes, verbosity)
|
|
97
|
+
|
|
98
|
+
return farm
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def read_windio(wio_dict, verbosity=1):
|
|
102
|
+
"""
|
|
103
|
+
Translate windio data to foxes input data
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
wio_dict: foxes.utils.Dict
|
|
108
|
+
The windio data
|
|
109
|
+
verbosity: int
|
|
110
|
+
The verbosity level, 0 = silent
|
|
111
|
+
|
|
112
|
+
Returns
|
|
113
|
+
-------
|
|
114
|
+
idict: foxes.utils.Dict
|
|
115
|
+
The foxes input data dictionary
|
|
116
|
+
states: foxes.core.States
|
|
117
|
+
The states object
|
|
118
|
+
farm: foxes.core.WindFarm
|
|
119
|
+
The wind farm
|
|
120
|
+
mbook: foxes.models.ModelBook
|
|
121
|
+
The model book
|
|
122
|
+
|
|
123
|
+
:group: input.yaml.windio
|
|
124
|
+
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
def _print(*args, level=1, **kwargs):
|
|
128
|
+
if verbosity >= level:
|
|
129
|
+
print(*args, **kwargs)
|
|
130
|
+
|
|
131
|
+
_print(f"Reading windio data")
|
|
132
|
+
_print(" Name:", wio_dict.pop("name", None))
|
|
133
|
+
_print(" Contents:", [k for k in wio_dict.keys()])
|
|
134
|
+
|
|
135
|
+
idict = Dict(
|
|
136
|
+
wind_farm=Dict(name="wio2fxs.farm"),
|
|
137
|
+
algorithm=Dict(
|
|
138
|
+
algo_type="Downwind",
|
|
139
|
+
wake_models=[],
|
|
140
|
+
name="wio2fxs.algorithm",
|
|
141
|
+
verbosity=verbosity - 3,
|
|
142
|
+
),
|
|
143
|
+
calc_farm=Dict(run=True, name="wio2fxs.calc_farm"),
|
|
144
|
+
outputs=Dict(name="wio2fxs.outputs"),
|
|
145
|
+
name="wio2fxs",
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
mbook = ModelBook()
|
|
149
|
+
states = _read_site(wio_dict, verbosity)
|
|
150
|
+
farm = _read_farm(wio_dict, mbook, verbosity)
|
|
151
|
+
|
|
152
|
+
odir = read_attributes(wio_dict, idict, mbook, verbosity=verbosity)
|
|
153
|
+
|
|
154
|
+
return idict, states, farm, mbook, odir
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def foxes_windio():
|
|
158
|
+
"""
|
|
159
|
+
Command line tool for running foxes from windio yaml file input.
|
|
160
|
+
|
|
161
|
+
Examples
|
|
162
|
+
--------
|
|
163
|
+
>>> foxes_windio input.yaml
|
|
164
|
+
|
|
165
|
+
:group: input.yaml.windio
|
|
166
|
+
|
|
167
|
+
"""
|
|
168
|
+
|
|
169
|
+
parser = argparse.ArgumentParser()
|
|
170
|
+
parser.add_argument(
|
|
171
|
+
"yml_file",
|
|
172
|
+
help="The windio yaml file",
|
|
173
|
+
)
|
|
174
|
+
parser.add_argument("-o", "--out_dir", help="The output directory", default=None)
|
|
175
|
+
parser.add_argument("-r", "--rotor", help="The rotor model", default="centre")
|
|
176
|
+
parser.add_argument(
|
|
177
|
+
"-p", "--pwakes", help="The partial wakes models", default="centre", nargs="+"
|
|
178
|
+
)
|
|
179
|
+
parser.add_argument(
|
|
180
|
+
"-w",
|
|
181
|
+
"--wakes",
|
|
182
|
+
help="The wake models",
|
|
183
|
+
default=["Jensen_linear_k007"],
|
|
184
|
+
nargs="+",
|
|
185
|
+
)
|
|
186
|
+
parser.add_argument("-f", "--frame", help="The wake frame", default="rotor_wd")
|
|
187
|
+
parser.add_argument("-e", "--engine", help="The engine", default=None)
|
|
188
|
+
parser.add_argument(
|
|
189
|
+
"-n", "--n_procs", help="The number of processes", default=None, type=int
|
|
190
|
+
)
|
|
191
|
+
parser.add_argument(
|
|
192
|
+
"-c",
|
|
193
|
+
"--chunksize_states",
|
|
194
|
+
help="The chunk size for states",
|
|
195
|
+
default=None,
|
|
196
|
+
type=int,
|
|
197
|
+
)
|
|
198
|
+
parser.add_argument(
|
|
199
|
+
"-C",
|
|
200
|
+
"--chunksize_points",
|
|
201
|
+
help="The chunk size for points",
|
|
202
|
+
default=5000,
|
|
203
|
+
type=int,
|
|
204
|
+
)
|
|
205
|
+
parser.add_argument(
|
|
206
|
+
"-it", "--iterative", help="Use iterative algorithm", action="store_true"
|
|
207
|
+
)
|
|
208
|
+
parser.add_argument(
|
|
209
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
210
|
+
)
|
|
211
|
+
parser.add_argument(
|
|
212
|
+
"-v",
|
|
213
|
+
"--verbosity",
|
|
214
|
+
help="The verbosity level, 0 = silent",
|
|
215
|
+
type=int,
|
|
216
|
+
default=None,
|
|
217
|
+
)
|
|
218
|
+
args = parser.parse_args()
|
|
219
|
+
|
|
220
|
+
v = 1 if args.verbosity is None else args.verbosity
|
|
221
|
+
|
|
222
|
+
def _print(*args, level=1, **kwargs):
|
|
223
|
+
if v >= level:
|
|
224
|
+
print(*args, **kwargs)
|
|
225
|
+
|
|
226
|
+
if (
|
|
227
|
+
args.engine is not None
|
|
228
|
+
or args.n_procs is not None
|
|
229
|
+
or args.chunksize_states is not None
|
|
230
|
+
or args.chunksize_points is not None
|
|
231
|
+
):
|
|
232
|
+
epars = dict(
|
|
233
|
+
engine_type=args.engine,
|
|
234
|
+
n_procs=args.n_procs,
|
|
235
|
+
chunk_size_states=args.chunksize_states,
|
|
236
|
+
chunk_size_points=args.chunksize_points,
|
|
237
|
+
verbosity=v,
|
|
238
|
+
)
|
|
239
|
+
else:
|
|
240
|
+
epars = None
|
|
241
|
+
|
|
242
|
+
wio_file = Path(args.yml_file)
|
|
243
|
+
_print(f"Reading windio file {wio_file}")
|
|
244
|
+
yml_utils = import_module(
|
|
245
|
+
"windIO.utils.yml_utils",
|
|
246
|
+
hint="pip install git+https://github.com/kilojoules/windIO@master#egg=windIO",
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
wio = Dict(yml_utils.load_yaml(wio_file), name="windio")
|
|
250
|
+
idict, states, farm, mbook, odir = read_windio(wio, verbosity=v)
|
|
251
|
+
|
|
252
|
+
if args.out_dir is not None:
|
|
253
|
+
odir = args.odir
|
|
254
|
+
|
|
255
|
+
run_dict(
|
|
256
|
+
idict,
|
|
257
|
+
farm=farm,
|
|
258
|
+
states=states,
|
|
259
|
+
mbook=mbook,
|
|
260
|
+
rotor_model=args.rotor,
|
|
261
|
+
partial_wakes=args.pwakes,
|
|
262
|
+
wake_models=args.wakes,
|
|
263
|
+
wake_frame=args.frame,
|
|
264
|
+
engine_pars=epars,
|
|
265
|
+
iterative=args.iterative,
|
|
266
|
+
work_dir=wio_file.parent,
|
|
267
|
+
out_dir=odir,
|
|
268
|
+
verbosity=args.verbosity,
|
|
269
|
+
)
|
foxes/input/yaml/yaml.py
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from foxes.utils import Dict
|
|
5
|
+
|
|
6
|
+
from .dict import run_dict
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def foxes_yaml():
|
|
10
|
+
"""
|
|
11
|
+
Command line tool for running foxes from yaml file input.
|
|
12
|
+
|
|
13
|
+
Examples
|
|
14
|
+
--------
|
|
15
|
+
>>> foxes_yaml input.yaml
|
|
16
|
+
|
|
17
|
+
:group: input.yaml
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
parser = argparse.ArgumentParser()
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"yml_file",
|
|
24
|
+
help="The input yaml file",
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument("-o", "--out_dir", help="The output directory", default=".")
|
|
27
|
+
parser.add_argument("-r", "--rotor", help="The rotor model", default="centre")
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"-p", "--pwakes", help="The partial wakes models", default="centre", nargs="+"
|
|
30
|
+
)
|
|
31
|
+
parser.add_argument(
|
|
32
|
+
"-w",
|
|
33
|
+
"--wakes",
|
|
34
|
+
help="The wake models",
|
|
35
|
+
default=["Jensen_linear_k007"],
|
|
36
|
+
nargs="+",
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument("-f", "--frame", help="The wake frame", default="rotor_wd")
|
|
39
|
+
parser.add_argument("-e", "--engine", help="The engine", default=None)
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
"-n", "--n_procs", help="The number of processes", default=None, type=int
|
|
42
|
+
)
|
|
43
|
+
parser.add_argument(
|
|
44
|
+
"-c",
|
|
45
|
+
"--chunksize_states",
|
|
46
|
+
help="The chunk size for states",
|
|
47
|
+
default=None,
|
|
48
|
+
type=int,
|
|
49
|
+
)
|
|
50
|
+
parser.add_argument(
|
|
51
|
+
"-C",
|
|
52
|
+
"--chunksize_points",
|
|
53
|
+
help="The chunk size for points",
|
|
54
|
+
default=5000,
|
|
55
|
+
type=int,
|
|
56
|
+
)
|
|
57
|
+
parser.add_argument(
|
|
58
|
+
"-it", "--iterative", help="Use iterative algorithm", action="store_true"
|
|
59
|
+
)
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
62
|
+
)
|
|
63
|
+
parser.add_argument(
|
|
64
|
+
"-v",
|
|
65
|
+
"--verbosity",
|
|
66
|
+
help="The verbosity level, 0 = silent",
|
|
67
|
+
type=int,
|
|
68
|
+
default=None,
|
|
69
|
+
)
|
|
70
|
+
args = parser.parse_args()
|
|
71
|
+
|
|
72
|
+
v = 1 if args.verbosity is None else args.verbosity
|
|
73
|
+
fpath = Path(args.yml_file)
|
|
74
|
+
idata = Dict.from_yaml(fpath, verbosity=v)
|
|
75
|
+
|
|
76
|
+
if (
|
|
77
|
+
args.engine is not None
|
|
78
|
+
or args.n_procs is not None
|
|
79
|
+
or args.chunksize_states is not None
|
|
80
|
+
or args.chunksize_points is not None
|
|
81
|
+
):
|
|
82
|
+
epars = dict(
|
|
83
|
+
engine_type=args.engine,
|
|
84
|
+
n_procs=args.n_procs,
|
|
85
|
+
chunk_size_states=args.chunksize_states,
|
|
86
|
+
chunk_size_points=args.chunksize_points,
|
|
87
|
+
verbosity=v,
|
|
88
|
+
)
|
|
89
|
+
else:
|
|
90
|
+
epars = None
|
|
91
|
+
|
|
92
|
+
run_dict(
|
|
93
|
+
idata,
|
|
94
|
+
rotor_model=args.rotor,
|
|
95
|
+
partial_wakes=args.pwakes,
|
|
96
|
+
wake_models=args.wakes,
|
|
97
|
+
wake_frame=args.frame,
|
|
98
|
+
engine_pars=epars,
|
|
99
|
+
iterative=args.iterative,
|
|
100
|
+
work_dir=fpath.parent,
|
|
101
|
+
out_dir=args.out_dir,
|
|
102
|
+
verbosity=args.verbosity,
|
|
103
|
+
)
|
|
@@ -2,6 +2,7 @@ import numpy as np
|
|
|
2
2
|
|
|
3
3
|
from foxes.models.wake_models.axisymmetric import AxisymmetricWakeModel
|
|
4
4
|
from foxes.utils.two_circles import calc_area
|
|
5
|
+
from foxes.config import config
|
|
5
6
|
import foxes.variables as FV
|
|
6
7
|
import foxes.constants as FC
|
|
7
8
|
|
|
@@ -130,11 +131,11 @@ class PartialAxiwake(PartialCentre):
|
|
|
130
131
|
x = wcoos[..., 0, 0]
|
|
131
132
|
n = wcoos[..., 0, 1:3]
|
|
132
133
|
R = np.linalg.norm(n, axis=-1)
|
|
133
|
-
r = np.zeros((n_states, n_targets, self.n), dtype=
|
|
134
|
+
r = np.zeros((n_states, n_targets, self.n), dtype=config.dtype_double)
|
|
134
135
|
del wcoos
|
|
135
136
|
|
|
136
137
|
# prepare circle section area calculation:
|
|
137
|
-
A = np.zeros((n_states, n_targets, self.n), dtype=
|
|
138
|
+
A = np.zeros((n_states, n_targets, self.n), dtype=config.dtype_double)
|
|
138
139
|
weights = np.zeros_like(A)
|
|
139
140
|
|
|
140
141
|
# get normalized 2D vector between rotor and wake centres:
|
|
@@ -148,12 +149,12 @@ class PartialAxiwake(PartialCentre):
|
|
|
148
149
|
sel = (x > 1e-8) & (R > D / 2)
|
|
149
150
|
if np.any(sel):
|
|
150
151
|
n_sel = np.sum(sel)
|
|
151
|
-
Rsel = np.zeros((n_sel, self.n + 1), dtype=
|
|
152
|
+
Rsel = np.zeros((n_sel, self.n + 1), dtype=config.dtype_double)
|
|
152
153
|
Rsel[:] = R[sel][:, None]
|
|
153
154
|
Dsel = D[sel][:, None]
|
|
154
155
|
|
|
155
156
|
# equal delta R2:
|
|
156
|
-
R1 = np.zeros((n_sel, self.n + 1), dtype=
|
|
157
|
+
R1 = np.zeros((n_sel, self.n + 1), dtype=config.dtype_double)
|
|
157
158
|
R1[:] = Dsel / 2
|
|
158
159
|
steps = np.linspace(0.0, 1.0, self.n + 1, endpoint=True) - 0.5
|
|
159
160
|
R2 = np.zeros_like(R1)
|
|
@@ -170,12 +171,12 @@ class PartialAxiwake(PartialCentre):
|
|
|
170
171
|
sel = (x > 0) & (R < D / 2)
|
|
171
172
|
if np.any(sel):
|
|
172
173
|
n_sel = np.sum(sel)
|
|
173
|
-
Rsel = np.zeros((n_sel, self.n + 1), dtype=
|
|
174
|
+
Rsel = np.zeros((n_sel, self.n + 1), dtype=config.dtype_double)
|
|
174
175
|
Rsel[:] = R[sel][:, None]
|
|
175
176
|
Dsel = D[sel][:, None]
|
|
176
177
|
|
|
177
178
|
# equal delta R2:
|
|
178
|
-
R1 = np.zeros((n_sel, self.n + 1), dtype=
|
|
179
|
+
R1 = np.zeros((n_sel, self.n + 1), dtype=config.dtype_double)
|
|
179
180
|
R1[:, 1:] = Dsel / 2
|
|
180
181
|
R2 = np.zeros_like(R1)
|
|
181
182
|
# R2[:, 1:] = Rsel[:, :-1] + Dsel/2
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
3
|
import foxes.variables as FV
|
|
4
|
-
|
|
4
|
+
from foxes.config import config
|
|
5
|
+
|
|
5
6
|
from .rotor_points import RotorPoints
|
|
6
7
|
|
|
7
8
|
|
|
@@ -37,4 +38,4 @@ class PartialCentre(RotorPoints):
|
|
|
37
38
|
The target point weights, shape: (n_tpoints,)
|
|
38
39
|
|
|
39
40
|
"""
|
|
40
|
-
return fdata[FV.TXYH][:, :, None], np.ones(1, dtype=
|
|
41
|
+
return fdata[FV.TXYH][:, :, None], np.ones(1, dtype=config.dtype_double)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
3
|
from foxes.core import PartialWakesModel
|
|
4
|
+
from foxes.config import config
|
|
4
5
|
import foxes.variables as FV
|
|
5
6
|
import foxes.constants as FC
|
|
6
7
|
|
|
@@ -143,7 +144,9 @@ class PartialSegregated(PartialWakesModel):
|
|
|
143
144
|
else:
|
|
144
145
|
ares = {}
|
|
145
146
|
for v, d in amb_res.items():
|
|
146
|
-
ares[v] = np.zeros(
|
|
147
|
+
ares[v] = np.zeros(
|
|
148
|
+
(n_states, 1, tdata.n_tpoints), dtype=config.dtype_double
|
|
149
|
+
)
|
|
147
150
|
ares[v][:] = np.einsum("sp,p->s", d[:, downwind_index], rpoint_weights)[
|
|
148
151
|
:, None, None
|
|
149
152
|
]
|
|
@@ -151,7 +154,7 @@ class PartialSegregated(PartialWakesModel):
|
|
|
151
154
|
wmodel.finalize_wake_deltas(algo, mdata, fdata, ares, wdel)
|
|
152
155
|
|
|
153
156
|
for v in wdel.keys():
|
|
154
|
-
hdel = np.zeros((n_states, n_rotor_points), dtype=
|
|
157
|
+
hdel = np.zeros((n_states, n_rotor_points), dtype=config.dtype_double)
|
|
155
158
|
hdel[:] = np.einsum("sp,p->s", wdel[v][:, 0], gweights)[:, None]
|
|
156
159
|
wdel[v] = hdel
|
|
157
160
|
|
|
@@ -2,8 +2,8 @@ import pandas as pd
|
|
|
2
2
|
|
|
3
3
|
from foxes.core.point_data_model import PointDataModel
|
|
4
4
|
from foxes.utils import PandasFileHelper
|
|
5
|
+
from foxes.config import config
|
|
5
6
|
import foxes.constants as FC
|
|
6
|
-
import foxes.variables as FV
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class SetUniformData(PointDataModel):
|
|
@@ -84,7 +84,7 @@ class SetUniformData(PointDataModel):
|
|
|
84
84
|
if isinstance(self.data_source, pd.DataFrame):
|
|
85
85
|
data = self.data_source[
|
|
86
86
|
[self.var2col.get(v, v) for v in self.ovars]
|
|
87
|
-
].to_numpy(
|
|
87
|
+
].to_numpy(config.dtype_double)
|
|
88
88
|
elif isinstance(self.data_source, dict):
|
|
89
89
|
pass
|
|
90
90
|
else:
|
|
@@ -93,7 +93,9 @@ class SetUniformData(PointDataModel):
|
|
|
93
93
|
rpars = dict(index_col=0)
|
|
94
94
|
rpars.update(self._rpars)
|
|
95
95
|
data = PandasFileHelper().read_file(self.data_source, **rpars)
|
|
96
|
-
data = data[[self.var2col.get(v, v) for v in self.ovars]].to_numpy(
|
|
96
|
+
data = data[[self.var2col.get(v, v) for v in self.ovars]].to_numpy(
|
|
97
|
+
config.dtype_double
|
|
98
|
+
)
|
|
97
99
|
|
|
98
100
|
idata = super().load_data(algo, verbosity)
|
|
99
101
|
idata["coords"][self.VARS] = self.ovars
|
|
@@ -3,7 +3,7 @@ import numpy as np
|
|
|
3
3
|
from foxes.core import RotorModel
|
|
4
4
|
from foxes.utils import wd2uv, uv2wd
|
|
5
5
|
import foxes.variables as FV
|
|
6
|
-
|
|
6
|
+
from foxes.config import config
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class CentreRotor(RotorModel):
|
|
@@ -155,7 +155,7 @@ class CentreRotor(RotorModel):
|
|
|
155
155
|
vdone = []
|
|
156
156
|
for v in self.calc_vars:
|
|
157
157
|
if v not in fdata:
|
|
158
|
-
fdata[v] = np.zeros((n_states, n_turbines), dtype=
|
|
158
|
+
fdata[v] = np.zeros((n_states, n_turbines), dtype=config.dtype_double)
|
|
159
159
|
|
|
160
160
|
if v == FV.WD or v == FV.YAW:
|
|
161
161
|
if wd is None:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
3
|
from foxes.core import RotorModel
|
|
4
|
-
|
|
4
|
+
from foxes.config import config
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class GridRotor(RotorModel):
|
|
@@ -75,12 +75,12 @@ class GridRotor(RotorModel):
|
|
|
75
75
|
x = [-1.0 + (i + 0.5) * delta for i in range(self.n)]
|
|
76
76
|
x, y = np.meshgrid(x, x, indexing="ij")
|
|
77
77
|
|
|
78
|
-
self.__dpoints = np.zeros([N, 3], dtype=
|
|
78
|
+
self.__dpoints = np.zeros([N, 3], dtype=config.dtype_double)
|
|
79
79
|
self.__dpoints[:, 1] = x.reshape(N)
|
|
80
80
|
self.__dpoints[:, 2] = y.reshape(N)
|
|
81
81
|
|
|
82
82
|
if self.reduce:
|
|
83
|
-
self.__weights = np.zeros((self.n, self.n), dtype=
|
|
83
|
+
self.__weights = np.zeros((self.n, self.n), dtype=config.dtype_double)
|
|
84
84
|
for i in range(0, self.n):
|
|
85
85
|
for j in range(0, self.n):
|
|
86
86
|
d = delta / self.nint
|
|
@@ -90,7 +90,7 @@ class GridRotor(RotorModel):
|
|
|
90
90
|
hy = [
|
|
91
91
|
y[i, j] - delta / 2.0 + (k + 0.5) * d for k in range(self.nint)
|
|
92
92
|
]
|
|
93
|
-
pts = np.zeros((self.nint, self.nint, 2), dtype=
|
|
93
|
+
pts = np.zeros((self.nint, self.nint, 2), dtype=config.dtype_double)
|
|
94
94
|
pts[:, :, 0], pts[:, :, 1] = np.meshgrid(hx, hy, indexing="ij")
|
|
95
95
|
|
|
96
96
|
d = np.linalg.norm(pts, axis=2)
|
|
@@ -105,7 +105,7 @@ class GridRotor(RotorModel):
|
|
|
105
105
|
else:
|
|
106
106
|
self.__dpoints[:, 1] = x.reshape(N)
|
|
107
107
|
self.__dpoints[:, 2] = y.reshape(N)
|
|
108
|
-
self.__weights = np.ones(N, dtype=
|
|
108
|
+
self.__weights = np.ones(N, dtype=config.dtype_double) / N
|
|
109
109
|
|
|
110
110
|
def n_rotor_points(self):
|
|
111
111
|
"""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
3
|
from foxes.core import RotorModel
|
|
4
|
-
|
|
4
|
+
from foxes.config import config
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class LevelRotor(RotorModel):
|
|
@@ -69,20 +69,20 @@ class LevelRotor(RotorModel):
|
|
|
69
69
|
|
|
70
70
|
delta = 2.0 / self.n
|
|
71
71
|
y = [-1.0 + (i + 0.5) * delta for i in range(self.n)]
|
|
72
|
-
x = np.zeros(self.n, dtype=
|
|
72
|
+
x = np.zeros(self.n, dtype=config.dtype_double)
|
|
73
73
|
|
|
74
|
-
self.dpoints = np.zeros([self.n, 3], dtype=
|
|
74
|
+
self.dpoints = np.zeros([self.n, 3], dtype=config.dtype_double)
|
|
75
75
|
self.dpoints[:, 1] = x
|
|
76
76
|
self.dpoints[:, 2] = y
|
|
77
77
|
|
|
78
78
|
if self.reduce:
|
|
79
|
-
self.weights = np.zeros((self.n), dtype=
|
|
79
|
+
self.weights = np.zeros((self.n), dtype=config.dtype_double)
|
|
80
80
|
hx = np.linspace(1, -1, self.nint)
|
|
81
81
|
|
|
82
82
|
for i in range(0, self.n):
|
|
83
83
|
d = delta / self.nint
|
|
84
84
|
hy = [y[i] - delta / 2.0 + (k + 0.5) * d for k in range(self.nint)]
|
|
85
|
-
pts = np.zeros((self.nint, self.nint, 2), dtype=
|
|
85
|
+
pts = np.zeros((self.nint, self.nint, 2), dtype=config.dtype_double)
|
|
86
86
|
pts[:, :, 0], pts[:, :, 1] = np.meshgrid(hx, hy, indexing="ij")
|
|
87
87
|
|
|
88
88
|
d = np.linalg.norm(pts, axis=2)
|
|
@@ -96,7 +96,7 @@ class LevelRotor(RotorModel):
|
|
|
96
96
|
else:
|
|
97
97
|
self.dpoints[:, 1] = x
|
|
98
98
|
self.dpoints[:, 2] = y
|
|
99
|
-
self.weights = np.ones(self.n, dtype=
|
|
99
|
+
self.weights = np.ones(self.n, dtype=config.dtype_double) / self.n
|
|
100
100
|
|
|
101
101
|
def n_rotor_points(self):
|
|
102
102
|
"""
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
3
|
from foxes.core import TurbineModel
|
|
4
|
+
from foxes.config import config
|
|
4
5
|
import foxes.variables as FV
|
|
5
6
|
import foxes.constants as FC
|
|
6
7
|
|
|
@@ -128,7 +129,8 @@ class kTI(TurbineModel):
|
|
|
128
129
|
)
|
|
129
130
|
|
|
130
131
|
k = fdata.get(
|
|
131
|
-
self.k_var,
|
|
132
|
+
self.k_var,
|
|
133
|
+
np.zeros((fdata.n_states, fdata.n_turbines), dtype=config.dtype_double),
|
|
132
134
|
)
|
|
133
135
|
|
|
134
136
|
k[st_sel] = kti * ti + kb
|
|
@@ -4,6 +4,7 @@ import xarray as xr
|
|
|
4
4
|
|
|
5
5
|
from foxes.core import TurbineModel
|
|
6
6
|
from foxes.utils import PandasFileHelper
|
|
7
|
+
from foxes.config import config, get_path
|
|
7
8
|
import foxes.constants as FC
|
|
8
9
|
|
|
9
10
|
|
|
@@ -127,9 +128,10 @@ class LookupTable(TurbineModel):
|
|
|
127
128
|
if isinstance(self.data_source, pd.DataFrame):
|
|
128
129
|
data = self.data_source
|
|
129
130
|
else:
|
|
131
|
+
fpath = get_path(self.data_source)
|
|
130
132
|
if verbosity > 0:
|
|
131
|
-
print(f"{self.name}: Reading file {
|
|
132
|
-
data = PandasFileHelper.read_file(
|
|
133
|
+
print(f"{self.name}: Reading file {fpath}")
|
|
134
|
+
data = PandasFileHelper.read_file(fpath, **self._rpars)
|
|
133
135
|
|
|
134
136
|
if verbosity > 0:
|
|
135
137
|
print(f"{self.name}: Preparing interpolation data")
|
|
@@ -138,7 +140,8 @@ class LookupTable(TurbineModel):
|
|
|
138
140
|
data = data[self.input_vars + self.output_vars]
|
|
139
141
|
data.sort_values(by=self.input_vars, inplace=True)
|
|
140
142
|
coords = {
|
|
141
|
-
v: np.asarray(data[v].unique(), dtype=
|
|
143
|
+
v: np.asarray(data[v].unique(), dtype=config.dtype_double)
|
|
144
|
+
for v in self.input_vars
|
|
142
145
|
}
|
|
143
146
|
|
|
144
147
|
dvars = {}
|
|
@@ -146,7 +149,7 @@ class LookupTable(TurbineModel):
|
|
|
146
149
|
pivot_matrix = data.pivot_table(index=self.input_vars, values=[oname])
|
|
147
150
|
dvars[oname] = (
|
|
148
151
|
self.input_vars,
|
|
149
|
-
pivot_matrix.to_numpy(
|
|
152
|
+
pivot_matrix.to_numpy(config.dtype_double).reshape(
|
|
150
153
|
pivot_matrix.index.levshape
|
|
151
154
|
),
|
|
152
155
|
)
|