forked from AndrewDMarquis/simple-VQ-matching-O2-transport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModelD_optimization.m
59 lines (47 loc) · 1.59 KB
/
ModelD_optimization.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
clear; close all; clc;
% This script optimizes the apparent diffusion parameter (D) to fit the
% CPET data processes in the CO_estimator script
%%% load data
load('ExerciseData','DATA')
%%% parameters
D = 50; %apparent diffusion (ml/s)
Pair = 150; %atmospheric oxygen partial pressure (mmHg)
Pin = 45; %mixed venous oxygen partial pressure - pulmonary inlet (mmHg)
Vvasc = 1; %volume of vascular space (ml)
Valv = 1; %alveolar volume (ml)
alpha = 1.3e-6*1e3; % O2 solubility in water/plasma(mM/mmHg)
CHb = 0.021*1e3; % Hb binding site conc (mmol/L of RBC's)
Hct = 0.40; % hematocrit (unitless)
C0 = CHb*Hct; % blood oxygen binding capacity (mol/L)
n = 2.7; % Hill exponent
P50 = 30; % half-max saturation of Hb
beta = 16800*1e-3; % O2 solubility in air (mmHg/mM)
l = 1; %length of capillary
par = [D Pair Pin alpha beta l];
%%% look up table
load('Lookup.mat') %outputs LOOK
P = LOOK.Plookup;
C = LOOK.Clookup;
%%% optimization
N = 300; %number of grid points for numerical discretization
tic;
[D_opt,J,EXITFLAG,OUTPUT] = fminsearch(@OBJECTIVE_D, D,[],par,P,C,DATA,N);
RT = toc;
disp(['Optimizaiton runtime: ',num2str(RT),' s'])
[~,PO2_pred] = OBJECTIVE_D(D_opt,par,P,C,DATA,N);
%%% save and load plots
save('ModelD_optimization_results.mat')
load('ModelD_results.mat','Q','V','pvasc')
%%% plots
CON = 0:5:150;
x = 0:70;
figure;
plot(DATA.CO,DATA.V,'ko','linewidth',2,'markersize',10)
hold on
contour(Q,V,pvasc,CON,'ShowText','on')
hold on
plot(x,x,'k--')
xlabel('Cardiac Output (L/min)')
ylabel('Ventilation (L/min)')
set(gca,'fontsize',18)
axis equal