API reference
Profile Optimizer¶
The API references for the Profile Optimizer can be found below:
(under construction)
ProfileOptimizer
¶
Source code in hydrolib/profile_optimizer/profile_optimizer/optimizer.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
__init__(base_model_fn: Path, bat_file, work_dir: Path, output_dir: Path, iteration_name = 'Iteration', iteration_start_count = 1)
¶
Framework for iterative cross-section changes and calculations with DHydro
The profile optimizer is a class that supplies a framework for running iterative DHydro calculations to optimize a crosssection profile. During the initialization, the base model is copied to the temporary folder (including all files in the parent folder of the base MDU). The base model is read with hydrolib-core and settings are saved to the class to create iterations afterwards.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_model_fn |
Path
|
Path to the MDU path of the base model (Pathlib-Path) |
required |
bat_file |
Path to a batch file that runs DIMR (Path or string) |
required | |
work_dir |
Path
|
Path to folder that does not yet exist, where the iterations can be saved temporarily (Pathlib-Path) |
required |
output_dir |
Path
|
Path to folder that does not yet exist where the final model is saved (Pathlib-Path) |
required |
iteration_name |
Name for the iteration models. Will be used like: "{iteration_name}_12" for example (string) |
'Iteration'
|
|
iteration_start_count |
What should be the first number of the iterations? Default is 1. Can be changed when iterations are run in multiple phases and should be continued. |
1
|
Functions
create_iteration: main function, every use of this function creates a new iteration model. run_model: function with which a model can be run using DIMR run_latest: applies run_model, on the most recently created iteration. export_model: using this function will export an iteration (default: last) to the output_dir.
Source code in hydrolib/profile_optimizer/profile_optimizer/optimizer.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
create_iteration(prof_ids: list, trapezium_pars: dict)
¶
Creates a new model, changing the profiles and saving it in the temporary folder.
Creates: - Iteration folder (number is incremental and counted via class) - New crossdef file in iteration folder - New MDU in the upper model folder - DIMR config file in the iteration folder - Batch file in the iteration folder
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prof_ids |
list
|
list of profiles that should be changed |
required |
trapezium_pars |
dict
|
dict of the new trapezium profile parameters (bottom_width, slope_l, slope_r, depth) |
required |
Returns:
Type | Description |
---|---|
filename to the batch file of this iteration |
Source code in hydrolib/profile_optimizer/profile_optimizer/optimizer.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
export_model(specific_iteration = 'latest', cleanup = True)
¶
Export a model iteration to the output directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
specific_iteration |
Default: 'latest' will export the last made iteration. Can also be a number-number. |
'latest'
|
|
cleanup |
bool, when True, the temp folder will be deleted afterwards. |
True
|
Source code in hydrolib/profile_optimizer/profile_optimizer/optimizer.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
run_latest()
¶
Runs DIMR for the most recently made iteration
Source code in hydrolib/profile_optimizer/profile_optimizer/optimizer.py
146 147 148 149 150 151 152 |
|
run_model(bat_path, model_folder)
staticmethod
¶
Runs DIMR for a model of choice
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bat_path |
Path to the desired bat file that runs DIMR |
required | |
model_folder |
directory where the model is ran |
required |
Source code in hydrolib/profile_optimizer/profile_optimizer/optimizer.py
134 135 136 137 138 139 140 141 142 143 144 |
|
find_optimum(window_b, calculated_v_values, target_v, waterlevel)
¶
A function for the optimization of the bottom width of a trapezoidal cross section profile for the desired/required flow velocity
Parameters:
Name | Type | Description | Default |
---|---|---|---|
window_b |
An array of the bottom widths that have been calculated so far in the search window. |
required | |
calculated_v_values |
An array of the calculated flow velocities for the bottom widths in the search window. |
required | |
target_v |
desired flow velocity to achieve in the cross section profile (int). |
required | |
waterlevel |
An array of the calculated water levels. |
required |
Returns:
Name | Type | Description |
---|---|---|
df | dataframe with the bottom widths, calculated velocity and the difference between the calculated Velocity and the target velocity. |
|
optimized_bottom_width | The optimalized bottom width for the desired flow velocity. |
Source code in hydrolib/profile_optimizer/profile_optimizer/optimizer.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|