|
[Sponsors] |
September 23, 2017, 08:31 |
burger equations
|
#1 |
Member
Marco Ghiani
Join Date: Jan 2011
Posts: 35
Rep Power: 15 |
Hi everybody !! I just wrote a fortran 95 code for solving the burger equations !
Code:
MODULE PARAM IMPLICIT NONE INTEGER, PARAMETER :: SP = KIND(1.0) INTEGER, PARAMETER :: DP = KIND(1.D0) END MODULE !----------------------------------------------------------------------- MODULE BURGER_2 USE PARAM IMPLICIT NONE REAL(DP), PARAMETER :: x0=0. , xF= 5. REAL(DP), PARAMETER :: t0=0. , tF= 1.0 REAL(DP), PARAMETER :: dx=0.001, dt=0.1 INTEGER , PARAMETER :: N= CEILING((xF-x0)/dx) INTEGER , PARAMETER :: M= CEILING((tF-t0)/dt) REAL(DP), PARAMETER :: nu = 2D-4 REAL(DP), PARAMETER :: pi=3.14159265358979323846 CONTAINS !----------------------------------------------------------------------- SUBROUTINE BURGER_EXPLICIT (x,t,u) USE PARAM REAL(DP), DIMENSION(N+1) :: x REAL(DP), DIMENSION(M+1) :: t REAL(DP), DIMENSION(N+1,M+1) :: U REAL(DP) :: r,k , CFL INTEGER :: i,j,stat CFL = DT/DX**2 Print '(A, F20.5)', 'CFL = ' , CFL x(1:N+1) = (/ ( x0+dx*(i-1) , i=1,N+1 ) /) t(1:M+1) = (/ (t0+ dt*(j-1) , j=1,M+1 ) /) U(1:N+1,1:M+1) = RESHAPE((/(((sin(2*pi*(i-1)/N)), i=1,N+1), j=1,M+1)/),(/N+1,M+1/)) !U(1:N+1,1:M+1) = RESHAPE((/(((i), i=1,N+1), j=1,M+1)/),(/N+1,M+1/)) !U(1:N+1,1:M+1) = RESHAPE((/(((( )), i=1,N+1), j=1,M+1)/),(/N+1,M+1/)) !DO i=1,N+1 ! IF (x(i) .LE. !END DO !U(1,:) = x0 !U(N+1,:) = xF !U(:,1) = t0 !U(:,M+1) = tF r = nu*DT/DX**2 k = DT/(2*DX) OPEN(10,file='bur2.dat',STATUS='UNKNOWN',IOSTAT=stat) DO J=2,M DO I=2,N U(i,j+1) = r*u(i+1,j)+(1-2*r)*u(i,j)+r*u(i-1,j) - k*u(i,j)*(u(i+1,j)-u(i-1,j)) END DO END DO !IF(J .EQ. 4) THEN !WRITE(10,FMT='(2F20.5)') x(i), u(i,4) !((u(i,j) , i=1,N+1), J=1,M+1) !END IF OPEN(10,file='bur1.dat',STATUS='UNKNOWN',IOSTAT=stat) IF (STAT .NE. 0) THEN WRITE(6,FMT='(A)')'Error opening File ''bur1.dat'' (EXIT1)' STOP ELSE DO j=1,M+1 WRITE(10,FMT='(3F20.5)') (x(i), t(j) ,u(i,j), i=1,N+1) !((u(i,j) , i=1,N+1), J=1,M+1) WRITE(10,*) !WRITE(10,FMT='(2F20.5)') (x(i), u(i,2), i=1,N) !((u(i,j) , i=1,N+1), J=1,M+1) WRITE(6,'(50("-"))') END DO END IF RETURN END SUBROUTINE !----------------------------------------------------------------------- END MODULE Code:
PROGRAM main USE BURGER_2 IMPLICIT NONE REAL(DP) , DIMENSION (N+1) :: xx REAL(DP) , DIMENSION (M+1) :: tt REAL(DP) , DIMENSION (n+1,M+1) :: UU CALL burger_EXPLICIT(xx,tt,UU) STOP END 1) I don't know why but if the domain is smaller (ex. L=2) che program give a strange result ! 2) one other thing is i've used for intialize the matrix U a sinusoidal wave (take from an example found in internet !) could somebody explain which several condition I can use excluding the condition used here .. 3) i see on the wiky https://www.cfd-online.com/Wiki/Burgers_equation the solution based on Finite volumes method ! i really don't understand 2 things : what is X_c ? and why the explicit solution is only space based ? and for the time ? Thanks in advance Marco |
|
September 23, 2017, 12:17 |
|
#2 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
What do you mean for "strange results"? Please add a plot.
Then I see this instruction that has nothing to do with the CFL condition. CFL = DT/DX**2 In the Wiki page the term explicit is used for the explicit formula of the discrete spatial derivatives. Implicit is used as counterpart of the formulas for the compact (and implicit) formulas. In this framework, it has nothing to do with the explicit/implicit time integration. Then I suggest to follow some examples of the books: http://mathcenter.hust.edu.cn/Upload...98740d59f8.pdf http://www.cambridge.org/it/academic...I9Radx3VqTX.97 |
|
September 23, 2017, 12:55 |
|
#3 | |
Member
Marco Ghiani
Join Date: Jan 2011
Posts: 35
Rep Power: 15 |
Quote:
|
||
September 23, 2017, 13:01 |
|
#4 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
you have to correct that considering also the diffusive constraint...however, in general the CFL contains the velocity that changes in time and space, so that you should consider at each time step to check the condition. However, for the Burgers exquation the velocity does not exceed the maximun at the initial condition, so the assignement CFL=DT/DX is valid only if umax(t=0)<=1
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Guide: Writing Equations in LaTeX on the CFD Online Forums | pete | Site Help, Feedback & Discussions | 27 | May 19, 2022 04:19 |
SIMPLE Algorithm Finite Difference Equations: how to discretize and solve? | DA6righthand | Main CFD Forum | 0 | August 3, 2015 13:12 |
modelling Differential equations in a udf | RikardMNorén | Fluent UDF and Scheme Programming | 2 | October 1, 2013 04:36 |
Riemann invariants of adjoint equations of shallow water equations | zqb0929 | Main CFD Forum | 0 | March 15, 2012 01:54 |
CFD governing equations | m.gos | Main CFD Forum | 0 | April 30, 2011 15:21 |