Newer
Older
%% Solve Fokker Planck equation for given parameter set
clear all; clc;
nu = 10^-6;
b = nu^(1/3)*sqrt(chi/(chi-2));
e = sqrt(3/8*(chi-2));
T = Ternary_model(0, 'Gauss', [-6, b, 0.5, e, 0.16, 0.2, 7],...
linspace(0.0, 400, 5000));
T.t = [0, 0.1, 1, 9.9];
T.solve_tern_frap()
%%
csvwrite('x_X73_1.csv', T.x+T.a);
csvwrite('sol_X73_1.csv', T.sol(:, :));

Lars Hubatsch
committed
%% Frank's solution to the transfer/rate problem via Laplace transform

Lars Hubatsch
committed
x0 = 2;

Lars Hubatsch
committed
D_m = 1*(1-T.u0-T.e); % to make equal to ternary FRAP
D_p = 1*(1-T.u0+T.e);
ga = (T.u0-T.e)/ (T.u0+T.e);

Lars Hubatsch
committed
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_left = linspace(-4, 0, 1000);
x_right = linspace(0, 4, 1000);

Lars Hubatsch
committed
%% Plot with full ternary model
figure(1); hold on; %cla;

Lars Hubatsch
committed
j = i+2;
plot(x_left, p_in(D_p, D_m, ga, x0, x_left, j/100));
plot(x_right, p_out(D_p, D_m, ga, x0, x_right, j/100));
plot(T.x+T.a, 2*T.sol(i, :), 'LineWidth', 2);
axis([-2, 2, 0, 1.8]);

Lars Hubatsch
committed
shg; pause();

Lars Hubatsch
committed
end
%% Check integral of solution, should be mass conserving and sum to 1.
[~, ind] = min(abs(T.x-50)); % integrate up to 50, to avoid right boundary
bins = (T.sol(:, 1:ind-1)+T.sol(:, 2:ind))/2;
bin_size = diff(T.x(1:ind));