foxes 0.8.1__py3-none-any.whl → 1.0__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 (175) hide show
  1. docs/source/conf.py +353 -0
  2. examples/abl_states/run.py +160 -0
  3. examples/compare_rotors_pwakes/run.py +217 -0
  4. examples/compare_wakes/run.py +241 -0
  5. examples/dyn_wakes/run.py +311 -0
  6. examples/field_data_nc/run.py +121 -0
  7. examples/induction_RHB/run.py +201 -0
  8. examples/multi_height/run.py +113 -0
  9. examples/power_mask/run.py +249 -0
  10. examples/random_timeseries/run.py +210 -0
  11. examples/scan_row/run.py +193 -0
  12. examples/sector_management/run.py +162 -0
  13. examples/sequential/run.py +209 -0
  14. examples/single_state/run.py +201 -0
  15. examples/states_lookup_table/run.py +137 -0
  16. examples/streamline_wakes/run.py +138 -0
  17. examples/tab_file/run.py +142 -0
  18. examples/timelines/run.py +267 -0
  19. examples/timeseries/run.py +183 -0
  20. examples/timeseries_slurm/run.py +185 -0
  21. examples/wind_rose/run.py +141 -0
  22. examples/windio/run.py +29 -0
  23. examples/yawed_wake/run.py +196 -0
  24. foxes/__init__.py +4 -8
  25. foxes/algorithms/__init__.py +1 -1
  26. foxes/algorithms/downwind/downwind.py +232 -101
  27. foxes/algorithms/downwind/models/farm_wakes_calc.py +11 -6
  28. foxes/algorithms/downwind/models/init_farm_data.py +1 -1
  29. foxes/algorithms/downwind/models/point_wakes_calc.py +5 -6
  30. foxes/algorithms/downwind/models/reorder_farm_output.py +0 -1
  31. foxes/algorithms/downwind/models/set_amb_point_results.py +4 -2
  32. foxes/algorithms/iterative/iterative.py +73 -33
  33. foxes/algorithms/iterative/models/farm_wakes_calc.py +11 -6
  34. foxes/algorithms/sequential/models/plugin.py +1 -1
  35. foxes/algorithms/sequential/sequential.py +126 -255
  36. foxes/constants.py +17 -2
  37. foxes/core/__init__.py +1 -0
  38. foxes/core/algorithm.py +631 -146
  39. foxes/core/data.py +252 -20
  40. foxes/core/data_calc_model.py +13 -289
  41. foxes/core/engine.py +630 -0
  42. foxes/core/farm_controller.py +37 -9
  43. foxes/core/farm_data_model.py +15 -0
  44. foxes/core/model.py +133 -80
  45. foxes/core/point_data_model.py +15 -0
  46. foxes/core/rotor_model.py +27 -21
  47. foxes/core/states.py +16 -0
  48. foxes/core/turbine_type.py +28 -0
  49. foxes/core/wake_frame.py +22 -4
  50. foxes/core/wake_model.py +2 -3
  51. foxes/data/windio/windio_5turbines_timeseries.yaml +23 -1
  52. foxes/engines/__init__.py +16 -0
  53. foxes/engines/dask.py +975 -0
  54. foxes/engines/default.py +75 -0
  55. foxes/engines/futures.py +72 -0
  56. foxes/engines/mpi.py +38 -0
  57. foxes/engines/multiprocess.py +74 -0
  58. foxes/engines/numpy.py +185 -0
  59. foxes/engines/pool.py +263 -0
  60. foxes/engines/single.py +139 -0
  61. foxes/input/farm_layout/__init__.py +1 -0
  62. foxes/input/farm_layout/from_csv.py +4 -0
  63. foxes/input/farm_layout/from_json.py +1 -1
  64. foxes/input/farm_layout/grid.py +2 -2
  65. foxes/input/farm_layout/ring.py +65 -0
  66. foxes/input/farm_layout/row.py +2 -2
  67. foxes/input/states/__init__.py +6 -0
  68. foxes/input/states/create/random_abl_states.py +1 -1
  69. foxes/input/states/field_data_nc.py +157 -32
  70. foxes/input/states/multi_height.py +127 -13
  71. foxes/input/states/one_point_flow.py +577 -0
  72. foxes/input/states/scan_ws.py +73 -2
  73. foxes/input/states/states_table.py +204 -35
  74. foxes/input/windio/__init__.py +1 -1
  75. foxes/input/windio/get_states.py +44 -23
  76. foxes/input/windio/read_attributes.py +41 -16
  77. foxes/input/windio/read_farm.py +116 -102
  78. foxes/input/windio/read_fields.py +13 -6
  79. foxes/input/windio/read_outputs.py +63 -22
  80. foxes/input/windio/runner.py +31 -17
  81. foxes/input/windio/windio.py +36 -22
  82. foxes/models/ground_models/wake_mirror.py +8 -4
  83. foxes/models/model_book.py +29 -18
  84. foxes/models/partial_wakes/rotor_points.py +3 -3
  85. foxes/models/rotor_models/centre.py +4 -0
  86. foxes/models/rotor_models/grid.py +22 -23
  87. foxes/models/rotor_models/levels.py +4 -5
  88. foxes/models/turbine_models/calculator.py +0 -2
  89. foxes/models/turbine_models/lookup_table.py +27 -2
  90. foxes/models/turbine_models/rotor_centre_calc.py +4 -3
  91. foxes/models/turbine_models/set_farm_vars.py +103 -34
  92. foxes/models/turbine_types/PCt_file.py +24 -0
  93. foxes/models/turbine_types/PCt_from_two.py +24 -0
  94. foxes/models/turbine_types/__init__.py +1 -0
  95. foxes/models/turbine_types/lookup.py +316 -0
  96. foxes/models/turbine_types/null_type.py +50 -0
  97. foxes/models/turbine_types/wsrho2PCt_from_two.py +24 -0
  98. foxes/models/turbine_types/wsti2PCt_from_two.py +24 -0
  99. foxes/models/vertical_profiles/data_profile.py +1 -1
  100. foxes/models/wake_frames/__init__.py +1 -0
  101. foxes/models/wake_frames/dynamic_wakes.py +424 -0
  102. foxes/models/wake_frames/farm_order.py +23 -3
  103. foxes/models/wake_frames/rotor_wd.py +4 -2
  104. foxes/models/wake_frames/seq_dynamic_wakes.py +56 -63
  105. foxes/models/wake_frames/streamlines.py +19 -20
  106. foxes/models/wake_frames/timelines.py +328 -127
  107. foxes/models/wake_frames/yawed_wakes.py +4 -1
  108. foxes/models/wake_models/dist_sliced.py +1 -3
  109. foxes/models/wake_models/induction/rankine_half_body.py +4 -4
  110. foxes/models/wake_models/induction/rathmann.py +2 -2
  111. foxes/models/wake_models/induction/self_similar.py +2 -2
  112. foxes/models/wake_models/induction/vortex_sheet.py +2 -2
  113. foxes/models/wake_models/ti/iec_ti.py +34 -17
  114. foxes/models/wake_models/top_hat.py +1 -1
  115. foxes/models/wake_models/wind/bastankhah14.py +2 -2
  116. foxes/models/wake_models/wind/bastankhah16.py +8 -7
  117. foxes/models/wake_models/wind/jensen.py +1 -1
  118. foxes/models/wake_models/wind/turbopark.py +2 -2
  119. foxes/output/__init__.py +4 -1
  120. foxes/output/farm_layout.py +2 -2
  121. foxes/output/flow_plots_2d/__init__.py +0 -1
  122. foxes/output/flow_plots_2d/flow_plots.py +70 -30
  123. foxes/output/grids.py +91 -21
  124. foxes/output/seq_plugins/__init__.py +2 -0
  125. foxes/output/{flow_plots_2d → seq_plugins}/seq_flow_ani_plugin.py +62 -20
  126. foxes/output/seq_plugins/seq_wake_debug_plugin.py +145 -0
  127. foxes/output/slice_data.py +131 -111
  128. foxes/output/state_turbine_map.py +18 -13
  129. foxes/output/state_turbine_table.py +19 -19
  130. foxes/utils/__init__.py +1 -1
  131. foxes/utils/dev_utils.py +42 -0
  132. foxes/utils/dict.py +1 -1
  133. foxes/utils/factory.py +147 -52
  134. foxes/utils/pandas_helpers.py +4 -3
  135. foxes/utils/wind_dir.py +0 -2
  136. foxes/utils/xarray_utils.py +25 -13
  137. foxes/variables.py +37 -0
  138. {foxes-0.8.1.dist-info → foxes-1.0.dist-info}/METADATA +72 -34
  139. foxes-1.0.dist-info/RECORD +307 -0
  140. {foxes-0.8.1.dist-info → foxes-1.0.dist-info}/WHEEL +1 -1
  141. foxes-1.0.dist-info/top_level.txt +4 -0
  142. tests/0_consistency/iterative/test_iterative.py +92 -0
  143. tests/0_consistency/partial_wakes/test_partial_wakes.py +90 -0
  144. tests/1_verification/flappy_0_6/PCt_files/flappy/run.py +85 -0
  145. tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +103 -0
  146. tests/1_verification/flappy_0_6/abl_states/flappy/run.py +85 -0
  147. tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +87 -0
  148. tests/1_verification/flappy_0_6/partial_top_hat/flappy/run.py +82 -0
  149. tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +82 -0
  150. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/flappy/run.py +92 -0
  151. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +93 -0
  152. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/flappy/run.py +92 -0
  153. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +96 -0
  154. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/flappy/run.py +94 -0
  155. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +122 -0
  156. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/flappy/run.py +94 -0
  157. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +122 -0
  158. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/flappy/run.py +92 -0
  159. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +93 -0
  160. tests/1_verification/flappy_0_6_2/grid_rotors/flappy/run.py +85 -0
  161. tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +130 -0
  162. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/flappy/run.py +96 -0
  163. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +116 -0
  164. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/flappy/run.py +93 -0
  165. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +99 -0
  166. tests/3_examples/test_examples.py +34 -0
  167. foxes/VERSION +0 -1
  168. foxes/output/flow_plots_2d.py +0 -0
  169. foxes/utils/plotly_helpers.py +0 -19
  170. foxes/utils/runners/__init__.py +0 -1
  171. foxes/utils/runners/runners.py +0 -280
  172. foxes-0.8.1.dist-info/RECORD +0 -248
  173. foxes-0.8.1.dist-info/top_level.txt +0 -1
  174. foxes-0.8.1.dist-info/zip-safe +0 -1
  175. {foxes-0.8.1.dist-info → foxes-1.0.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
- try:
24
- from importlib.resources import files
24
+ from importlib.metadata import version
25
25
 
26
- __version__ = files(__package__).joinpath("VERSION").read_text()
27
- except ImportError:
28
- from importlib.resources import read_text
29
-
30
- __version__ = read_text(__package__, "VERSION")
26
+ __version__ = version(__package__ or __name__)
@@ -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.sequential import Sequential
7
+ from .sequential import Sequential
8
8
 
9
9
  from . import downwind
10
10
  from . import iterative