Skip to content
Snippets Groups Projects
Commit 6d3cab3e authored by Lars Hubatsch's avatar Lars Hubatsch
Browse files

Debugging create_mesh, checking influence of mesh density

Whether or not two meshes agree well numerically seems to depend on
how well connected two differently spaced mesh domains are.
parent cf0148ae
No related branches found
No related tags found
No related merge requests found
......@@ -36,11 +36,11 @@ classdef Ternary_model < handle
T.e_g0 = params(5);
T.u_g0 = params(6);
end
T.create_mesh();
T.create_mesh(1);
T.phi_t = Ternary_model.phi_tot(T.x, T.a, T.b, T.e, T.u0);
end
create_mesh(T)
plot_sim(T, mode, nth)
create_mesh(T, i)
plot_sim(T, mode, nth, color)
solve_tern_frap(T)
calc_time_scales(T);
end
......
function create_mesh(T)
function create_mesh(T, i)
%CREATE_MESH creates mesh for solving PDE
% Mesh density larger for steeper gradients (using inverse of tanh).
T.x = linspace(-T.a-1, -T.a+1, 3000);
T.g0 = Ternary_model.gamma0(T.x, T.a, T.b, T.e_g0, T.u_g0);
g_unique = unique(T.g0);
x = linspace(g_unique(1), g_unique(end-1), 300);
g_inv = Ternary_model.spacing(x, T.a, 2*T.b, T.e_g0, T.u_g0);
x = linspace(g_unique(1), g_unique(end-1), 600);
g_inv = Ternary_model.spacing(x, T.a, i*T.b, T.e_g0, T.u_g0);
g_inv = g_inv(2:end-1);
T.x = [linspace(0, -T.a-0.501, 500), linspace(-T.a-0.5, g_inv(2), 300), g_inv(3:end-2), ...
linspace(g_inv(end-1), -T.a+1, 30), ...
linspace(-T.a+1.1, T.system_size, 3000)];
% T.x = [linspace(0, g_inv(5), 300), g_inv(6:end-5), ...
% linspace(g_inv(end-4), -T.a+1, 300), linspace(-T.a+1.01, T.system_size, 1000)];
left = 0:g_inv(8)-g_inv(7):g_inv(7);
right = g_inv(end-4):g_inv(5)-g_inv(4):-T.a+1;
T.x = [left, (g_inv(8)+left(end))/2, g_inv(8:end-5), (g_inv(end-5)+right(1))/2, ...
right, linspace(-T.a+1.01, T.system_size, 1000)];
end
function plot_sim(T, mode, nth)
function plot_sim(T, mode, nth, color)
%PLOT_SIM Show movie of simulation
% mode 'mov' ... show movie
% mode 'plot' ... show plot
......@@ -21,12 +21,12 @@ if strcmp(mode, 'mov')
% print([num2str(i),'.png'],'-dpng')
end
elseif strcmp(mode, 'plot')
figure; hold on;
% figure; hold on;
xlim([0, 2]); ylim([0, 1]);
ax = gca;
ax.FontSize = 26;
xlabel('x [\mum]'); ylabel('volume fraction');
plot(T.x, T.sol(1:nth:150, :), 'LineWidth', 4, 'Color', [0.5294, 0.8, 0.98]);
plot(T.x, T.sol(1:nth:150, :), 'LineWidth', 1, 'Color', color);%[0.5294, 0.8, 0.98]);
plot(T.x, Ternary_model.phi_tot(T.x, T.a, T.b, T.e, T.u0), 'LineWidth', 6,...
'LineStyle', '--', 'Color', [0.97, 0.55, 0.03]);
end
......
......@@ -204,4 +204,26 @@ plot(v_q);
plot(v_fit')
figure; hold on;
plot(sum(v_q));
plot(sum(v_fit, 2));
\ No newline at end of file
plot(sum(v_fit, 2));
%%
color = ['r', 'b', 'k', 'm', 'y', 'g'];
figure; hold on;
wi = [0.1, 0.5, 1.1, 5, 10, 20];
for i = 1:length(wi)
% Ts{i} =Ternary_model(2, 'FRAP', [-1, 0.02, 0.5, 0.3, 0.3, 0.5], t);
% Ts{i}.create_mesh(wi(i));
% Ts{i}.solve_tern_frap();
T.create_mesh(i);
plot(T.x, color(i), 'Marker', '.');
length(T.x)
end
axis([0, 1000, 0, 2])
%%
figure; hold on;
Ts{1}.plot_sim('plot', 10, 'red')
Ts{2}.plot_sim('plot', 10, 'blue')
Ts{3}.plot_sim('plot', 10, 'black')
Ts{4}.plot_sim('plot', 10, 'yellow')
Ts{5}.plot_sim('plot', 10, 'magenta')
Ts{end}.plot_sim('plot', 10, 'green')
xlim([0, 2]); ylim([0, 1]);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment