Upload
russell-wood
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
USER GUIDELINES OF:
PARABOLIC PDE SOLVERPARABOLIC PDE SOLVER
Revision 2.11 of DeRevision 2.11 of December 2, 2010 cember 2, 2010 by M. MICCIOby M. MICCIO
MUC 1.0 ALLOWS TO SOLVE P.D.E. OF THE KIND :
• SECOND
ORDER;• PARABOLIC;• LINEAR;• COSTANT
COEFFICIENTS.
txukx
txu
t
txu,
,,2
2
INITIAL CONDITION :
The initial condition can be a general function of x , not only a costant value
u0 .
xutxut 00
,
BOUNDARY CONDITIONS :
tCx
txuBtxuA
xx
00
,,
tFx
txuEtxuD
LxLx
,,
The boundary conditions can be function of time: C(t) e F(t).
WHAT MUC 1.0 CAN DO:
• Resolution of PDE with:explicit Euler method andimplicit Crank&Nicholson method.
• Check of the Mean Square Error between the solutions.
RESOLUTION OF P.D.E. (1)
The parameters to indicate for each
specific problem are :
Δ;
k .
Lenght of the domain (Lenght);
Number of points for discretization (# Points);
Time of last solution (Time);
Timestep for time discretization (Timestep);
RESOLUTION OF P.D.E. (2)
It is necessary to specify initial and boundary conditions in the proper controls.
Initial and boundary conditions can be function,
respectevely,
of x and t.
VALID FUNCTIONS FOR I.C. AND B.C. (1)
abs(x) Absolute Value acos(x) Inverse Cosine acosh(x) Inverse Hyperbolic Cosine asin(x) Inverse Sine asinh(x) Inverse Hyperbolic Sine atan(x) Inverse Tangent atanh(x) Inverse Hyperbolic Tangent cos(x) Cosine cosh(x) Hyperbolic Cosine cot(x) Cotangent
VALID FUNCTIONS FOR I.C. AND B.C. (2)
• csc(x) Cosecant (1/sin(x))• exp(x) Exponential • expm1(x) Exponential (Arg - 1): (e^(x-1))• getexp(x) Mantissa & Exponent (returns the
exponent of x)• getman(x) Mantissa & Exponent (returns the
mantissa of x)• int(x) Round To Nearest (rounds its argument to
the nearest integer)• intrz(x) Round Toward 0 (rounds x to the
nearest integer between x and zero)• ln(x) Natural Logarithm
VALID FUNCTIONS FOR I.C. AND B.C. (3)
• lnp1(x) Natural Logarithm (Arg +1) • log(x) Logarithm Base 10 • log2(x) Logarithm Base 2 • max(x,y) Maximum • min(x,y) Minimum • mod(x,y) Quotient & Remainder • pow(x,y) x^y • rand( )Random Number (0- 1) • rem(x,y) Remainder • sec(x) Secant [computes the secant of x, where
x is in radians: (1/cos(x))]• sign(x) Sign (returns 1 if x is greater than
0, returns 0 if x is equal to 0, and returns -1 if x is less than 0)
VALID FUNCTIONS FOR I.C. AND B.C. (4)
• sin(x) Sine
• sinc(x) Sinc [computes the sine of x divided by x radians: (sin(x)/x)]
• sinh(x) Hyperbolic Sin
• sqrt(x) Square Root
• tan(x) Tangent
• tanh(x) Hyperbolic Tangent
N.B.1 The independent variable can be indicated as either x or t
N.B.2 The costant must be indicated as pi(1)
EULER METHOD (1)
Timestep and spatial step must be chosen
( ) so that the Stability
Parameter be:1int#
sPo
LenghtpSpacialSte
2
12
pSpacialSte
Timestep
Otherwise the solution is unstable, and the warning led of the Stability Parameter lights on.
EULER METHOD (2)
If the Stability Parameter is greater than 0.5 the solution is unstable. Pushing the button Euler Method Stability Safety, the s.p. is forced to 0.499 and the graph does not twist.
Anyway the solution plotted is wrong if the Stability Parameter led is red.
CRANK-NICHOLSON METHOD
• Implicit Method• Ever stable• Stability Parameter suggested:
102 2
pSpacialSte
Timestep
Example of students’ test
15
txukx
txu
t
txu,
,,2
2
1) Check the stability of the explicit method for the PDE having = 1 and k = 0 and further subject to a linear initial condition: I.C.: u(x,0) = 0,4*xto a Dirichlet condition at the left boundary: B.C.1: u(0,t) =1and a a mixed condition at the right boundary:with:Lenght of the domain (Lenght) = 1Number of points for discretization (# Points) = 40Time of last solution (Time) = 0.3Timestep for time discretization (Timestep) = 0,00033
2) How much is the spatial step?
3) What is the new value for the time step if the explicit method turns out unstable?
4) Discuss and comment the final diagram
5) Repeat integration with the Crank-Nicholson method and compare the results with the explicit method through the Mean Square Error
B.C.2 : u x,t xL
u x,t
xxL
0
STABILITY EXAMPLE 1 – EULER METHOD
Parameters:
Lenght=1
#Points=40
Time=0,3
Timestep=0,00033
=1
k=0
I.C. u(x,o)=0,4x
A=1
B=0
C=1
D=1
E=-1
F=0
Initial Condition
Unstable Solution
STABILITY EXAMPLE 2 – EULER METHOD
Parameters:
Lenght=1
#Points=40
Time=0,02-0,03
Timestep=0,00055
=1
k=0
I.C. u(x,0)=sin(pi(1)*x)
A=1
B=0
C=0
D=1
E=0
F=0
EXAMPLE 1 - CRANK & NICHOLSON METHOD
Parameters:
Lenght=1#Points=40Time=1,7Timestep=0,00327024 =1k=0I.C. sin(pi(1)*x)A=1B=0C=abs(sin(pi(1)*x))D=1E=0F=0
EXAMPLE 2 - CRANK & NICHOLSON METHOD
Parameters:
L=1
#Points=41
Time=1
Timestep=0,00082
=1
k=0
I.C. abs(sin(2*pi(1)*x))
A=1
B=0
C=abs(cos(4*pi(1)*x))
D=1
E=0
F=abs(sin(4*pi(1)*x))
COMPARING OF THE SOLUTIONS
MUC 1.0 allows comparison of the solutions calculated with Euler and Crank-Nicholson methods through the function Mean Square Error.
COMPARING OF THE SOLUTIONS (2)
The solution vectors –calculated by solving the same problem with each of the two methods – are compared with the MSE appearing in the proper indicator.
MEAN SQUARE ERROR
Two vectors having n elements:
1
0
21 n
iii yx
nMSE
110
110
...,...,,
...,...,,
niT
niT
yyyyy
xxxxx
can be compared calculating the MSE as:
MEAN SQUARE ERROR (2)
The MSE found comparing two solutions can not indicate which solution is better: it only calculates a mean error between the solutions.
To test the software, some numerical solutions have been compared with analytical solutions
or commercial softwares.
Here some of the results.
MEAN SQUARE ERROR (3)
2 KINDS OF PROOF:
• Variable # Points and constant Timestep
• Constant # Points and variable Timestep
Parameters: Lenght=1; Time=0,05; =1; k=0; I.C. u(x,0)=0; A=1; B=0; C=1; D=1; E=0; F=1.
MUC 1.0 vs COMMERCIAL SOFTWARE
It has been considered the problem of diffusion of a component through a layer of infinite lenght and unitary thickness.
1,
1,0
00,
2
2
tLC
tC
xCx
C
t
C
FEM SOLUTION WITH A COMMERCIAL SOFTWARE
AUTOMATIC MESH :
Number of nodes = 16Number of elements = 15Max spatial step = 0,066667
Time = 0,1Timestep = 0,001
FEM SOLUTION (1)
FEM SOLUTION (2)
t 0,01 0,02 0,03 0,04 0,05 0,06 0,07 0,08 0,09 0,1NODE 1 1 1 1 1 1 1 1 1 1 1
2 0.65088 0.74419 0.78826 0.81625 0.83668 0.85319 0.86756 0.88036 0.89502 0.902043 0.36326 0.51349 0.59126 0.64265 0.68137 0.71322 0.74111 0.76603 0.78834 0.808364 0.16927 0.32604 0.42084 3.389583 0.54139 0.58646 0.62631 0.66204 0.69415 0.723065 0.063515 0.18915 0.28425 0.35937 0.42288 0.47845 0.52816 0.57295 0.61337 0.649876 0.018016 0.099797 0.18401 0.26078 0.33048 0.39364 0.45082 3.490278 3.815972 0.591997 0.0033129 0.048852 0.11925 1.350694 0.26736 0.33532 0.39747 0.45398 0.50532 0.551948 0.000124330.026448 0.08772 0.16129 0.23538 0.30563 0.37026 0.42916 0.48275 0.531469 0.000124330.026448 0.08772 0.16129 0.23538 0.30563 0.37026 0.42916 0.48275 0.53146
10 0.0033129 0.048852 0.11925 1.350694 0.26736 0.33532 0.39747 0.45398 0.50532 0.5519411 0.018016 0.099797 0.18401 0.26078 0.33048 0.39364 0.45082 3.490278 3.815972 0.5919912 0.063515 0.18915 0.28425 0.35937 0.42288 0.47845 0.52816 0.57295 0.61337 0.6498713 0.16927 0.32604 0.42084 3.389583 0.54139 0.58646 0.62631 0.66204 0.69415 0.7230614 0.36326 0.51349 0.59126 0.64265 0.68137 0.71322 0.74111 0.76603 0.78834 0.8083615 0.65088 0.74419 0.78826 0.81625 0.83668 0.85319 0.86756 0.88036 0.89502 0.9020416 1 1 1 1 1 1 1 1 1 1
MUC 1.0 SOLUTION
Parametri:
Lenght=1
# Points=16
Time=0,1
Timestep=0,01
=1
k=0
I.C. u(x,0)=0
A=1
B=0
C=1
D=1
E=0
F=1
MEAN SQUARE ERROR
Comparing the Crank & Nicholson Solution Vector with the FEM solution for time 0,1 :
Timestep=0,01
S.P.=1,1250
MSE=1,3 E-3
Timestep=0,001
S.P.=0,1125
MSE=3 E-5
Timestep=0,00001
S.P.=0,0013
MSE= 5,5 E-6
MUC 1.0 vs ANALYTICAL SOLUTION (1)
Problem of monodimensional
diffusion: xxC
tCtCx
C
t
C
sin0,
0,1,0
2
2
1,0x0>t
Analytical solution: xetxC t sin,2
MUC 1.0 vs ANALYTICAL SOLUTION (2)
Lenght=1# Points=16Time=0,1Timestep=0,0001
Points X
Analytical
solution
Euler
method
Crank & Nicholson
method
0 0 0 0 0
1 0,667 0,07753 0,07773 0,07777
2 0,1134 0,1517 0,15207 0,15214
3 0,2001 0,2192 0,21976 0,21986
4 0,2668 0,27708 0,27784 0,27798
5 0,3335 0,32287 0,32378 0,32394
6 0,4002 0,35454 0,35557 0,35575
7 0,4669 0,37069 0,37182 0,37200
MUC 1.0 vs ANALYTICAL SOLUTION (3)
MSEA/E = 5,3 E-7
MSEA/C&N = 7,3 E-7
PARABOLIC PDE SOLVERPARABOLIC PDE SOLVER
Future developments: solving PDE with two and three spacial variables and systems of PDE.
by
Ugo Avagliano
student of Chemical and Food Engineering
University of Salerno - Italy