From 2c7efb33d435f5feea1c7d48810c24afe2daa569 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Tue, 3 Dec 2024 15:44:57 +0100 Subject: [PATCH] Enable processing of desorption 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 | 2 +- get_important_pressure.m | 10 +++++----- process_experiment.m | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/detect_change.m b/detect_change.m index 0c71010..3a5f91a 100644 --- a/detect_change.m +++ b/detect_change.m @@ -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)) diff --git a/get_important_pressure.m b/get_important_pressure.m index 153ca6b..9862475 100644 --- a/get_important_pressure.m +++ b/get_important_pressure.m @@ -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)) diff --git a/process_experiment.m b/process_experiment.m index ac94b5e..039dc24 100644 --- a/process_experiment.m +++ b/process_experiment.m @@ -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 -- 2.30.2