File Exchange

Gaver-Stehfest algorithm for inverse Laplace transform

version 1.0 (1.57 KB) by

Gaver-Stehfest algorithm for inverse Laplace transform

Updated

%
% ilt=gavsteh(funname,t,L)
%
% funname The name of the function to be transformed.
% t The transform argument (usually a snapshot of time).
% ilt The value of the inverse transform
% L number of coefficient ---> depends on computer word length used
% (examples: L=8, 10, 12, 14, 16, so on..)
%
% Numerical Inverse Laplace Transform using Gaver-Stehfest method
%
%Refferences:
% 1. Villinger, H., 1985, Solving cylindrical geothermal problems using
% Gaver-Stehfest inverse Laplace transform, Geophysics, vol. 50 no. 10 p.
% 1581-1587
% 2. Stehfest, H., 1970, Algorithm 368: Numerical inversion of Laplace transform,
% Communication of the ACM, vol. 13 no. 1 p. 47-49
%
% Simple (and yet rush) examples included in functions fun1 and fun2 with
% their comparisons to the exact value (use testgs.m to run the examples)

rui kou

rui kou (view profile)

Easy to use function

How Can I get this file? I not familiar how to download from file exchange

I am trying to solve the heat equation with both conduction and advective terms:

alpha*(d^2)T/(d^2)z-v*dT/dz-dT/dt (1)

where v=u*Cw/Cv, alpha is a constant. According to the literature the temperature frequency cariation solution of equation 1 is:

That=T0*exp(gamma*z)*exp(i*omega*t) (2)

where T0 and omega are constants. To get the actual temperature (T) value I am trying to use the Gaver-Stehfest numerical inversion. However, the values I get are not realistic, while my input parameters are fine. What am I doing wrong?

My input function is:

function f=fun_s(p)

%Define constants u=3.08*10^-8; %ms^-1 Cw=4.18*10^6; %Jm^-3K^-1 Cv=0.7*10^6; %Jm^-3K^-1 k=0.3; %Wm^-1K^-1 L=1; %m alpha=0.4*10^-6; %m^2 s^-1 omega=(2*pi())/(365.25*86400); theta0=11.5112; z=1;

v=u*Cw/Cv; gamma=(v-sqrt(v^2+4*i*omega*alpha))/(2*alpha);

f=theta0*(exp(gamma*z))*(exp(i*omega*p));

which I then run with the following to get a daily temperature value:

t=1:2*pi/365:2*pi; l=length(t);

for i=1:l T(i)=gavsteh('fun_s',t(i),18); end

Any help on this will be greatly appreciated!

Peng

Peng (view profile)

this one totally helps a lot

Alireza Keramat

Alireza Keramat (view profile)

Thank you. It was interesting because of its simplicity.

Mark

Mark (view profile)

Worked great for me. Nice job.

Montaru Maxime

Montaru Maxime (view profile)

You need to use multi-precision toolbox to enhance results. Very good results for one staircase simulation with a big L. Beware when you simulate multiple staircase.

Binbin Qi

Andor Bariska

This is a solid implementation of the Stehfest Laplace Inversion algorithm. It computes the Stehfest-vector for arbitrary even L. Two examples are supplied, the inversion of 1/s^2 and 1/(s^2+1).

Heinrich Schuchardt

The main advantage of the algorithm is that it only uses real numbers. Hence it can easily be ported to other programming languages.

The algorithm is accurate for overdamped and slightly underdamped systems. But it is not accurate for systems with prolonged oscillations.

Quentin de Waziers

useles function

Sylvain Chupin

This function is not able to fit a simple cosinus!