Comparison of Two Different Implementations of A Finite-Difference-Method For First-Order Pde in M and M
Comparison of Two Different Implementations of A Finite-Difference-Method For First-Order Pde in M and M
Abstract
In this article two implementations of a symmetric finite difference algorithm (ftcs-method)
for a first-order partial differential equation are discussed. The considered partial differen-
tial equation discribes the time evolution of the crack length ditribution of microcracks in
brittle materia.
∗
Technische Universität Berlin – Institut für Theoretische Physik – Sekr.: PN 7-1 – Hardenbergstr. 36 – 10623
Berlin – Germany
†
Correspondend autor: Heiko Herrmann
1
(a) step-wise initial condition (b) step-wise initial condition
Figure 1: Analytical solution for crack lenght distributuion. Shown is f (l, t)l2 over l and t.
2
2 The numerical algorithm
The partial differential equations are first order in time and crack length. Two different al-
gorithms, upwind and fcts (forward time centered space), have been tested. The symmetric
algorithm (ftcs-method) is in this case a bit more stable than the upwind, which is somewhat
astonishing. Both algorithms can be found in [2].
In the symmetric algorithm f (l, t + 1) is calculated from f (l − 1, t), f (l, t) and f (l + 1, t) by
2 2α 2
f (l, t + 1) = f (l, t) 1 − 3βσ (t) − )dt − dl lβσ (t) − α ×
dl l
dt
× (f (l + 1, t) − f (l − 1, t)) (4)
2dl
This is what the main part of the implementation in M ATHEMATICA® looks like:
For[t = 1, t < TMAX, t++, For[l = 1, l < LMAX, l++,
If[l*dl*(t*dt)^2*be - al > 0,
If[l == 0, f[l, t + 1] = f[l, t],
f[l, t + 1] =
f[l, t]*(1 - (3*be*(t*dt)^2 - (2*al)/(dl*l))*dt) -
(dl*l*be*(t*dt)^2 - al)*dt/dl*(f[l + 1, t] - f[l - 1, t])],
f[l, t + 1] = f[l, t]
]
]
]
This is what the main part of the implementation in M ATLAB® looks like:
for t=1:1:TMAX-1
for l=1:1:LMAX-1
if (l.*dl.*sigma(t).*beta-alpha > 0)
f(l,t+1)=f(l,t).*(1-(3.*beta.*(sigma(t)).^2 - ...
(2.*alpha)./(dl.*l)).*dt)-(dl.*l.*beta.*(sigma(t)).^2 - ...
alpha).*dt./(2*dl).*(f(l+1,t)-f(l-1,t));
else
f(l,t+1)=f(l,t);
end
end
end
3
3 Results obtained by M ATHEMATICA®
M ATHEMATICA® is a general purpose computer algebra system (cas) by Wolfram Research
Inc.. As one can see the solution shows some wave-like efects, which can be interpreted as a
Figure 2: Numerical solution for crack lenght distributuion calculated with M ATHEMATICA®
sign for numerical instability. This instability is a result of the discontinous initial condition.
4
4 Results obtained by M ATLAB®
M ATLAB® is a tool for numerical mathematics, especially designed for matrix manipulation,
by The MathWorks Inc.. Here in both cases huge instabilities occur. As soon as some cracks
Figure 3: Numerical solution for crack lenght distributuion calculated with M ATLAB®
start growing the numerical error goes to infinity. The following pictures show an extract of the
above pictures.
Figure 4: Numerical solution for crack lenght distributuion calculated with M ATLAB® (extract
of figure 3)
5
5 Comparison of the results and conclusion
Obviously the results, obtained with both programs, show huge errors. But in contrast to the
results calculated with M ATLAB® , one can use the results obtained with M ATHEMATICA® at
least for some rough predictions.
The difference in the two software packages, used for these simulations, is that M ATLAB® uses
floating-point variables of precision “double” (16 byte), whereas M ATHEMATICA® is capable
of both numerical and symolic computation. Therefore it is possible that M ATHEMATICA® uses
a much higher precision to perform some of the operations than M ATLAB® .
Acknowledgement
We thank Dr. Christina Papenfuß and Dr. Peter Ván for discussions. Financial support by the
DAAD, OTKA and by the VISHAY Company, 95100 Selb, Germany, is greatfully acknowl-
edged.
References
[1] P. Ván, C. Papenfuss, and W. Muschik. Griffith cracks in the mesoscopic microcrack theory.
Journal of Physics A, 37(20):5315–5328, 2004. (cond-mat/0211207).