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

Files changed (131) hide show
  1. docs/source/conf.py +3 -1
  2. examples/dyn_wakes/run.py +2 -2
  3. examples/timelines/run.py +1 -1
  4. foxes/__init__.py +13 -2
  5. foxes/algorithms/downwind/downwind.py +6 -1
  6. foxes/algorithms/downwind/models/init_farm_data.py +5 -2
  7. foxes/algorithms/downwind/models/point_wakes_calc.py +0 -1
  8. foxes/algorithms/iterative/iterative.py +1 -1
  9. foxes/algorithms/sequential/sequential.py +4 -3
  10. foxes/config/__init__.py +1 -0
  11. foxes/config/config.py +134 -0
  12. foxes/constants.py +15 -6
  13. foxes/core/algorithm.py +22 -10
  14. foxes/core/data.py +2 -1
  15. foxes/core/engine.py +40 -34
  16. foxes/core/farm_controller.py +4 -3
  17. foxes/core/farm_data_model.py +6 -2
  18. foxes/core/model.py +2 -1
  19. foxes/core/point_data_model.py +4 -2
  20. foxes/core/rotor_model.py +8 -4
  21. foxes/core/turbine_type.py +1 -1
  22. foxes/core/wake_frame.py +7 -5
  23. foxes/core/wake_model.py +6 -1
  24. foxes/data/__init__.py +1 -1
  25. foxes/data/static_data.py +0 -7
  26. foxes/engines/dask.py +4 -3
  27. foxes/engines/single.py +1 -1
  28. foxes/input/__init__.py +1 -1
  29. foxes/input/farm_layout/from_csv.py +3 -1
  30. foxes/input/farm_layout/from_file.py +10 -10
  31. foxes/input/farm_layout/from_json.py +4 -3
  32. foxes/input/farm_layout/grid.py +3 -3
  33. foxes/input/states/create/random_abl_states.py +5 -3
  34. foxes/input/states/field_data_nc.py +22 -14
  35. foxes/input/states/multi_height.py +26 -15
  36. foxes/input/states/one_point_flow.py +6 -5
  37. foxes/input/states/scan_ws.py +4 -1
  38. foxes/input/states/single.py +15 -6
  39. foxes/input/states/slice_data_nc.py +18 -12
  40. foxes/input/states/states_table.py +17 -10
  41. foxes/input/yaml/__init__.py +3 -0
  42. foxes/input/yaml/dict.py +210 -0
  43. foxes/input/yaml/windio/__init__.py +4 -0
  44. foxes/input/{windio → yaml/windio}/get_states.py +7 -7
  45. foxes/input/{windio → yaml/windio}/read_attributes.py +61 -40
  46. foxes/input/{windio → yaml/windio}/read_farm.py +34 -43
  47. foxes/input/{windio → yaml/windio}/read_fields.py +11 -10
  48. foxes/input/yaml/windio/read_outputs.py +147 -0
  49. foxes/input/yaml/windio/windio.py +269 -0
  50. foxes/input/yaml/yaml.py +103 -0
  51. foxes/models/partial_wakes/axiwake.py +7 -6
  52. foxes/models/partial_wakes/centre.py +3 -2
  53. foxes/models/partial_wakes/segregated.py +5 -2
  54. foxes/models/point_models/set_uniform_data.py +5 -3
  55. foxes/models/rotor_models/centre.py +2 -2
  56. foxes/models/rotor_models/grid.py +5 -5
  57. foxes/models/rotor_models/levels.py +6 -6
  58. foxes/models/turbine_models/kTI_model.py +3 -1
  59. foxes/models/turbine_models/lookup_table.py +7 -4
  60. foxes/models/turbine_models/power_mask.py +14 -8
  61. foxes/models/turbine_models/sector_management.py +4 -2
  62. foxes/models/turbine_models/set_farm_vars.py +53 -23
  63. foxes/models/turbine_models/table_factors.py +8 -7
  64. foxes/models/turbine_models/yaw2yawm.py +0 -1
  65. foxes/models/turbine_models/yawm2yaw.py +0 -1
  66. foxes/models/turbine_types/CpCt_file.py +6 -3
  67. foxes/models/turbine_types/CpCt_from_two.py +6 -3
  68. foxes/models/turbine_types/PCt_file.py +7 -6
  69. foxes/models/turbine_types/PCt_from_two.py +11 -2
  70. foxes/models/turbine_types/TBL_file.py +3 -4
  71. foxes/models/turbine_types/wsrho2PCt_from_two.py +19 -11
  72. foxes/models/turbine_types/wsti2PCt_from_two.py +19 -11
  73. foxes/models/vertical_profiles/abl_log_neutral_ws.py +1 -1
  74. foxes/models/vertical_profiles/abl_log_stable_ws.py +1 -1
  75. foxes/models/vertical_profiles/abl_log_unstable_ws.py +1 -1
  76. foxes/models/vertical_profiles/abl_log_ws.py +1 -1
  77. foxes/models/wake_frames/dynamic_wakes.py +17 -9
  78. foxes/models/wake_frames/farm_order.py +4 -3
  79. foxes/models/wake_frames/rotor_wd.py +3 -1
  80. foxes/models/wake_frames/seq_dynamic_wakes.py +14 -7
  81. foxes/models/wake_frames/streamlines.py +9 -6
  82. foxes/models/wake_frames/timelines.py +21 -14
  83. foxes/models/wake_frames/yawed_wakes.py +3 -1
  84. foxes/models/wake_models/induction/vortex_sheet.py +0 -1
  85. foxes/models/wake_models/ti/crespo_hernandez.py +2 -1
  86. foxes/models/wake_models/wind/bastankhah14.py +3 -2
  87. foxes/models/wake_models/wind/bastankhah16.py +2 -1
  88. foxes/models/wake_models/wind/turbopark.py +9 -7
  89. foxes/models/wake_superpositions/ws_product.py +0 -1
  90. foxes/output/calc_points.py +7 -4
  91. foxes/output/farm_layout.py +30 -18
  92. foxes/output/farm_results_eval.py +4 -3
  93. foxes/output/grids.py +8 -7
  94. foxes/output/output.py +7 -2
  95. foxes/output/results_writer.py +10 -11
  96. foxes/output/rose_plot.py +38 -20
  97. foxes/output/rotor_point_plots.py +7 -3
  98. foxes/output/slice_data.py +1 -1
  99. foxes/output/state_turbine_map.py +5 -1
  100. foxes/output/state_turbine_table.py +7 -3
  101. foxes/output/turbine_type_curves.py +7 -2
  102. foxes/utils/dict.py +107 -3
  103. foxes/utils/geopandas_utils.py +3 -2
  104. {foxes-1.1.1.dist-info → foxes-1.2.dist-info}/METADATA +18 -17
  105. {foxes-1.1.1.dist-info → foxes-1.2.dist-info}/RECORD +122 -122
  106. {foxes-1.1.1.dist-info → foxes-1.2.dist-info}/WHEEL +1 -1
  107. foxes-1.2.dist-info/entry_points.txt +3 -0
  108. tests/0_consistency/iterative/test_iterative.py +65 -67
  109. tests/0_consistency/partial_wakes/test_partial_wakes.py +58 -61
  110. tests/1_verification/flappy_0_6/PCt_files/test_PCt_files.py +56 -53
  111. tests/1_verification/flappy_0_6/abl_states/test_abl_states.py +41 -41
  112. tests/1_verification/flappy_0_6/partial_top_hat/test_partial_top_hat.py +34 -34
  113. tests/1_verification/flappy_0_6/row_Jensen_linear_centre/test_row_Jensen_linear_centre.py +50 -50
  114. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat/test_row_Jensen_linear_tophat.py +51 -52
  115. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2005/test_row_Jensen_linear_tophat_IECTI_2005.py +73 -74
  116. tests/1_verification/flappy_0_6/row_Jensen_linear_tophat_IECTI2019/test_row_Jensen_linear_tophat_IECTI_2019.py +73 -74
  117. tests/1_verification/flappy_0_6/row_Jensen_quadratic_centre/test_row_Jensen_quadratic_centre.py +51 -49
  118. tests/1_verification/flappy_0_6_2/grid_rotors/test_grid_rotors.py +101 -103
  119. tests/1_verification/flappy_0_6_2/row_Bastankhah_Crespo/test_row_Bastankhah_Crespo.py +61 -62
  120. tests/1_verification/flappy_0_6_2/row_Bastankhah_linear_centre/test_row_Bastankhah_linear_centre.py +51 -52
  121. examples/windio/run.py +0 -29
  122. foxes/data/states/windio_timeseries_5000.nc +0 -0
  123. foxes/data/windio/DTU_10MW_turbine.yaml +0 -10
  124. foxes/data/windio/__init__.py +0 -0
  125. foxes/data/windio/windio_5turbines_timeseries.yaml +0 -79
  126. foxes/input/windio/__init__.py +0 -11
  127. foxes/input/windio/read_outputs.py +0 -172
  128. foxes/input/windio/runner.py +0 -183
  129. foxes/input/windio/windio.py +0 -193
  130. {foxes-1.1.1.dist-info → foxes-1.2.dist-info}/LICENSE +0 -0
  131. {foxes-1.1.1.dist-info → foxes-1.2.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"
@@ -39,54 +37,56 @@ def test():
39
37
  verbosity=0,
40
38
  )
41
39
 
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()
40
+ with foxes.Engine.new("threads", chunk_size_states=1000):
41
+
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()
90
90
 
91
91
 
92
92
  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,8 +19,6 @@ 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
@@ -41,55 +39,56 @@ def test():
41
39
  verbosity=0,
42
40
  )
43
41
 
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()
42
+ with foxes.Engine.new("threads", chunk_size_states=c):
43
+
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
+ verbosity=0,
53
+ )
54
+
55
+ data = algo.calc_farm()
56
+
57
+ df = data.to_dataframe()[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
58
+
59
+ print("\nReading file", cfile)
60
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
61
+
62
+ print()
63
+ print("TRESULTS\n")
64
+ sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
65
+ df = df.loc[sel]
66
+ fdata = fdata.loc[sel]
67
+ print(df.loc[sel])
68
+ print(fdata.loc[sel])
69
+
70
+ print("\nVERIFYING\n")
71
+ df[FV.WS] = df["REWS"]
72
+ df[FV.AMB_WS] = df["AMB_REWS"]
73
+
74
+ delta = df - fdata
75
+ print(delta)
76
+
77
+ chk = delta.abs()
78
+ print(chk.max())
79
+
80
+ var = FV.WS
81
+ print(f"\nCHECKING {var}")
82
+ sel = chk[var] >= 1e-7
83
+ print(df.loc[sel])
84
+ print(fdata.loc[sel])
85
+ print(chk.loc[sel])
86
+ assert (chk[var] < 1e-7).all()
87
+
88
+ var = FV.P
89
+ sel = chk[var] >= 1e-5
90
+ print(f"\nCHECKING {var}\n", delta.loc[sel])
91
+ assert (chk[var] < 1e-5).all()
93
92
 
94
93
 
95
94
  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,8 +22,6 @@ 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
@@ -44,78 +42,79 @@ def test():
44
42
  verbosity=1,
45
43
  )
46
44
 
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,
45
+ with foxes.Engine.new("threads", chunk_size_states=c):
46
+
47
+ algo = foxes.algorithms.Downwind(
48
+ farm,
49
+ states,
50
+ rotor_model=rotor,
51
+ mbook=mbook,
52
+ wake_models=["Jensen_linear_k007", "IECTI2005_max"],
53
+ wake_frame="rotor_wd",
54
+ partial_wakes=["top_hat", "top_hat"],
55
+ verbosity=1,
56
+ )
57
+
58
+ data = algo.calc_farm()
59
+
60
+ df = data.to_dataframe()[
61
+ [
62
+ FV.X,
63
+ FV.Y,
64
+ FV.WD,
65
+ FV.AMB_REWS,
66
+ FV.REWS,
67
+ FV.AMB_TI,
68
+ FV.TI,
69
+ FV.AMB_CT,
70
+ FV.CT,
71
+ ]
72
72
  ]
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()
73
+
74
+ print("\nReading file", cfile)
75
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
76
+
77
+ print()
78
+ print("TRESULTS\n")
79
+ """sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
80
+ df = df.loc[sel]
81
+ fdata = fdata.loc[sel]"""
82
+ print(df)
83
+ print(fdata)
84
+
85
+ print("\nVERIFYING\n")
86
+ df[FV.WS] = df["REWS"]
87
+ df[FV.AMB_WS] = df["AMB_REWS"]
88
+
89
+ delta = df - fdata
90
+ print(delta)
91
+
92
+ chk = delta.abs()
93
+ print(chk.max())
94
+
95
+ var = FV.WS
96
+ print(f"\nCHECKING {var}")
97
+ sel = chk[var] >= 3e-3
98
+ print(df.loc[sel])
99
+ print(fdata.loc[sel])
100
+ print(chk.loc[sel])
101
+ assert (chk[var] < 3e-3).all()
102
+
103
+ var = FV.TI
104
+ print(f"\nCHECKING {var}")
105
+ sel = chk[var] >= 3e-4
106
+ print(df.loc[sel])
107
+ print(fdata.loc[sel])
108
+ print(chk.loc[sel])
109
+ assert (chk[var] < 3e-4).all()
110
+
111
+ var = FV.CT
112
+ print(f"\nCHECKING {var}")
113
+ sel = chk[var] >= 3e-5
114
+ print(df.loc[sel])
115
+ print(fdata.loc[sel])
116
+ print(chk.loc[sel])
117
+ assert (chk[var] < 3e-5).all()
119
118
 
120
119
 
121
120
  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,8 +22,6 @@ 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
@@ -44,78 +42,79 @@ def test():
44
42
  verbosity=1,
45
43
  )
46
44
 
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,
45
+ with foxes.Engine.new("threads", chunk_size_states=c):
46
+
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
+ verbosity=1,
56
+ )
57
+
58
+ data = algo.calc_farm()
59
+
60
+ df = data.to_dataframe()[
61
+ [
62
+ FV.X,
63
+ FV.Y,
64
+ FV.WD,
65
+ FV.AMB_REWS,
66
+ FV.REWS,
67
+ FV.AMB_TI,
68
+ FV.TI,
69
+ FV.AMB_CT,
70
+ FV.CT,
71
+ ]
72
72
  ]
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()
73
+
74
+ print("\nReading file", cfile)
75
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
76
+
77
+ print()
78
+ print("TRESULTS\n")
79
+ """sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
80
+ df = df.loc[sel]
81
+ fdata = fdata.loc[sel]"""
82
+ print(df)
83
+ print(fdata)
84
+
85
+ print("\nVERIFYING\n")
86
+ df[FV.WS] = df["REWS"]
87
+ df[FV.AMB_WS] = df["AMB_REWS"]
88
+
89
+ delta = df - fdata
90
+ print(delta)
91
+
92
+ chk = delta.abs()
93
+ print(chk.max())
94
+
95
+ var = FV.WS
96
+ print(f"\nCHECKING {var}")
97
+ sel = chk[var] >= 3e-3
98
+ print(df.loc[sel])
99
+ print(fdata.loc[sel])
100
+ print(chk.loc[sel])
101
+ assert (chk[var] < 3e-3).all()
102
+
103
+ var = FV.TI
104
+ print(f"\nCHECKING {var}")
105
+ sel = chk[var] >= 3e-4
106
+ print(df.loc[sel])
107
+ print(fdata.loc[sel])
108
+ print(chk.loc[sel])
109
+ assert (chk[var] < 3e-4).all()
110
+
111
+ var = FV.CT
112
+ print(f"\nCHECKING {var}")
113
+ sel = chk[var] >= 3e-5
114
+ print(df.loc[sel])
115
+ print(fdata.loc[sel])
116
+ print(chk.loc[sel])
117
+ assert (chk[var] < 3e-5).all()
119
118
 
120
119
 
121
120
  if __name__ == "__main__":