GUIDA ALL'USO DEL:

advertisement
USER GUIDELINES OF:
PARABOLIC PDE SOLVER
Revision 2.11 of December 2, 2010 by M. MICCIO
MUC 1.0 ALLOWS TO
SOLVE P.D.E. OF THE KIND :
u x, t 
 u  x, t 

 k  u  x, t 
2
t
x
2
• SECOND
ORDER;
• PARABOLIC;
• LINEAR;
• COSTANT
COEFFICIENTS.
INITIAL CONDITION :
ux, t  t 0  u0 x 
The initial condition can be a general
function of x , not only a costant value
u0 .
BOUNDARY CONDITIONS :
ux, t 
A  ux, t  x 0  B
 C t 
x x 0
ux, t 
D  ux, t  x  L  E
 F t 
x x  L
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 and
implicit 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)
acos(x)
acosh(x)
asin(x)
asinh(x)
atan(x)
atanh(x)
cos(x)
cosh(x)
cot(x)
Absolute Value
Inverse Cosine
Inverse Hyperbolic Cosine
Inverse Sine
Inverse Hyperbolic Sine
Inverse Tangent
Inverse Hyperbolic Tangent
Cosine
Hyperbolic Cosine
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
SpacialStep 
Lenght
# Po int s  1
(
) so that the Stability
Parameter be:
  Timestep 1


2
SpacialStep
2
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:
  Timestep

 10
2
2  SpacialStep
Example of students’ test
u x, t 
 2 u  x, t 

 k  u  x, t 
2
t
x
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*x
to a Dirichlet condition at the left boundary:
B.C.1: u(0,t) =1
and a a mixed condition at the right boundary:
with:
ux,t 
B.C.2 : ux,t  x L 
0
Lenght of the domain (Lenght) = 1
x x L
Number of points for discretization (# Points) = 40
Time of last solution (Time) = 0.3
Timestep 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
15
with the explicit method through the Mean Square Error
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
Unstable Solution

Initial Condition
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=40
Time=1,7
Timestep=0,00327024
 =1
k=0
I.C. sin(pi(1)*x)
A=1
B=0
C=abs(sin(pi(1)*x))
D=1
E=0
F=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:
x  x0 , x1 , ... xi , ... xn1 
T
y   y0 ,
T
y1 , ... yi , ... yn1 
can be compared calculating the MSE as:
1 n 1
2
MSE    xi  yi 
n i 0
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)
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.
2 KINDS OF PROOF:
•
Variable # Points and constant Timestep
•
Constant # Points and variable Timestep
MUC 1.0 vs COMMERCIAL SOFTWARE
C  C
 2
t
x
C  x ,0   0
2
It has been
considered the
problem of diffusion
of a component
through a layer of
infinite lenght and
unitary thickness.
C 0, t   1
C  L, t   1
FEM SOLUTION WITH A COMMERCIAL
SOFTWARE
AUTOMATIC MESH :
Number of nodes = 16
Number of elements = 15
Max spatial step = 0,066667
Time = 0,1
Timestep = 0,001
FEM SOLUTION (1)
FEM SOLUTION (2)
t 0,01
NODE 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
0,02
1
0,03
1
0.65088 0.74419
0.36326 0.51349
0.16927 0.32604
0.063515 0.18915
0.018016 0.099797
0.0033129 0.048852
0.000124330.026448
0.000124330.026448
0.0033129 0.048852
0.018016 0.099797
0.063515 0.18915
0.16927 0.32604
0.36326 0.51349
0.65088 0.74419
1
1
0,04
1
0.78826
0.59126
0.42084
0.28425
0.18401
0.11925
0.08772
0.08772
0.11925
0.18401
0.28425
0.42084
0.59126
0.78826
0,05
1
0.81625
0.64265
3.389583
0.35937
0.26078
1.350694
0.16129
0.16129
1.350694
0.26078
0.35937
3.389583
0.64265
0.81625
1
1
0,06
1
0.83668
0.68137
0.54139
0.42288
0.33048
0.26736
0.23538
0.23538
0.26736
0.33048
0.42288
0.54139
0.68137
0.83668
0,07
1
0.85319
0.71322
0.58646
0.47845
0.39364
0.33532
0.30563
0.30563
0.33532
0.39364
0.47845
0.58646
0.71322
0.85319
1
1
0.86756
0.74111
0.62631
0.52816
0.45082
0.39747
0.37026
0.37026
0.39747
0.45082
0.52816
0.62631
0.74111
0.86756
1
0,08
0,09
0,1
1
1
0.88036
0.76603
0.66204
0.57295
3.490278
0.45398
0.42916
0.42916
0.45398
3.490278
0.57295
0.66204
0.76603
0.88036
1
1
0.89502
0.78834
0.69415
0.61337
3.815972
0.50532
0.48275
0.48275
0.50532
3.815972
0.61337
0.69415
0.78834
0.89502
1
1
0.90204
0.80836
0.72306
0.64987
0.59199
0.55194
0.53146
0.53146
0.55194
0.59199
0.64987
0.72306
0.80836
0.90204
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
Timestep=0,001
Timestep=0,00001
S.P.=1,1250
S.P.=0,1125
S.P.=0,0013
MSE=1,3 E-3
MSE=3 E-5
MSE= 5,5 E-6
MUC 1.0 vs ANALYTICAL SOLUTION (1)
Problem of
monodimensional
diffusion:
C  C
 2
t
x
C 0, t   C 1, t   0
Analytical solution:
Cx, t   e
2
t>0
C x,0  sin   x  x  0,1
 2t
sin   x
MUC 1.0 vs ANALYTICAL SOLUTION (2)
Lenght=1
# Points=16
Time=0,1
Timestep=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
Future developments: solving PDE with two
and three spacial variables and systems of PDE.
PARABOLIC PDE SOLVER
by
Ugo Avagliano
student of Chemical and Food Engineering
University of Salerno - Italy
Download