Program “burger.for”

Program description

The program was written in Fortran 90.

The scheme used is the Crank-Nicholson generalised scheme.

The program permits to realize two types of calculation, by means of two types of initialization.

The first initialization has rigid boundary conditions: the initial value of u is a sinusoidal curve from x=0 to 1. The boundary values are set to 0.

The second initialization has free boundary conditions. The initial value of u is a straight line from 1 to -1 while x=0 to 1. The boundary condition is free, so the fluxes in 0 and 1 are set to 0.

UP

Input-Output

The input and output phasis are made by means of three files: input.txt, output.txt and burger.ini.

input

The input file contains all the necessary values to perform the calculation:

Variables

Use

Nu

Cinematic viscosity (m2/s)

delta_t

Time step (s)

n_iter

Number of time iterations

pas_sortie

Output time step (iterations)

n_points

Number of points in space (<121)

scheme

Choice of the scheme:
1: finite differences
2: finite elements
3: mass operator
4: 4pts-upwind

init

Type of initialization:
1: sinusoidal
2: straight line

output

The output file is divided into two sections: the first describes the parameters of the simulation and the second contains the results, in a matrix format (u in fonction of x and t).

format

The program needs to read the format of writing in a configuration file, burger.ini. To avoid problems at the writing, the maximum number of points in space is 121.

UP

Solver

The program calculates the matrix corresponding to the scheme and storages it in a vector format.

To solve the system AX=B, it uses the subroutine “GAUSS”, a subroutine designed to solve the systems with a band matrix. This subroutine was furnished by Mrs. Maubourguet from the IMFT laboratory (Toulouse) (http://www.imft.fr).

The listing and the arguments of the subroutine are detailed below:

 c*****************************************************c MODE D'UTILISATION : CALL GAUSS (A,B,LV,MX) *c*****************************************************C Donnees : A Coefficients de la matrice bande, ** variable a une dimension dont les ** valeurs numeriques doivent etre ** fournies conformement au schema ** ci-dessous. ** Les points exterieurs a la bande ne ** sont pas pris en compte pdt le calcul ** A la sortie de GAUSS, A est detruite ** B Termes du 2eme membre, variable a un ** indice. A la sortie de GAUSS, la ** solution se trouve dans B. ** LV Ordre de la matrice A. ** LB Largeur de la bande = 2 MX + 1; ** MX est appelee "demi largeur de bande" ** ******************************************************* SUBROUTINE GAUSS(A,B,LV,MX)DIMENSION A(1),B(1)LMOI=LV-MXICODE=1MX2=2*MX+1MX1=MX+1M22=MX2-1L=MX1DO K=1,LVDIVB=1./A(L)LMX=L+MXIF(K .GT. LMOI) THENLMX=LMX-ICODEICODE=ICODE+1ENDIFDO J=L,LMXA(J)=A(J)*DIVBENDDOB(K)=B(K)*DIVBIF(K.NE.LV) THENMI22=0DO II=ICODE,MXMI22=MI22+M22LMI22=L+MI22IF (A(LMI22).NE.0) THENCOEFF=A(LMI22)DO J=L,LMXJMI22=J+MI22A(JMI22)=A(JMI22)-A(J)*COEFFENDDOIII=II-ICODE+1KIII=K+IIIB(KIII)=B(KIII)-B(K)*COEFFENDIFENDDOL=L+MX2ENDIFENDDOICODE=0I=LVL=MX1+1+(LV-1)*MX2DO WHILE (I.GT.1)SIGMA=0.L=L-MX2LMX=L+MX-1IF(I.GT.LMOI) THENLMX=L+ICODEICODE=ICODE+1ENDIFII=IDO J=L,LMXSIGMA=SIGMA+A(J)*B(II)II=II+1ENDDOI=I-1B(I)=B(I)-SIGMAENDDORETURNEND

UP

Program listing

The listing of the program is entirely commented and uses the different files mentionned above to run. It is compiled in Fortran 90 and designed to run on a Windows environment, but is also compliant with other OS, with an appropriate compiler.

It manages the different types of schemes, initializations and boundary conditions detailed in the description of the scheme.

You can download the program with the appropriate files and configurations by clicking on the button below. The download file is under the ZIP format (size 8Ko). The program is not compiled, so you will need a Fortran90 compiler to use it.