foxes 0.8.2__py3-none-any.whl → 1.1.0.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 +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/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 +190 -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 +247 -111
- foxes/algorithms/downwind/models/farm_wakes_calc.py +12 -7
- foxes/algorithms/downwind/models/init_farm_data.py +2 -2
- foxes/algorithms/downwind/models/point_wakes_calc.py +6 -7
- foxes/algorithms/downwind/models/reorder_farm_output.py +1 -2
- foxes/algorithms/downwind/models/set_amb_farm_results.py +1 -1
- foxes/algorithms/downwind/models/set_amb_point_results.py +5 -3
- foxes/algorithms/iterative/iterative.py +74 -34
- foxes/algorithms/iterative/models/farm_wakes_calc.py +12 -7
- foxes/algorithms/iterative/models/urelax.py +3 -3
- foxes/algorithms/sequential/models/plugin.py +5 -5
- foxes/algorithms/sequential/models/seq_state.py +1 -1
- foxes/algorithms/sequential/sequential.py +126 -255
- foxes/constants.py +22 -7
- foxes/core/__init__.py +1 -0
- foxes/core/algorithm.py +632 -147
- foxes/core/data.py +252 -20
- foxes/core/data_calc_model.py +15 -291
- foxes/core/engine.py +640 -0
- foxes/core/farm_controller.py +38 -10
- foxes/core/farm_data_model.py +16 -1
- foxes/core/ground_model.py +2 -2
- foxes/core/model.py +249 -182
- foxes/core/partial_wakes_model.py +1 -1
- foxes/core/point_data_model.py +17 -2
- foxes/core/rotor_model.py +27 -21
- foxes/core/states.py +17 -1
- foxes/core/turbine_type.py +28 -0
- foxes/core/wake_frame.py +30 -34
- foxes/core/wake_model.py +5 -5
- foxes/core/wake_superposition.py +1 -1
- foxes/data/windio/windio_5turbines_timeseries.yaml +31 -15
- foxes/engines/__init__.py +17 -0
- foxes/engines/dask.py +982 -0
- foxes/engines/default.py +75 -0
- foxes/engines/futures.py +72 -0
- foxes/engines/mpi.py +38 -0
- foxes/engines/multiprocess.py +71 -0
- foxes/engines/numpy.py +167 -0
- foxes/engines/pool.py +249 -0
- foxes/engines/ray.py +79 -0
- foxes/engines/single.py +141 -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 +2 -2
- 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 +7 -0
- foxes/input/states/create/random_abl_states.py +1 -1
- foxes/input/states/field_data_nc.py +158 -33
- foxes/input/states/multi_height.py +128 -14
- foxes/input/states/one_point_flow.py +577 -0
- foxes/input/states/scan_ws.py +74 -3
- foxes/input/states/single.py +1 -1
- foxes/input/states/slice_data_nc.py +681 -0
- foxes/input/states/states_table.py +204 -35
- foxes/input/windio/__init__.py +2 -2
- foxes/input/windio/get_states.py +44 -23
- foxes/input/windio/read_attributes.py +48 -17
- foxes/input/windio/read_farm.py +116 -102
- foxes/input/windio/read_fields.py +16 -6
- foxes/input/windio/read_outputs.py +71 -24
- foxes/input/windio/runner.py +31 -17
- foxes/input/windio/windio.py +41 -23
- foxes/models/farm_models/turbine2farm.py +1 -1
- foxes/models/ground_models/wake_mirror.py +10 -6
- foxes/models/model_book.py +58 -20
- foxes/models/partial_wakes/axiwake.py +3 -3
- foxes/models/partial_wakes/rotor_points.py +3 -3
- foxes/models/partial_wakes/top_hat.py +2 -2
- foxes/models/point_models/set_uniform_data.py +1 -1
- foxes/models/point_models/tke2ti.py +1 -1
- foxes/models/point_models/wake_deltas.py +1 -1
- foxes/models/rotor_models/centre.py +4 -0
- foxes/models/rotor_models/grid.py +24 -25
- foxes/models/rotor_models/levels.py +4 -5
- foxes/models/turbine_models/calculator.py +4 -6
- foxes/models/turbine_models/kTI_model.py +22 -6
- foxes/models/turbine_models/lookup_table.py +30 -4
- 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 +27 -3
- foxes/models/turbine_types/PCt_from_two.py +27 -3
- foxes/models/turbine_types/TBL_file.py +80 -0
- foxes/models/turbine_types/__init__.py +2 -0
- foxes/models/turbine_types/lookup.py +316 -0
- foxes/models/turbine_types/null_type.py +51 -1
- foxes/models/turbine_types/wsrho2PCt_from_two.py +29 -5
- foxes/models/turbine_types/wsti2PCt_from_two.py +31 -7
- foxes/models/vertical_profiles/__init__.py +1 -1
- 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 +25 -5
- foxes/models/wake_frames/rotor_wd.py +6 -4
- foxes/models/wake_frames/seq_dynamic_wakes.py +61 -74
- foxes/models/wake_frames/streamlines.py +21 -22
- foxes/models/wake_frames/timelines.py +330 -129
- foxes/models/wake_frames/yawed_wakes.py +7 -4
- foxes/models/wake_models/dist_sliced.py +2 -4
- foxes/models/wake_models/induction/rankine_half_body.py +5 -5
- foxes/models/wake_models/induction/rathmann.py +78 -24
- foxes/models/wake_models/induction/self_similar.py +78 -28
- foxes/models/wake_models/induction/vortex_sheet.py +86 -48
- foxes/models/wake_models/ti/crespo_hernandez.py +6 -4
- foxes/models/wake_models/ti/iec_ti.py +40 -21
- foxes/models/wake_models/top_hat.py +1 -1
- foxes/models/wake_models/wind/bastankhah14.py +8 -6
- foxes/models/wake_models/wind/bastankhah16.py +17 -16
- foxes/models/wake_models/wind/jensen.py +4 -3
- foxes/models/wake_models/wind/turbopark.py +16 -13
- foxes/models/wake_superpositions/ti_linear.py +1 -1
- foxes/models/wake_superpositions/ti_max.py +1 -1
- foxes/models/wake_superpositions/ti_pow.py +1 -1
- foxes/models/wake_superpositions/ti_quadratic.py +1 -1
- foxes/models/wake_superpositions/ws_linear.py +8 -7
- foxes/models/wake_superpositions/ws_max.py +8 -7
- foxes/models/wake_superpositions/ws_pow.py +8 -7
- foxes/models/wake_superpositions/ws_product.py +5 -5
- foxes/models/wake_superpositions/ws_quadratic.py +8 -7
- foxes/output/__init__.py +4 -1
- foxes/output/farm_layout.py +16 -12
- foxes/output/farm_results_eval.py +1 -1
- foxes/output/flow_plots_2d/__init__.py +0 -1
- foxes/output/flow_plots_2d/flow_plots.py +70 -30
- foxes/output/grids.py +92 -22
- foxes/output/results_writer.py +2 -2
- foxes/output/rose_plot.py +3 -3
- foxes/output/seq_plugins/__init__.py +2 -0
- foxes/output/{flow_plots_2d → seq_plugins}/seq_flow_ani_plugin.py +64 -22
- foxes/output/seq_plugins/seq_wake_debug_plugin.py +145 -0
- foxes/output/slice_data.py +131 -111
- foxes/output/state_turbine_map.py +19 -14
- foxes/output/state_turbine_table.py +19 -19
- foxes/utils/__init__.py +1 -1
- foxes/utils/abl/neutral.py +2 -2
- foxes/utils/abl/stable.py +2 -2
- foxes/utils/abl/unstable.py +2 -2
- foxes/utils/data_book.py +1 -1
- foxes/utils/dev_utils.py +42 -0
- foxes/utils/dict.py +24 -1
- foxes/utils/exec_python.py +1 -1
- foxes/utils/factory.py +176 -53
- foxes/utils/geom2d/circle.py +1 -1
- foxes/utils/geom2d/polygon.py +1 -1
- foxes/utils/geopandas_utils.py +2 -2
- foxes/utils/load.py +2 -2
- foxes/utils/pandas_helpers.py +3 -2
- foxes/utils/wind_dir.py +0 -2
- foxes/utils/xarray_utils.py +24 -14
- foxes/variables.py +39 -2
- {foxes-0.8.2.dist-info → foxes-1.1.0.2.dist-info}/METADATA +75 -33
- foxes-1.1.0.2.dist-info/RECORD +309 -0
- {foxes-0.8.2.dist-info → foxes-1.1.0.2.dist-info}/WHEEL +1 -1
- foxes-1.1.0.2.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/geopandas_helpers.py +0 -294
- 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.1.0.2.dist-info}/LICENSE +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import inspect
|
|
3
|
+
|
|
4
|
+
import foxes
|
|
5
|
+
import foxes.variables as FV
|
|
6
|
+
import foxes.constants as FC
|
|
7
|
+
|
|
8
|
+
thisdir = Path(inspect.getfile(inspect.currentframe())).parent
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test():
|
|
12
|
+
c = 1000
|
|
13
|
+
ttype = "DTU10MW"
|
|
14
|
+
sfile = "wind_rose_bremen.csv"
|
|
15
|
+
lfile = thisdir / "test_farm.csv"
|
|
16
|
+
cases = [
|
|
17
|
+
(foxes.algorithms.Downwind, "rotor_wd"),
|
|
18
|
+
(foxes.algorithms.Iterative, "rotor_wd"),
|
|
19
|
+
(foxes.algorithms.Iterative, "rotor_wd_farmo"),
|
|
20
|
+
]
|
|
21
|
+
lims = {FV.REWS: 5e-7, FV.P: 5e-4}
|
|
22
|
+
|
|
23
|
+
ck = {FC.STATE: c}
|
|
24
|
+
|
|
25
|
+
base_results = None
|
|
26
|
+
for Algo, frame in cases:
|
|
27
|
+
print(f"\nENTERING CASE {(Algo.__name__, frame)}\n")
|
|
28
|
+
|
|
29
|
+
mbook = foxes.models.ModelBook()
|
|
30
|
+
|
|
31
|
+
states = foxes.input.states.StatesTable(
|
|
32
|
+
data_source=sfile,
|
|
33
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
|
|
34
|
+
var2col={FV.WS: "ws", FV.WD: "wd", FV.WEIGHT: "weight"},
|
|
35
|
+
fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
farm = foxes.WindFarm()
|
|
39
|
+
foxes.input.farm_layout.add_from_file(
|
|
40
|
+
farm, lfile, turbine_models=[ttype], verbosity=1
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
kwargs = {}
|
|
44
|
+
if Algo is foxes.algorithms.Iterative:
|
|
45
|
+
kwargs["mod_cutin"] = {"modify_ct": False, "modify_P": False}
|
|
46
|
+
|
|
47
|
+
algo = Algo(
|
|
48
|
+
farm,
|
|
49
|
+
states,
|
|
50
|
+
mbook=mbook,
|
|
51
|
+
rotor_model="grid16",
|
|
52
|
+
wake_models=["Bastankhah2014_linear_k004", "IECTI2019_max"],
|
|
53
|
+
wake_frame=frame,
|
|
54
|
+
partial_wakes="rotor_points",
|
|
55
|
+
chunks=ck,
|
|
56
|
+
verbosity=1,
|
|
57
|
+
**kwargs,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# f Algo is foxes.algorithms.Iterative:
|
|
61
|
+
# algo.set_urelax("post_rotor", CT=0.9)
|
|
62
|
+
|
|
63
|
+
data = algo.calc_farm()
|
|
64
|
+
|
|
65
|
+
df = data.to_dataframe()[
|
|
66
|
+
[FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
print()
|
|
70
|
+
print("TRESULTS\n")
|
|
71
|
+
print(df)
|
|
72
|
+
|
|
73
|
+
df = df.reset_index()
|
|
74
|
+
|
|
75
|
+
if base_results is None:
|
|
76
|
+
base_results = df
|
|
77
|
+
|
|
78
|
+
else:
|
|
79
|
+
print(f"CASE {(Algo.__name__, frame)}")
|
|
80
|
+
delta = df - base_results
|
|
81
|
+
print(delta)
|
|
82
|
+
print(delta.min(), delta.max())
|
|
83
|
+
|
|
84
|
+
for v, lim in lims.items():
|
|
85
|
+
chk = delta[v].abs().loc[df["AMB_REWS"] > 7]
|
|
86
|
+
print(f"CASE {(Algo.__name__, frame, v, lim)}:", chk.max())
|
|
87
|
+
|
|
88
|
+
assert (chk < lim).all()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
test()
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import inspect
|
|
3
|
+
|
|
4
|
+
import foxes
|
|
5
|
+
import foxes.variables as FV
|
|
6
|
+
import foxes.constants as FC
|
|
7
|
+
|
|
8
|
+
thisdir = Path(inspect.getfile(inspect.currentframe())).parent
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test():
|
|
12
|
+
c = 180
|
|
13
|
+
tfile = thisdir / "NREL-5MW-D126-H90.csv"
|
|
14
|
+
sfile = thisdir / "states.csv.gz"
|
|
15
|
+
lfile = thisdir / "test_farm.csv"
|
|
16
|
+
cases = [
|
|
17
|
+
("grid400", "rotor_points", None),
|
|
18
|
+
("grid4", "rotor_points", 0.15),
|
|
19
|
+
("grid9", "rotor_points", 0.07),
|
|
20
|
+
("centre", "axiwake5", 0.03),
|
|
21
|
+
("centre", "axiwake10", 0.0081),
|
|
22
|
+
("centre", "grid9", 0.07),
|
|
23
|
+
("centre", "grid16", 0.05),
|
|
24
|
+
("centre", "grid36", 0.025),
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
ck = {FC.STATE: c}
|
|
28
|
+
|
|
29
|
+
base_results = None
|
|
30
|
+
for rotor, pwake, lim in cases:
|
|
31
|
+
print(f"\nENTERING CASE {(rotor, pwake, lim)}\n")
|
|
32
|
+
|
|
33
|
+
mbook = foxes.models.ModelBook()
|
|
34
|
+
ttype = foxes.models.turbine_types.PCtFile(
|
|
35
|
+
data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
|
|
36
|
+
)
|
|
37
|
+
mbook.turbine_types[ttype.name] = ttype
|
|
38
|
+
|
|
39
|
+
states = foxes.input.states.StatesTable(
|
|
40
|
+
data_source=sfile,
|
|
41
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
|
|
42
|
+
var2col={FV.WS: "ws", FV.WD: "wd", FV.TI: "ti"},
|
|
43
|
+
fixed_vars={FV.RHO: 1.225},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
farm = foxes.WindFarm()
|
|
47
|
+
foxes.input.farm_layout.add_from_file(
|
|
48
|
+
farm, lfile, turbine_models=[ttype.name], verbosity=1
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
algo = foxes.algorithms.Downwind(
|
|
52
|
+
farm,
|
|
53
|
+
states,
|
|
54
|
+
mbook=mbook,
|
|
55
|
+
rotor_model=rotor,
|
|
56
|
+
wake_models=["Bastankhah025_linear_k002"],
|
|
57
|
+
wake_frame="rotor_wd",
|
|
58
|
+
partial_wakes=pwake,
|
|
59
|
+
chunks=ck,
|
|
60
|
+
verbosity=1,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
data = algo.calc_farm()
|
|
64
|
+
|
|
65
|
+
df = data.to_dataframe()[
|
|
66
|
+
[FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
print()
|
|
70
|
+
print("TRESULTS\n")
|
|
71
|
+
print(df)
|
|
72
|
+
|
|
73
|
+
df = df.reset_index()
|
|
74
|
+
|
|
75
|
+
if base_results is None:
|
|
76
|
+
base_results = df
|
|
77
|
+
|
|
78
|
+
else:
|
|
79
|
+
print(f"CASE {(rotor, pwake, lim)}")
|
|
80
|
+
delta = df - base_results
|
|
81
|
+
print(delta)
|
|
82
|
+
print(delta.min(), delta.max())
|
|
83
|
+
chk = delta[FV.REWS].abs()
|
|
84
|
+
print(f"CASE {(rotor, pwake, lim)}:", chk.max())
|
|
85
|
+
|
|
86
|
+
assert (chk < lim).all()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
test()
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import time
|
|
4
|
+
import argparse
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import flappy as fl
|
|
8
|
+
from flappy.config.variables import variables as FV
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
parser = argparse.ArgumentParser()
|
|
12
|
+
parser.add_argument(
|
|
13
|
+
"-c", "--chunksize", help="The maximal chunk size", type=int, default=500
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"-o", "--ofile", help="The output file name", default="results.csv.gz"
|
|
17
|
+
)
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"--n_cpus", help="The number of processors", type=int, default=4
|
|
20
|
+
)
|
|
21
|
+
args = parser.parse_args()
|
|
22
|
+
|
|
23
|
+
c = args.chunksize
|
|
24
|
+
p0 = np.array([0.0, 0.0])
|
|
25
|
+
stp = np.array([500.0, 0.0])
|
|
26
|
+
ofile = Path(args.ofile)
|
|
27
|
+
tPfile = "../NREL-5MW-D126-H90-P.csv"
|
|
28
|
+
tCtfile = "../NREL-5MW-D126-H90-Ct.csv"
|
|
29
|
+
sfile = "../states.csv.gz"
|
|
30
|
+
lfile = "../test_farm.csv"
|
|
31
|
+
|
|
32
|
+
# init flappy:
|
|
33
|
+
fl.init_flappy(n_cpus=args.n_cpus)
|
|
34
|
+
|
|
35
|
+
# load model book:
|
|
36
|
+
mbook = fl.ModelBook()
|
|
37
|
+
mbook.turbine_models[f"ws_P"] = fl.models.Ws2P(P_curve_file=tPfile)
|
|
38
|
+
mbook.turbine_models[f"ws_Ct"] = fl.models.Ws2Ct(ct_curve_file=tCtfile)
|
|
39
|
+
|
|
40
|
+
# create wind farm:
|
|
41
|
+
farm = fl.WindFarm()
|
|
42
|
+
fl.input.add_turbines_from_csv(
|
|
43
|
+
farm,
|
|
44
|
+
lfile,
|
|
45
|
+
col_index="index",
|
|
46
|
+
col_x="x",
|
|
47
|
+
col_y="y",
|
|
48
|
+
rotor_diameter=126.0,
|
|
49
|
+
hub_height=90.0,
|
|
50
|
+
rotor_model="centre",
|
|
51
|
+
wake_models=["Jensen007"],
|
|
52
|
+
turbine_models=["ws_P", "ws_Ct"],
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# create states:
|
|
56
|
+
states = fl.input.AFSStatesTable(
|
|
57
|
+
data_file=sfile,
|
|
58
|
+
col_wd="wd",
|
|
59
|
+
col_ws="ws",
|
|
60
|
+
col_ti="ti",
|
|
61
|
+
col_weight="weight",
|
|
62
|
+
air_density=1.225,
|
|
63
|
+
max_chunk_size=args.chunksize,
|
|
64
|
+
)
|
|
65
|
+
states.initialize()
|
|
66
|
+
|
|
67
|
+
time0 = time.time()
|
|
68
|
+
|
|
69
|
+
# run calculation:
|
|
70
|
+
results = farm.calculate(mbook, states, wake_superp=["wind_linear"])
|
|
71
|
+
|
|
72
|
+
time1 = time.time()
|
|
73
|
+
print("\nCalc time =", time1 - time0, "\n")
|
|
74
|
+
|
|
75
|
+
df = results.state_turbine_results[[FV.WD, FV.AMB_WS, FV.WS, FV.AMB_P, FV.P]]
|
|
76
|
+
|
|
77
|
+
print()
|
|
78
|
+
print("TRESULTS\n")
|
|
79
|
+
print(df)
|
|
80
|
+
|
|
81
|
+
print("\nWriting file", ofile)
|
|
82
|
+
df.to_csv(ofile)
|
|
83
|
+
|
|
84
|
+
# close flappy:
|
|
85
|
+
fl.shutdown_flappy()
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import inspect
|
|
4
|
+
|
|
5
|
+
import foxes
|
|
6
|
+
import foxes.variables as FV
|
|
7
|
+
import foxes.constants as FC
|
|
8
|
+
|
|
9
|
+
thisdir = Path(inspect.getfile(inspect.currentframe())).parent
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test():
|
|
13
|
+
print(thisdir)
|
|
14
|
+
|
|
15
|
+
c = 2000
|
|
16
|
+
cfile = thisdir / "flappy" / "results.csv.gz"
|
|
17
|
+
tPfile = thisdir / "NREL-5MW-D126-H90-P.csv"
|
|
18
|
+
tCtfile = thisdir / "NREL-5MW-D126-H90-Ct.csv"
|
|
19
|
+
sfile = thisdir / "states.csv.gz"
|
|
20
|
+
lfile = thisdir / "test_farm.csv"
|
|
21
|
+
|
|
22
|
+
ck = {FC.STATE: c}
|
|
23
|
+
|
|
24
|
+
mbook = foxes.models.ModelBook()
|
|
25
|
+
ttype = foxes.models.turbine_types.PCtFromTwo(
|
|
26
|
+
data_source_P=tPfile,
|
|
27
|
+
data_source_ct=tCtfile,
|
|
28
|
+
col_ws_P_file="ws",
|
|
29
|
+
col_ws_ct_file="ws",
|
|
30
|
+
col_P="P",
|
|
31
|
+
col_ct="ct",
|
|
32
|
+
P_nominal=5000,
|
|
33
|
+
H=90.0,
|
|
34
|
+
D=126,
|
|
35
|
+
name="power_and_ct_curve",
|
|
36
|
+
)
|
|
37
|
+
mbook.turbine_types[ttype.name] = ttype
|
|
38
|
+
|
|
39
|
+
states = foxes.input.states.StatesTable(
|
|
40
|
+
data_source=sfile,
|
|
41
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
|
|
42
|
+
var2col={FV.WS: "ws", FV.WD: "wd", FV.TI: "ti"},
|
|
43
|
+
fixed_vars={FV.RHO: 1.225},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
farm = foxes.WindFarm()
|
|
47
|
+
foxes.input.farm_layout.add_from_file(
|
|
48
|
+
farm, lfile, turbine_models=[ttype.name], verbosity=0
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
algo = foxes.algorithms.Downwind(
|
|
52
|
+
farm,
|
|
53
|
+
states,
|
|
54
|
+
mbook=mbook,
|
|
55
|
+
rotor_model="centre",
|
|
56
|
+
wake_models=["Jensen_linear_k007"],
|
|
57
|
+
wake_frame="rotor_wd",
|
|
58
|
+
partial_wakes={"Jensen_linear_k007": "top_hat"},
|
|
59
|
+
chunks=ck,
|
|
60
|
+
verbosity=0,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
data = algo.calc_farm()
|
|
64
|
+
|
|
65
|
+
df = data.to_dataframe()[[FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
|
|
66
|
+
df = df.reset_index()
|
|
67
|
+
|
|
68
|
+
print()
|
|
69
|
+
print("TRESULTS\n")
|
|
70
|
+
print(df)
|
|
71
|
+
|
|
72
|
+
# print("\Reading file", cfile)
|
|
73
|
+
fdata = pd.read_csv(cfile)
|
|
74
|
+
print(fdata)
|
|
75
|
+
|
|
76
|
+
print("\nVERIFYING\n")
|
|
77
|
+
df[FV.WS] = df["REWS"]
|
|
78
|
+
df[FV.AMB_WS] = df["AMB_REWS"]
|
|
79
|
+
|
|
80
|
+
# neglecting ws < 5 and ws > 20
|
|
81
|
+
sel_ws = (
|
|
82
|
+
(fdata[FV.WS] > 5) & (fdata[FV.WS] < 20) & (df["REWS"] > 5) & (df["REWS"] < 20)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# calculating difference
|
|
86
|
+
delta = df.reset_index() - fdata
|
|
87
|
+
delta = delta[sel_ws]
|
|
88
|
+
print(delta)
|
|
89
|
+
print(delta.max())
|
|
90
|
+
chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]].abs()
|
|
91
|
+
sel = chk[FV.WS] >= 1e-5
|
|
92
|
+
print(sel)
|
|
93
|
+
print(df[sel & sel_ws])
|
|
94
|
+
print(fdata[sel & sel_ws])
|
|
95
|
+
print(chk.loc[sel & sel_ws])
|
|
96
|
+
print(chk.max())
|
|
97
|
+
|
|
98
|
+
assert ((chk[FV.WS] < 1e-5)).all()
|
|
99
|
+
assert (chk[FV.P] < 1e-3).all()
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if __name__ == "__main__":
|
|
103
|
+
test()
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import time
|
|
4
|
+
import argparse
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import flappy as fl
|
|
8
|
+
from flappy.config.variables import variables as FV
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
parser = argparse.ArgumentParser()
|
|
12
|
+
parser.add_argument(
|
|
13
|
+
"-c", "--chunksize", help="The maximal chunk size", type=int, default=500
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"-o", "--ofile", help="The output file name", default="results.csv.gz"
|
|
17
|
+
)
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"--n_cpus", help="The number of processors", type=int, default=4
|
|
20
|
+
)
|
|
21
|
+
args = parser.parse_args()
|
|
22
|
+
|
|
23
|
+
c = args.chunksize
|
|
24
|
+
p0 = np.array([0.0, 0.0])
|
|
25
|
+
stp = np.array([500.0, 0.0])
|
|
26
|
+
ofile = Path(args.ofile)
|
|
27
|
+
tfile = "../NREL-5MW-D126-H90.csv"
|
|
28
|
+
sfile = "../states.csv.gz"
|
|
29
|
+
lfile = "../test_farm.csv"
|
|
30
|
+
|
|
31
|
+
# init flappy:
|
|
32
|
+
fl.init_flappy(n_cpus=args.n_cpus)
|
|
33
|
+
|
|
34
|
+
# load model book:
|
|
35
|
+
mbook = fl.ModelBook(ct_power_curve_file=tfile)
|
|
36
|
+
|
|
37
|
+
# create wind farm:
|
|
38
|
+
farm = fl.WindFarm()
|
|
39
|
+
fl.input.add_turbines_from_csv(
|
|
40
|
+
farm,
|
|
41
|
+
lfile,
|
|
42
|
+
col_index="index",
|
|
43
|
+
col_x="x",
|
|
44
|
+
col_y="y",
|
|
45
|
+
col_h="H",
|
|
46
|
+
rotor_diameter=126.0,
|
|
47
|
+
rotor_model="centre",
|
|
48
|
+
wake_models=["Jensen007_rotor"],
|
|
49
|
+
turbine_models=["ct_P_curves"],
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# create states:
|
|
53
|
+
states = fl.input.AFSStatesTable(
|
|
54
|
+
data_file=sfile,
|
|
55
|
+
col_wd="wd",
|
|
56
|
+
col_ws_ref="ws",
|
|
57
|
+
col_ti="ti",
|
|
58
|
+
col_mol="mol",
|
|
59
|
+
z0=0.05,
|
|
60
|
+
h_ref=100.0,
|
|
61
|
+
col_weight="weight",
|
|
62
|
+
air_density=1.225,
|
|
63
|
+
max_chunk_size=args.chunksize,
|
|
64
|
+
)
|
|
65
|
+
states.initialize()
|
|
66
|
+
|
|
67
|
+
time0 = time.time()
|
|
68
|
+
|
|
69
|
+
# run calculation:
|
|
70
|
+
results = farm.calculate(mbook, states, wake_superp=["wind_linear"])
|
|
71
|
+
|
|
72
|
+
time1 = time.time()
|
|
73
|
+
print("\nCalc time =", time1 - time0, "\n")
|
|
74
|
+
|
|
75
|
+
df = results.state_turbine_results[[FV.WD, FV.AMB_WS, FV.WS, FV.AMB_P, FV.P]]
|
|
76
|
+
|
|
77
|
+
print()
|
|
78
|
+
print("TRESULTS\n")
|
|
79
|
+
print(df)
|
|
80
|
+
|
|
81
|
+
print("\nWriting file", ofile)
|
|
82
|
+
df.to_csv(ofile)
|
|
83
|
+
|
|
84
|
+
# close flappy:
|
|
85
|
+
fl.shutdown_flappy()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import inspect
|
|
4
|
+
|
|
5
|
+
import foxes
|
|
6
|
+
import foxes.variables as FV
|
|
7
|
+
import foxes.constants as FC
|
|
8
|
+
|
|
9
|
+
thisdir = Path(inspect.getfile(inspect.currentframe())).parent
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test():
|
|
13
|
+
c = 2000
|
|
14
|
+
cfile = thisdir / "flappy" / "results.csv.gz"
|
|
15
|
+
tfile = thisdir / "NREL-5MW-D126-H90.csv"
|
|
16
|
+
sfile = thisdir / "states.csv.gz"
|
|
17
|
+
lfile = thisdir / "test_farm.csv"
|
|
18
|
+
|
|
19
|
+
ck = {FC.STATE: c}
|
|
20
|
+
|
|
21
|
+
mbook = foxes.models.ModelBook()
|
|
22
|
+
ttype = foxes.models.turbine_types.PCtFile(
|
|
23
|
+
data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
|
|
24
|
+
)
|
|
25
|
+
mbook.turbine_types[ttype.name] = ttype
|
|
26
|
+
|
|
27
|
+
states = foxes.input.states.StatesTable(
|
|
28
|
+
data_source=sfile,
|
|
29
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO, FV.MOL],
|
|
30
|
+
var2col={FV.WS: "ws", FV.WD: "wd", FV.TI: "ti", FV.MOL: "mol"},
|
|
31
|
+
fixed_vars={FV.RHO: 1.225, FV.Z0: 0.05, FV.H: 100.0},
|
|
32
|
+
profiles={FV.WS: "ABLLogWsProfile"},
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
farm = foxes.WindFarm()
|
|
36
|
+
foxes.input.farm_layout.add_from_file(
|
|
37
|
+
farm,
|
|
38
|
+
lfile,
|
|
39
|
+
col_x="x",
|
|
40
|
+
col_y="y",
|
|
41
|
+
col_H="H",
|
|
42
|
+
turbine_models=[ttype.name],
|
|
43
|
+
verbosity=0,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
algo = foxes.algorithms.Downwind(
|
|
47
|
+
farm,
|
|
48
|
+
states,
|
|
49
|
+
mbook=mbook,
|
|
50
|
+
rotor_model="centre",
|
|
51
|
+
wake_models=["Jensen_linear_k007"],
|
|
52
|
+
wake_frame="rotor_wd",
|
|
53
|
+
partial_wakes={"Jensen_linear_k007": "centre"},
|
|
54
|
+
chunks=ck,
|
|
55
|
+
verbosity=0,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
data = algo.calc_farm()
|
|
59
|
+
|
|
60
|
+
df = data.to_dataframe()[[FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
|
|
61
|
+
|
|
62
|
+
print()
|
|
63
|
+
print("TRESULTS\n")
|
|
64
|
+
print(df)
|
|
65
|
+
|
|
66
|
+
print("\nReading file", cfile)
|
|
67
|
+
fdata = pd.read_csv(cfile)
|
|
68
|
+
print(fdata)
|
|
69
|
+
|
|
70
|
+
print("\nVERIFYING\n")
|
|
71
|
+
df[FV.WS] = df["REWS"]
|
|
72
|
+
df[FV.AMB_WS] = df["AMB_REWS"]
|
|
73
|
+
|
|
74
|
+
delta = df.reset_index() - fdata
|
|
75
|
+
print(delta)
|
|
76
|
+
print(delta.max())
|
|
77
|
+
chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]].abs()
|
|
78
|
+
print(chk.max())
|
|
79
|
+
|
|
80
|
+
assert (chk[FV.AMB_WS] < 1e-5).all()
|
|
81
|
+
assert (chk[FV.AMB_P] < 1e-3).all()
|
|
82
|
+
assert (chk[FV.WS] < 1e-5).all()
|
|
83
|
+
assert (chk[FV.P] < 1e-3).all()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if __name__ == "__main__":
|
|
87
|
+
test()
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pandas as pd
|
|
3
|
+
import time
|
|
4
|
+
import argparse
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import flappy as fl
|
|
8
|
+
from flappy.config.variables import variables as FV
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
parser = argparse.ArgumentParser()
|
|
12
|
+
parser.add_argument(
|
|
13
|
+
"-c", "--chunksize", help="The maximal chunk size", type=int, default=500
|
|
14
|
+
)
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"-o", "--ofile", help="The output file name", default="results.csv.gz"
|
|
17
|
+
)
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"--n_cpus", help="The number of processors", type=int, default=4
|
|
20
|
+
)
|
|
21
|
+
args = parser.parse_args()
|
|
22
|
+
|
|
23
|
+
c = args.chunksize
|
|
24
|
+
p0 = np.array([0.0, 0.0])
|
|
25
|
+
stp = np.array([500.0, 0.0])
|
|
26
|
+
ofile = Path(args.ofile)
|
|
27
|
+
tfile = "../NREL-5MW-D126-H90.csv"
|
|
28
|
+
sfile = "../states.csv.gz"
|
|
29
|
+
lfile = "../test_farm.csv"
|
|
30
|
+
|
|
31
|
+
# init flappy:
|
|
32
|
+
fl.init_flappy(n_cpus=args.n_cpus)
|
|
33
|
+
|
|
34
|
+
# load model book:
|
|
35
|
+
mbook = fl.ModelBook(ct_power_curve_file=tfile)
|
|
36
|
+
|
|
37
|
+
# create wind farm:
|
|
38
|
+
farm = fl.WindFarm()
|
|
39
|
+
fl.input.add_turbines_from_csv(
|
|
40
|
+
farm,
|
|
41
|
+
lfile,
|
|
42
|
+
col_index="index",
|
|
43
|
+
col_x="x",
|
|
44
|
+
col_y="y",
|
|
45
|
+
rotor_diameter=126.0,
|
|
46
|
+
hub_height=90.0,
|
|
47
|
+
rotor_model="centre",
|
|
48
|
+
wake_models=["Jensen007"],
|
|
49
|
+
turbine_models=["ct_P_curves"],
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# create states:
|
|
53
|
+
states = fl.input.AFSStatesTable(
|
|
54
|
+
data_file=sfile,
|
|
55
|
+
col_wd="wd",
|
|
56
|
+
col_ws="ws",
|
|
57
|
+
col_ti="ti",
|
|
58
|
+
col_weight="weight",
|
|
59
|
+
air_density=1.225,
|
|
60
|
+
max_chunk_size=args.chunksize,
|
|
61
|
+
)
|
|
62
|
+
states.initialize()
|
|
63
|
+
|
|
64
|
+
time0 = time.time()
|
|
65
|
+
|
|
66
|
+
# run calculation:
|
|
67
|
+
results = farm.calculate(mbook, states, wake_superp=["wind_linear"])
|
|
68
|
+
|
|
69
|
+
time1 = time.time()
|
|
70
|
+
print("\nCalc time =", time1 - time0, "\n")
|
|
71
|
+
|
|
72
|
+
df = results.state_turbine_results[[FV.WD, FV.AMB_WS, FV.WS, FV.AMB_P, FV.P]]
|
|
73
|
+
|
|
74
|
+
print()
|
|
75
|
+
print("TRESULTS\n")
|
|
76
|
+
print(df)
|
|
77
|
+
|
|
78
|
+
print("\nWriting file", ofile)
|
|
79
|
+
df.to_csv(ofile)
|
|
80
|
+
|
|
81
|
+
# close flappy:
|
|
82
|
+
fl.shutdown_flappy()
|