foxes 1.1.1__py3-none-any.whl → 1.2.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 (155) hide show
  1. docs/source/conf.py +3 -1
  2. examples/abl_states/run.py +5 -5
  3. examples/dyn_wakes/run.py +2 -2
  4. examples/induction/run.py +5 -5
  5. examples/random_timeseries/run.py +13 -13
  6. examples/scan_row/run.py +12 -7
  7. examples/sector_management/run.py +11 -7
  8. examples/single_state/run.py +5 -5
  9. examples/tab_file/run.py +1 -1
  10. examples/timelines/run.py +1 -1
  11. examples/timeseries/run.py +5 -5
  12. examples/timeseries_slurm/run.py +5 -5
  13. examples/wind_rose/run.py +1 -1
  14. examples/yawed_wake/run.py +5 -5
  15. foxes/__init__.py +13 -2
  16. foxes/algorithms/downwind/downwind.py +21 -6
  17. foxes/algorithms/downwind/models/init_farm_data.py +5 -2
  18. foxes/algorithms/downwind/models/point_wakes_calc.py +0 -1
  19. foxes/algorithms/iterative/iterative.py +1 -1
  20. foxes/algorithms/sequential/sequential.py +5 -4
  21. foxes/config/__init__.py +1 -0
  22. foxes/config/config.py +134 -0
  23. foxes/constants.py +15 -6
  24. foxes/core/algorithm.py +46 -30
  25. foxes/core/axial_induction_model.py +18 -0
  26. foxes/core/data.py +2 -1
  27. foxes/core/engine.py +43 -49
  28. foxes/core/farm_controller.py +22 -3
  29. foxes/core/farm_data_model.py +6 -2
  30. foxes/core/ground_model.py +19 -0
  31. foxes/core/model.py +2 -1
  32. foxes/core/partial_wakes_model.py +9 -21
  33. foxes/core/point_data_model.py +22 -2
  34. foxes/core/rotor_model.py +9 -21
  35. foxes/core/states.py +2 -17
  36. foxes/core/turbine_model.py +2 -18
  37. foxes/core/turbine_type.py +2 -18
  38. foxes/core/vertical_profile.py +8 -20
  39. foxes/core/wake_frame.py +9 -25
  40. foxes/core/wake_model.py +24 -20
  41. foxes/core/wake_superposition.py +19 -0
  42. foxes/data/__init__.py +1 -1
  43. foxes/data/static_data.py +0 -7
  44. foxes/engines/dask.py +4 -3
  45. foxes/engines/single.py +1 -1
  46. foxes/input/__init__.py +1 -1
  47. foxes/input/farm_layout/from_csv.py +3 -1
  48. foxes/input/farm_layout/from_file.py +10 -10
  49. foxes/input/farm_layout/from_json.py +4 -3
  50. foxes/input/farm_layout/grid.py +3 -3
  51. foxes/input/states/__init__.py +1 -1
  52. foxes/input/states/create/random_abl_states.py +5 -3
  53. foxes/input/states/field_data_nc.py +36 -15
  54. foxes/input/states/multi_height.py +26 -15
  55. foxes/input/states/one_point_flow.py +6 -5
  56. foxes/input/states/{scan_ws.py → scan.py} +42 -52
  57. foxes/input/states/single.py +15 -6
  58. foxes/input/states/slice_data_nc.py +18 -12
  59. foxes/input/states/states_table.py +17 -10
  60. foxes/input/yaml/__init__.py +3 -0
  61. foxes/input/yaml/dict.py +381 -0
  62. foxes/input/yaml/windio/__init__.py +4 -0
  63. foxes/input/{windio → yaml/windio}/get_states.py +7 -7
  64. foxes/input/{windio → yaml/windio}/read_attributes.py +61 -40
  65. foxes/input/{windio → yaml/windio}/read_farm.py +34 -43
  66. foxes/input/{windio → yaml/windio}/read_fields.py +11 -10
  67. foxes/input/yaml/windio/read_outputs.py +147 -0
  68. foxes/input/yaml/windio/windio.py +269 -0
  69. foxes/input/yaml/yaml.py +103 -0
  70. foxes/models/partial_wakes/axiwake.py +7 -6
  71. foxes/models/partial_wakes/centre.py +3 -2
  72. foxes/models/partial_wakes/segregated.py +5 -2
  73. foxes/models/point_models/set_uniform_data.py +5 -3
  74. foxes/models/rotor_models/centre.py +2 -2
  75. foxes/models/rotor_models/grid.py +5 -5
  76. foxes/models/rotor_models/levels.py +6 -6
  77. foxes/models/turbine_models/kTI_model.py +3 -1
  78. foxes/models/turbine_models/lookup_table.py +7 -4
  79. foxes/models/turbine_models/power_mask.py +14 -8
  80. foxes/models/turbine_models/sector_management.py +4 -2
  81. foxes/models/turbine_models/set_farm_vars.py +53 -23
  82. foxes/models/turbine_models/table_factors.py +8 -7
  83. foxes/models/turbine_models/yaw2yawm.py +0 -1
  84. foxes/models/turbine_models/yawm2yaw.py +0 -1
  85. foxes/models/turbine_types/CpCt_file.py +6 -3
  86. foxes/models/turbine_types/CpCt_from_two.py +6 -3
  87. foxes/models/turbine_types/PCt_file.py +7 -6
  88. foxes/models/turbine_types/PCt_from_two.py +11 -2
  89. foxes/models/turbine_types/TBL_file.py +3 -4
  90. foxes/models/turbine_types/wsrho2PCt_from_two.py +19 -11
  91. foxes/models/turbine_types/wsti2PCt_from_two.py +19 -11
  92. foxes/models/vertical_profiles/abl_log_neutral_ws.py +1 -1
  93. foxes/models/vertical_profiles/abl_log_stable_ws.py +1 -1
  94. foxes/models/vertical_profiles/abl_log_unstable_ws.py +1 -1
  95. foxes/models/vertical_profiles/abl_log_ws.py +1 -1
  96. foxes/models/wake_frames/dynamic_wakes.py +17 -9
  97. foxes/models/wake_frames/farm_order.py +4 -3
  98. foxes/models/wake_frames/rotor_wd.py +3 -1
  99. foxes/models/wake_frames/seq_dynamic_wakes.py +14 -7
  100. foxes/models/wake_frames/streamlines.py +9 -6
  101. foxes/models/wake_frames/timelines.py +21 -14
  102. foxes/models/wake_frames/yawed_wakes.py +3 -1
  103. foxes/models/wake_models/induction/vortex_sheet.py +0 -1
  104. foxes/models/wake_models/ti/crespo_hernandez.py +2 -1
  105. foxes/models/wake_models/wind/bastankhah14.py +3 -2
  106. foxes/models/wake_models/wind/bastankhah16.py +2 -1
  107. foxes/models/wake_models/wind/turbopark.py +9 -7
  108. foxes/models/wake_superpositions/ws_product.py +0 -1
  109. foxes/output/__init__.py +2 -1
  110. foxes/output/calc_points.py +7 -4
  111. foxes/output/farm_layout.py +30 -18
  112. foxes/output/farm_results_eval.py +61 -38
  113. foxes/output/grids.py +8 -7
  114. foxes/output/output.py +9 -20
  115. foxes/output/plt.py +19 -0
  116. foxes/output/results_writer.py +10 -11
  117. foxes/output/rose_plot.py +448 -224
  118. foxes/output/rotor_point_plots.py +7 -3
  119. foxes/output/slice_data.py +1 -1
  120. foxes/output/state_turbine_map.py +5 -1
  121. foxes/output/state_turbine_table.py +7 -3
  122. foxes/output/turbine_type_curves.py +7 -2
  123. foxes/utils/__init__.py +1 -2
  124. foxes/utils/dict.py +107 -3
  125. foxes/utils/geopandas_utils.py +3 -2
  126. foxes/utils/subclasses.py +69 -0
  127. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/METADATA +18 -18
  128. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/RECORD +145 -145
  129. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/WHEEL +1 -1
  130. foxes-1.2.1.dist-info/entry_points.txt +3 -0
  131. tests/0_consistency/iterative/test_iterative.py +65 -67
  132. tests/0_consistency/partial_wakes/test_partial_wakes.py +58 -61
  133. tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +56 -53
  134. tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +41 -41
  135. tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +34 -34
  136. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +57 -52
  137. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +58 -54
  138. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +80 -76
  139. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +80 -76
  140. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +58 -51
  141. tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +101 -103
  142. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +67 -64
  143. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +58 -54
  144. examples/windio/run.py +0 -29
  145. foxes/data/states/windio_timeseries_5000.nc +0 -0
  146. foxes/data/windio/DTU_10MW_turbine.yaml +0 -10
  147. foxes/data/windio/__init__.py +0 -0
  148. foxes/data/windio/windio_5turbines_timeseries.yaml +0 -79
  149. foxes/input/windio/__init__.py +0 -11
  150. foxes/input/windio/read_outputs.py +0 -172
  151. foxes/input/windio/runner.py +0 -183
  152. foxes/input/windio/windio.py +0 -193
  153. foxes/utils/windrose_plot.py +0 -152
  154. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/LICENSE +0 -0
  155. {foxes-1.1.1.dist-info → foxes-1.2.1.dist-info}/top_level.txt +0 -0
@@ -5,7 +5,6 @@ import inspect
5
5
 
6
6
  import foxes
7
7
  import foxes.variables as FV
8
- import foxes.constants as FC
9
8
 
10
9
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
11
10
 
@@ -13,7 +12,6 @@ thisdir = Path(inspect.getfile(inspect.currentframe())).parent
13
12
  def test():
14
13
  n_s = 800
15
14
  n_t = 76
16
- c = 1000
17
15
  p0 = np.array([0.0, 0.0])
18
16
  stp = np.array([497.0, 0.0])
19
17
  cfile = thisdir / "flappy" / "results.csv.gz"
@@ -25,8 +23,13 @@ def test():
25
23
  )
26
24
  mbook.turbine_types[ttype.name] = ttype
27
25
 
28
- states = foxes.input.states.ScanWS(
29
- ws_list=np.linspace(3.0, 30.0, n_s), wd=270.0, ti=0.08, rho=1.225
26
+ states = foxes.input.states.ScanStates(
27
+ {
28
+ FV.WS: np.linspace(3.0, 30.0, n_s),
29
+ FV.WD: [270],
30
+ FV.TI: [0.08],
31
+ FV.RHO: [1.225],
32
+ }
30
33
  )
31
34
 
32
35
  farm = foxes.WindFarm()
@@ -39,54 +42,56 @@ def test():
39
42
  verbosity=0,
40
43
  )
41
44
 
42
- algo = foxes.algorithms.Downwind(
43
- farm,
44
- states,
45
- mbook=mbook,
46
- rotor_model="centre",
47
- wake_models=["Jensen_linear_k007"],
48
- wake_frame="rotor_wd",
49
- partial_wakes={"Jensen_linear_k007": "rotor_points"},
50
- verbosity=0,
51
- )
52
-
53
- data = algo.calc_farm()
54
-
55
- df = data.to_dataframe()[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
56
-
57
- print("\nReading file", cfile)
58
- fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
59
-
60
- print()
61
- print("TRESULTS\n")
62
- sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
63
- df = df.loc[sel]
64
- fdata = fdata.loc[sel]
65
- print(df.loc[sel])
66
- print(fdata.loc[sel])
67
-
68
- print("\nVERIFYING\n")
69
- df[FV.WS] = df["REWS"]
70
- df[FV.AMB_WS] = df["AMB_REWS"]
71
-
72
- delta = df - fdata
73
- print(delta)
74
-
75
- chk = delta.abs()
76
- print(chk.max())
77
-
78
- var = FV.WS
79
- print(f"\nCHECKING {var}")
80
- sel = chk[var] >= 1e-7
81
- print(df.loc[sel])
82
- print(fdata.loc[sel])
83
- print(chk.loc[sel])
84
- assert (chk[var] < 1e-7).all()
85
-
86
- var = FV.P
87
- sel = chk[var] >= 1e-5
88
- print(f"\nCHECKING {var}\n", delta.loc[sel])
89
- assert (chk[var] < 1e-5).all()
45
+ with foxes.Engine.new("threads", chunk_size_states=1000):
46
+
47
+ algo = foxes.algorithms.Downwind(
48
+ farm,
49
+ states,
50
+ mbook=mbook,
51
+ rotor_model="centre",
52
+ wake_models=["Jensen_linear_k007"],
53
+ wake_frame="rotor_wd",
54
+ partial_wakes={"Jensen_linear_k007": "rotor_points"},
55
+ verbosity=0,
56
+ )
57
+
58
+ data = algo.calc_farm()
59
+
60
+ df = data.to_dataframe()[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
61
+
62
+ print("\nReading file", cfile)
63
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
64
+
65
+ print()
66
+ print("TRESULTS\n")
67
+ sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
68
+ df = df.loc[sel]
69
+ fdata = fdata.loc[sel]
70
+ print(df.loc[sel])
71
+ print(fdata.loc[sel])
72
+
73
+ print("\nVERIFYING\n")
74
+ df[FV.WS] = df["REWS"]
75
+ df[FV.AMB_WS] = df["AMB_REWS"]
76
+
77
+ delta = df - fdata
78
+ print(delta)
79
+
80
+ chk = delta.abs()
81
+ print(chk.max())
82
+
83
+ var = FV.WS
84
+ print(f"\nCHECKING {var}")
85
+ sel = chk[var] >= 1e-7
86
+ print(df.loc[sel])
87
+ print(fdata.loc[sel])
88
+ print(chk.loc[sel])
89
+ assert (chk[var] < 1e-7).all()
90
+
91
+ var = FV.P
92
+ sel = chk[var] >= 1e-5
93
+ print(f"\nCHECKING {var}\n", delta.loc[sel])
94
+ assert (chk[var] < 1e-5).all()
90
95
 
91
96
 
92
97
  if __name__ == "__main__":
@@ -5,7 +5,7 @@ import inspect
5
5
 
6
6
  import foxes
7
7
  import foxes.variables as FV
8
- import foxes.constants as FC
8
+ from foxes.config import config
9
9
 
10
10
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
11
11
 
@@ -19,16 +19,19 @@ def test():
19
19
  cfile = thisdir / "flappy" / "results.csv.gz"
20
20
  tfile = thisdir / "NREL-5MW-D126-H90.csv"
21
21
 
22
- ck = {FC.STATE: c}
23
-
24
22
  mbook = foxes.models.ModelBook()
25
23
  ttype = foxes.models.turbine_types.PCtFile(
26
24
  data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
27
25
  )
28
26
  mbook.turbine_types[ttype.name] = ttype
29
27
 
30
- states = foxes.input.states.ScanWS(
31
- ws_list=np.linspace(3.0, 30.0, n_s), wd=270.0, ti=0.08, rho=1.225
28
+ states = foxes.input.states.ScanStates(
29
+ {
30
+ FV.WS: np.linspace(3.0, 30.0, n_s),
31
+ FV.WD: [270],
32
+ FV.TI: [0.08],
33
+ FV.RHO: [1.225],
34
+ }
32
35
  )
33
36
 
34
37
  farm = foxes.WindFarm()
@@ -41,55 +44,56 @@ def test():
41
44
  verbosity=0,
42
45
  )
43
46
 
44
- algo = foxes.algorithms.Downwind(
45
- farm,
46
- states,
47
- mbook=mbook,
48
- rotor_model="centre",
49
- wake_models=["Jensen_linear_k007"],
50
- wake_frame="rotor_wd",
51
- partial_wakes={"Jensen_linear_k007": "top_hat"},
52
- chunks=ck,
53
- verbosity=0,
54
- )
55
-
56
- data = algo.calc_farm()
57
-
58
- df = data.to_dataframe()[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
59
-
60
- print("\nReading file", cfile)
61
- fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
62
-
63
- print()
64
- print("TRESULTS\n")
65
- sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
66
- df = df.loc[sel]
67
- fdata = fdata.loc[sel]
68
- print(df.loc[sel])
69
- print(fdata.loc[sel])
70
-
71
- print("\nVERIFYING\n")
72
- df[FV.WS] = df["REWS"]
73
- df[FV.AMB_WS] = df["AMB_REWS"]
74
-
75
- delta = df - fdata
76
- print(delta)
77
-
78
- chk = delta.abs()
79
- print(chk.max())
80
-
81
- var = FV.WS
82
- print(f"\nCHECKING {var}")
83
- sel = chk[var] >= 1e-7
84
- print(df.loc[sel])
85
- print(fdata.loc[sel])
86
- print(chk.loc[sel])
87
- assert (chk[var] < 1e-7).all()
88
-
89
- var = FV.P
90
- sel = chk[var] >= 1e-5
91
- print(f"\nCHECKING {var}\n", delta.loc[sel])
92
- assert (chk[var] < 1e-5).all()
47
+ with foxes.Engine.new("threads", chunk_size_states=c):
48
+
49
+ algo = foxes.algorithms.Downwind(
50
+ farm,
51
+ states,
52
+ mbook=mbook,
53
+ rotor_model="centre",
54
+ wake_models=["Jensen_linear_k007"],
55
+ wake_frame="rotor_wd",
56
+ partial_wakes={"Jensen_linear_k007": "top_hat"},
57
+ verbosity=0,
58
+ )
59
+
60
+ data = algo.calc_farm()
61
+
62
+ df = data.to_dataframe()[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
63
+
64
+ print("\nReading file", cfile)
65
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
66
+
67
+ print()
68
+ print("TRESULTS\n")
69
+ sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
70
+ df = df.loc[sel]
71
+ fdata = fdata.loc[sel]
72
+ print(df.loc[sel])
73
+ print(fdata.loc[sel])
74
+
75
+ print("\nVERIFYING\n")
76
+ df[FV.WS] = df["REWS"]
77
+ df[FV.AMB_WS] = df["AMB_REWS"]
78
+
79
+ delta = df - fdata
80
+ print(delta)
81
+
82
+ chk = delta.abs()
83
+ print(chk.max())
84
+
85
+ var = FV.WS
86
+ print(f"\nCHECKING {var}")
87
+ sel = chk[var] >= 1e-7
88
+ print(df.loc[sel])
89
+ print(fdata.loc[sel])
90
+ print(chk.loc[sel])
91
+ assert (chk[var] < 1e-7).all()
92
+
93
+ var = FV.P
94
+ sel = chk[var] >= 1e-5
95
+ print(f"\nCHECKING {var}\n", delta.loc[sel])
96
+ assert (chk[var] < 1e-5).all()
93
97
 
94
98
 
95
99
  if __name__ == "__main__":
@@ -5,7 +5,7 @@ import inspect
5
5
 
6
6
  import foxes
7
7
  import foxes.variables as FV
8
- import foxes.constants as FC
8
+ from foxes.config import config
9
9
 
10
10
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
11
11
 
@@ -22,16 +22,19 @@ def test():
22
22
  cfile = thisdir / "flappy" / "results.csv.gz"
23
23
  tfile = thisdir / "NREL-5MW-D126-H90.csv"
24
24
 
25
- ck = {FC.STATE: c}
26
-
27
25
  mbook = foxes.models.ModelBook()
28
26
  ttype = foxes.models.turbine_types.PCtFile(
29
27
  data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
30
28
  )
31
29
  mbook.turbine_types[ttype.name] = ttype
32
30
 
33
- states = foxes.input.states.ScanWS(
34
- ws_list=np.linspace(6.0, 16.0, n_s), wd=wd, ti=ti, rho=1.225
31
+ states = foxes.input.states.ScanStates(
32
+ {
33
+ FV.WS: np.linspace(6.0, 16.0, n_s),
34
+ FV.WD: [wd],
35
+ FV.TI: [ti],
36
+ FV.RHO: [1.225],
37
+ }
35
38
  )
36
39
 
37
40
  farm = foxes.WindFarm()
@@ -44,78 +47,79 @@ def test():
44
47
  verbosity=1,
45
48
  )
46
49
 
47
- algo = foxes.algorithms.Downwind(
48
- farm,
49
- states,
50
- rotor_model="centre",
51
- mbook=mbook,
52
- wake_models=["Jensen_linear_k007", "IECTI2005_max"],
53
- wake_frame="rotor_wd",
54
- partial_wakes=["top_hat", "top_hat"],
55
- chunks=ck,
56
- verbosity=1,
57
- )
58
-
59
- data = algo.calc_farm()
60
-
61
- df = data.to_dataframe()[
62
- [
63
- FV.X,
64
- FV.Y,
65
- FV.WD,
66
- FV.AMB_REWS,
67
- FV.REWS,
68
- FV.AMB_TI,
69
- FV.TI,
70
- FV.AMB_CT,
71
- FV.CT,
50
+ with foxes.Engine.new("threads", chunk_size_states=c):
51
+
52
+ algo = foxes.algorithms.Downwind(
53
+ farm,
54
+ states,
55
+ rotor_model=rotor,
56
+ mbook=mbook,
57
+ wake_models=["Jensen_linear_k007", "IECTI2005_max"],
58
+ wake_frame="rotor_wd",
59
+ partial_wakes=["top_hat", "top_hat"],
60
+ verbosity=1,
61
+ )
62
+
63
+ data = algo.calc_farm()
64
+
65
+ df = data.to_dataframe()[
66
+ [
67
+ FV.X,
68
+ FV.Y,
69
+ FV.WD,
70
+ FV.AMB_REWS,
71
+ FV.REWS,
72
+ FV.AMB_TI,
73
+ FV.TI,
74
+ FV.AMB_CT,
75
+ FV.CT,
76
+ ]
72
77
  ]
73
- ]
74
-
75
- print("\nReading file", cfile)
76
- fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
77
-
78
- print()
79
- print("TRESULTS\n")
80
- """sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
81
- df = df.loc[sel]
82
- fdata = fdata.loc[sel]"""
83
- print(df)
84
- print(fdata)
85
-
86
- print("\nVERIFYING\n")
87
- df[FV.WS] = df["REWS"]
88
- df[FV.AMB_WS] = df["AMB_REWS"]
89
-
90
- delta = df - fdata
91
- print(delta)
92
-
93
- chk = delta.abs()
94
- print(chk.max())
95
-
96
- var = FV.WS
97
- print(f"\nCHECKING {var}")
98
- sel = chk[var] >= 3e-3
99
- print(df.loc[sel])
100
- print(fdata.loc[sel])
101
- print(chk.loc[sel])
102
- assert (chk[var] < 3e-3).all()
103
-
104
- var = FV.TI
105
- print(f"\nCHECKING {var}")
106
- sel = chk[var] >= 3e-4
107
- print(df.loc[sel])
108
- print(fdata.loc[sel])
109
- print(chk.loc[sel])
110
- assert (chk[var] < 3e-4).all()
111
-
112
- var = FV.CT
113
- print(f"\nCHECKING {var}")
114
- sel = chk[var] >= 3e-5
115
- print(df.loc[sel])
116
- print(fdata.loc[sel])
117
- print(chk.loc[sel])
118
- assert (chk[var] < 3e-5).all()
78
+
79
+ print("\nReading file", cfile)
80
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
81
+
82
+ print()
83
+ print("TRESULTS\n")
84
+ """sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
85
+ df = df.loc[sel]
86
+ fdata = fdata.loc[sel]"""
87
+ print(df)
88
+ print(fdata)
89
+
90
+ print("\nVERIFYING\n")
91
+ df[FV.WS] = df["REWS"]
92
+ df[FV.AMB_WS] = df["AMB_REWS"]
93
+
94
+ delta = df - fdata
95
+ print(delta)
96
+
97
+ chk = delta.abs()
98
+ print(chk.max())
99
+
100
+ var = FV.WS
101
+ print(f"\nCHECKING {var}")
102
+ sel = chk[var] >= 3e-3
103
+ print(df.loc[sel])
104
+ print(fdata.loc[sel])
105
+ print(chk.loc[sel])
106
+ assert (chk[var] < 3e-3).all()
107
+
108
+ var = FV.TI
109
+ print(f"\nCHECKING {var}")
110
+ sel = chk[var] >= 3e-4
111
+ print(df.loc[sel])
112
+ print(fdata.loc[sel])
113
+ print(chk.loc[sel])
114
+ assert (chk[var] < 3e-4).all()
115
+
116
+ var = FV.CT
117
+ print(f"\nCHECKING {var}")
118
+ sel = chk[var] >= 3e-5
119
+ print(df.loc[sel])
120
+ print(fdata.loc[sel])
121
+ print(chk.loc[sel])
122
+ assert (chk[var] < 3e-5).all()
119
123
 
120
124
 
121
125
  if __name__ == "__main__":
@@ -5,7 +5,7 @@ import inspect
5
5
 
6
6
  import foxes
7
7
  import foxes.variables as FV
8
- import foxes.constants as FC
8
+ from foxes.config import config
9
9
 
10
10
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
11
11
 
@@ -22,16 +22,19 @@ def test():
22
22
  cfile = thisdir / "flappy" / "results.csv.gz"
23
23
  tfile = thisdir / "NREL-5MW-D126-H90.csv"
24
24
 
25
- ck = {FC.STATE: c}
26
-
27
25
  mbook = foxes.models.ModelBook()
28
26
  ttype = foxes.models.turbine_types.PCtFile(
29
27
  data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
30
28
  )
31
29
  mbook.turbine_types[ttype.name] = ttype
32
30
 
33
- states = foxes.input.states.ScanWS(
34
- ws_list=np.linspace(6.0, 16.0, n_s), wd=wd, ti=ti, rho=1.225
31
+ states = foxes.input.states.ScanStates(
32
+ {
33
+ FV.WS: np.linspace(6.0, 16.0, n_s),
34
+ FV.WD: [wd],
35
+ FV.TI: [ti],
36
+ FV.RHO: [1.225],
37
+ }
35
38
  )
36
39
 
37
40
  farm = foxes.WindFarm()
@@ -44,78 +47,79 @@ def test():
44
47
  verbosity=1,
45
48
  )
46
49
 
47
- algo = foxes.algorithms.Downwind(
48
- farm,
49
- states,
50
- mbook=mbook,
51
- rotor_model=rotor,
52
- wake_models=["Jensen_linear_k007", "IECTI2019_max"],
53
- wake_frame="rotor_wd",
54
- partial_wakes=["top_hat", "top_hat"],
55
- chunks=ck,
56
- verbosity=1,
57
- )
58
-
59
- data = algo.calc_farm()
60
-
61
- df = data.to_dataframe()[
62
- [
63
- FV.X,
64
- FV.Y,
65
- FV.WD,
66
- FV.AMB_REWS,
67
- FV.REWS,
68
- FV.AMB_TI,
69
- FV.TI,
70
- FV.AMB_CT,
71
- FV.CT,
50
+ with foxes.Engine.new("threads", chunk_size_states=c):
51
+
52
+ algo = foxes.algorithms.Downwind(
53
+ farm,
54
+ states,
55
+ mbook=mbook,
56
+ rotor_model=rotor,
57
+ wake_models=["Jensen_linear_k007", "IECTI2019_max"],
58
+ wake_frame="rotor_wd",
59
+ partial_wakes=["top_hat", "top_hat"],
60
+ verbosity=1,
61
+ )
62
+
63
+ data = algo.calc_farm()
64
+
65
+ df = data.to_dataframe()[
66
+ [
67
+ FV.X,
68
+ FV.Y,
69
+ FV.WD,
70
+ FV.AMB_REWS,
71
+ FV.REWS,
72
+ FV.AMB_TI,
73
+ FV.TI,
74
+ FV.AMB_CT,
75
+ FV.CT,
76
+ ]
72
77
  ]
73
- ]
74
-
75
- print("\nReading file", cfile)
76
- fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
77
-
78
- print()
79
- print("TRESULTS\n")
80
- """sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
81
- df = df.loc[sel]
82
- fdata = fdata.loc[sel]"""
83
- print(df)
84
- print(fdata)
85
-
86
- print("\nVERIFYING\n")
87
- df[FV.WS] = df["REWS"]
88
- df[FV.AMB_WS] = df["AMB_REWS"]
89
-
90
- delta = df - fdata
91
- print(delta)
92
-
93
- chk = delta.abs()
94
- print(chk.max())
95
-
96
- var = FV.WS
97
- print(f"\nCHECKING {var}")
98
- sel = chk[var] >= 3e-3
99
- print(df.loc[sel])
100
- print(fdata.loc[sel])
101
- print(chk.loc[sel])
102
- assert (chk[var] < 3e-3).all()
103
-
104
- var = FV.TI
105
- print(f"\nCHECKING {var}")
106
- sel = chk[var] >= 3e-4
107
- print(df.loc[sel])
108
- print(fdata.loc[sel])
109
- print(chk.loc[sel])
110
- assert (chk[var] < 3e-4).all()
111
-
112
- var = FV.CT
113
- print(f"\nCHECKING {var}")
114
- sel = chk[var] >= 3e-5
115
- print(df.loc[sel])
116
- print(fdata.loc[sel])
117
- print(chk.loc[sel])
118
- assert (chk[var] < 3e-5).all()
78
+
79
+ print("\nReading file", cfile)
80
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
81
+
82
+ print()
83
+ print("TRESULTS\n")
84
+ """sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
85
+ df = df.loc[sel]
86
+ fdata = fdata.loc[sel]"""
87
+ print(df)
88
+ print(fdata)
89
+
90
+ print("\nVERIFYING\n")
91
+ df[FV.WS] = df["REWS"]
92
+ df[FV.AMB_WS] = df["AMB_REWS"]
93
+
94
+ delta = df - fdata
95
+ print(delta)
96
+
97
+ chk = delta.abs()
98
+ print(chk.max())
99
+
100
+ var = FV.WS
101
+ print(f"\nCHECKING {var}")
102
+ sel = chk[var] >= 3e-3
103
+ print(df.loc[sel])
104
+ print(fdata.loc[sel])
105
+ print(chk.loc[sel])
106
+ assert (chk[var] < 3e-3).all()
107
+
108
+ var = FV.TI
109
+ print(f"\nCHECKING {var}")
110
+ sel = chk[var] >= 3e-4
111
+ print(df.loc[sel])
112
+ print(fdata.loc[sel])
113
+ print(chk.loc[sel])
114
+ assert (chk[var] < 3e-4).all()
115
+
116
+ var = FV.CT
117
+ print(f"\nCHECKING {var}")
118
+ sel = chk[var] >= 3e-5
119
+ print(df.loc[sel])
120
+ print(fdata.loc[sel])
121
+ print(chk.loc[sel])
122
+ assert (chk[var] < 3e-5).all()
119
123
 
120
124
 
121
125
  if __name__ == "__main__":