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
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
from foxes.core import PointDataModel, TData
|
|
1
|
+
from foxes.core import PointDataModel
|
|
3
2
|
import foxes.variables as FV
|
|
4
|
-
import foxes.constants as FC
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
class PointWakesCalculation(PointDataModel):
|
|
@@ -55,7 +53,7 @@ class PointWakesCalculation(PointDataModel):
|
|
|
55
53
|
"""
|
|
56
54
|
return [self.emodels] if self.emodels is not None else []
|
|
57
55
|
|
|
58
|
-
def initialize(self, algo, verbosity=0):
|
|
56
|
+
def initialize(self, algo, verbosity=0, force=False):
|
|
59
57
|
"""
|
|
60
58
|
Initializes the model.
|
|
61
59
|
|
|
@@ -65,9 +63,11 @@ class PointWakesCalculation(PointDataModel):
|
|
|
65
63
|
The calculation algorithm
|
|
66
64
|
verbosity: int
|
|
67
65
|
The verbosity level, 0 = silent
|
|
66
|
+
force: bool
|
|
67
|
+
Overwrite existing data
|
|
68
68
|
|
|
69
69
|
"""
|
|
70
|
-
super().initialize(algo, verbosity)
|
|
70
|
+
super().initialize(algo, verbosity, force)
|
|
71
71
|
self.pvars = algo.states.output_point_vars(algo)
|
|
72
72
|
|
|
73
73
|
def output_point_vars(self, algo):
|
|
@@ -88,7 +88,7 @@ class PointWakesCalculation(PointDataModel):
|
|
|
88
88
|
return self.pvars
|
|
89
89
|
|
|
90
90
|
def calculate(self, algo, mdata, fdata, tdata, downwind_index=None):
|
|
91
|
-
"""
|
|
91
|
+
"""
|
|
92
92
|
The main model calculation.
|
|
93
93
|
|
|
94
94
|
This function is executed on a single chunk of data,
|
|
@@ -120,7 +120,6 @@ class PointWakesCalculation(PointDataModel):
|
|
|
120
120
|
algo.wake_models.values() if self.wake_models is None else self.wake_models
|
|
121
121
|
)
|
|
122
122
|
for wmodel in wmodels:
|
|
123
|
-
pwake = algo.partial_wakes[wmodel.name]
|
|
124
123
|
gmodel = algo.ground_models[wmodel.name]
|
|
125
124
|
|
|
126
125
|
wdeltas = gmodel.new_point_wake_deltas(algo, mdata, fdata, tdata, wmodel)
|
|
@@ -48,7 +48,7 @@ class ReorderFarmOutput(FarmDataModel):
|
|
|
48
48
|
return self.outputs if self.outputs is not None else algo.farm_vars
|
|
49
49
|
|
|
50
50
|
def calculate(self, algo, mdata, fdata):
|
|
51
|
-
"""
|
|
51
|
+
"""
|
|
52
52
|
The main model calculation.
|
|
53
53
|
|
|
54
54
|
This function is executed on a single chunk of data,
|
|
@@ -79,5 +79,4 @@ class ReorderFarmOutput(FarmDataModel):
|
|
|
79
79
|
out[v] = fdata[v][ssel, order_inv]
|
|
80
80
|
else:
|
|
81
81
|
out[v] = fdata[v]
|
|
82
|
-
|
|
83
82
|
return out
|
|
@@ -25,7 +25,7 @@ class SetAmbPointResults(PointDataModel):
|
|
|
25
25
|
self.pvars = None
|
|
26
26
|
self.vars = None
|
|
27
27
|
|
|
28
|
-
def initialize(self, algo, verbosity=0):
|
|
28
|
+
def initialize(self, algo, verbosity=0, force=False):
|
|
29
29
|
"""
|
|
30
30
|
Initializes the model.
|
|
31
31
|
|
|
@@ -35,11 +35,13 @@ class SetAmbPointResults(PointDataModel):
|
|
|
35
35
|
The calculation algorithm
|
|
36
36
|
verbosity: int
|
|
37
37
|
The verbosity level, 0 = silent
|
|
38
|
+
force: bool
|
|
39
|
+
Overwrite existing data
|
|
38
40
|
|
|
39
41
|
"""
|
|
40
42
|
self.pvars = algo.states.output_point_vars(algo)
|
|
41
43
|
self.vars = [v for v in self.pvars if v in FV.var2amb]
|
|
42
|
-
super().initialize(algo, verbosity)
|
|
44
|
+
super().initialize(algo, verbosity, force)
|
|
43
45
|
|
|
44
46
|
def output_point_vars(self, algo):
|
|
45
47
|
"""
|
|
@@ -59,7 +61,7 @@ class SetAmbPointResults(PointDataModel):
|
|
|
59
61
|
return [FV.var2amb[v] for v in self.vars]
|
|
60
62
|
|
|
61
63
|
def calculate(self, algo, mdata, fdata, pdata):
|
|
62
|
-
"""
|
|
64
|
+
"""
|
|
63
65
|
The main model calculation.
|
|
64
66
|
|
|
65
67
|
This function is executed on a single chunk of data,
|
|
@@ -44,7 +44,14 @@ class Iterative(Downwind):
|
|
|
44
44
|
except AttributeError:
|
|
45
45
|
return super().get_model(name)
|
|
46
46
|
|
|
47
|
-
def __init__(
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
*args,
|
|
50
|
+
max_it=None,
|
|
51
|
+
conv_crit="default",
|
|
52
|
+
mod_cutin={},
|
|
53
|
+
**kwargs,
|
|
54
|
+
):
|
|
48
55
|
"""
|
|
49
56
|
Constructor.
|
|
50
57
|
|
|
@@ -68,7 +75,7 @@ class Iterative(Downwind):
|
|
|
68
75
|
self.conv_crit = (
|
|
69
76
|
self.get_model("DefaultConv")() if conv_crit == "default" else conv_crit
|
|
70
77
|
)
|
|
71
|
-
self.
|
|
78
|
+
self.__prev_farm_results = None
|
|
72
79
|
self._it = None
|
|
73
80
|
self._mlist = None
|
|
74
81
|
self._reamb = False
|
|
@@ -77,6 +84,22 @@ class Iterative(Downwind):
|
|
|
77
84
|
self._mod_cutin = dict(modify_ct=True, modify_P=False)
|
|
78
85
|
self._mod_cutin.update(mod_cutin)
|
|
79
86
|
|
|
87
|
+
self.verbosity = self.verbosity - 1
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def farm_results_downwind(self):
|
|
91
|
+
"""
|
|
92
|
+
Gets the all-chunks farm results in downwind order
|
|
93
|
+
from the previous iteration
|
|
94
|
+
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
97
|
+
fres: xarray.Datatset
|
|
98
|
+
The all-chunks farm results during calculations
|
|
99
|
+
|
|
100
|
+
"""
|
|
101
|
+
return self.__prev_farm_results
|
|
102
|
+
|
|
80
103
|
def set_urelax(self, entry_point, **urel):
|
|
81
104
|
"""
|
|
82
105
|
Sets under-relaxation parameters.
|
|
@@ -215,11 +238,6 @@ class Iterative(Downwind):
|
|
|
215
238
|
|
|
216
239
|
# rotate back from downwind order:
|
|
217
240
|
else:
|
|
218
|
-
|
|
219
|
-
# add model that calculates wake effects:
|
|
220
|
-
# mlist.models.append(self.get_model("FarmWakesCalculation")(urelax=None))
|
|
221
|
-
# calc_pars.append(calc_parameters.get(mlist.models[-1].name, {}))
|
|
222
|
-
|
|
223
241
|
mlist.models.append(self.get_model("ReorderFarmOutput")(outputs))
|
|
224
242
|
calc_pars.append(calc_parameters.get(mlist.models[-1].name, {}))
|
|
225
243
|
|
|
@@ -230,16 +248,26 @@ class Iterative(Downwind):
|
|
|
230
248
|
if self._it == 0:
|
|
231
249
|
super()._calc_farm_vars(mlist)
|
|
232
250
|
|
|
233
|
-
def
|
|
251
|
+
def _launch_parallel_farm_calc(self, mlist, *data, **kwargs):
|
|
234
252
|
"""Helper function for running the main farm calculation"""
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if self.prev_farm_results is None
|
|
238
|
-
else self.chunked(self.prev_farm_results)
|
|
253
|
+
return super()._launch_parallel_farm_calc(
|
|
254
|
+
mlist, *data, farm_data=self.__prev_farm_results, iterative=True, **kwargs
|
|
239
255
|
)
|
|
240
|
-
return super()._run_farm_calc(mlist, *data, initial_results=ir, **kwargs)
|
|
241
256
|
|
|
242
|
-
|
|
257
|
+
@property
|
|
258
|
+
def final_iteration(self):
|
|
259
|
+
"""
|
|
260
|
+
Flag for the final iteration
|
|
261
|
+
|
|
262
|
+
Returns
|
|
263
|
+
-------
|
|
264
|
+
flag: bool
|
|
265
|
+
Flag for the final iteration
|
|
266
|
+
|
|
267
|
+
"""
|
|
268
|
+
return self._final_run
|
|
269
|
+
|
|
270
|
+
def calc_farm(self, finalize=True, ret_dwnd_order=False, **kwargs):
|
|
243
271
|
"""
|
|
244
272
|
Calculate farm data.
|
|
245
273
|
|
|
@@ -247,6 +275,8 @@ class Iterative(Downwind):
|
|
|
247
275
|
----------
|
|
248
276
|
finalize: bool
|
|
249
277
|
Flag for finalization after calculation
|
|
278
|
+
ret_dwnd_order: bool
|
|
279
|
+
Also return the results in downwind order
|
|
250
280
|
kwargs: dict, optional
|
|
251
281
|
Arguments for calc_farm in the base class.
|
|
252
282
|
|
|
@@ -257,44 +287,54 @@ class Iterative(Downwind):
|
|
|
257
287
|
dimensions (state, turbine)
|
|
258
288
|
|
|
259
289
|
"""
|
|
260
|
-
outputs = kwargs.pop("outputs",
|
|
261
|
-
|
|
290
|
+
outputs = kwargs.pop("outputs", None)
|
|
291
|
+
if outputs == "default":
|
|
292
|
+
outputs = self.DEFAULT_FARM_OUTPUTS
|
|
262
293
|
|
|
263
294
|
fres = None
|
|
264
295
|
self._it = -1
|
|
265
296
|
self._final_run = False
|
|
297
|
+
fres_dwnd = None
|
|
266
298
|
while self._it < self.max_it:
|
|
267
299
|
self._it += 1
|
|
268
300
|
|
|
269
301
|
self.print(f"\nAlgorithm {self.name}: Iteration {self._it}\n", vlim=0)
|
|
270
302
|
|
|
271
|
-
self.
|
|
303
|
+
self.__prev_farm_results = fres
|
|
272
304
|
fres = super().calc_farm(outputs=None, finalize=False, **kwargs)
|
|
273
305
|
|
|
306
|
+
fres_dwnd = fres
|
|
274
307
|
if self.conv_crit is not None:
|
|
275
|
-
|
|
276
|
-
self
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
308
|
+
if self.eval_conv_block():
|
|
309
|
+
self.print(f"{self.name}: Convergence blocked", vlim=0)
|
|
310
|
+
else:
|
|
311
|
+
conv = self.conv_crit.check_converged(
|
|
312
|
+
self,
|
|
313
|
+
self.__prev_farm_results,
|
|
314
|
+
fres,
|
|
315
|
+
verbosity=self.verbosity + 1,
|
|
282
316
|
)
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
317
|
+
if conv:
|
|
318
|
+
self.print(
|
|
319
|
+
f"\nAlgorithm {self.name}: Convergence reached.\n", vlim=0
|
|
320
|
+
)
|
|
321
|
+
break
|
|
287
322
|
|
|
288
|
-
|
|
289
|
-
|
|
323
|
+
# final run, recovers farm order of results:
|
|
324
|
+
self.print("Starting final run", vlim=0)
|
|
325
|
+
self._final_run = True
|
|
326
|
+
fres = super().calc_farm(outputs=outputs, finalize=False, **kwargs)
|
|
290
327
|
|
|
291
328
|
# finalize models:
|
|
292
329
|
if finalize:
|
|
293
|
-
self.print("\n")
|
|
330
|
+
self.print("\n", vlim=0)
|
|
294
331
|
self.finalize()
|
|
295
332
|
for m in self._mlist0.models:
|
|
296
|
-
if m not in self.
|
|
297
|
-
m.finalize(self, self.verbosity)
|
|
333
|
+
if m not in self.sub_models():
|
|
334
|
+
m.finalize(self, self.verbosity - 1)
|
|
298
335
|
del self._mlist0, self._calc_pars0
|
|
299
336
|
|
|
300
|
-
|
|
337
|
+
if ret_dwnd_order:
|
|
338
|
+
return fres, fres_dwnd
|
|
339
|
+
else:
|
|
340
|
+
return fres
|
|
@@ -2,6 +2,7 @@ import numpy as np
|
|
|
2
2
|
from copy import deepcopy
|
|
3
3
|
|
|
4
4
|
from foxes.core import FarmDataModel, TData
|
|
5
|
+
import foxes.constants as FC
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class FarmWakesCalculation(FarmDataModel):
|
|
@@ -63,7 +64,7 @@ class FarmWakesCalculation(FarmDataModel):
|
|
|
63
64
|
return [] if self.urelax is None else [self.urelax]
|
|
64
65
|
|
|
65
66
|
def calculate(self, algo, mdata, fdata):
|
|
66
|
-
"""
|
|
67
|
+
"""
|
|
67
68
|
The main model calculation.
|
|
68
69
|
|
|
69
70
|
This function is executed on a single chunk of data,
|
|
@@ -87,8 +88,8 @@ class FarmWakesCalculation(FarmDataModel):
|
|
|
87
88
|
"""
|
|
88
89
|
# collect ambient rotor results and weights:
|
|
89
90
|
rotor = algo.rotor_model
|
|
90
|
-
weights =
|
|
91
|
-
amb_res =
|
|
91
|
+
weights = algo.get_from_chunk_store(FC.ROTOR_WEIGHTS, mdata=mdata)
|
|
92
|
+
amb_res = algo.get_from_chunk_store(FC.AMB_ROTOR_RES, mdata=mdata)
|
|
92
93
|
|
|
93
94
|
# generate all wake evaluation points
|
|
94
95
|
# (n_states, n_order, n_rpoints)
|
|
@@ -99,9 +100,9 @@ class FarmWakesCalculation(FarmDataModel):
|
|
|
99
100
|
tpoints, tweights = pwake.get_wake_points(algo, mdata, fdata)
|
|
100
101
|
pwake2tdata[pwake.name] = TData.from_tpoints(tpoints, tweights)
|
|
101
102
|
|
|
102
|
-
def _get_wdata(tdatap, wdeltas, s):
|
|
103
|
+
def _get_wdata(tdatap, wdeltas, variables, s):
|
|
103
104
|
"""Helper function for wake data extraction"""
|
|
104
|
-
tdata = tdatap.get_slice(
|
|
105
|
+
tdata = tdatap.get_slice(variables, s)
|
|
105
106
|
wdelta = {v: d[s] for v, d in wdeltas.items()}
|
|
106
107
|
return tdata, wdelta
|
|
107
108
|
|
|
@@ -116,13 +117,17 @@ class FarmWakesCalculation(FarmDataModel):
|
|
|
116
117
|
for oi in range(n_turbines):
|
|
117
118
|
|
|
118
119
|
if oi > 0:
|
|
119
|
-
tdata, wdelta = _get_wdata(
|
|
120
|
+
tdata, wdelta = _get_wdata(
|
|
121
|
+
tdatap, wdeltas, [FC.STATE, FC.TARGET], np.s_[:, :oi]
|
|
122
|
+
)
|
|
120
123
|
gmodel.contribute_to_farm_wakes(
|
|
121
124
|
algo, mdata, fdata, tdata, oi, wdelta, wmodel, pwake
|
|
122
125
|
)
|
|
123
126
|
|
|
124
127
|
if oi < n_turbines - 1:
|
|
125
|
-
tdata, wdelta = _get_wdata(
|
|
128
|
+
tdata, wdelta = _get_wdata(
|
|
129
|
+
tdatap, wdeltas, [FC.STATE, FC.TARGET], np.s_[:, oi + 1 :]
|
|
130
|
+
)
|
|
126
131
|
gmodel.contribute_to_farm_wakes(
|
|
127
132
|
algo, mdata, fdata, tdata, oi, wdelta, wmodel, pwake
|
|
128
133
|
)
|
|
@@ -10,7 +10,7 @@ class URelax(FarmDataModel):
|
|
|
10
10
|
----------
|
|
11
11
|
urel: dict
|
|
12
12
|
The variables and their under-relaxation
|
|
13
|
-
factors
|
|
13
|
+
factors between 0 and 1
|
|
14
14
|
|
|
15
15
|
:group: algorithms.iterative.models
|
|
16
16
|
|
|
@@ -24,7 +24,7 @@ class URelax(FarmDataModel):
|
|
|
24
24
|
----------
|
|
25
25
|
urel: dict
|
|
26
26
|
The variables and their under-relaxation
|
|
27
|
-
factors
|
|
27
|
+
factors between 0 and 1
|
|
28
28
|
|
|
29
29
|
"""
|
|
30
30
|
super().__init__()
|
|
@@ -49,7 +49,7 @@ class URelax(FarmDataModel):
|
|
|
49
49
|
return list(self.urel.keys())
|
|
50
50
|
|
|
51
51
|
def calculate(self, algo, mdata, fdata):
|
|
52
|
-
"""
|
|
52
|
+
"""
|
|
53
53
|
The main model calculation.
|
|
54
54
|
|
|
55
55
|
This function is executed on a single chunk of data,
|
|
@@ -6,7 +6,7 @@ class SequentialPlugin:
|
|
|
6
6
|
Parameters
|
|
7
7
|
----------
|
|
8
8
|
algo: foxes.algorithms.sequential.Sequential
|
|
9
|
-
The
|
|
9
|
+
The sequential algorithm
|
|
10
10
|
|
|
11
11
|
:group: algorithms.sequential.models
|
|
12
12
|
|
|
@@ -25,7 +25,7 @@ class SequentialPlugin:
|
|
|
25
25
|
Parameters
|
|
26
26
|
----------
|
|
27
27
|
algo: foxes.algorithms.sequential.Sequential
|
|
28
|
-
The current
|
|
28
|
+
The current sequential algorithm
|
|
29
29
|
|
|
30
30
|
"""
|
|
31
31
|
self.algo = algo
|
|
@@ -37,7 +37,7 @@ class SequentialPlugin:
|
|
|
37
37
|
Parameters
|
|
38
38
|
----------
|
|
39
39
|
algo: foxes.algorithms.sequential.Sequential
|
|
40
|
-
The latest
|
|
40
|
+
The latest sequential algorithm
|
|
41
41
|
fres: xarray.Dataset
|
|
42
42
|
The latest farm results
|
|
43
43
|
pres: xarray.Dataset, optional
|
|
@@ -53,7 +53,7 @@ class SequentialPlugin:
|
|
|
53
53
|
Parameters
|
|
54
54
|
----------
|
|
55
55
|
algo: foxes.algorithms.sequential.Sequential
|
|
56
|
-
The final
|
|
56
|
+
The final sequential algorithm
|
|
57
57
|
|
|
58
58
|
"""
|
|
59
|
-
self.algo =
|
|
59
|
+
self.algo = algo
|