function [res, AFLAG] = do_cap_Mu_fitd(INPUTS, lam0) % Integrates over a hemispherical cap calculating the extensions and tau m as we go. % If A0 runs out before we get to the end, AFLAG is set to 2 and all derivatives % are set to zero. If A0 does not run out, AFLAG is set to 0. % res returns a matrix with five rows: s, A0, taum, r and z. % First umnpack the needed parameters from INPUTS: PROPS = INPUTS{2}; % Set the number of points to be kept from the cap integration: INDEX = INPUTS{4}; npts = INDEX(1); % Calculate the tension at the tip based on the value of lam0, the % extensionratio at thetip: tmtip = taumd(lam0,lam0, PROPS); % Pull out the cells dimensions (Atot and Rp) and set the starting % values for the integration. Note that there are singularities at % the tip, so we define a small area (0.1Rp) and perform an isotrpic % expansion of that region before starting the integration. dims = INPUTS{3}; Rp = dims{3}; rstart = INPUTS{5}; A0start = pi*rstart^2/lam0^2; % Set the range for the integration. abit = asin(rstart/Rp)*Rp; cap_length = (pi/2 - abit)*Rp; y0 = [A0start, tmtip, abit]; span = linspace(abit, cap_length, npts); % Set the output options for ode45 options = odeset('RelTol',1e-3,'AbsTol',1e-6,'OutputSel',4); % Perform the integration returning the surface coordinate s (in span)and % an array containing Ao, tau, r and z. Line these up as rows and return % in res. % [span, AntauTemp] = ode23s(@cap_derivs_fitd, span, y0, options, INPUTS); [span, AntauTemp] = ode45(@cap_derivs_fitd, span, y0, options, INPUTS); restemp = AntauTemp'; A0tau = [restemp(1,:); restemp(2,:)]; if (AntauTemp(end,3) > (span(end)+100*eps)) || (AntauTemp(end,3) < (span(end)-100*eps)) AFLAG = 1; else AFLAG = 0; end res = [span'; A0tau];