Newer
Older
%% Boundary condition: Jump makes sense
[~, ind] = min(abs(T.x+T.a)); % Find x position of boundary
plot(max(T.sol(:, 1:ind-1), [], 2)./min(T.sol(:, ind+1:end), [], 2), 'LineWidth', 2)
make_graph_pretty('time', 'ratio outside/inside', 'unbleached component');

Lars Hubatsch
committed
figure; % Shouldn't be symmetric, different SS for phi_u and phi_b??
plot(min(T.u0+T.e-T.sol(:, 1:ind-1), [], 2)./max(T.u0-T.sol(:, ind+1:end), [], 2),...
'LineWidth', 2)

Lars Hubatsch
committed
make_graph_pretty('time', 'ratio outside/inside', 'bleached component');
%% Plot flux at boundary

Lars Hubatsch
committed
%% Figures
% Time course
figure; hold on;
xlim([0, 3]); ylim([0, 0.5]);

Lars Hubatsch
committed
ax = gca;
ax.FontSize = 16;
xlabel('x [\mum]'); ylabel('volume fraction');
plot(T.x, T.sol(1:2:200, :), 'LineWidth', 2, 'Color', [135/255 204/255 250/255]);
plot(T.x, Ternary_model.phi_tot(T.x, T.a, T.b, T.e, T.u0), 'LineWidth', 4,...
'LineStyle', '--', 'Color', [247/255, 139/255, 7/255]);
print([T.pa, 'ternary_time_course'], '-depsc');

Lars Hubatsch
committed
%% Plot and check derivatives of pt
figure; hold on;

Lars Hubatsch
committed
x = linspace(40, 60, 100000);
plot(T.x, Ternary_model.phi_tot(T.x, T.a, T.b, T.e, T.u0));
plot(T.x, Ternary_model.gradient_analytical(T.x, T.a, T.b, T.e));
plot(T.x(1:end-1)+mean(diff(T.x))/2, ...
diff(Ternary_model.phi_tot(T.x, T.a, T.b, T.e, T.u0)/mean(diff(T.x))));
plot(T.x, Ternary_model.gamma0(T.x, T.a, T.b, T.e_g0, T.o_g0));
axis([0, 3, 0, 1])
plot(Ternary_model.gamma0(T.x, T.a, T.b, T.e_g0, T.o_g0),...
Ternary_model.spacing(Ternary_model.gamma0(T.x, T.a, T.b, T.e_g0, T.o_g0),...
T.a, T.b, T.e_g0, T.o_g0));
T = Ternary_model(2, 'FRAP', [], linspace(0.0, 400, 5000));
T.solve_tern_frap();
x_seed = 60;
s = T.sol(1:end, 1:30)./max(T.sol(1:end, 1:30))/1.022;
ts = T.t(1:end)';
f_min = @(x) to_minimize(s, ts, x, 'simple_drop', s(:, end));
opt = optimset('MaxFunEvals', 2000, 'PlotFcns',@optimplotfval);
x_seed = fminsearch(f_min, x_seed, opt);
%%
[cost, v_fit, r_n, v_fit_end] = to_minimize(s, ts, x_seed, 'simple_drop', s(:, end));
%% Plot for
figure; hold on;
s_all = T.sol(1:end, 1:400)./max(max(T.sol(1:end, 1:30)))/1.022;
plot(T.x(1:340), s_all(1:10:200, 1:340), 'Color', [0.5294, 0.8, 0.98], 'LineWidth', 2.5);
plot(T.x(1:30), v_fit(1:10:200, :)', '.', 'Color', [0.83, 0.23, 0.09], 'MarkerSize', 10);
make_graph_pretty('$x [\mu m]$', 'intensity [a.u.]', '');
% print([T.pa, 'Timecourse_model_only'],'-depsc')
%% Plot boundary condition (read out)
figure; hold on;
plot(ts(1:200), s(1:200, end), 'Color', [0.1608 0.5412 0.2118])
make_graph_pretty('t [s]', 'intensity [a.u.]', '');
print([T.pa, 'Timecourse_BC'],'-depsc')
%% Fit boundary condition with exponential
f = fit(ts(1:200), s(1:200, end), 'B+C-B*exp(-x/tau)-C*exp(-x/tau2)');
plot(f)
%% Plot flux at boundary (x close to 1) Only works close to boundary!
% T = Ternary_model(2, 'FRAP', [], linspace(0.0, 400, 2000));
% T.e_g0 = 0.001;
% T.b = 0.001;
% T.solve_tern_frap();
[~, ind_in] = min(abs(T.x+T.a+0.02)); % Find x position of boundary close to 0.9
% Calculate local diffusion coefficient
g0 = Ternary_model.gamma0((T.x(ind_in)+T.x(ind_in+1))/2, T.a, T.b, T.e_g0, T.o_g0);
pt = Ternary_model.phi_tot((T.x(ind_in)+T.x(ind_in+1))/2, T.a, T.b, T.e, T.u0);
D_in = g0*(1-pt);
Diffs_in = D_in*diff(T.sol')/(T.x(ind_in+1)-T.x(ind_in));
[~, ind_out] = min(abs(T.x+T.a-0.02)); % Find x position of boundary close to 0.9
% Calculate local diffusion coefficient
g0 = Ternary_model.gamma0((T.x(ind_out)+T.x(ind_out+1))/2, T.a, T.b, T.e_g0, T.o_g0);
pt = Ternary_model.phi_tot((T.x(ind_out)+T.x(ind_out+1))/2, T.a, T.b, T.e, T.u0);
D_out = g0*(1-pt);
Diffs_out = D_out*diff(T.sol')/(T.x(ind_out+1)-T.x(ind_out));
figure; hold on;
plot(Diffs_in(ind_in, :))
plot(Diffs_out(ind_out, :));
make_graph_pretty('time', '$\vec{j}$', 'boundary flux inside/outside of drop');
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
axis([0, 200, 0, 0.035])
%% Check out inner and outer length scales
e_g0 = [0.01, 0.05, 0.1, 0.2, 0.5, 3, 10, 100];
for i = 1:8
% T1{i} = Ternary_model(2, 'FRAP', [], linspace(0.0, 400, 5000));
% T1{i}.e_g0 = e_g0(i);
% T1{i}.solve_tern_frap();
T1{i}.calc_time_scales();
end
%%
figure; hold on;
for i = 1:length(T1)
[~, ind] = min(abs(T1{i}.x+T1{i}.a));
plot(T1{i}.t, sum(T1{i}.sol(:, 1:ind), 2)); axis([0, 100, 0, 80]);
end
%% Mix
o_g0 = [0.01, 0.05, 0.1, 0.2, 0.5, 3, 10, 100];
for i = 1:8
T2{i} = Ternary_model(2, 'FRAP', [], linspace(0.0, 400, 5000));
T2{i}.o_g0 = o_g0(i);
T2{i}.solve_tern_frap();
T2{i}.calc_time_scales();
end
%%
figure; hold on;
for i = 1:length(T1)
[~, ind] = min(abs(T2{i}.x+T2{i}.a));
plot(T2{i}.t, sum(T2{i}.sol(:, 1:ind), 2)); axis([0, 100, 0, 80]);
end
%%
%%
o_g0 = [0.01, 0.05, 0.1, 0.2, 0.5, 3, 10, 100];
for i = 1:8
T3{i} = Ternary_model(2, 'FRAP', [], linspace(0.0, 400, 5000));
T3{i}.e_g0 = 0.01;
T3{i}.o_g0 = o_g0(i);
T3{i}.solve_tern_frap();
T3{i}.calc_time_scales();
end
%%
figure; hold on;
for i = 1:length(T1)
[~, ind] = min(abs(T2{i}.x+T2{i}.a));
plot(T2{i}.t, sum(T2{i}.sol(:, 1:ind), 2)); axis([0, 100, 0, 80]);
end
%% Outside time scale
p = logspace(1, 3, 20);
R_in = 1;
tau_out = p.^(1/3);
plot(p, tau_out);
make_graph_pretty('partitioning coefficient $\xi$', '$\tau_{out}$', '');
%%
T_large_p = Ternary_model(2, 'FRAP', [-1, 0.025, 0.0004, 0.4, 0.16, 0.2], linspace(0.0, 400, 5000));
T_large_p.solve_tern_frap()
%%
T_small_p = Ternary_model(2, 'FRAP', [-1, 0.025, 0.05, 0.4, 0.16, 0.2], linspace(0.0, 400, 5000));
T_small_p.solve_tern_frap()