%% Frank's solution to the transfer/rate problem via Laplace transform
x0 = 1;
p_out = @(D_p, D_m, ga, x0, x, t) 1./(2*sqrt(D_p*pi*t))*...
            (exp(-(x+x0).^2./(4*D_p*t))*(ga*sqrt(D_p)-sqrt(D_m))./...
            (ga*sqrt(D_p)+sqrt(D_m))+exp(-(x-x0).^2./(4*D_p*t)));
p_in = @(D_p, D_m, ga, x0, x, t) 1./(sqrt(pi*t)*(sqrt(D_m)+ga*sqrt(D_p)))*...
            exp(-(x-x0*sqrt(D_m/D_p)).^2/(4*D_m*t));
x_in = linspace(-4, 0, 1000);
x_out = linspace(0, 4, 1000);
for i = 1:100
    figure(1); hold on; cla;
    plot(x_out, p_out(0.85, 0.15, 1/5.66, x0, x_out, i/10));
    plot(x_in, p_in(0.85, 0.15, 1/5.66, x0, x_in, i/10));
    axis([-4, 4, 0, 2]);
    shg; pause();
end