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

In summary: 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.In summary, the water flow in two dimensions in F90 is giving the user trouble with the dD/dt equation. RK4 may be a better option than a simple predictor - corrector method such as the euler - trapezoidal example.
  • #1
amberf90
3
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
  • #2
  • #3
Thanks for the suggestion; I was really looking for an implicit solution though...
 
  • #4
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:
  • #5
Thanks,

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

A
 

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

1. What is an ODE?

An ODE, or Ordinary Differential Equation, is a mathematical equation that describes how one or more variables change over time. It contains a dependent variable, an independent variable, and the derivatives of the dependent variable with respect to the independent variable.

2. What is the importance of integrating a single ODE in F90?

Integrating a single ODE in F90 allows for the numerical solution of the equation, which is crucial in many scientific fields such as physics, engineering, and biology. F90, or Fortran 90, is a powerful programming language that is optimized for scientific computing and is commonly used for solving ODEs.

3. How do I integrate a single ODE in F90?

To integrate a single ODE in F90, you will need to define the equation, set initial conditions, select a numerical integration method, and write the necessary code using F90 syntax. You can also use existing libraries or packages in F90 that are specifically designed for solving ODEs.

4. What are the benefits of integrating a single ODE in F90?

Integrating a single ODE in F90 allows for a more accurate and efficient solution compared to analytical methods. It also allows for more complex and realistic models to be solved, as well as the ability to easily modify and adapt the code to different equations and scenarios.

5. Are there any challenges in integrating a single ODE in F90?

Like any programming task, there may be challenges in integrating a single ODE in F90, such as debugging errors in the code, selecting the appropriate integration method, and ensuring numerical stability. It is important to understand the mathematical concepts behind the ODE and the syntax of F90 to overcome these challenges.

Similar threads

  • Engineering and Comp Sci Homework Help
2
Replies
56
Views
3K
  • Introductory Physics Homework Help
Replies
8
Views
2K
Replies
1
Views
1K
  • Differential Equations
Replies
8
Views
2K
Replies
17
Views
2K
  • Mechanics
Replies
6
Views
2K
  • Mechanical Engineering
Replies
6
Views
1K
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
12
Views
912
Replies
29
Views
5K
Back
Top