Enable processing of desorption
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 3 Dec 2024 14:44:57 +0000 (15:44 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Tue, 3 Dec 2024 14:44:57 +0000 (15:44 +0100)
This change makes the changes detection a little dumber, because the
change direction cannot be used to differentiate. So now the
odd-numbered changes are assumed filling (vacuuming) and the
even-numbered changes are assumed to be connections to the cell.

detect_change.m
get_important_pressure.m
process_experiment.m

index 0c710101e51a4c5ed827c017a6ab289ee1118835..3a5f91a70d629410d008dbad815759887d559368 100644 (file)
@@ -1,7 +1,7 @@
 function changed = detect_change(t, p, threshold = 0.2, min_dist = 10)
        dp = (p(2:end) - p(1:end - 1)) ./ (t(2:end) - t(1:end - 1));
        dp = dp / max(dp);
-       changed = dp / threshold > 1;
+       changed = abs(dp) / threshold > 1;
        for i = (length(changed):-1:1)
                j = i - 1;
                while (j > 0 && t(j) + min_dist > t(i))
index 153ca6bc14f93ff73c85e52256d718519912ae7d..98624757e25176500299bacc1ec5cf7366a8492f 100644 (file)
@@ -1,8 +1,8 @@
 function [p_eq, p_after_fill] = get_important_pressure(t, p,  graph = 1, threshold = 0.01)
-       fill_loginds = detect_change(t, p, threshold);
-       fill_inds = [1 find(fill_loginds == 1) length(p)];
-       open_loginds = detect_change(t, p, -threshold);
-       open_inds = [1 find(open_loginds == 1) length(p)];
+       big_pressure_changes_loginds = detect_change(t, p, threshold);
+       big_pressure_changes_inds = find(big_pressure_changes_loginds == 1);
+       fill_inds = [1 big_pressure_changes_inds(1:2:end) numel(p)];
+       open_inds = [1 big_pressure_changes_inds(2:2:end) numel(p)];
        if (graph)
                figure()
                plot(t, p);
@@ -13,7 +13,7 @@ function [p_eq, p_after_fill] = get_important_pressure(t, p,  graph = 1, thresho
                p_single = p(open_inds(i - 1):(fill_inds(i) - 1));
                p_eq(i - 1)  = get_equilibrium_pressure(t_single, p_single);
                if (i > 2)
-                       p_after_fill(i - 1) = mean(p(fill_inds(i - 1):open_inds(i - 1) - 1));
+                       p_after_fill(i - 1) = get_equilibrium_pressure(t(fill_inds(i - 1):open_inds(i - 1) - 1), p(fill_inds(i - 1):open_inds(i - 1) - 1));
                end
                if (graph)
                        if (i < length(fill_inds))
index ac94b5e6d016b0b984688a06ab83d818018c6355..039dc246d98a43b5916c8f8af96b2d2135478527 100644 (file)
@@ -1,4 +1,4 @@
-function [p_eq n] = process_experiment(t, p, V1, V2, Vvz, T = 298, graph = 1, threshold = 0.01)
+function [p_eq n] = process_experiment(t, p, V1, V2, Vvz, T = 298, graph = 1, threshold = 0.1)
        R = 8.314;
        [p_eq, p_fill] = get_important_pressure(t, p, graph, threshold);
        p_start = (p_eq(1:(end - 1)) * (V2 - Vvz) + p_fill * V1) / (V1 + V2 - Vvz);
@@ -6,6 +6,6 @@ function [p_eq n] = process_experiment(t, p, V1, V2, Vvz, T = 298, graph = 1, th
        n = [0 cumsum(delta_n)];
        if (graph)
                figure();
-               plot(p_eq, n, "-o");
+               plot(p_eq, n, "o");
        end
 end