Testing of the 5U-R-RL model
Verify against MuPad "analysis" document: 5U_R_RL_analysis.html Run in "Publish" mode to have a report.
9/8/17 - suitable for testing vectorized analytical models
Contents
close all clear all
Set input parameters
model_name='5U-R-RL'; % Set some meaningful parameters matching settings of MuPad analysis % document LRratio_array=[0.0001 : 0.05 : 1.5]'; % Array of L/R Rtotal_array=1e-3*ones(length(LRratio_array),1); % Receptor concentration, M K_B_1_p_1=2; K_B_1_p_2=2.1; K_B_1_p_3=2.2; K_B_1_p_4=2.3; K_B_1_p_5=2.4; K_A_p_1=1e5; K_A_p_2=2e5; K_A_p_3=3e5; K_A_p_4=4e5; K_A_p_5=5e5; K_B_2_p_1=3; % Set appropriate options for the model (see model file for details) % model_numeric_solver='fminbnd' ; % % model_numeric_options=optimset('Diagnostics','off', ... % 'Display','off',... % 'TolX',1e-9,... % 'MaxFunEvals', 1e9);
The important option here is "TolX" that sets termination tolerance on free ligand concentation in molar units. With our solution concentrations in 1e-3 range TolX should be set to some 1e-9.
Compute arrays for populations and plot
Call as non-vectorized:
concentrations_array=[]; tic for counter=1:length(LRratio_array) % compute [concentrations species_names] = equilibrium_thermodynamic_equations.a5U_R_RL_model(... Rtotal_array(counter), LRratio_array(counter),... K_B_1_p_1, K_B_1_p_2, K_B_1_p_3, K_B_1_p_4, K_B_1_p_5, ... K_A_p_1, K_A_p_2, K_A_p_3, K_A_p_4, K_A_p_5, ... K_B_2_p_1, ... 'analytical', 'none'); % collect concentrations_array = [concentrations_array ; concentrations]; end toc
Elapsed time is 0.017052 seconds.
Plot
Figure_title= model_name; X_range=[0 max(LRratio_array)+0.1 ]; % extend X just a bit past last point Y_range=[ ]; % keep automatic scaling for Y % display figure figure_handle=equilibrium_thermodynamic_equations.plot_populations(... Rtotal_array, LRratio_array, concentrations_array, species_names, Figure_title, X_range, Y_range);
Observations The result matches simulations in the 'analysis' MuPad notebook. The code is correct.
Test vectorization (if analytical model was vectorized!)
Call as vectorized:
tic [concentrations_array species_names] = equilibrium_thermodynamic_equations.a5U_R_RL_model(... Rtotal_array, LRratio_array,... K_B_1_p_1, K_B_1_p_2, K_B_1_p_3, K_B_1_p_4, K_B_1_p_5, ... K_A_p_1, K_A_p_2, K_A_p_3, K_A_p_4, K_A_p_5, ... K_B_2_p_1, ... 'analytical', 'none'); toc Figure_title= sprintf(' %s - vectorized version', model_name); X_range=[0 max(LRratio_array)+0.1 ]; % extend X just a bit past last point Y_range=[ ]; % keep automatic scaling for Y % display figure figure_handle=equilibrium_thermodynamic_equations.plot_populations(... Rtotal_array, LRratio_array, concentrations_array, species_names, Figure_title, X_range, Y_range);
Elapsed time is 0.009924 seconds.
Conclusions
Both vectorized and non-vectorized calls work well.