Change pseudo_exp.m so it is closer to real data
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 20 May 2024 13:59:31 +0000 (15:59 +0200)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 20 May 2024 13:59:31 +0000 (15:59 +0200)
The data was meassured in a different way to what I assumed hence the
pseudo experimental data were not that similar to the real data.
This commit changes the pseudo_exp function so it mimics the experiment
much more closely.

pseudo_exp.m

index 8d5a40a6fa2e1fe31d25285e2735d3a7b9fa7ae8..26cf9d7dac564a3488f2e5b2c832343e35ec14c7 100644 (file)
@@ -1,13 +1,22 @@
-function [t, p, t_open] = pseudo_exp(p1, V1, V2, Vvz, n)
-       t_open = rand(1, n) * (50 - 15) + 15;
-       t_open = ceil(cumsum(t_open));
-       t = (0:ceil(t_open(n)) + 20);
+function [t, p, t_open, t_fill] = pseudo_exp(p_supply = 10, V1 = 1000, V2 = 1000, Vvz = 200, n = 10, V_supply = V1)
+       t_fill = rand(1, n) * (200 - 100) + 100;
+       t_fill = ceil(cumsum(t_fill));
+       t_open = t_fill + 10;
+       t = (0:ceil(t_open(n)) + 100);
        p = zeros(size(t));
-       peq = 0;
-       for i = ceil(t_open)
-               p2 = (p(i + 1) * (V2 - Vvz) + p1 * V1) / (V1 + V2 - Vvz);
-               peq += 0.7 * (p2 - peq);
-               p(i + 1:end) = (p2 - peq) * exp((-((i + 1):length(p)) + i + 1) / 10) + peq;
+       p1 = 0;
+       p2 = 0;
+       for i = 1:length(t_fill)
+               p1 = (p1 * V1 + p_supply * V_supply) / (V1 + V_supply);
+               p((t_fill(i) + 1):(t_open(i))) = p1;
+               p1 = (p1 * V1 + p2 * (V2 - Vvz)) / (V1 + V2 - Vvz);
+               peq = p2 + 0.7 * (p1 - p2);
+               if (i != length(t_fill))
+                       p((t_open(i) + 1):t_fill(i + 1)) = (p1 - peq) * exp(-(t((t_open(i) + 1):t_fill(i + 1)) - t(t_open(i))) / 10) + peq;
+               else
+                       p((t_open(i) + 1):end) = (p1 - peq) * exp(-(t((t_open(i) + 1):end) - t(t_open(i))) / 10) + peq;
+               end
+               p2 = peq;
        end
        p += rand(size(t)) * p1 / 100;
 end