From 1e4abf9306a6383c0ad9d80ebd0af037c9ff8b43 Mon Sep 17 00:00:00 2001 From: Lars Hubatsch <hubatsch@pks.mpg.de> Date: Fri, 18 Sep 2020 12:02:32 +0200 Subject: [PATCH] WIP: Matlab jump length distribution moving boundary. --- @Ternary_model/create_mesh.m | 2 +- @Ternary_model/plot_sim.m | 2 +- prob_laplace.m | 47 +++++++++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/@Ternary_model/create_mesh.m b/@Ternary_model/create_mesh.m index 11c7828..0a1b0f4 100644 --- a/@Ternary_model/create_mesh.m +++ b/@Ternary_model/create_mesh.m @@ -30,6 +30,6 @@ if strcmp(T.mode, 'Constituent') T.x(ind+21:end)]; end elseif strcmp(T.mode, 'Client') - T.x = linspace(0, 20, 24000); + T.x = linspace(0, T.system_size, 24000); end end diff --git a/@Ternary_model/plot_sim.m b/@Ternary_model/plot_sim.m index 218d175..72f7768 100644 --- a/@Ternary_model/plot_sim.m +++ b/@Ternary_model/plot_sim.m @@ -27,7 +27,7 @@ elseif strcmp(mode, 'plot') figure(20); cla; hold on; - xlim([-inf, 6.0]); ylim([-inf, max(T.sol(:))]); +% xlim([-inf, 6.0]); ylim([-inf, max(T.sol(:))]); ax = gca; ax.FontSize = 12; xlabel('x [\mum]'); ylabel('volume fraction'); diff --git a/prob_laplace.m b/prob_laplace.m index 910b2da..1ae5a47 100644 --- a/prob_laplace.m +++ b/prob_laplace.m @@ -113,15 +113,16 @@ end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% t = linspace(0, 10, 9000); tic -T_mov = Ternary_model(0, 'phi_tot', {-10, b(7/3, 10^-6), 0.5, e(7/3),... - 0, 1, 10, 7, 0.5, 'Client'}, t, 0); +params_mov_bound = {-10, b(7/3, 10^-6), 0.5, e(7/3),... + 0, 1, 20, 7, 0.5, 'Client'}; +T_mov = Ternary_model(0, 'phi_tot', params_mov_bound, t, 0); T_mov.solve_tern_frap(); toc norm_fac = 1/sum(diff(T_mov.x).*... (T_mov.sol(1, 1:end-1)+T_mov.sol(1, 2:end))/2); s = '~/Nextcloud/Langevin_vs_MeanField/Data_Figs_FokkPla/'; -csvwrite([s, 'MovingBound.csv'], [T_mov.x', norm_fac*T_mov.sol(1, :)',... - norm_fac*T_mov.sol(end, :)']) +% csvwrite([s, 'MovingBound.csv'], [T_mov.x', norm_fac*T_mov.sol(1, :)',... +% norm_fac*T_mov.sol(end, :)']) %% Flux and entropy change for moving boundary chi_phi = -4.530864768482371; s_dot = zeros(1, length(T_mov.t)); @@ -143,8 +144,42 @@ s_dot(i) = sum(diff(T_mov.x).*f.^2./(g0.*u_interp)); % [0, T_mov.system_size, min(f(:)), max(f)]) % pause() end -csvwrite([s, 'Mov_Bou_Flux.csv'], [x_interp; f]) -csvwrite([s, 'Mov_Bou_Entr.csv'], [T_mov.t; s_dot]) +% csvwrite([s, 'Mov_Bou_Flux.csv'], [x_interp; f]) +% csvwrite([s, 'Mov_Bou_Entr.csv'], [T_mov.t; s_dot]) +%% MOVING BOUNDARY JUMP LENGTH DISTRIBUTION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +direction = 1; % 1: jump from left to right, -1: jump from right to left. +x0 = sort(10-direction*(0:0.02:4.01)); +t_snap = repmat((0.25:0.5:9.75)', 1, length(x0)); +si_t = size(t_snap); +x0 = sort(10-T_mov.v*t_snap-direction*repmat(0:0.02:4.01, [si_t(1), 1]), 2); +%% Run simulations for 'delta' IC across outside +F = {}; +v = T_mov.v; +for i = 1:si_t(2) + tic + parfor j = 1:si_t(1) + F{i, j} = Ternary_model(0, 'Gauss', params_mov_bound, t, 0); + F{i, j} = Ternary_model(0, 'Gauss', params, t, 0.1); + F{i, j}.x0 = x0(j, i); + F{i, j}.a = -10+v*t_snap(i); + F{i, j}.solve_tern_frap(); + end + toc +end +%% Calc. probs. for each jump length in ls and sum over time +%%% THIS PART DOES NOT WORK YET!!! +ls = -direction*(0.001:0.04:4); +n_T=45; +p = nan(length(ls), n_T); +for j = 1:n_T + tic + parfor i = 1:length(ls) + p(i, j) = int_prob(ls(i), F, x0, direction, j, T_mov, 5); + end + toc +end +% save prob_laplace_X_7_3_FRAP_in_out %% %%%%%%%%%%%%%%%%%%%%%% FRAP TIME COURSE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- GitLab