foxes 1.1.0.2__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 -2
  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.0.2.dist-info → foxes-1.2.dist-info}/METADATA +20 -21
  105. {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/RECORD +122 -122
  106. {foxes-1.1.0.2.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.0.2.dist-info → foxes-1.2.dist-info}/LICENSE +0 -0
  131. {foxes-1.1.0.2.dist-info → foxes-1.2.dist-info}/top_level.txt +0 -0
@@ -3,13 +3,13 @@ import inspect
3
3
 
4
4
  import foxes
5
5
  import foxes.variables as FV
6
- import foxes.constants as FC
6
+ from foxes.config import config
7
7
 
8
8
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
9
9
 
10
10
 
11
11
  def test():
12
- c = 1000
12
+
13
13
  ttype = "DTU10MW"
14
14
  sfile = "wind_rose_bremen.csv"
15
15
  lfile = thisdir / "test_farm.csv"
@@ -20,72 +20,70 @@ def test():
20
20
  ]
21
21
  lims = {FV.REWS: 5e-7, FV.P: 5e-4}
22
22
 
23
- ck = {FC.STATE: c}
24
-
25
23
  base_results = None
26
- for Algo, frame in cases:
27
- print(f"\nENTERING CASE {(Algo.__name__, frame)}\n")
28
-
29
- mbook = foxes.models.ModelBook()
30
-
31
- states = foxes.input.states.StatesTable(
32
- data_source=sfile,
33
- output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
34
- var2col={FV.WS: "ws", FV.WD: "wd", FV.WEIGHT: "weight"},
35
- fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},
36
- )
37
-
38
- farm = foxes.WindFarm()
39
- foxes.input.farm_layout.add_from_file(
40
- farm, lfile, turbine_models=[ttype], verbosity=1
41
- )
42
-
43
- kwargs = {}
44
- if Algo is foxes.algorithms.Iterative:
45
- kwargs["mod_cutin"] = {"modify_ct": False, "modify_P": False}
46
-
47
- algo = Algo(
48
- farm,
49
- states,
50
- mbook=mbook,
51
- rotor_model="grid16",
52
- wake_models=["Bastankhah2014_linear_k004", "IECTI2019_max"],
53
- wake_frame=frame,
54
- partial_wakes="rotor_points",
55
- chunks=ck,
56
- verbosity=1,
57
- **kwargs,
58
- )
59
-
60
- # f Algo is foxes.algorithms.Iterative:
61
- # algo.set_urelax("post_rotor", CT=0.9)
62
-
63
- data = algo.calc_farm()
64
-
65
- df = data.to_dataframe()[
66
- [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
67
- ]
68
-
69
- print()
70
- print("TRESULTS\n")
71
- print(df)
72
-
73
- df = df.reset_index()
74
-
75
- if base_results is None:
76
- base_results = df
77
-
78
- else:
79
- print(f"CASE {(Algo.__name__, frame)}")
80
- delta = df - base_results
81
- print(delta)
82
- print(delta.min(), delta.max())
83
-
84
- for v, lim in lims.items():
85
- chk = delta[v].abs().loc[df["AMB_REWS"] > 7]
86
- print(f"CASE {(Algo.__name__, frame, v, lim)}:", chk.max())
87
-
88
- assert (chk < lim).all()
24
+ with foxes.Engine.new("process", chunk_size_states=1000):
25
+ for Algo, frame in cases:
26
+ print(f"\nENTERING CASE {(Algo.__name__, frame)}\n")
27
+
28
+ mbook = foxes.models.ModelBook()
29
+
30
+ states = foxes.input.states.StatesTable(
31
+ data_source=sfile,
32
+ output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
33
+ var2col={FV.WS: "ws", FV.WD: "wd", FV.WEIGHT: "weight"},
34
+ fixed_vars={FV.RHO: 1.225, FV.TI: 0.05},
35
+ )
36
+
37
+ farm = foxes.WindFarm()
38
+ foxes.input.farm_layout.add_from_file(
39
+ farm, lfile, turbine_models=[ttype], verbosity=1
40
+ )
41
+
42
+ kwargs = {}
43
+ if Algo is foxes.algorithms.Iterative:
44
+ kwargs["mod_cutin"] = {"modify_ct": False, "modify_P": False}
45
+
46
+ algo = Algo(
47
+ farm,
48
+ states,
49
+ mbook=mbook,
50
+ rotor_model="grid16",
51
+ wake_models=["Bastankhah2014_linear_k004", "IECTI2019_max"],
52
+ wake_frame=frame,
53
+ partial_wakes="rotor_points",
54
+ verbosity=1,
55
+ **kwargs,
56
+ )
57
+
58
+ # f Algo is foxes.algorithms.Iterative:
59
+ # algo.set_urelax("post_rotor", CT=0.9)
60
+
61
+ data = algo.calc_farm()
62
+
63
+ df = data.to_dataframe()[
64
+ [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
65
+ ]
66
+
67
+ print()
68
+ print("TRESULTS\n")
69
+ print(df)
70
+
71
+ df = df.reset_index()
72
+
73
+ if base_results is None:
74
+ base_results = df
75
+
76
+ else:
77
+ print(f"CASE {(Algo.__name__, frame)}")
78
+ delta = df - base_results
79
+ print(delta)
80
+ print(delta.min(), delta.max())
81
+
82
+ for v, lim in lims.items():
83
+ chk = delta[v].abs().loc[df["AMB_REWS"] > 7]
84
+ print(f"CASE {(Algo.__name__, frame, v, lim)}:", chk.max())
85
+
86
+ assert (chk < lim).all()
89
87
 
90
88
 
91
89
  if __name__ == "__main__":
@@ -3,13 +3,12 @@ import inspect
3
3
 
4
4
  import foxes
5
5
  import foxes.variables as FV
6
- import foxes.constants as FC
7
6
 
8
7
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
9
8
 
10
9
 
11
10
  def test():
12
- c = 180
11
+
13
12
  tfile = thisdir / "NREL-5MW-D126-H90.csv"
14
13
  sfile = thisdir / "states.csv.gz"
15
14
  lfile = thisdir / "test_farm.csv"
@@ -24,66 +23,64 @@ def test():
24
23
  ("centre", "grid36", 0.025),
25
24
  ]
26
25
 
27
- ck = {FC.STATE: c}
28
-
29
26
  base_results = None
30
- for rotor, pwake, lim in cases:
31
- print(f"\nENTERING CASE {(rotor, pwake, lim)}\n")
32
-
33
- mbook = foxes.models.ModelBook()
34
- ttype = foxes.models.turbine_types.PCtFile(
35
- data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
36
- )
37
- mbook.turbine_types[ttype.name] = ttype
38
-
39
- states = foxes.input.states.StatesTable(
40
- data_source=sfile,
41
- output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
42
- var2col={FV.WS: "ws", FV.WD: "wd", FV.TI: "ti"},
43
- fixed_vars={FV.RHO: 1.225},
44
- )
45
-
46
- farm = foxes.WindFarm()
47
- foxes.input.farm_layout.add_from_file(
48
- farm, lfile, turbine_models=[ttype.name], verbosity=1
49
- )
50
-
51
- algo = foxes.algorithms.Downwind(
52
- farm,
53
- states,
54
- mbook=mbook,
55
- rotor_model=rotor,
56
- wake_models=["Bastankhah025_linear_k002"],
57
- wake_frame="rotor_wd",
58
- partial_wakes=pwake,
59
- chunks=ck,
60
- verbosity=1,
61
- )
62
-
63
- data = algo.calc_farm()
64
-
65
- df = data.to_dataframe()[
66
- [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
67
- ]
68
-
69
- print()
70
- print("TRESULTS\n")
71
- print(df)
72
-
73
- df = df.reset_index()
74
-
75
- if base_results is None:
76
- base_results = df
77
-
78
- else:
79
- print(f"CASE {(rotor, pwake, lim)}")
80
- delta = df - base_results
81
- print(delta)
82
- print(delta.min(), delta.max())
83
- chk = delta[FV.REWS].abs()
84
- print(f"CASE {(rotor, pwake, lim)}:", chk.max())
85
-
86
- assert (chk < lim).all()
27
+ with foxes.Engine.new("process", chunk_size_states=100):
28
+ for rotor, pwake, lim in cases:
29
+ print(f"\nENTERING CASE {(rotor, pwake, lim)}\n")
30
+
31
+ mbook = foxes.models.ModelBook()
32
+ ttype = foxes.models.turbine_types.PCtFile(
33
+ data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
34
+ )
35
+ mbook.turbine_types[ttype.name] = ttype
36
+
37
+ states = foxes.input.states.StatesTable(
38
+ data_source=sfile,
39
+ output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
40
+ var2col={FV.WS: "ws", FV.WD: "wd", FV.TI: "ti"},
41
+ fixed_vars={FV.RHO: 1.225},
42
+ )
43
+
44
+ farm = foxes.WindFarm()
45
+ foxes.input.farm_layout.add_from_file(
46
+ farm, lfile, turbine_models=[ttype.name], verbosity=1
47
+ )
48
+
49
+ algo = foxes.algorithms.Downwind(
50
+ farm,
51
+ states,
52
+ mbook=mbook,
53
+ rotor_model=rotor,
54
+ wake_models=["Bastankhah025_linear_k002"],
55
+ wake_frame="rotor_wd",
56
+ partial_wakes=pwake,
57
+ verbosity=1,
58
+ )
59
+
60
+ data = algo.calc_farm()
61
+
62
+ df = data.to_dataframe()[
63
+ [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
64
+ ]
65
+
66
+ print()
67
+ print("TRESULTS\n")
68
+ print(df)
69
+
70
+ df = df.reset_index()
71
+
72
+ if base_results is None:
73
+ base_results = df
74
+
75
+ else:
76
+ print(f"CASE {(rotor, pwake, lim)}")
77
+ delta = df - base_results
78
+ print(delta)
79
+ print(delta.min(), delta.max())
80
+ chk = delta[FV.REWS].abs()
81
+ print(f"CASE {(rotor, pwake, lim)}:", chk.max())
82
+
83
+ assert (chk < lim).all()
87
84
 
88
85
 
89
86
  if __name__ == "__main__":
@@ -4,7 +4,7 @@ import inspect
4
4
 
5
5
  import foxes
6
6
  import foxes.variables as FV
7
- import foxes.constants as FC
7
+ from foxes.config import config
8
8
 
9
9
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
10
10
 
@@ -12,15 +12,12 @@ thisdir = Path(inspect.getfile(inspect.currentframe())).parent
12
12
  def test():
13
13
  print(thisdir)
14
14
 
15
- c = 2000
16
15
  cfile = thisdir / "flappy" / "results.csv.gz"
17
16
  tPfile = thisdir / "NREL-5MW-D126-H90-P.csv"
18
17
  tCtfile = thisdir / "NREL-5MW-D126-H90-Ct.csv"
19
18
  sfile = thisdir / "states.csv.gz"
20
19
  lfile = thisdir / "test_farm.csv"
21
20
 
22
- ck = {FC.STATE: c}
23
-
24
21
  mbook = foxes.models.ModelBook()
25
22
  ttype = foxes.models.turbine_types.PCtFromTwo(
26
23
  data_source_P=tPfile,
@@ -48,55 +45,61 @@ def test():
48
45
  farm, lfile, turbine_models=[ttype.name], verbosity=0
49
46
  )
50
47
 
51
- algo = foxes.algorithms.Downwind(
52
- farm,
53
- states,
54
- mbook=mbook,
55
- rotor_model="centre",
56
- wake_models=["Jensen_linear_k007"],
57
- wake_frame="rotor_wd",
58
- partial_wakes={"Jensen_linear_k007": "top_hat"},
59
- chunks=ck,
60
- verbosity=0,
61
- )
62
-
63
- data = algo.calc_farm()
64
-
65
- df = data.to_dataframe()[[FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
66
- df = df.reset_index()
67
-
68
- print()
69
- print("TRESULTS\n")
70
- print(df)
71
-
72
- # print("\Reading file", cfile)
73
- fdata = pd.read_csv(cfile)
74
- print(fdata)
75
-
76
- print("\nVERIFYING\n")
77
- df[FV.WS] = df["REWS"]
78
- df[FV.AMB_WS] = df["AMB_REWS"]
79
-
80
- # neglecting ws < 5 and ws > 20
81
- sel_ws = (
82
- (fdata[FV.WS] > 5) & (fdata[FV.WS] < 20) & (df["REWS"] > 5) & (df["REWS"] < 20)
83
- )
84
-
85
- # calculating difference
86
- delta = df.reset_index() - fdata
87
- delta = delta[sel_ws]
88
- print(delta)
89
- print(delta.max())
90
- chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]].abs()
91
- sel = chk[FV.WS] >= 1e-5
92
- print(sel)
93
- print(df[sel & sel_ws])
94
- print(fdata[sel & sel_ws])
95
- print(chk.loc[sel & sel_ws])
96
- print(chk.max())
97
-
98
- assert ((chk[FV.WS] < 1e-5)).all()
99
- assert (chk[FV.P] < 1e-3).all()
48
+ with foxes.Engine.new("threads", chunk_size_states=1000):
49
+
50
+ algo = foxes.algorithms.Downwind(
51
+ farm,
52
+ states,
53
+ mbook=mbook,
54
+ rotor_model="centre",
55
+ wake_models=["Jensen_linear_k007"],
56
+ wake_frame="rotor_wd",
57
+ partial_wakes={"Jensen_linear_k007": "top_hat"},
58
+ verbosity=0,
59
+ )
60
+
61
+ data = algo.calc_farm()
62
+
63
+ df = data.to_dataframe()[
64
+ [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
65
+ ]
66
+ df = df.reset_index()
67
+
68
+ print()
69
+ print("TRESULTS\n")
70
+ print(df)
71
+
72
+ # print("\Reading file", cfile)
73
+ fdata = pd.read_csv(cfile)
74
+ print(fdata)
75
+
76
+ print("\nVERIFYING\n")
77
+ df[FV.WS] = df["REWS"]
78
+ df[FV.AMB_WS] = df["AMB_REWS"]
79
+
80
+ # neglecting ws < 5 and ws > 20
81
+ sel_ws = (
82
+ (fdata[FV.WS] > 5)
83
+ & (fdata[FV.WS] < 20)
84
+ & (df["REWS"] > 5)
85
+ & (df["REWS"] < 20)
86
+ )
87
+
88
+ # calculating difference
89
+ delta = df.reset_index() - fdata
90
+ delta = delta[sel_ws]
91
+ print(delta)
92
+ print(delta.max())
93
+ chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]].abs()
94
+ sel = chk[FV.WS] >= 1e-5
95
+ print(sel)
96
+ print(df[sel & sel_ws])
97
+ print(fdata[sel & sel_ws])
98
+ print(chk.loc[sel & sel_ws])
99
+ print(chk.max())
100
+
101
+ assert ((chk[FV.WS] < 1e-5)).all()
102
+ assert (chk[FV.P] < 1e-3).all()
100
103
 
101
104
 
102
105
  if __name__ == "__main__":
@@ -4,7 +4,6 @@ import inspect
4
4
 
5
5
  import foxes
6
6
  import foxes.variables as FV
7
- import foxes.constants as FC
8
7
 
9
8
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
10
9
 
@@ -16,8 +15,6 @@ def test():
16
15
  sfile = thisdir / "states.csv.gz"
17
16
  lfile = thisdir / "test_farm.csv"
18
17
 
19
- ck = {FC.STATE: c}
20
-
21
18
  mbook = foxes.models.ModelBook()
22
19
  ttype = foxes.models.turbine_types.PCtFile(
23
20
  data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
@@ -43,44 +40,47 @@ def test():
43
40
  verbosity=0,
44
41
  )
45
42
 
46
- algo = foxes.algorithms.Downwind(
47
- farm,
48
- states,
49
- mbook=mbook,
50
- rotor_model="centre",
51
- wake_models=["Jensen_linear_k007"],
52
- wake_frame="rotor_wd",
53
- partial_wakes={"Jensen_linear_k007": "centre"},
54
- chunks=ck,
55
- verbosity=0,
56
- )
57
-
58
- data = algo.calc_farm()
59
-
60
- df = data.to_dataframe()[[FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
61
-
62
- print()
63
- print("TRESULTS\n")
64
- print(df)
65
-
66
- print("\nReading file", cfile)
67
- fdata = pd.read_csv(cfile)
68
- print(fdata)
69
-
70
- print("\nVERIFYING\n")
71
- df[FV.WS] = df["REWS"]
72
- df[FV.AMB_WS] = df["AMB_REWS"]
73
-
74
- delta = df.reset_index() - fdata
75
- print(delta)
76
- print(delta.max())
77
- chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]].abs()
78
- print(chk.max())
79
-
80
- assert (chk[FV.AMB_WS] < 1e-5).all()
81
- assert (chk[FV.AMB_P] < 1e-3).all()
82
- assert (chk[FV.WS] < 1e-5).all()
83
- assert (chk[FV.P] < 1e-3).all()
43
+ with foxes.Engine.new("threads", chunk_size_states=c):
44
+
45
+ algo = foxes.algorithms.Downwind(
46
+ farm,
47
+ states,
48
+ mbook=mbook,
49
+ rotor_model="centre",
50
+ wake_models=["Jensen_linear_k007"],
51
+ wake_frame="rotor_wd",
52
+ partial_wakes={"Jensen_linear_k007": "centre"},
53
+ verbosity=0,
54
+ )
55
+
56
+ data = algo.calc_farm()
57
+
58
+ df = data.to_dataframe()[
59
+ [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
60
+ ]
61
+
62
+ print()
63
+ print("TRESULTS\n")
64
+ print(df)
65
+
66
+ print("\nReading file", cfile)
67
+ fdata = pd.read_csv(cfile)
68
+ print(fdata)
69
+
70
+ print("\nVERIFYING\n")
71
+ df[FV.WS] = df["REWS"]
72
+ df[FV.AMB_WS] = df["AMB_REWS"]
73
+
74
+ delta = df.reset_index() - fdata
75
+ print(delta)
76
+ print(delta.max())
77
+ chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]].abs()
78
+ print(chk.max())
79
+
80
+ assert (chk[FV.AMB_WS] < 1e-5).all()
81
+ assert (chk[FV.AMB_P] < 1e-3).all()
82
+ assert (chk[FV.WS] < 1e-5).all()
83
+ assert (chk[FV.P] < 1e-3).all()
84
84
 
85
85
 
86
86
  if __name__ == "__main__":
@@ -4,7 +4,7 @@ import inspect
4
4
 
5
5
  import foxes
6
6
  import foxes.variables as FV
7
- import foxes.constants as FC
7
+ from foxes.config import config
8
8
 
9
9
  thisdir = Path(inspect.getfile(inspect.currentframe())).parent
10
10
 
@@ -12,14 +12,11 @@ thisdir = Path(inspect.getfile(inspect.currentframe())).parent
12
12
  def test():
13
13
  print(thisdir)
14
14
 
15
- c = 2000
16
15
  cfile = thisdir / "flappy" / "results.csv.gz"
17
16
  tfile = thisdir / "NREL-5MW-D126-H90.csv"
18
17
  sfile = thisdir / "states.csv.gz"
19
18
  lfile = thisdir / "test_farm.csv"
20
19
 
21
- ck = {FC.STATE: c}
22
-
23
20
  mbook = foxes.models.ModelBook()
24
21
  ttype = foxes.models.turbine_types.PCtFile(
25
22
  data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
@@ -38,44 +35,47 @@ def test():
38
35
  farm, lfile, turbine_models=[ttype.name], verbosity=0
39
36
  )
40
37
 
41
- algo = foxes.algorithms.Downwind(
42
- farm,
43
- states,
44
- mbook=mbook,
45
- rotor_model="centre",
46
- wake_models=["Jensen_linear_k007"],
47
- wake_frame="rotor_wd",
48
- partial_wakes={"Jensen_linear_k007": "top_hat"},
49
- chunks=ck,
50
- verbosity=0,
51
- )
38
+ with foxes.Engine.new("threads", chunk_size_states=1000):
39
+
40
+ algo = foxes.algorithms.Downwind(
41
+ farm,
42
+ states,
43
+ mbook=mbook,
44
+ rotor_model="centre",
45
+ wake_models=["Jensen_linear_k007"],
46
+ wake_frame="rotor_wd",
47
+ partial_wakes={"Jensen_linear_k007": "top_hat"},
48
+ verbosity=0,
49
+ )
52
50
 
53
- data = algo.calc_farm()
51
+ data = algo.calc_farm()
54
52
 
55
- df = data.to_dataframe()[[FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
53
+ df = data.to_dataframe()[
54
+ [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
55
+ ]
56
56
 
57
- print()
58
- print("TRESULTS\n")
59
- print(df)
57
+ print()
58
+ print("TRESULTS\n")
59
+ print(df)
60
60
 
61
- print("\nReading file", cfile)
62
- fdata = pd.read_csv(cfile)
63
- print(fdata)
61
+ print("\nReading file", cfile)
62
+ fdata = pd.read_csv(cfile)
63
+ print(fdata)
64
64
 
65
- print("\nVERIFYING\n")
66
- df[FV.WS] = df["REWS"]
67
- df[FV.AMB_WS] = df["AMB_REWS"]
65
+ print("\nVERIFYING\n")
66
+ df[FV.WS] = df["REWS"]
67
+ df[FV.AMB_WS] = df["AMB_REWS"]
68
68
 
69
- delta = (df.reset_index() - fdata)[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]]
70
- print("\nDELTA\n", delta.describe())
69
+ delta = (df.reset_index() - fdata)[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]]
70
+ print("\nDELTA\n", delta.describe())
71
71
 
72
- chk = delta.abs().max()
73
- print("\nCHK\n", chk)
74
- print("CHK WS =", chk[FV.WS])
75
- print("CHK P =", chk[FV.P])
72
+ chk = delta.abs().max()
73
+ print("\nCHK\n", chk)
74
+ print("CHK WS =", chk[FV.WS])
75
+ print("CHK P =", chk[FV.P])
76
76
 
77
- assert chk[FV.WS] < 1e-5
78
- assert chk[FV.P] < 1e-3
77
+ assert chk[FV.WS] < 1e-5
78
+ assert chk[FV.P] < 1e-3
79
79
 
80
80
 
81
81
  if __name__ == "__main__":