% LimitCycleEQ % % Module solves Limit Cycle System. % % Script delivers a vector of solutions for the limit cycle system of % equations in two patches. % % Inputs: % Interruption Time in loop (InterruptionTime) % Number of generations (looplength) % Intial Condtions (HA HB PA PB) % % Geneva Mottet UAF 6-28-18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Limit cycle equation g = @(s,x)[gamma*x(1)*(1-(x(1)/f))-((c*x(1)*x(2))/(a+x(1)));(b*c*x(1)*x(2)/(a+x(1)))- d*x(2)];%system of diff eqs x(1)=x(t), x(2)=y(t), ect. XAtotal = []; SAtotal = []; XBtotal = []; SBtotal = []; for j = 1:looplength [sA,xA] = ode45(@(s,x) g(s,x),[InterruptionTime*(j-1) InterruptionTime*(j)],[HA, PA]); [sB,xB] = ode45(@(s,x) g(s,x),[InterruptionTime*(j-1) InterruptionTime*(j)],[HB, PB]); XAtotal = [XAtotal;xA(1:length(xA) - 1,:)]; SAtotal = [SAtotal;sA(1:length(sA) - 1,:)]; XBtotal = [XBtotal;xB(1:length(xB) - 1,:)]; SBtotal = [SBtotal;sB(1:length(sB) - 1,:)]; HA = xA(end,1); PA = xA(end,2); HB = xB(end,1); PB = xB(end,2); if mod(j, MigInterval) == 0 % Migration HA =(1-HostMig)*HA + HostMig*HB;% Sets a new HA with contributions from hosts in both patches HB =(HostMig)*HA + (1-HostMig)*HB;% Sets a new HB with contributions from hosts in both patches PA =(1-ParaMig)*PA + ParaMig*PB;% Sets a new PA with contributions from parasites in both patches PB =(ParaMig)*PA + (1-ParaMig)*PB;% Sets a new PB with contributions end end