Menu

Regarding custom runtime logic in ANUGA

Rup
2025-12-16
2025-12-18
  • Rup

    Rup - 2025-12-16

    Hello All,
    I am developing a flood simulation model using ANUGA Hydro and I am interested in automatically detecting when the flood event has concluded. My goal is to configure the simulation to terminate as soon as the water depth is zero. (no floods) returns to zero. I would like to know if it is possible to program this condition into the ANUGA runtime.

    thank you for your help.
    kind regards,

     
  • Rup

    Rup - 2025-12-18

    hello,

    I have implemented an if condition within my evolve loop to stop the simulation once the water depth in a specific downstream area (covering the river and floodplains) falls below a certain threshold. Although the code runs without errors, the simulation stops as soon as it begins. As a beginner in Python, I am unsure why this is happening or how to ensure the simulation only stops after the water has actually arrived and then receded.

    ds_polygon = [[619708.796,3085199.395],[620345.056,3090989.363],[665901.284,3079345.802],[654066.845,3061594.143]]
    region = anuga.Region(domain, polygon = ds_polygon)
    indices = region.indices

    stage = domain.quantities['stage'].centroid_values[indices]
    elevation = domain.quantities['elevation'].centroid_values[indices]
    depth = stage - elevation

    yieldstep = 60
    finaltime = 5400
    t = 0

    for t in domain.evolve(yieldstep=yieldstep, finaltime=finaltime):
    print(domain.timestepping_statistics())
    current_depths = domain.quantities['height'].centroid_values[indices]
    max_ds_depth = np.max(current_depths)
    print(f"Time: {t}s, Max depth in polygon: {max_ds_depth:.3f}m")

    thank you for your help.

    kind regards,

     
  • Stephen Roberts

    Stephen Roberts - 2025-12-18

    Rup, the example code you have provided doesn't have an if statement in the evolve loop. Can you provide the actual code you are using. Also in the email the python indentation has been lost. I assume the code is correctly indented in the file?

    I would suggest creating variables

    stage = domain.quantities['stage'].centroid_values
    elev = domain.quantities['elevation'].centroid_values

    before the evolve loop and calculate the depth specifically inside your evolve loop

    depth = stage[indices] - elev[indicies]

    and check on the state of depth to test for completion of your loop.

    You might be able to use the break command to break out of the evolve loop. It would be interesting to see if that works.

    Cheers
    Steve

     
  • Rup

    Rup - 2025-12-19
    Post awaiting moderation.

Log in to post a comment.

MongoDB Logo MongoDB