How to Integrate a Single ODE in F90 for Water Flow Simulation?

  • Thread starter Thread starter amberf90
  • Start date Start date
  • Tags Tags
    Integrate Ode
Click For Summary

Discussion Overview

The discussion revolves around integrating a single ordinary differential equation (ODE) for simulating water flow in two dimensions using Fortran 90 (F90). Participants explore different numerical methods for solving the ODE related to the rate of change of water depth, focusing on both explicit and implicit integration techniques.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes difficulties with an Euler forward method for integrating the ODE, noting that it requires a very fine time-step, which is computationally expensive.
  • Another participant suggests using the Runge Kutta 4 (RK4) method as a potential solution, providing a link to a wiki article for reference.
  • A later reply argues that RK4 could be considered "semi-implicit" and discusses its accuracy compared to other methods, such as a predictor-corrector approach involving Euler and trapezoidal corrections.
  • The original poster expresses a preference for an implicit solution and seeks simpler ODE integrators suitable for a single equation.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach, with some advocating for RK4 while others emphasize the need for an implicit solution. The discussion remains unresolved regarding the most suitable method for the participant's specific needs.

Contextual Notes

The discussion highlights the challenges of integrating a single ODE in a computationally efficient manner, with participants noting the dependence on the chosen numerical method and the implications of accuracy and computational cost.

amberf90
Messages
3
Reaction score
0
Hi all,

I've written a simulation of water flow in two dimensions in F90 but I'm having some trouble with it. Water flows from one cell to another using an equation for rate of change of depth and an algorithm for assigning flow direction.

The flow direction bit is fine but the dD/dt equation is giving me some trouble. I've tried an Euler forward method of integrating this equation through time but more water wants to move than is in the cell and I have to use a very fine time-step to allow the water to get where it wants to go, which is computationally expensive. A colleague suggested I adopt an implicit integrator as this will allow the hydraulic head (which depth is linked with) to reduce gradually, and presumably slow down the flow.

I've tried using two subroutines I found online; bsstep.f and ode.f but I can't manage to get either to work successfully. One of the problems is that the r.h.s includes values that need to be passed through from the main program. Also they talk about a system of ODEs but as far as I'm aware I only have 1. I'm not the best at maths sadly...

Does anybody have any ideas about simple ODE integrators, for one equation only, that aren't to difficult/complicated to use?

Thanks in advance...
 
Technology news on Phys.org
Thanks for the suggestion; I was really looking for an implicit solution though...
 
amberf90 said:
Thanks for the suggestion; I was really looking for an implicit solution though...
You could consider RK4 to be "semi-implicit", since it calculates 3 intermediate increments using feedback from the initial euler increment and the first 2 intermediate increments. RK4 is more accurate than a simple predictor - corrector method such as the euler - trapezoidal example in this wiki article:

wiki_predictor_corrector_method.htm

Note that repeating correction step will quickly converge to a specific value, but since it's based on trapezoidal rule, it's a linear aproximation, versus RK4's 4th order approximation. If you did 1 euler and 3 trapezoidal correction steps, the overhead would be similar to RK4, but the result would not be as accurate (you'd need a much smaller step size).
 
Last edited:
Thanks,

I'll code up the RK4 and see what happens!

A
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 21 ·
Replies
21
Views
2K
  • · Replies 56 ·
2
Replies
56
Views
6K
  • · Replies 8 ·
Replies
8
Views
4K
Replies
4
Views
3K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
6
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K