wolfhece.drowning_victims.drowning_functions
Module Contents
- wolfhece.drowning_victims.drowning_functions.beta_find(x, *data)[source]
Iterative function that finds the parameters alpha and beta defining a beta distribution and scales it in a range. The function fits the parameters based on two given percentiles of the data.
- Parameters:
x – Array containing initial guesses for alpha and beta.
data – Tuple containing (down, up, mini, maxi, perc1, perc2).
- Returns:
Array containing the differences between the calculated and given percentiles.
- wolfhece.drowning_victims.drowning_functions.Body_motion(a_RK, batch_turb, CFL, Delta, epsilon, H_pre, H_post, Human, k, NbX, NbY, Pos_bp, resurface, sinking, time_b, t_Wolf_pre, t_Wolf_post, time_goal, U_bp, Ux_pre, Ux_post, Uy_pre, Uy_post, Z_param)[source]
Function calculating the motion of the body at each time step using a Runge-Kutta method. From body position, velocity and flow environment, the function determines the flow velocity at the body position and calculates its new velocities, checking for collisions with walls.
- Parameters:
a_RK – Runge-Kutta coefficient.
batch_turb – Batch turbulence.
CFL – Courant-Friedrichs-Lewy number.
Delta – Array of delta values.
epsilon – Epsilon value.
H_pre – Pre-update water depth.
H_post – Post-update water depth.
Human – Human parameters array.
k – Turbulence kinetic energy.
NbX – Number of cells in X direction.
NbY – Number of cells in Y direction.
Pos_bp – Body position array for calculations.
resurface – Resurface array.
sinking – Sinking array.
time_b – Time array for savings.
t_Wolf_pre – Pre-update Wolf time.
t_Wolf_post – Post-update Wolf time.
time_goal – Time goal.
U_bp – Body velocity array for calculations.
Ux_pre – Pre-update X velocity.
Ux_post – Post-update X velocity.
Uy_pre – Pre-update Y velocity.
Uy_post – Post-update Y velocity.
Z_param – Z parameters array.
- Returns:
Updated Human, Pos_b, resurface, sinking, time_b, U_b arrays.
- wolfhece.drowning_victims.drowning_functions.Body_temperature(BSA, mass, T_w, t)[source]
Gives the body temperature at time t considering ONLY the conduction.
- Parameters:
BSA – Body surface area [m²].
mass – Body mass [kg].
T_w – Water temperature [°C].
t – Time from the beginning.
- Returns:
ADD (Accumulated Degree Days) and body temperature.
- wolfhece.drowning_victims.drowning_functions.Body_volume_variation(alpha_1, BSA, FRC, H_f, m_b, time_b, T_w, TLC, V_b0, V_clothes1, V_clothes2, z)[source]
Function calculating the body volume variation due to the putrefaction gases. The method is described in Delhez et al. 2025, “Predicting the buoyancy and Postmortem Submersion Interval of victims of river drowning”.
- Parameters:
alpha_1 – Alpha parameter.
BSA – Body surface area.
FRC – Functional residual capacity.
H_f – Water depth.
m_b – Body mass.
time_b – Time array for savings.
T_w – Water temperature.
TLC – Total lung capacity.
V_b0 – Initial body volume.
V_clothes1 – Clothes volume for temperature < 15°C.
V_clothes2 – Clothes volume for temperature >= 15°C.
z – Depth array.
- Returns:
Body volume.
- wolfhece.drowning_victims.drowning_functions.Collision(Delta, Pos, Pos_p, U, walls)[source]
Correct the bodies that hit a wall by correcting its velocity and replace it on the wall (+marge).
- Parameters:
Delta – Array of delta values.
Pos – Body position array for calculations.
Pos_p – Previous body position array.
U – Body velocity array for calculations.
walls – Walls array.
- Returns:
Corrected position and velocity arrays.
- wolfhece.drowning_victims.drowning_functions.Flow_time_t(batch_turb, dt, epsilon, H_f, k, turb_type, U_bp, U_x_vec, U_y_vec, z, z_0)[source]
Calculates the difference between the body velocity and the flow velocity (-> relative body velocity) and its sign before and after evaluating the turbulences.
- Parameters:
batch_turb – Batch turbulence.
dt – Time step.
epsilon – Epsilon value.
H_f – Water depth.
k – Turbulence kinetic energy.
turb_type – Turbulence type.
U_bp – Body velocity array for calculations.
U_x_vec – X velocity vector.
U_y_vec – Y velocity vector.
z – Depth array.
z_0 – Roughness length.
- Returns:
U_x_dif, U_x_sign, U_y_dif, U_y_sign arrays.
- wolfhece.drowning_victims.drowning_functions.interp_mailles_mat(Delta, epsilon, H_0, H_1, index_b, k, NbX, NbY, Pos_b, t_WOLF_perc, t_Wolf_perc_insta, Ux_0, Ux_1, Uy_0, Uy_1)[source]
Determines the flow velocity and height at the body position based on the value of the cells in which the body is and the next cells in x, y and xy. It is a spatial bi-linear and temporal linear interpolation. Method described in Delhez et al. 2025, Lagrangian modelling of the drift of a victim of river drowning.
- Parameters:
Delta – Array of delta values.
epsilon – Epsilon value.
H_0 – Pre-update water depth.
H_1 – Post-update water depth.
index_b – Body position indices.
k – Turbulence kinetic energy.
NbX – Number of cells in X direction.
NbY – Number of cells in Y direction.
Pos_b – Body position array for savings.
t_WOLF_perc – Percentage of Wolf time.
t_Wolf_perc_insta – Instantaneous percentage of Wolf time.
Ux_0 – Pre-update X velocity.
Ux_1 – Post-update X velocity.
Uy_0 – Pre-update Y velocity.
Uy_1 – Post-update Y velocity.
- Returns:
du_insta, epsilon_v, ind_walls, H_v, k_v, Ux_v, Uy_v, walls arrays.
- wolfhece.drowning_victims.drowning_functions.known_1(g, mini, maxi, down, up, perc1, perc2)[source]
Used in the fit of the beta parameters alpha and beta by iteration.
- Parameters:
g – Guess array.
mini – Minimum value.
maxi – Maximum value.
down – Lower percentile value.
up – Upper percentile value.
perc1 – Lower percentile.
perc2 – Upper percentile.
- Returns:
Tuple containing alpha and beta.
- wolfhece.drowning_victims.drowning_functions.Loading(Path_loading, Pos_b, time_b, U_b)[source]
Loads the results of a previous simulation and returns the data needed to start from these results.
- Parameters:
Path_loading – Path to the loading file.
Pos_b – Body position array for savings.
time_b – Time array for savings.
U_b – Body velocity array for savings.
- Returns:
count_initial, Human, n_loaded, Pos_b, time_b, U_b, Z_param arrays.
- wolfhece.drowning_victims.drowning_functions.Loop_management(progress_queue, process_id, a_RK, BC_cells, count, count_Wolf, CFL, Delta, Human_np, i_initial, n_b, n_saved, n_t, NbX, NbY, Path_Saving, Path_Wolf, Pos, Pos_b, resurface, sinking, time, time_b, time_goal, U, U_b, wanted_time, wanted_Wolf, Z_param_np)[source]
Main loop of the code. Calculates the motion of each body at each time in the loop and updates the flow when needed. Everything is based on the array “still” which contains the index of all the bodies that need more calculations, as we work with variable time step for each body. If a body is out of the domain, it is out of still; if a body reaches a time for which we need a save, it is out of still; if a body reaches a time for which the flow needs to be updated, it is out of still.
- Parameters:
progress_queue – Queue for progress updates.
process_id – Process ID.
a_RK – Runge-Kutta coefficient.
BC_cells – Boundary condition cells.
count – Count of saved states.
count_Wolf – Count of Wolf states.
CFL – Courant-Friedrichs-Lewy number.
Delta – Array of delta values.
Human_np – Human parameters array.
i_initial – Initial index.
n_b – Number of bodies.
n_saved – Number of saved states.
n_t – Number of time steps.
NbX – Number of cells in X direction.
NbY – Number of cells in Y direction.
Path_Saving – Path to save results.
Path_Wolf – Path to Wolf results.
Pos – Body position array for calculations.
Pos_b – Body position array for savings.
resurface – Resurface array.
sinking – Sinking array.
time – Time array for calculations.
time_b – Time array for savings.
time_goal – Time goal.
U – Body velocity array for calculations.
U_b – Body velocity array for savings.
wanted_time – Array of wanted times.
wanted_Wolf – Array of wanted Wolf times.
Z_param_np – Z parameters array.
- Returns:
Updated Pos_b, resurface, sinking, time_b, U_b arrays.
- wolfhece.drowning_victims.drowning_functions.Motion_equations(CAM, CDA, CLA, CSA, dt, du_insta, m_b, mu, U_bp, U_x_dif, U_x_sign, U_y_dif, U_y_sign, V_b, vertical)[source]
Calculates the body acceleration and velocity based on the motion equation with the Flow to the body forces (Drag, Side and Lift), Gravity and Buoyancy, Friction with the bottom and added mass effect. Equations described in Delhez et al., 2025 “Lagrangian modelling of the drift of a victim of river drowning”
- Parameters:
CAM – Added mass coefficient.
CDA – Drag coefficient.
CLA – Lift coefficient.
CSA – Side force coefficient.
dt – Time step.
du_insta – Instantaneous velocity difference.
m_b – Body mass.
mu – Friction coefficient.
U_bp – Body velocity array for calculations.
U_x_dif – X velocity difference.
U_x_sign – X velocity sign.
U_y_dif – Y velocity difference.
U_y_sign – Y velocity sign.
V_b – Body volume.
vertical – Vertical position.
- Returns:
Body acceleration and velocity arrays.
- wolfhece.drowning_victims.drowning_functions.Parallel_loop(args)[source]
Used to run the code in Multiprocess.
- Parameters:
args – Arguments for the Loop_management function.
- Returns:
Result of the Loop_management function.
- wolfhece.drowning_victims.drowning_functions.Preparation_parallelisation(progress_queue, a_RK, BC_cells, count, count_Wolf, CFL, Delta, Human_np, i_initial, n_b, n_saved, n_parallel, n_t, NbX, NbY, Path_saving, Path_Wolf, Pos, Pos_b, resurface, sinking, time, time_b, time_goal, U, U_b, wanted_time, wanted_Wolf, Z_param_np)[source]
Splits the arrays in the number we want to be ran in MultiProcess.
- Parameters:
progress_queue – Queue for progress updates.
a_RK – Runge-Kutta coefficient.
BC_cells – Boundary condition cells.
count – Count of saved states.
count_Wolf – Count of Wolf states.
CFL – Courant-Friedrichs-Lewy number.
Delta – Array of delta values.
Human_np – Human parameters array.
i_initial – Initial index.
n_b – Number of bodies.
n_saved – Number of saved states.
n_parallel – Number of parallel processes.
n_t – Number of time steps.
NbX – Number of cells in X direction.
NbY – Number of cells in Y direction.
Path_saving – Path to save results.
Path_Wolf – Path to Wolf results.
Pos – Body position array for calculations.
Pos_b – Body position array for savings.
resurface – Resurface array.
sinking – Sinking array.
time – Time array for calculations.
time_b – Time array for savings.
time_goal – Time goal.
U – Body velocity array for calculations.
U_b – Body velocity array for savings.
wanted_time – Array of wanted times.
wanted_Wolf – Array of wanted Wolf times.
Z_param_np – Z parameters array.
- Returns:
List of tasks for parallel processing.
- wolfhece.drowning_victims.drowning_functions.Read_Wolf_GPU_mat(i_Wolf, Path_Wolf)[source]
Reads the results of WolfGPU at a particular time and returns the water depth and velocities’ matrix.
- Parameters:
i_Wolf – Index of the WolfGPU result.
Path_Wolf – Path to the WolfGPU results.
- Returns:
Water depth and velocities’ matrix.
- wolfhece.drowning_victims.drowning_functions.Read_Wolf_GPU_metadata(Path_Wolf)[source]
Reads the parameters of the WolfGPU simulation and returns the relevant ones.
- Parameters:
Path_Wolf – Path to the WolfGPU results.
- Returns:
Boundary condition cells, Wolf time step, grid spacing, water depth, number of cells in X and Y directions, and total simulation time.
- wolfhece.drowning_victims.drowning_functions.Save_wanted_time(Path, Pos_b, U_b, count)[source]
Saves the body positions and velocities at a given time.
- Parameters:
Path – Path to save the results.
Pos_b – Body position array for savings.
U_b – Body velocity array for savings.
count – Count of saved states.
- wolfhece.drowning_victims.drowning_functions.Skinfold(n_b, known, Human)[source]
Determines the body density based on its age and BMI using Siri’s equation. An error percentage body fat is also set, according to Meeuwsen et al., 2010.
- Parameters:
n_b – Number of bodies.
known – Known parameter.
Human – Human parameters array.
- Returns:
Updated Human parameters and error percentage body fat.
- wolfhece.drowning_victims.drowning_functions.state_of_run(progress_queue, frame, interval)[source]
Monitoring function that displays progress every interval seconds.
- Parameters:
progress_queue – Queue for progress updates.
frame – Frame object for GUI updates.
interval – Time interval for updates.
- wolfhece.drowning_victims.drowning_functions.U_turbulence(batch, dt, epsilon, H, k, turb_type, U_x, U_x_dif, U_y, U_y_dif, z, z_0)[source]
Adjust the flow velocity with turbulence. 4 different evaluations are proposed but each uses a log law of the wall to go from depth-averaged velocity to velocity related to the body vertical position.
- Parameters:
batch – Batch turbulence.
dt – Time step.
epsilon – Epsilon value.
H – Water depth.
k – Turbulence kinetic energy.
turb_type – Turbulence type.
U_x – X velocity.
U_x_dif – X velocity difference.
U_y – Y velocity.
U_y_dif – Y velocity difference.
z – Depth array.
z_0 – Roughness length.
- Returns:
Adjusted X and Y velocities.