From e3839e8a6670d2b99ad2110c916a1992a4fffc55 Mon Sep 17 00:00:00 2001
From: Lars Hubatsch <hubatsch@pks.mpg.de>
Date: Wed, 18 Nov 2020 00:35:02 +0100
Subject: [PATCH] Initial condition corrected to match proper client profile.

---
 @Ternary_model/plot_sim.m        |  1 +
 @Ternary_model/solve_tern_frap.m | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/@Ternary_model/plot_sim.m b/@Ternary_model/plot_sim.m
index d901b65..faa2bb9 100644
--- a/@Ternary_model/plot_sim.m
+++ b/@Ternary_model/plot_sim.m
@@ -9,6 +9,7 @@ si = size(T.sol);
 if nargin < 3
     nth = 1;
     color = 'red';
+    start = 1;
 end
 if strcmp(mode, 'mov')
     figure(20); hold on;
diff --git a/@Ternary_model/solve_tern_frap.m b/@Ternary_model/solve_tern_frap.m
index 7f026bb..0abd8fb 100644
--- a/@Ternary_model/solve_tern_frap.m
+++ b/@Ternary_model/solve_tern_frap.m
@@ -38,7 +38,19 @@ elseif strcmp(ic, 'Gauss')
         u = 0;
     end
 elseif strcmp(ic, 'phi_tot')
-    u = Ternary_model.phi_tot(x, a, 0.021282, 0.460977, u0, 0);
+    % This uses standard phi_tot profile, which is not correct for moving
+    % boundary with client
+%     u = Ternary_model.phi_tot(x, a, 0.021282, 0.460977, u0, 0);
+
+    % correct form of initial profile for moving boundary with client
+    chi = -4.530864768482371;
+    tern = @(x) Ternary_model.phi_tot(x, a, 0.021282, 0.460977, u0, 0);
+    exp_tern = @(x) exp(-chi*Ternary_model.phi_tot(x, a, 0.021282, 0.460977, u0, 0));
+    off = tern(200);
+    P = tern(-200)/tern(200);
+    A = (P-1)*off/(exp_tern(-200)-exp_tern(200));
+    B = off - A*exp_tern(200);
+    u =  A*exp_tern(x)+B;
 elseif isnumeric(ic)
     % use ic as initial condition by interpolating the given values between
     % 0 and a
-- 
GitLab