#> set up model path shipped with floodam.building
model_path = list(
data = system.file("extdata", package = "floodam.building"),
output = tempdir()
)
model = analyse_model(
model = "adu_t",
type = "adu",
stage = c("load", "extract", "hydraulic", "damaging"),
path = model_path
)
Damage functions based on hydraulic simulations
2026-02-12
To be able to simulate the hydraulic dynamics inside a building during a flood event comes with its perks. One of them is that it allows us to refine flood damage estimation in those case in which the floodwater depth outside and inside the building differ. Instead of assuming that the level of water observed outside is the same that we had inside (current standard practice), we can simulate the actual maximum flood water depth inside each room in the building and estimate the damage.
In this vignette we would like to show the procedure to use if you want to estimate a damage function that takes into account the hydraulic dynamics of your building for a set of specific flood events.
Estimating the damage function of reference.
We will use one of the models shipped with floodam.buildingcalled adu_t as an example. This model proposes a 4-room house where three of them are organized around a central living room.
The models are available in your library’s installation folder. To get the path to this folder just ask R to locate them using the system.file() function. Once the path is set you can call the analyse_model() function to create the object model, using the shipped adu_t model and specifying c("load", "extract", "hydraulic", "damaging") as stages of analysis.
The function analyse_model() estimates damage functions by room in the hydraulic stage. These functions are the reference that the function analyse_hydraulic() uses to estimate the damage with hydraulic dynamics. The damaging stage is also included in the function analyse_model() so the damage function without hydraulic dynamics for flood events up to 48 hours is also available for comparison.
It should be noted that the damage function without hydraulic dynamics for flood events up to 48 hours is the equivalent to a damage function estimated including hydraulic dynamics for those cases in which the floodwater depths inside and outside of the building are the same.
Preparing the set of flood events
In this example we are going to focus in estimating the damage function include hydraulic dynamics for a 1-hour long event in which the water rises from 0 and reaching a plateau lasting 0.5 hours and then recedes to 0 (symmetrical). The floodwater depth will be a variable parameter. We will use a sequence from 0 to 2 meters, increasing the depth 10 centimeters at a time. The library floodam.building allows you to go up to 5 meters if you want to. Fortunatly you don’t have to do it manually, the analyse_hydraulic() function will take care of it for you.
Simulating flood events and estimating flood damage
To reduce simulation time, we will use a parallel lapply() function included in the parallel library, the mclapply() function, setting the number of cores to use as the half of cores available in your computer (parameter power = 0.5). We recommend you to keep half your cores unsed so you can still use your computer without any hindrance.
This step may take a few moments depending on your computer.
exp_plan = analyse_hydraulic(
model = model,
stage = c("experiment_plan")
)Once the simulations are done, the object hydraulic is created. It is a list of 21 slots, each containing two slots: hmax and damage. The slot hmax contains a matrix with maximum flood water depth in each room plus outside the building (column boundary_1). The slot damage contains a matrix with the estimated damage corresponding to the estimated floodwater depth by room, using as reference the room’s damage function for events up to 48 hours. The matrix also includes the sum of the rooms’ damage.
plot(exp_plan, model)
First step is done, now let’s explore the variability. We can give the function sets of parameters to see how our model will behave under diffferent flood scenarios.
exp_plan = analyse_hydraulic(
model = model,
opening_scenario = c("combine", "close"),
plateau = c(0.1, 0.5),
stage = c("experiment_plan")
)
plot(exp_plan, model)
Congrats you have made your first refined damage function taking in account a flood scenario!