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,141 @@
|
|
|
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="wind_rose_bremen.csv",
|
|
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=None, 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.StatesTable(
|
|
79
|
+
data_source=args.states,
|
|
80
|
+
output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
|
|
81
|
+
var2col={FV.WS: "ws", FV.WD: "wd", FV.WEIGHT: "weight"},
|
|
82
|
+
fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
farm = foxes.WindFarm()
|
|
86
|
+
foxes.input.farm_layout.add_from_file(
|
|
87
|
+
farm,
|
|
88
|
+
args.layout,
|
|
89
|
+
col_x="x",
|
|
90
|
+
col_y="y",
|
|
91
|
+
col_H="H",
|
|
92
|
+
turbine_models=[ttype.name, "kTI_02"] + args.tmodels,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
if not args.nofig and args.show_layout:
|
|
96
|
+
ax = foxes.output.FarmLayoutOutput(farm).get_figure()
|
|
97
|
+
plt.show()
|
|
98
|
+
plt.close(ax.get_figure())
|
|
99
|
+
|
|
100
|
+
algo = foxes.algorithms.Downwind(
|
|
101
|
+
farm,
|
|
102
|
+
states=states,
|
|
103
|
+
rotor_model=args.rotor,
|
|
104
|
+
wake_models=args.wakes,
|
|
105
|
+
wake_frame="rotor_wd",
|
|
106
|
+
partial_wakes=args.pwakes,
|
|
107
|
+
mbook=mbook,
|
|
108
|
+
engine=args.engine,
|
|
109
|
+
n_procs=args.n_cpus,
|
|
110
|
+
chunk_size_states=args.chunksize_states,
|
|
111
|
+
chunk_size_points=args.chunksize_points,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
if not args.nofig:
|
|
115
|
+
o = foxes.output.StatesRosePlotOutput(states, point=[0.0, 0.0, 100.0])
|
|
116
|
+
fig = o.get_figure(16, FV.AMB_WS, [0, 3.5, 6, 10, 15, 20])
|
|
117
|
+
plt.show()
|
|
118
|
+
|
|
119
|
+
time0 = time.time()
|
|
120
|
+
farm_results = algo.calc_farm()
|
|
121
|
+
time1 = time.time()
|
|
122
|
+
|
|
123
|
+
print("\nCalc time =", time1 - time0, "\n")
|
|
124
|
+
|
|
125
|
+
print(farm_results)
|
|
126
|
+
|
|
127
|
+
fr = farm_results.to_dataframe()
|
|
128
|
+
print(fr[[FV.WD, FV.H, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P, FV.WEIGHT]])
|
|
129
|
+
|
|
130
|
+
o = foxes.output.FarmResultsEval(farm_results)
|
|
131
|
+
P0 = o.calc_mean_farm_power(ambient=True)
|
|
132
|
+
P = o.calc_mean_farm_power()
|
|
133
|
+
print(f"\nFarm power : {P/1000:.1f} MW")
|
|
134
|
+
print(f"Farm ambient power: {P0/1000:.1f} MW")
|
|
135
|
+
print(f"Farm efficiency : {o.calc_farm_efficiency()*100:.2f} %")
|
|
136
|
+
print(f"Annual farm yield : {o.calc_farm_yield(algo=algo):.2f} GWh")
|
|
137
|
+
|
|
138
|
+
if not args.nofig and args.calc_mean:
|
|
139
|
+
o = foxes.output.FlowPlots2D(algo, farm_results)
|
|
140
|
+
fig = o.get_mean_fig_xy(FV.WS, resolution=30)
|
|
141
|
+
plt.show()
|
examples/windio/run.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
|
|
3
|
+
import foxes
|
|
4
|
+
|
|
5
|
+
if __name__ == "__main__":
|
|
6
|
+
# define arguments and options:
|
|
7
|
+
parser = argparse.ArgumentParser()
|
|
8
|
+
parser.add_argument(
|
|
9
|
+
"-wio",
|
|
10
|
+
"--windio_yaml",
|
|
11
|
+
help="The windio wind energy systems yaml file",
|
|
12
|
+
default="windio_5turbines_timeseries.yaml",
|
|
13
|
+
)
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
16
|
+
)
|
|
17
|
+
parser.add_argument(
|
|
18
|
+
"-V", "--verbosity", help="The verbosity level, 0=silent", type=int, default=1
|
|
19
|
+
)
|
|
20
|
+
args = parser.parse_args()
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
wio_runner = foxes.input.windio.read_windio(
|
|
24
|
+
args.windio_yaml, verbosity=args.verbosity
|
|
25
|
+
)
|
|
26
|
+
with wio_runner as runner:
|
|
27
|
+
runner.run()
|
|
28
|
+
except ModuleNotFoundError as e:
|
|
29
|
+
print(e.msg)
|
|
@@ -0,0 +1,196 @@
|
|
|
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
|
+
"-y", "--yawm", help="YAWM angle of first turbine", default=30.0, type=float
|
|
13
|
+
)
|
|
14
|
+
parser.add_argument(
|
|
15
|
+
"-y2", "--yawm2", help="YAWM angle of second turbine", default=0.0, type=float
|
|
16
|
+
)
|
|
17
|
+
parser.add_argument("--ws", help="The wind speed", type=float, default=9.0)
|
|
18
|
+
parser.add_argument("--wd", help="The wind direction", type=float, default=270.0)
|
|
19
|
+
parser.add_argument("--ti", help="The TI value", type=float, default=0.08)
|
|
20
|
+
parser.add_argument("--rho", help="The air density", type=float, default=1.225)
|
|
21
|
+
parser.add_argument(
|
|
22
|
+
"-dx", "--deltax", help="The turbine distance in x", type=float, default=1500.0
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"-dy", "--deltay", help="Turbine layout y step", type=float, default=0.0
|
|
26
|
+
)
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"-t",
|
|
29
|
+
"--turbine_file",
|
|
30
|
+
help="The P-ct-curve csv file (path or static)",
|
|
31
|
+
default="NREL-5MW-D126-H90.csv",
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"-w",
|
|
35
|
+
"--wakes",
|
|
36
|
+
help="The wake models",
|
|
37
|
+
default=["Bastankhah2016_linear_ka02", "CrespoHernandez_quadratic_ka04"],
|
|
38
|
+
nargs="+",
|
|
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("-f", "--frame", help="The wake frame", default="yawed")
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"-m", "--tmodels", help="The turbine models", default=[], nargs="+"
|
|
47
|
+
)
|
|
48
|
+
parser.add_argument("-v", "--var", help="The plot variable", default=FV.WS)
|
|
49
|
+
parser.add_argument("-e", "--engine", help="The engine", default="process")
|
|
50
|
+
parser.add_argument(
|
|
51
|
+
"-n", "--n_cpus", help="The number of cpus", default=None, type=int
|
|
52
|
+
)
|
|
53
|
+
parser.add_argument(
|
|
54
|
+
"-c",
|
|
55
|
+
"--chunksize_states",
|
|
56
|
+
help="The chunk size for states",
|
|
57
|
+
default=None,
|
|
58
|
+
type=int,
|
|
59
|
+
)
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
"-C",
|
|
62
|
+
"--chunksize_points",
|
|
63
|
+
help="The chunk size for points",
|
|
64
|
+
default=5000,
|
|
65
|
+
type=int,
|
|
66
|
+
)
|
|
67
|
+
parser.add_argument(
|
|
68
|
+
"-nf", "--nofig", help="Do not show figures", action="store_true"
|
|
69
|
+
)
|
|
70
|
+
args = parser.parse_args()
|
|
71
|
+
|
|
72
|
+
# create model book
|
|
73
|
+
mbook = foxes.ModelBook()
|
|
74
|
+
ttype = foxes.models.turbine_types.PCtFile(args.turbine_file)
|
|
75
|
+
mbook.turbine_types[ttype.name] = ttype
|
|
76
|
+
|
|
77
|
+
# set turbines in yaw
|
|
78
|
+
yawm = np.array([[args.yawm, args.yawm2]])
|
|
79
|
+
mbook.turbine_models["set_yawm"] = foxes.models.turbine_models.SetFarmVars()
|
|
80
|
+
mbook.turbine_models["set_yawm"].add_var(FV.YAWM, yawm)
|
|
81
|
+
|
|
82
|
+
# create states
|
|
83
|
+
states = foxes.input.states.SingleStateStates(
|
|
84
|
+
ws=args.ws, wd=args.wd, ti=args.ti, rho=args.rho
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# create wind farm
|
|
88
|
+
print("\nCreating wind farm")
|
|
89
|
+
farm = foxes.WindFarm()
|
|
90
|
+
foxes.input.farm_layout.add_row(
|
|
91
|
+
farm=farm,
|
|
92
|
+
xy_base=np.array([0.0, 0.0]),
|
|
93
|
+
xy_step=np.array([args.deltax, args.deltay]),
|
|
94
|
+
n_turbines=2,
|
|
95
|
+
turbine_models=args.tmodels + ["set_yawm", "yawm2yaw", ttype.name],
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# create algorithm
|
|
99
|
+
algo = foxes.algorithms.Downwind(
|
|
100
|
+
farm,
|
|
101
|
+
states=states,
|
|
102
|
+
rotor_model=args.rotor,
|
|
103
|
+
wake_models=args.wakes,
|
|
104
|
+
wake_frame=args.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
|
+
# calculate farm results
|
|
114
|
+
farm_results = algo.calc_farm()
|
|
115
|
+
print("\nResults data:\n", farm_results)
|
|
116
|
+
|
|
117
|
+
if not args.nofig:
|
|
118
|
+
# xy horizontal flow plot
|
|
119
|
+
print("\nHorizontal flow figure output:")
|
|
120
|
+
o = foxes.output.FlowPlots2D(algo, farm_results)
|
|
121
|
+
g = o.gen_states_fig_xy(
|
|
122
|
+
args.var, resolution=10, xmin=-100, xmax=3000, rotor_color="red"
|
|
123
|
+
)
|
|
124
|
+
fig = next(g)
|
|
125
|
+
plt.show()
|
|
126
|
+
plt.close(fig)
|
|
127
|
+
|
|
128
|
+
# yz flow plot
|
|
129
|
+
print("\nVertical flow figure output:")
|
|
130
|
+
o = foxes.output.FlowPlots2D(algo, farm_results)
|
|
131
|
+
g = o.gen_states_fig_yz(
|
|
132
|
+
args.var,
|
|
133
|
+
resolution=10,
|
|
134
|
+
x=750,
|
|
135
|
+
ymin=-200,
|
|
136
|
+
ymax=200,
|
|
137
|
+
zmin=0,
|
|
138
|
+
zmax=250,
|
|
139
|
+
rotor_color="red",
|
|
140
|
+
verbosity=0,
|
|
141
|
+
)
|
|
142
|
+
fig = next(g)
|
|
143
|
+
plt.show()
|
|
144
|
+
plt.close(fig)
|
|
145
|
+
|
|
146
|
+
# add capacity and efficiency to farm results
|
|
147
|
+
o = foxes.output.FarmResultsEval(farm_results)
|
|
148
|
+
o.add_capacity(algo)
|
|
149
|
+
o.add_capacity(algo, ambient=True)
|
|
150
|
+
o.add_efficiency()
|
|
151
|
+
|
|
152
|
+
# state-turbine results
|
|
153
|
+
farm_df = farm_results.to_dataframe()
|
|
154
|
+
print("\nFarm results data:\n")
|
|
155
|
+
print(
|
|
156
|
+
farm_df[
|
|
157
|
+
[
|
|
158
|
+
FV.X,
|
|
159
|
+
FV.AMB_REWS,
|
|
160
|
+
FV.REWS,
|
|
161
|
+
FV.AMB_TI,
|
|
162
|
+
FV.TI,
|
|
163
|
+
FV.AMB_P,
|
|
164
|
+
FV.P,
|
|
165
|
+
FV.WD,
|
|
166
|
+
FV.YAW,
|
|
167
|
+
FV.YAWM,
|
|
168
|
+
]
|
|
169
|
+
]
|
|
170
|
+
)
|
|
171
|
+
print()
|
|
172
|
+
|
|
173
|
+
# results by turbine
|
|
174
|
+
turbine_results = o.reduce_states(
|
|
175
|
+
{
|
|
176
|
+
FV.AMB_P: "mean",
|
|
177
|
+
FV.P: "mean",
|
|
178
|
+
FV.AMB_CAP: "mean",
|
|
179
|
+
FV.CAP: "mean",
|
|
180
|
+
FV.EFF: "mean",
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
turbine_results[FV.AMB_YLD] = o.calc_turbine_yield(
|
|
184
|
+
algo=algo, annual=True, ambient=True
|
|
185
|
+
)
|
|
186
|
+
turbine_results[FV.YLD] = o.calc_turbine_yield(algo=algo, annual=True)
|
|
187
|
+
print("\nResults by turbine:\n")
|
|
188
|
+
print(turbine_results)
|
|
189
|
+
|
|
190
|
+
# power results
|
|
191
|
+
P0 = o.calc_mean_farm_power(ambient=True)
|
|
192
|
+
P = o.calc_mean_farm_power()
|
|
193
|
+
print(f"\nFarm power : {P/1000:.1f} MW")
|
|
194
|
+
print(f"Farm ambient power: {P0/1000:.1f} MW")
|
|
195
|
+
print(f"Farm efficiency : {o.calc_farm_efficiency()*100:.2f} %")
|
|
196
|
+
print(f"Annual farm yield : {turbine_results[FV.YLD].sum():.2f} GWh.")
|
foxes/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@ Farm Optimization and eXtended yield Evaluation Software
|
|
|
3
3
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .core import WindFarm, Turbine # noqa: F401
|
|
6
|
+
from .core import Engine, WindFarm, Turbine, get_engine, reset_engine # noqa: F401
|
|
7
7
|
from .models import ModelBook # noqa: F401
|
|
8
8
|
from .data import (
|
|
9
9
|
parse_Pct_file_name,
|
|
@@ -15,16 +15,12 @@ from .data import (
|
|
|
15
15
|
) # noqa: F401
|
|
16
16
|
|
|
17
17
|
from . import algorithms # noqa: F401
|
|
18
|
+
from . import engines # noqa: F401
|
|
18
19
|
from . import models # noqa: F401
|
|
19
20
|
from . import input # noqa: F401
|
|
20
21
|
from . import output # noqa: F401
|
|
21
22
|
from . import utils # noqa: F401
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
from importlib.resources import files
|
|
24
|
+
from importlib.metadata import version
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
except ImportError:
|
|
28
|
-
from importlib.resources import read_text
|
|
29
|
-
|
|
30
|
-
__version__ = read_text(__package__, "VERSION")
|
|
26
|
+
__version__ = version(__package__ or __name__)
|
foxes/algorithms/__init__.py
CHANGED
|
@@ -4,7 +4,7 @@ Algorithms define the main calculation routines.
|
|
|
4
4
|
|
|
5
5
|
from .downwind.downwind import Downwind
|
|
6
6
|
from .iterative.iterative import Iterative
|
|
7
|
-
from .sequential
|
|
7
|
+
from .sequential import Sequential
|
|
8
8
|
|
|
9
9
|
from . import downwind
|
|
10
10
|
from . import iterative
|