foxes 1.0__py3-none-any.whl → 1.1.1__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.

Files changed (128) hide show
  1. docs/source/conf.py +0 -1
  2. examples/states_lookup_table/run.py +1 -1
  3. examples/timeseries/run.py +11 -4
  4. foxes/algorithms/downwind/downwind.py +18 -13
  5. foxes/algorithms/downwind/models/farm_wakes_calc.py +1 -1
  6. foxes/algorithms/downwind/models/init_farm_data.py +1 -1
  7. foxes/algorithms/downwind/models/point_wakes_calc.py +1 -1
  8. foxes/algorithms/downwind/models/reorder_farm_output.py +1 -1
  9. foxes/algorithms/downwind/models/set_amb_farm_results.py +1 -1
  10. foxes/algorithms/downwind/models/set_amb_point_results.py +1 -1
  11. foxes/algorithms/iterative/iterative.py +1 -1
  12. foxes/algorithms/iterative/models/farm_wakes_calc.py +1 -1
  13. foxes/algorithms/iterative/models/urelax.py +3 -3
  14. foxes/algorithms/sequential/models/plugin.py +4 -4
  15. foxes/algorithms/sequential/models/seq_state.py +1 -1
  16. foxes/constants.py +5 -5
  17. foxes/core/algorithm.py +2 -2
  18. foxes/core/data_calc_model.py +2 -2
  19. foxes/core/engine.py +20 -10
  20. foxes/core/farm_controller.py +3 -3
  21. foxes/core/farm_data_model.py +1 -1
  22. foxes/core/ground_model.py +2 -2
  23. foxes/core/model.py +122 -108
  24. foxes/core/partial_wakes_model.py +1 -1
  25. foxes/core/point_data_model.py +2 -2
  26. foxes/core/states.py +1 -1
  27. foxes/core/turbine_type.py +2 -2
  28. foxes/core/wake_frame.py +8 -30
  29. foxes/core/wake_model.py +3 -2
  30. foxes/core/wake_superposition.py +1 -1
  31. foxes/data/windio/windio_5turbines_timeseries.yaml +9 -15
  32. foxes/engines/__init__.py +1 -0
  33. foxes/engines/dask.py +13 -6
  34. foxes/engines/multiprocess.py +5 -8
  35. foxes/engines/numpy.py +8 -26
  36. foxes/engines/pool.py +10 -24
  37. foxes/engines/ray.py +79 -0
  38. foxes/engines/single.py +3 -1
  39. foxes/input/farm_layout/from_json.py +1 -1
  40. foxes/input/states/__init__.py +1 -0
  41. foxes/input/states/field_data_nc.py +4 -4
  42. foxes/input/states/multi_height.py +4 -4
  43. foxes/input/states/scan_ws.py +1 -1
  44. foxes/input/states/single.py +1 -1
  45. foxes/input/states/slice_data_nc.py +681 -0
  46. foxes/input/states/states_table.py +3 -3
  47. foxes/input/windio/__init__.py +1 -1
  48. foxes/input/windio/read_attributes.py +8 -2
  49. foxes/input/windio/read_fields.py +3 -0
  50. foxes/input/windio/read_outputs.py +8 -2
  51. foxes/input/windio/windio.py +6 -2
  52. foxes/models/farm_models/turbine2farm.py +1 -1
  53. foxes/models/ground_models/wake_mirror.py +2 -2
  54. foxes/models/model_book.py +29 -2
  55. foxes/models/partial_wakes/axiwake.py +3 -3
  56. foxes/models/partial_wakes/top_hat.py +2 -2
  57. foxes/models/point_models/set_uniform_data.py +1 -1
  58. foxes/models/point_models/tke2ti.py +1 -1
  59. foxes/models/point_models/wake_deltas.py +1 -1
  60. foxes/models/rotor_models/grid.py +2 -2
  61. foxes/models/turbine_models/calculator.py +4 -4
  62. foxes/models/turbine_models/kTI_model.py +22 -6
  63. foxes/models/turbine_models/lookup_table.py +3 -2
  64. foxes/models/turbine_types/PCt_file.py +5 -5
  65. foxes/models/turbine_types/PCt_from_two.py +5 -5
  66. foxes/models/turbine_types/TBL_file.py +80 -0
  67. foxes/models/turbine_types/__init__.py +1 -0
  68. foxes/models/turbine_types/lookup.py +5 -5
  69. foxes/models/turbine_types/null_type.py +3 -3
  70. foxes/models/turbine_types/wsrho2PCt_from_two.py +7 -7
  71. foxes/models/turbine_types/wsti2PCt_from_two.py +9 -9
  72. foxes/models/vertical_profiles/__init__.py +1 -1
  73. foxes/models/wake_frames/dynamic_wakes.py +2 -2
  74. foxes/models/wake_frames/farm_order.py +2 -2
  75. foxes/models/wake_frames/rotor_wd.py +2 -2
  76. foxes/models/wake_frames/seq_dynamic_wakes.py +5 -11
  77. foxes/models/wake_frames/streamlines.py +2 -2
  78. foxes/models/wake_frames/timelines.py +2 -2
  79. foxes/models/wake_frames/yawed_wakes.py +3 -3
  80. foxes/models/wake_models/dist_sliced.py +1 -1
  81. foxes/models/wake_models/induction/rankine_half_body.py +1 -1
  82. foxes/models/wake_models/induction/rathmann.py +76 -22
  83. foxes/models/wake_models/induction/self_similar.py +76 -26
  84. foxes/models/wake_models/induction/vortex_sheet.py +84 -46
  85. foxes/models/wake_models/ti/crespo_hernandez.py +6 -4
  86. foxes/models/wake_models/ti/iec_ti.py +7 -5
  87. foxes/models/wake_models/wind/bastankhah14.py +6 -4
  88. foxes/models/wake_models/wind/bastankhah16.py +9 -9
  89. foxes/models/wake_models/wind/jensen.py +3 -2
  90. foxes/models/wake_models/wind/turbopark.py +14 -11
  91. foxes/models/wake_superpositions/ti_linear.py +1 -1
  92. foxes/models/wake_superpositions/ti_max.py +1 -1
  93. foxes/models/wake_superpositions/ti_pow.py +1 -1
  94. foxes/models/wake_superpositions/ti_quadratic.py +1 -1
  95. foxes/models/wake_superpositions/ws_linear.py +8 -7
  96. foxes/models/wake_superpositions/ws_max.py +8 -7
  97. foxes/models/wake_superpositions/ws_pow.py +8 -7
  98. foxes/models/wake_superpositions/ws_product.py +5 -5
  99. foxes/models/wake_superpositions/ws_quadratic.py +8 -7
  100. foxes/output/farm_layout.py +14 -10
  101. foxes/output/farm_results_eval.py +1 -1
  102. foxes/output/grids.py +1 -1
  103. foxes/output/results_writer.py +2 -2
  104. foxes/output/rose_plot.py +3 -3
  105. foxes/output/seq_plugins/seq_flow_ani_plugin.py +2 -2
  106. foxes/output/seq_plugins/seq_wake_debug_plugin.py +2 -2
  107. foxes/output/state_turbine_map.py +1 -1
  108. foxes/utils/abl/neutral.py +2 -2
  109. foxes/utils/abl/stable.py +2 -2
  110. foxes/utils/abl/unstable.py +2 -2
  111. foxes/utils/data_book.py +1 -1
  112. foxes/utils/dict.py +23 -0
  113. foxes/utils/exec_python.py +1 -1
  114. foxes/utils/factory.py +29 -1
  115. foxes/utils/geom2d/circle.py +1 -1
  116. foxes/utils/geom2d/polygon.py +1 -1
  117. foxes/utils/geopandas_utils.py +2 -2
  118. foxes/utils/load.py +2 -2
  119. foxes/utils/pandas_helpers.py +1 -1
  120. foxes/utils/xarray_utils.py +1 -1
  121. foxes/variables.py +3 -3
  122. {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/METADATA +8 -6
  123. {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/RECORD +127 -125
  124. {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/WHEEL +1 -1
  125. foxes/utils/geopandas_helpers.py +0 -294
  126. /examples/{induction_RHB → induction}/run.py +0 -0
  127. {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/LICENSE +0 -0
  128. {foxes-1.0.dist-info → foxes-1.1.1.dist-info}/top_level.txt +0 -0
docs/source/conf.py CHANGED
@@ -344,7 +344,6 @@ python_apigen_modules = {
344
344
  "foxes.utils": "_foxes/utils/",
345
345
  "foxes.utils.abl": "_foxes/utils/abl",
346
346
  "foxes.utils.geom2d": "_foxes/utils/geom2d/",
347
- "foxes.utils.runners": "_foxes/utils/runners/",
348
347
  "foxes.utils.two_circles": "_foxes/utils/two_circles/",
349
348
  "foxes.utils.abl.neutral": "_foxes/utils/abl/neutral/",
350
349
  "foxes.utils.abl.stable": "_foxes/utils/abl/stable/",
@@ -51,7 +51,7 @@ if __name__ == "__main__":
51
51
  parser.add_argument(
52
52
  "-m", "--tmodels", help="The turbine models", default=[], nargs="+"
53
53
  )
54
- parser.add_argument("-e", "--engine", help="The engine", default=None)
54
+ parser.add_argument("-e", "--engine", help="The engine", default="default")
55
55
  parser.add_argument(
56
56
  "-n", "--n_cpus", help="The number of cpus", default=None, type=int
57
57
  )
@@ -99,6 +99,15 @@ if __name__ == "__main__":
99
99
  plt.show()
100
100
  plt.close(ax.get_figure())
101
101
 
102
+ engine = foxes.Engine.new(
103
+ args.engine,
104
+ n_procs=args.n_cpus,
105
+ chunk_size_states=args.chunksize_states,
106
+ chunk_size_points=args.chunksize_points,
107
+ verbosity=1,
108
+ )
109
+ engine.initialize()
110
+
102
111
  Algo = foxes.algorithms.Iterative if args.iterative else foxes.algorithms.Downwind
103
112
  algo = Algo(
104
113
  farm,
@@ -108,10 +117,6 @@ if __name__ == "__main__":
108
117
  wake_frame=args.frame,
109
118
  partial_wakes=args.pwakes,
110
119
  mbook=mbook,
111
- engine=args.engine,
112
- n_procs=args.n_cpus,
113
- chunk_size_states=args.chunksize_states,
114
- chunk_size_points=args.chunksize_points,
115
120
  verbosity=1,
116
121
  )
117
122
 
@@ -177,6 +182,8 @@ if __name__ == "__main__":
177
182
  print(f"Farm efficiency : {o.calc_farm_efficiency()*100:.2f} %")
178
183
  print(f"Annual farm yield : {turbine_results[FV.YLD].sum():.2f} GWh")
179
184
 
185
+ engine.finalize()
186
+
180
187
  if not args.nofig:
181
188
  o = foxes.output.StateTurbineMap(farm_results)
182
189
  ax = o.plot_map(FV.P, cmap="inferno", figsize=(6, 7))
@@ -115,15 +115,15 @@ class Downwind(Algorithm):
115
115
  self.__states = states
116
116
  self.n_states = None
117
117
 
118
- self.__rotor_model = self.mbook.rotor_models[rotor_model]
118
+ self.__rotor_model = self.mbook.rotor_models.get_item(rotor_model)
119
119
  self.rotor_model.name = rotor_model
120
120
 
121
- self.__wake_frame = self.mbook.wake_frames[wake_frame]
121
+ self.__wake_frame = self.mbook.wake_frames.get_item(wake_frame)
122
122
  self.wake_frame.name = wake_frame
123
123
 
124
124
  self.__wake_models = {}
125
125
  for w in wake_models:
126
- m = self.mbook.wake_models[w]
126
+ m = self.mbook.wake_models.get_item(w)
127
127
  m.name = w
128
128
  self.wake_models[w] = m
129
129
 
@@ -137,10 +137,12 @@ class Downwind(Algorithm):
137
137
  try:
138
138
  pw = values
139
139
  if checkw:
140
- mbooks[pw].check_wmodel(self.wake_models[w], error=True)
140
+ mbooks.get_item(pw).check_wmodel(
141
+ self.wake_models[w], error=True
142
+ )
141
143
  except TypeError:
142
144
  pw = deffunc(self.wake_models[w])
143
- target[w] = mbooks[pw]
145
+ target[w] = mbooks.get_item(pw)
144
146
  target[w].name = pw
145
147
  elif isinstance(values, list):
146
148
  for i, w in enumerate(wake_models):
@@ -149,7 +151,7 @@ class Downwind(Algorithm):
149
151
  f"Not enough {descr} in list {values}, expecting {len(wake_models)}"
150
152
  )
151
153
  pw = values[i]
152
- target[w] = mbooks[pw]
154
+ target[w] = mbooks.get_item(pw)
153
155
  target[w].name = pw
154
156
  else:
155
157
  for w in wake_models:
@@ -157,7 +159,7 @@ class Downwind(Algorithm):
157
159
  pw = values[w]
158
160
  else:
159
161
  pw = deffunc(self.wake_models[w])
160
- target[w] = mbooks[pw]
162
+ target[w] = mbooks.get_item(pw)
161
163
  target[w].name = pw
162
164
 
163
165
  self.__partial_wakes = {}
@@ -180,7 +182,7 @@ class Downwind(Algorithm):
180
182
  checkw=False,
181
183
  )
182
184
 
183
- self.__farm_controller = self.mbook.farm_controllers[farm_controller]
185
+ self.__farm_controller = self.mbook.farm_controllers.get_item(farm_controller)
184
186
  self.farm_controller.name = farm_controller
185
187
 
186
188
  @property
@@ -541,7 +543,7 @@ class Downwind(Algorithm):
541
543
 
542
544
  # initialize models:
543
545
  if not mlist.initialized:
544
- mlist.initialize(self, self.verbosity)
546
+ mlist.initialize(self, self.verbosity - 1)
545
547
  self._calc_farm_vars(mlist)
546
548
  self._print_model_oder(mlist, calc_pars)
547
549
 
@@ -574,7 +576,7 @@ class Downwind(Algorithm):
574
576
  # finalize models:
575
577
  if finalize:
576
578
  self.print("\n")
577
- mlist.finalize(self, self.verbosity)
579
+ mlist.finalize(self, self.verbosity - 1)
578
580
  self.finalize()
579
581
  else:
580
582
  self.del_model_data(mlist)
@@ -678,6 +680,7 @@ class Downwind(Algorithm):
678
680
  farm_results,
679
681
  points,
680
682
  point_models=None,
683
+ outputs=None,
681
684
  calc_parameters={},
682
685
  persist_mdata=True,
683
686
  persist_pdata=False,
@@ -698,6 +701,8 @@ class Downwind(Algorithm):
698
701
  dimensions (state, turbine)
699
702
  points: numpy.ndarray
700
703
  The points of interest, shape: (n_states, n_points, 3)
704
+ outputs: list of str, optional
705
+ The output variables, or None for defaults
701
706
  point_models: str or foxes.core.PointDataModel
702
707
  Additional point models to be executed
703
708
  calc_parameters: dict
@@ -746,7 +751,7 @@ class Downwind(Algorithm):
746
751
 
747
752
  # initialize models:
748
753
  if not mlist.initialized:
749
- mlist.initialize(self, self.verbosity)
754
+ mlist.initialize(self, self.verbosity - 1)
750
755
 
751
756
  # subset selections:
752
757
  sel = {} if states_sel is None else {FC.STATE: states_sel}
@@ -780,7 +785,7 @@ class Downwind(Algorithm):
780
785
  self.print("\nInput point data:\n\n", point_data, "\n")
781
786
 
782
787
  # check vars:
783
- ovars = mlist.output_point_vars(self)
788
+ ovars = mlist.output_point_vars(self) if outputs is None else outputs
784
789
  self.print(f"\nOutput point variables:", ", ".join(ovars))
785
790
 
786
791
  # calculate:
@@ -800,7 +805,7 @@ class Downwind(Algorithm):
800
805
  # finalize models:
801
806
  if finalize:
802
807
  self.print("\n")
803
- mlist.finalize(self, self.verbosity)
808
+ mlist.finalize(self, self.verbosity - 1)
804
809
  self.finalize()
805
810
 
806
811
  if ambient:
@@ -34,7 +34,7 @@ class FarmWakesCalculation(FarmDataModel):
34
34
  return list(dict.fromkeys(ovars))
35
35
 
36
36
  def calculate(self, algo, mdata, fdata):
37
- """ "
37
+ """
38
38
  The main model calculation.
39
39
 
40
40
  This function is executed on a single chunk of data,
@@ -48,7 +48,7 @@ class InitFarmData(FarmDataModel):
48
48
  ]
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,
@@ -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,
@@ -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,
@@ -42,7 +42,7 @@ class SetAmbFarmResults(FarmDataModel):
42
42
  return [FV.var2amb[v] for v in self.vars]
43
43
 
44
44
  def calculate(self, algo, mdata, fdata):
45
- """ "
45
+ """
46
46
  The main model calculation.
47
47
 
48
48
  This function is executed on a single chunk of data,
@@ -61,7 +61,7 @@ class SetAmbPointResults(PointDataModel):
61
61
  return [FV.var2amb[v] for v in self.vars]
62
62
 
63
63
  def calculate(self, algo, mdata, fdata, pdata):
64
- """ "
64
+ """
65
65
  The main model calculation.
66
66
 
67
67
  This function is executed on a single chunk of data,
@@ -331,7 +331,7 @@ class Iterative(Downwind):
331
331
  self.finalize()
332
332
  for m in self._mlist0.models:
333
333
  if m not in self.sub_models():
334
- m.finalize(self, self.verbosity)
334
+ m.finalize(self, self.verbosity - 1)
335
335
  del self._mlist0, self._calc_pars0
336
336
 
337
337
  if ret_dwnd_order:
@@ -64,7 +64,7 @@ class FarmWakesCalculation(FarmDataModel):
64
64
  return [] if self.urelax is None else [self.urelax]
65
65
 
66
66
  def calculate(self, algo, mdata, fdata):
67
- """ "
67
+ """
68
68
  The main model calculation.
69
69
 
70
70
  This function is executed on a single chunk of data,
@@ -10,7 +10,7 @@ class URelax(FarmDataModel):
10
10
  ----------
11
11
  urel: dict
12
12
  The variables and their under-relaxation
13
- factors bewteen 0 and 1
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 bewteen 0 and 1
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 sequetial algorithm
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 sequetial algorithm
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 sequetial algorithm
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 sequetial algorithm
56
+ The final sequential algorithm
57
57
 
58
58
  """
59
59
  self.algo = algo
@@ -135,7 +135,7 @@ class SeqState(States):
135
135
  return self.states.output_point_vars(algo)
136
136
 
137
137
  def calculate(self, algo, mdata, fdata, tdata):
138
- """ "
138
+ """
139
139
  The main model calculation.
140
140
 
141
141
  This function is executed on a single chunk of data,
foxes/constants.py CHANGED
@@ -143,7 +143,7 @@ BLOCK_CONVERGENCE = "block_convergence"
143
143
 
144
144
 
145
145
  KAPPA = 0.41
146
- """ The Van-Karman constant
146
+ """ The Von Karman constant
147
147
  :group: foxes.constants
148
148
  """
149
149
 
@@ -154,22 +154,22 @@ W = "W"
154
154
  """
155
155
 
156
156
  kW = "kW"
157
- """ The unit kilo watt
157
+ """ The unit kilowatt
158
158
  :group: foxes.constants
159
159
  """
160
160
 
161
161
  MW = "MW"
162
- """ The unit mega watt
162
+ """ The unit megawatt
163
163
  :group: foxes.constants
164
164
  """
165
165
 
166
166
  GW = "GW"
167
- """ The unit giga watt
167
+ """ The unit gigawatt
168
168
  :group: foxes.constants
169
169
  """
170
170
 
171
171
  TW = "TW"
172
- """ The unit terra watt
172
+ """ The unit terawatt
173
173
  :group: foxes.constants
174
174
  """
175
175
 
foxes/core/algorithm.py CHANGED
@@ -179,7 +179,7 @@ class Algorithm(Model):
179
179
  raise ValueError(
180
180
  f"Algorithm '{self.name}': Cannot initialize while running"
181
181
  )
182
- super().initialize(self, self.verbosity)
182
+ super().initialize(self, self.verbosity - 1)
183
183
 
184
184
  def store_model_data(self, model, idata, force=False):
185
185
  """
@@ -894,7 +894,7 @@ class Algorithm(Model):
894
894
  """
895
895
  if self.running:
896
896
  raise ValueError(f"Algorithm '{self.name}': Cannot finalize while running")
897
- super().finalize(self, self.verbosity)
897
+ super().finalize(self, self.verbosity - 1)
898
898
  if clear_mem:
899
899
  self.__idata_mem = Dict()
900
900
  # self.reset_chunk_store()
@@ -5,7 +5,7 @@ from .model import Model
5
5
 
6
6
  class DataCalcModel(Model):
7
7
  """
8
- Abstract base class for models with
8
+ Abstract base class for models
9
9
  that run calculation on xarray Dataset
10
10
  data.
11
11
 
@@ -35,7 +35,7 @@ class DataCalcModel(Model):
35
35
 
36
36
  @abstractmethod
37
37
  def calculate(self, algo, *data, **parameters):
38
- """ "
38
+ """
39
39
  The main model calculation.
40
40
 
41
41
  This function is executed on a single chunk of data,
foxes/core/engine.py CHANGED
@@ -1,6 +1,6 @@
1
+ import os
1
2
  import numpy as np
2
3
  from abc import ABC, abstractmethod
3
- from os import cpu_count
4
4
  from tqdm import tqdm
5
5
  from xarray import Dataset
6
6
 
@@ -58,7 +58,10 @@ class Engine(ABC):
58
58
  """
59
59
  self.chunk_size_states = chunk_size_states
60
60
  self.chunk_size_points = chunk_size_points
61
- self.n_procs = n_procs if n_procs is not None else max(cpu_count() - 1, 1)
61
+ try:
62
+ self.n_procs = n_procs if n_procs is not None else os.process_cpu_count()
63
+ except AttributeError:
64
+ self.n_procs = os.cpu_count()
62
65
  self.verbosity = verbosity
63
66
  self.__initialized = False
64
67
  self.__entered = False
@@ -257,14 +260,18 @@ class Engine(ABC):
257
260
  chunk_sizes_targets = [n_targets]
258
261
  if n_targets > 1:
259
262
  if self.chunk_size_points is None:
260
- chunk_size_targets = n_targets
261
- n_chunks_targets = 1
263
+ if n_chunks_states == 1:
264
+ n_chunks_targets = min(self.n_procs, n_targets)
265
+ chunk_size_targets = max(int(n_targets / self.n_procs), 1)
266
+ else:
267
+ chunk_size_targets = n_targets
268
+ n_chunks_targets = 1
262
269
  else:
263
270
  chunk_size_targets = min(n_targets, self.chunk_size_points)
264
271
  n_chunks_targets = max(int(n_targets / chunk_size_targets), 1)
265
- if int(n_targets / n_chunks_targets) > chunk_size_targets:
266
- n_chunks_targets += 1
267
- chunk_size_targets = int(n_targets / n_chunks_targets)
272
+ if int(n_targets / n_chunks_targets) > chunk_size_targets:
273
+ n_chunks_targets += 1
274
+ chunk_size_targets = int(n_targets / n_chunks_targets)
268
275
  chunk_sizes_targets = np.full(n_chunks_targets, chunk_size_targets)
269
276
  extra = n_targets - n_chunks_targets * chunk_size_targets
270
277
  if extra > 0:
@@ -419,7 +426,7 @@ class Engine(ABC):
419
426
  The final results dataset
420
427
 
421
428
  """
422
- self.print("Combining results", level=2)
429
+ self.print(f"{type(self).__name__}: Combining results", level=2)
423
430
  pbar = tqdm(total=len(out_vars)) if self.verbosity > 1 else None
424
431
  data_vars = {}
425
432
  for v in out_vars:
@@ -502,10 +509,12 @@ class Engine(ABC):
502
509
  """
503
510
  n_states = model_data.sizes[FC.STATE]
504
511
  if point_data is None:
505
- self.print(f"Calculating {n_states} states for {algo.n_turbines} turbines")
512
+ self.print(
513
+ f"{type(self).__name__}: Calculating {n_states} states for {algo.n_turbines} turbines"
514
+ )
506
515
  else:
507
516
  self.print(
508
- f"Calculating data at {point_data.sizes[FC.TARGET]} points for {n_states} states"
517
+ f"{type(self).__name__}: Calculating data at {point_data.sizes[FC.TARGET]} points for {n_states} states"
509
518
  )
510
519
  if not self.initialized:
511
520
  raise ValueError(f"Engine '{type(self).__name__}' not initialized")
@@ -541,6 +550,7 @@ class Engine(ABC):
541
550
  local_cluster="LocalClusterEngine",
542
551
  slurm_cluster="SlurmClusterEngine",
543
552
  mpi="MPIEngine",
553
+ ray="RayEngine",
544
554
  numpy="NumpyEngine",
545
555
  single="SingleChunkEngine",
546
556
  ).get(engine_type, engine_type)
@@ -87,7 +87,7 @@ class FarmController(FarmDataModel):
87
87
 
88
88
  def needs_rews2(self):
89
89
  """
90
- Returns flag for requirering REWS2 variable
90
+ Returns flag for requiring REWS2 variable
91
91
 
92
92
  Returns
93
93
  -------
@@ -102,7 +102,7 @@ class FarmController(FarmDataModel):
102
102
 
103
103
  def needs_rews3(self):
104
104
  """
105
- Returns flag for requirering REWS3 variable
105
+ Returns flag for requiring REWS3 variable
106
106
 
107
107
  Returns
108
108
  -------
@@ -348,7 +348,7 @@ class FarmController(FarmDataModel):
348
348
  return list(ovars)
349
349
 
350
350
  def calculate(self, algo, mdata, fdata, pre_rotor, downwind_index=None):
351
- """ "
351
+ """
352
352
  The main model calculation.
353
353
 
354
354
  This function is executed on a single chunk of data,
@@ -87,7 +87,7 @@ class FarmDataModel(DataCalcModel):
87
87
 
88
88
  @abstractmethod
89
89
  def calculate(self, algo, mdata, fdata):
90
- """ "
90
+ """
91
91
  The main model calculation.
92
92
 
93
93
  This function is executed on a single chunk of data,
@@ -70,7 +70,7 @@ class GroundModel(Model):
70
70
  The target point data
71
71
  downwind_index: int
72
72
  The index of the wake causing turbine
73
- in the downwnd order
73
+ in the downwind order
74
74
  wake_deltas: dict
75
75
  The wake deltas. Key: variable name,
76
76
  value: numpy.ndarray with shape
@@ -207,7 +207,7 @@ class GroundModel(Model):
207
207
  The target point data
208
208
  downwind_index: int
209
209
  The index of the wake causing turbine
210
- in the downwnd order
210
+ in the downwind order
211
211
  wake_deltas: dict
212
212
  The wake deltas. Key: variable name,
213
213
  value: numpy.ndarray with shape