%% Testing of the U_R_RL model 
% by Evgenii Kovrigin, 06/23/2011
%%


close all 
clear all

%%
% Here you will find all figures
figures_folder='Testing_figures';


%%  Set some meaningful parameters
Rtotal=1e-3; % Receptor concentration, M
LRratio_array=[0 : 0.02 : 1.45]; % Array of L/R 
K_A_1=1e6;  % Binding affinity constant
K_B_1=4;  % Isomerization constant
K_B_2=0.5;  % Isomerization constant

%%
% Dependent constant: 
K_A_2 = (K_A_1*K_B_2)/K_B_1  % eq 3.2

%%
% Set appropriate options for the model (see model file for details)
model_numeric_solver='analytical'  ; 
model_numeric_options='none';                                




%% Compute arrays for populations and plot
concentrations_array=[];
for counter=1:length(LRratio_array)
    % compute
    [concentrations species_names] = equilibrium_thermodynamic_equations.U_R_RL_model(...
        Rtotal, LRratio_array(counter), K_A_1, K_B_1, K_B_2,...
        model_numeric_solver, model_numeric_options);
    % collect
    concentrations_array = [concentrations_array ; concentrations];
end

%% 
% Plot
Figure_title= 'U-R-RL model';
X_range=[0 max(LRratio_array)+0.1 ]; % extend X just a bit past last point
Y_range=[ 0 Rtotal]; % keep automatic scaling for Y
% display figure
figure_handle=equilibrium_thermodynamic_equations.plot_populations(...
    LRratio_array, concentrations_array, species_names, Figure_title, X_range, Y_range);
% save it
results_output.output_figure(figure_handle, figures_folder, 'Concentrations_plot');

%% Observations
% The result is exactly what we expect from this model. The receptor is
% split between two forms at a constant ratio. Similarly, the bound complex
% is split between two forms at a constant ratio.s, RL and RL*
%
% *Conclusion*
%
% The model *|equilibrium_thermodynamic_equations.U_R_RL_model()|* works
% well.















