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
@@ -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
 
@@ -39,54 +39,56 @@ def test():
39
39
  verbosity=0,
40
40
  )
41
41
 
42
- algo = foxes.algorithms.Downwind(
43
- farm,
44
- states,
45
- mbook=mbook,
46
- rotor_model="centre",
47
- wake_models=["Jensen_quadratic_k007"],
48
- wake_frame="rotor_wd",
49
- partial_wakes={"Jensen_linear_k007": "centre"},
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()
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_quadratic_k007"],
50
+ wake_frame="rotor_wd",
51
+ partial_wakes={"Jensen_linear_k007": "centre"},
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()
90
92
 
91
93
 
92
94
  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
 
@@ -22,108 +22,106 @@ def test():
22
22
  (["Basta"], "grid64", "grid64"),
23
23
  ]
24
24
 
25
- ck = {FC.STATE: c}
26
-
27
- for i, (wakes, rotor, pwake) in enumerate(cases):
28
- print(f"\nENTERING CASE {(wakes, rotor, pwake)}\n")
29
-
30
- mbook = foxes.models.ModelBook()
31
- ttype = foxes.models.turbine_types.PCtFile(
32
- data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
33
- )
34
- mbook.turbine_types[ttype.name] = ttype
35
-
36
- mbook.wake_models["Basta"] = foxes.models.wake_models.wind.Bastankhah2014(
37
- sbeta_factor=0.25, superposition="ws_linear", induction="Betz"
38
- )
39
-
40
- states = foxes.input.states.StatesTable(
41
- data_source=sfile,
42
- output_vars=[FV.WS, FV.WD, FV.TI, FV.RHO],
43
- var2col={FV.WS: "ws", FV.WD: "wd", FV.TI: "ti"},
44
- fixed_vars={FV.RHO: 1.225, FV.Z0: 0.1, FV.H: 100.0},
45
- profiles={FV.WS: "ABLLogNeutralWsProfile"},
46
- )
47
-
48
- farm = foxes.WindFarm()
49
- foxes.input.farm_layout.add_from_file(
50
- farm,
51
- lfile,
52
- turbine_models=["kTI_amb_02", ttype.name],
53
- verbosity=1,
54
- )
55
-
56
- algo = foxes.algorithms.Downwind(
57
- farm,
58
- states,
59
- mbook=mbook,
60
- rotor_model=rotor,
61
- wake_models=wakes,
62
- wake_frame="rotor_wd",
63
- partial_wakes=pwake,
64
- chunks=ck,
65
- verbosity=1,
66
- )
67
-
68
- data = algo.calc_farm()
69
-
70
- df = data.to_dataframe()[
71
- [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
72
- ]
73
-
74
- cfile = cpath / f"results_{i}.csv.gz"
75
- print("\nReading file", cfile)
76
- fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
77
-
78
- print()
79
- print("TRESULTS\n")
80
- print(df)
81
- print(fdata)
82
-
83
- print("\nVERIFYING\n")
84
- df[FV.WS] = df["REWS"]
85
- df[FV.AMB_WS] = df["AMB_REWS"]
86
-
87
- delta = df - fdata
88
- print(delta)
89
- chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]]
90
- print(chk)
91
- chk = chk.abs()
92
- print(chk.max())
93
-
94
- var = FV.AMB_WS
95
- sel = chk[var] >= 1e-7
96
- print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
97
- print(df.loc[sel])
98
- print(fdata.loc[sel])
99
- print(delta.loc[sel])
100
- assert (chk[var] < 1e-7).all()
101
-
102
- var = FV.AMB_P
103
- sel = chk[var] >= 1e-5
104
- print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
105
- print(df.loc[sel])
106
- print(fdata.loc[sel])
107
- print(delta.loc[sel])
108
- assert (chk[var] < 1e-5).all()
109
-
110
- var = FV.WS
111
- sel = chk[var] >= 1.7e-3
112
- print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
113
- print(df.loc[sel])
114
- print(fdata.loc[sel])
115
- print(delta.loc[sel])
116
- assert (chk[var] < 1.7e-3).all()
117
-
118
- var = FV.P
119
- sel = chk[var] >= 1.51
120
- print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
121
- print(df.loc[sel])
122
- print(fdata.loc[sel])
123
- print(delta.loc[sel])
124
- assert (chk[var] < 1.51).all()
125
-
126
- print()
25
+ with foxes.Engine.new("threads", chunk_size_states=c):
26
+ for i, (wakes, rotor, pwake) in enumerate(cases):
27
+ print(f"\nENTERING CASE {(wakes, rotor, pwake)}\n")
28
+
29
+ mbook = foxes.models.ModelBook()
30
+ ttype = foxes.models.turbine_types.PCtFile(
31
+ data_source=tfile, var_ws_ct=FV.REWS, var_ws_P=FV.REWS
32
+ )
33
+ mbook.turbine_types[ttype.name] = ttype
34
+
35
+ mbook.wake_models["Basta"] = foxes.models.wake_models.wind.Bastankhah2014(
36
+ sbeta_factor=0.25, superposition="ws_linear", induction="Betz"
37
+ )
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, FV.Z0: 0.1, FV.H: 100.0},
44
+ profiles={FV.WS: "ABLLogNeutralWsProfile"},
45
+ )
46
+
47
+ farm = foxes.WindFarm()
48
+ foxes.input.farm_layout.add_from_file(
49
+ farm,
50
+ lfile,
51
+ turbine_models=["kTI_amb_02", ttype.name],
52
+ verbosity=1,
53
+ )
54
+
55
+ algo = foxes.algorithms.Downwind(
56
+ farm,
57
+ states,
58
+ mbook=mbook,
59
+ rotor_model=rotor,
60
+ wake_models=wakes,
61
+ wake_frame="rotor_wd",
62
+ partial_wakes=pwake,
63
+ verbosity=1,
64
+ )
65
+
66
+ data = algo.calc_farm()
67
+
68
+ df = data.to_dataframe()[
69
+ [FV.AMB_WD, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]
70
+ ]
71
+
72
+ cfile = cpath / f"results_{i}.csv.gz"
73
+ print("\nReading file", cfile)
74
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
75
+
76
+ print()
77
+ print("TRESULTS\n")
78
+ print(df)
79
+ print(fdata)
80
+
81
+ print("\nVERIFYING\n")
82
+ df[FV.WS] = df["REWS"]
83
+ df[FV.AMB_WS] = df["AMB_REWS"]
84
+
85
+ delta = df - fdata
86
+ print(delta)
87
+ chk = delta[[FV.AMB_WS, FV.AMB_P, FV.WS, FV.P]]
88
+ print(chk)
89
+ chk = chk.abs()
90
+ print(chk.max())
91
+
92
+ var = FV.AMB_WS
93
+ sel = chk[var] >= 1e-7
94
+ print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
95
+ print(df.loc[sel])
96
+ print(fdata.loc[sel])
97
+ print(delta.loc[sel])
98
+ assert (chk[var] < 1e-7).all()
99
+
100
+ var = FV.AMB_P
101
+ sel = chk[var] >= 1e-5
102
+ print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
103
+ print(df.loc[sel])
104
+ print(fdata.loc[sel])
105
+ print(delta.loc[sel])
106
+ assert (chk[var] < 1e-5).all()
107
+
108
+ var = FV.WS
109
+ sel = chk[var] >= 1.7e-3
110
+ print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
111
+ print(df.loc[sel])
112
+ print(fdata.loc[sel])
113
+ print(delta.loc[sel])
114
+ assert (chk[var] < 1.7e-3).all()
115
+
116
+ var = FV.P
117
+ sel = chk[var] >= 1.51
118
+ print(f"\nCHECKING {var}, {(wakes, rotor, pwake)}\n")
119
+ print(df.loc[sel])
120
+ print(fdata.loc[sel])
121
+ print(delta.loc[sel])
122
+ assert (chk[var] < 1.51).all()
123
+
124
+ print()
127
125
 
128
126
 
129
127
  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
@@ -51,65 +49,66 @@ def test():
51
49
  verbosity=1,
52
50
  )
53
51
 
54
- algo = foxes.algorithms.Downwind(
55
- farm,
56
- states,
57
- mbook=mbook,
58
- rotor_model=rotor,
59
- wake_models=["Basta", "Crespo"],
60
- wake_frame="rotor_wd",
61
- partial_wakes=["axiwake6", "top_hat"],
62
- chunks=ck,
63
- verbosity=1,
64
- )
65
-
66
- data = algo.calc_farm()
67
-
68
- df = data.to_dataframe()[
69
- [FV.X, FV.Y, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_TI, FV.TI]
70
- ]
71
-
72
- print()
73
- print("TRESULTS\n")
74
- print(df)
75
-
76
- print("\nReading file", cfile)
77
- fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
78
-
79
- print()
80
- print("TRESULTS\n")
81
- # sel = (df[FV.P]>0) & (fdata[FV.P]>0)
82
- # df = df.loc[sel]
83
- # fdata = fdata.loc[sel]
84
- print(df)
85
- print(fdata)
86
-
87
- print("\nVERIFYING\n")
88
- df[FV.WS] = df["REWS"]
89
- df[FV.AMB_WS] = df["AMB_REWS"]
90
-
91
- delta = df - fdata
92
- print(df)
93
- print(delta[[FV.WS, FV.TI]])
94
-
95
- chk = delta.abs()
96
- print(chk.max())
97
-
98
- var = FV.WS
99
- print(f"\nCHECKING {var}")
100
- sel = chk[var] >= 3e-3
101
- print(df.loc[sel])
102
- print(fdata.loc[sel])
103
- print(chk.loc[sel])
104
- assert (chk[var] < 3e-3).all()
105
-
106
- var = FV.TI
107
- print(f"\nCHECKING {var}")
108
- sel = chk[var] >= 3e-4
109
- print(df.loc[sel])
110
- print(fdata.loc[sel])
111
- print(chk.loc[sel])
112
- assert (chk[var] < 3e-4).all()
52
+ with foxes.Engine.new("threads", chunk_size_states=c):
53
+
54
+ algo = foxes.algorithms.Downwind(
55
+ farm,
56
+ states,
57
+ mbook=mbook,
58
+ rotor_model=rotor,
59
+ wake_models=["Basta", "Crespo"],
60
+ wake_frame="rotor_wd",
61
+ partial_wakes=["axiwake6", "top_hat"],
62
+ verbosity=1,
63
+ )
64
+
65
+ data = algo.calc_farm()
66
+
67
+ df = data.to_dataframe()[
68
+ [FV.X, FV.Y, FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_TI, FV.TI]
69
+ ]
70
+
71
+ print()
72
+ print("TRESULTS\n")
73
+ print(df)
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(df)
92
+ print(delta[[FV.WS, FV.TI]])
93
+
94
+ chk = delta.abs()
95
+ print(chk.max())
96
+
97
+ var = FV.WS
98
+ print(f"\nCHECKING {var}")
99
+ sel = chk[var] >= 3e-3
100
+ print(df.loc[sel])
101
+ print(fdata.loc[sel])
102
+ print(chk.loc[sel])
103
+ assert (chk[var] < 3e-3).all()
104
+
105
+ var = FV.TI
106
+ print(f"\nCHECKING {var}")
107
+ sel = chk[var] >= 3e-4
108
+ print(df.loc[sel])
109
+ print(fdata.loc[sel])
110
+ print(chk.loc[sel])
111
+ assert (chk[var] < 3e-4).all()
113
112
 
114
113
 
115
114
  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
@@ -48,52 +46,53 @@ def test():
48
46
  verbosity=1,
49
47
  )
50
48
 
51
- algo = foxes.algorithms.Downwind(
52
- farm,
53
- states,
54
- mbook=mbook,
55
- rotor_model=rotor,
56
- wake_models=["Basta"],
57
- wake_frame="rotor_wd",
58
- partial_wakes="rotor_points",
59
- chunks=ck,
60
- verbosity=1,
61
- )
62
-
63
- data = algo.calc_farm()
64
-
65
- df = data.to_dataframe()[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
66
-
67
- print("\nReading file", cfile)
68
- fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
69
-
70
- print()
71
- print("TRESULTS\n")
72
- sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
73
- df = df.loc[sel]
74
- fdata = fdata.loc[sel]
75
- print(df.loc[sel])
76
- print(fdata.loc[sel])
77
-
78
- print("\nVERIFYING\n")
79
- df[FV.WS] = df["REWS"]
80
- df[FV.AMB_WS] = df["AMB_REWS"]
81
-
82
- delta = df - fdata
83
- print(delta)
84
-
85
- chk = delta.abs()
86
- print(chk.max())
87
-
88
- var = FV.WS
89
- print(f"\nCHECKING {var}")
90
- sel = chk[var] >= 1e-7
91
- print(df.loc[sel])
92
- print(fdata.loc[sel])
93
- print(chk.loc[sel])
94
- assert (chk[var] < 1e-7).all()
95
-
96
- var = FV.P
97
- sel = chk[var] >= 1e-5
98
- print(f"\nCHECKING {var}\n", delta.loc[sel])
99
- assert (chk[var] < 1e-5).all()
49
+ with foxes.Engine.new("threads", chunk_size_states=c):
50
+
51
+ algo = foxes.algorithms.Downwind(
52
+ farm,
53
+ states,
54
+ mbook=mbook,
55
+ rotor_model=rotor,
56
+ wake_models=["Basta"],
57
+ wake_frame="rotor_wd",
58
+ partial_wakes="rotor_points",
59
+ verbosity=1,
60
+ )
61
+
62
+ data = algo.calc_farm()
63
+
64
+ df = data.to_dataframe()[[FV.WD, FV.AMB_REWS, FV.REWS, FV.AMB_P, FV.P]]
65
+
66
+ print("\nReading file", cfile)
67
+ fdata = pd.read_csv(cfile).set_index(["state", "turbine"])
68
+
69
+ print()
70
+ print("TRESULTS\n")
71
+ sel = (df[FV.P] > 0) & (fdata[FV.P] > 0)
72
+ df = df.loc[sel]
73
+ fdata = fdata.loc[sel]
74
+ print(df.loc[sel])
75
+ print(fdata.loc[sel])
76
+
77
+ print("\nVERIFYING\n")
78
+ df[FV.WS] = df["REWS"]
79
+ df[FV.AMB_WS] = df["AMB_REWS"]
80
+
81
+ delta = df - fdata
82
+ print(delta)
83
+
84
+ chk = delta.abs()
85
+ print(chk.max())
86
+
87
+ var = FV.WS
88
+ print(f"\nCHECKING {var}")
89
+ sel = chk[var] >= 1e-7
90
+ print(df.loc[sel])
91
+ print(fdata.loc[sel])
92
+ print(chk.loc[sel])
93
+ assert (chk[var] < 1e-7).all()
94
+
95
+ var = FV.P
96
+ sel = chk[var] >= 1e-5
97
+ print(f"\nCHECKING {var}\n", delta.loc[sel])
98
+ assert (chk[var] < 1e-5).all()
examples/windio/run.py DELETED
@@ -1,29 +0,0 @@
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)
Binary file
@@ -1,10 +0,0 @@
1
- name: DTU 10MW Offshore Reference Turbine
2
- performance:
3
- power_curve:
4
- power_values: [263388., 751154., 1440738., 2355734., 3506858., 4993092., 6849310., 9116402., 10000754., 10009590., 10000942., 10042678., 10003480., 10001600., 10001506., 10013632., 10007428., 10005360., 10002728., 10001130., 10004984., 9997558.]
5
- power_wind_speeds: [4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.]
6
- Ct_curve:
7
- Ct_values: [0.923,0.919,0.904,0.858,0.814,0.814,0.814,0.814,0.577,0.419,0.323,0.259,0.211,0.175,0.148,0.126,0.109,0.095,0.084,0.074,0.066,0.059]
8
- Ct_wind_speeds: [4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.]
9
- hub_height: 119.0
10
- rotor_diameter: 178.3
File without changes