function [rldxdt] = OmpReq(t,x)


tf=1; % seconds 
nM=1;
% units in the paper are seconds, we want minutes

% time in minutes
% concentration in muM

% EnvZ autophosphorelation
k_ap=0.1*tf;
% EnvZ dephosphorelation
k_ad=0.001*tf;
% binding EnvZ-P & OmpR
k_b1=0.5*tf;
% unbinding EnvZ-P_OmpR
k_d1=0.5*tf;
% phosphotransfer rate
k_pt=1.5*tf;
% unbinding EnvZ_OmpR-P
k_d2=0.5*tf;
% binding of EnvZ & OmpR-P
k_b2=0.05*tf;
% dephosphorelation EnvZ_OmpR-P
k_ph=0.05*tf;
% unbinding EnvZ_OmpR
k_d3=5*tf;
% binding EnvZ & OmpR
k_b3=0.5*tf;


rldxdt=[
    %EnvZ x(1)
    k_ad*x(2) - k_ap*x(1)*RedLight(t) + k_d2*x(4) - k_b2*x(5)*x(1) - k_b3*x(6)*x(1) + k_d3*x(7);
    %EnvZ-P x(2)
    k_ap*x(1)*RedLight(t) - k_ad*x(2) + k_d1*x(3) - k_b1*x(6)*x(2);
    %EnvZ-P.OmpR x(3)
    - (k_d1+k_pt)*x(3) + k_b1*x(6)*x(2);
    %EnvZ.OmpR-p x(4)
    k_pt*x(3) - (k_ph + k_d2)*x(4) + k_b2*x(5)*x(1);    
    %OmpR-P x(5)
    k_d2*x(4) - k_b2*x(5)*x(1);
    %OmpR x(6)
    k_d1*x(3) + k_d3*x(7)  - k_b3*x(6)*x(1) - k_b1*x(6)*x(2) ;
    %EnvZ.OmpR x(7)
    k_ph*x(4) - k_d3*x(7) + k_b3*x(6)*x(1);
    ];
end

function R=RedLight(t)
global p
%gives red light impulse intensity, normalized to 1
if (t>p.rstart) && (t<p.rstart+p.rdur)
    R=p.rint;
else
    R=0;
end
end