CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

EULER-Forward-Method

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   June 10, 2001, 03:40
Default EULER-Forward-Method
  #1
freak
Guest
 
Posts: n/a
I am a stupid student looking out for help. The task is: Draw up a computerprogram in a programming language of your choice (delphi, fortran,...) by which you will be able to analyse the mistakes and stability of an wearing off process. Given is the equation: du/dt=d2u/du2 (2 means square) Please use for the discretization the explicit Euler-Forward-method. The distribution of the beginning looks like a sine oscillation. The abscissa is standardized: x0=0 x1=1 The locas increment is dx=0,002. By using the following increments in time examine the stability of calculation. increment in time dt : dt/(dx)^2 ---------------------------------------- 0,000002 : 0,5 2,0004E-6 : 0,5001 2,004E-6 : 0,501 2,04E-6 : 0,51 1,96E-6 : 0,49 1,8E-6 : 0,45 1,6E-6 : 0,4 0,8E-6 : 0,2 0,4E-6 : 0,1

Give a statement about the precision resp. the number of itterations to reach a mistake less than 0,000001.

Depict (graphical) the trend of the mistake in dependence on the number of itterations in a loarithmic coordinate system for the cases listed in the table ahead specialy for x=1/4.

Depict the results of the calculation.

Please help me with this problem.

It would be nice if anyone is able to send me a program source code for the Euler-Forward-method. Or please tell me an good webpage where I can find somthing to solve my problem.

Thanx!!!
  Reply With Quote

Old   June 10, 2001, 14:23
Default Re: EULER-Forward-Method
  #2
John C. Chien
Guest
 
Posts: n/a
(1). Read the book,"Applied Numerical Methods", by Brice Carnahan, H.A. Luther, and James O. Wilkes. (2).Chapter 7, Approximation of the solution of partial differential equations. (methods, Fortran codes included)
  Reply With Quote

Old   June 11, 2001, 19:12
Default Re: EULER-Forward-Method
  #3
Mr. Bee
Guest
 
Posts: n/a
Here you go.

SUBROUTINE EULER(A,B,M,MBDCND,BDA,BDB,C,D,N,NBDCND,BDC,BDD,

1 ELMBDA,F,IDIMF,PERTRB,IERROR,W)

DIMENSION F(IDIMF,1)

DIMENSION BDA(1) ,BDB(1) ,BDC(1) ,BDD(1) ,

1 W(1) C C CHECK FOR INVALID PARAMETERS. C

IERROR = 0

IF (A .LT. 0.) IERROR = 1

IF (A .GE. B) IERROR = 2

IF (MBDCND.LE.0 .OR. MBDCND.GE.7) IERROR = 3

IF (C .GE. D) IERROR = 4

IF (N .LE. 3) IERROR = 5

IF (NBDCND.LE.-1 .OR. NBDCND.GE.5) IERROR = 6

IF (A.EQ.0. .AND. (MBDCND.EQ.3 .OR. MBDCND.EQ.4)) IERROR = 7

IF (A.GT.0. .AND. MBDCND.GE.5) IERROR = 8

IF (MBDCND.GE.5 .AND. NBDCND.NE.0 .AND. NBDCND.NE.3) IERROR = 9

IF (IDIMF .LT. M+1) IERROR = 10

IF (M .LE. 3) IERROR = 12

IF (IERROR .NE. 0) RETURN

MP1 = M+1

DELTAR = (B-A)/FLOAT(M)

DLRBY2 = DELTAR/2.

DLRSQ = DELTAR**2

NP1 = N+1

DELTHT = (D-C)/FLOAT(N)

DLTHSQ = DELTHT**2

NP = NBDCND+1 C C DEFINE RANGE OF INDICES I AND J FOR UNKNOWNS U(I,J). C

MSTART = 2

MSTOP = MP1

GO TO (101,105,102,103,104,105),MBDCND 101 MSTOP = M

GO TO 105 102 MSTART = 1

GO TO 105 103 MSTART = 1 104 MSTOP = M 105 MUNK = MSTOP-MSTART+1

NSTART = 1

NSTOP = N

GO TO (109,106,107,108,109),NP 106 NSTART = 2

GO TO 109 107 NSTART = 2 108 NSTOP = NP1 109 NUNK = NSTOP-NSTART+1 C C DEFINE A,B,C COEFFICIENTS IN W-ARRAY. C

ID2 = MUNK

ID3 = ID2+MUNK

ID4 = ID3+MUNK

ID5 = ID4+MUNK

ID6 = ID5+MUNK

A1 = 2./DLRSQ

IJ = 0

IF (MBDCND.EQ.3 .OR. MBDCND.EQ.4) IJ = 1

DO 110 I=1,MUNK

R = A+FLOAT(I-IJ)*DELTAR

J = ID5+I

W(J) = R

J = ID6+I

W(J) = 1./R**2

W(I) = (R-DLRBY2)/(R*DLRSQ)

J = ID3+I

W(J) = (R+DLRBY2)/(R*DLRSQ)

J = ID2+I

W(J) = -A1+ELMBDA 110 CONTINUE

GO TO (114,111,112,113,114,111),MBDCND 111 W(ID2) = A1

GO TO 114 112 W(ID2) = A1 113 W(ID3+1) = A1 114 CONTINUE C C ENTER BOUNDARY DATA FOR R-BOUNDARIES. C

GO TO (115,115,117,117,119,119),MBDCND 115 A1 = W(1)

DO 116 J=NSTART,NSTOP

F(2,J) = F(2,J)-A1*F(1,J) 116 CONTINUE

GO TO 119 117 A1 = 2.*DELTAR*W(1)

DO 118 J=NSTART,NSTOP

F(1,J) = F(1,J)+A1*BDA(J) 118 CONTINUE 119 GO TO (120,122,122,120,120,122),MBDCND 120 A1 = W(ID4)

DO 121 J=NSTART,NSTOP

F(M,J) = F(M,J)-A1*F(MP1,J) 121 CONTINUE

GO TO 124 122 A1 = 2.*DELTAR*W(ID4)

DO 123 J=NSTART,NSTOP

F(MP1,J) = F(MP1,J)-A1*BDB(J) 123 CONTINUE C C ENTER BOUNDARY DATA FOR THETA-BOUNDARIES. C 124 A1 = 1./DLTHSQ

L = ID5-MSTART+1

LP = ID6-MSTART+1

GO TO (134,125,125,127,127),NP 125 DO 126 I=MSTART,MSTOP

J = I+LP

F(I,2) = F(I,2)-A1*W(J)*F(I,1) 126 CONTINUE

GO TO 129 127 A1 = 2./DELTHT

DO 128 I=MSTART,MSTOP

J = I+LP

F(I,1) = F(I,1)+A1*W(J)*BDC(I) 128 CONTINUE 129 A1 = 1./DLTHSQ

GO TO (134,130,132,132,130),NP 130 DO 131 I=MSTART,MSTOP

J = I+LP

F(I,N) = F(I,N)-A1*W(J)*F(I,NP1) 131 CONTINUE

GO TO 134 132 A1 = 2./DELTHT

DO 133 I=MSTART,MSTOP

J = I+LP

F(I,NP1) = F(I,NP1)-A1*W(J)*BDD(I) 133 CONTINUE 134 CONTINUE C C ADJUST RIGHT SIDE OF EQUATION FOR UNKNOWN AT POLE WHEN HAVE C DERIVATIVE SPECIFIED BOUNDARY CONDITIONS. C

IF (MBDCND.GE.5 .AND. NBDCND.EQ.3)

1 F(1,1) = F(1,1)-(BDD(2)-BDC(2))*4./(FLOAT(N)*DELTHT*DLRSQ) C C ADJUST RIGHT SIDE OF SINGULAR PROBLEMS TO INSURE EXISTENCE OF A C SOLUTION. C

PERTRB = 0.

IF (ELMBDA) 144,136,135 135 IERROR = 11

GO TO 144 136 IF (NBDCND.NE.0 .AND. NBDCND.NE.3) GO TO 144

S2 = 0.

GO TO (144,144,137,144,144,138),MBDCND 137 W(ID5+1) = .5*(W(ID5+2)-DLRBY2)

S2 = .25*DELTAR 138 A2 = 2.

IF (NBDCND .EQ. 0) A2 = 1.

J = ID5+MUNK

W(J) = .5*(W(J-1)+DLRBY2)

S = 0.

DO 140 I=MSTART,MSTOP

S1 = 0.

IJ = NSTART+1

K = NSTOP-1

DO 139 J=IJ,K

S1 = S1+F(I,J) 139 CONTINUE

J = I+L

S = S+(A2*S1+F(I,NSTART)+F(I,NSTOP))*W(J) 140 CONTINUE

S2 = FLOAT(M)*A+DELTAR*(FLOAT((M-1)*(M+1))*.5+.25)+S2

S1 = (2.+A2*FLOAT(NUNK-2))*S2

IF (MBDCND .EQ. 3) GO TO 141

S2 = FLOAT(N)*A2*DELTAR/8.

S = S+F(1,1)*S2

S1 = S1+S2 141 CONTINUE

PERTRB = S/S1

DO 143 I=MSTART,MSTOP

DO 142 J=NSTART,NSTOP

F(I,J) = F(I,J)-PERTRB 142 CONTINUE 143 CONTINUE 144 CONTINUE C C MULTIPLY I-TH EQUATION THROUGH BY (R(I)*DELTHT)**2. C

DO 146 I=MSTART,MSTOP

K = I-MSTART+1

J = I+LP

A1 = DLTHSQ/W(J)

W(K) = A1*W(K)

J = ID2+K

W(J) = A1*W(J)

J = ID3+K

W(J) = A1*W(J)

DO 145 J=NSTART,NSTOP

F(I,J) = A1*F(I,J) 145 CONTINUE 146 CONTINUE

W(1) = 0.

W(ID4) = 0. C C CALL GENBUN TO SOLVE THE SYSTEM OF EQUATIONS. C

CALL GENBUN (NBDCND,NUNK,1,MUNK,W(1),W(ID2+1),W(ID3+1),IDIMF,

1 F(MSTART,NSTART),IERR1,W(ID4+1))

IWSTOR = W(ID4+1)+3.*FLOAT(MUNK)

GO TO (157,157,157,157,148,147),MBDCND C C ADJUST THE SOLUTION AS NECESSARY FOR THE PROBLEMS WHERE A = 0. C 147 IF (ELMBDA .NE. 0.) GO TO 148

YPOLE = 0.

GO TO 155 148 CONTINUE

J = ID5+MUNK

W(J) = W(ID2)/W(ID3)

DO 149 IP=3,MUNK

I = MUNK-IP+2

J = ID5+I

LP = ID2+I

K = ID3+I

W(J) = W(I)/(W(LP)-W(K)*W(J+1)) 149 CONTINUE

W(ID5+1) = -.5*DLTHSQ/(W(ID2+1)-W(ID3+1)*W(ID5+2))

DO 150 I=2,MUNK

J = ID5+I

W(J) = -W(J)*W(J-1) 150 CONTINUE

S = 0.

DO 151 J=NSTART,NSTOP

S = S+F(2,J) 151 CONTINUE

A2 = NUNK

IF (NBDCND .EQ. 0) GO TO 152

S = S-.5*(F(2,NSTART)+F(2,NSTOP))

A2 = A2-1. 152 YPOLE = (.25*DLRSQ*F(1,1)-S/A2)/(W(ID5+1)-1.+ELMBDA*DLRSQ*.25)

DO 154 I=MSTART,MSTOP

K = L+I

DO 153 J=NSTART,NSTOP

F(I,J) = F(I,J)+YPOLE*W(K) 153 CONTINUE 154 CONTINUE 155 DO 156 J=1,NP1

F(1,J) = YPOLE 156 CONTINUE 157 CONTINUE

IF (NBDCND .NE. 0) GO TO 159

DO 158 I=MSTART,MSTOP

F(I,NP1) = F(I,1) 158 CONTINUE 159 CONTINUE

W(1) = IWSTOR

RETURN

END
  Reply With Quote

Old   June 12, 2001, 01:22
Default Re: EULER-Forward-Method
  #4
freak
Guest
 
Posts: n/a
tahnx for answering, but i can not refer the variables. that kind of programing language is it?
  Reply With Quote

Old   June 12, 2001, 09:19
Default Re: EULER-Forward-Method
  #5
Mr. Bee
Guest
 
Posts: n/a
ax++ version 3.125
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh gschaider OpenFOAM 300 October 29, 2014 19:00
population balance with and Euler Euler method. thomas CFX 3 August 30, 2011 19:20
population balance with and Euler Euler method. thomas Main CFD Forum 0 May 7, 2004 07:58
population balance with and Euler Euler method. thomas FLUENT 0 May 7, 2004 07:57
Unstructured Multigrid Method for Euler equations Jian Xia Main CFD Forum 8 December 20, 1999 13:31


All times are GMT -4. The time now is 07:58.