Changeset 8081
- Timestamp:
- Nov 20, 2010, 10:06:12 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/structures/inlet.py
r8080 r8081 227 227 stages_order = stages.argsort() 228 228 229 summed_areas = num.zeros_like(areas) 230 summed_volume = num.zeros_like(areas) 231 #diff_stage = num.zeros_like(areas) 232 233 for i,a in enumerate(areas[stages_order]): 234 #print i,a, stages[stages_order[i]] 235 if i == 0: 236 summed_areas[i] = a 237 summed_volume[i] = 0.0 238 #diff_stage[i] = 0.0 239 else: 240 summed_areas[i] = summed_areas[i-1] + a 241 242 summed_volume[i] = summed_volume[i-1] + summed_areas[i-1]*\ 243 (stages[stages_order[i]] - stages[stages_order[i-1]]) 244 245 #diff_stage[i] = stages[stages_order[i]] - stages[stages_order[i-1]] 246 247 #print 'amount ',amount 248 #print summed_areas 249 #print summed_amount 250 #print diff_stage 251 252 253 #index = len(summed_amount) 254 for i,a in enumerate(summed_volume): 255 #print 'a ',a 256 if volume > a : 257 index = i 258 259 #print index 260 261 #print stages_order 262 #print stages 263 229 # accumulate areas of cells ordered by stage 230 summed_areas = num.cumsum(areas[stages_order]) 231 232 # accumulate the volume need to fill cells 233 summed_volume = num.zeros_like(areas) 234 summed_volume[1:] = num.cumsum(summed_areas[:-1]*num.diff(stages[stages_order])) 235 236 # find the number of cells which will be filled 237 index = num.nonzero(summed_volume<volume)[0][-1] 238 239 # calculate stage needed to fill chosen cells with given volume of water 264 240 depth = (volume - summed_volume[index])/summed_areas[index] 265 266 241 stages[stages_order[0:index+1]] = stages[stages_order[index]]+depth 267 242
Note: See TracChangeset
for help on using the changeset viewer.