1 function varargout=fuel_left_cell(t,fuel_time)
2 % frac=fuel_left(t,fuel_time)
3 % [frac,dfracdt]=fuel_left(t,fuel_time)
4 % [frac,dfracdt,dfrac]=fuel_left(t,fuel_time)
6 % compute fuel fraction left in one cell
9 % t fire arrival time (0=now) at corners, size (2,2)
10 % fuel_time time the fuel takes to burn to 1/e = 0.36
12 % frac the fuel fraction
13 % dfracdt derivative the all components of t change by the same
14 % dfrac partial derivatives wrf to components of t
17 % t=[-1,0;0,1.1], s=0.1, f=1, dt=0.01
18 % p1=fuel_left_cell(t-dt-s,f);p2=fuel_left_cell(t+dt-s,f);
19 % [p,dp]=fuel_left_cell(t-s,f);d=(p2-p1)/(2*dt);err=d-dp
22 aps=ssum(abs(t))+realmin;
26 frac=area*exp(ta/fuel_time) + (1. - area);
30 if nargout < 2, return, end
32 % derivative wrt same increment in all 4 values of t
35 dareadt=0.5*(dapsdt*ps-dpsdt*aps)./(aps.*aps);
36 dtadt=0.25*ssum(0.5*(1-sign(t)));
37 dfracdt=(dareadt+(area/fuel_time)*dtadt)*exp(ta/fuel_time)-dareadt;
39 varargout(2)={dfracdt};
41 if nargout < 3, return, end
43 % for heat flux, need derivative wrt same increment
46 darea=0.5*(daps*ps-dps*aps)./(aps.*aps);
47 dta=0.25*(0.5*(1-sign(t)));
48 dfrac=((area/fuel_time)*dta+darea)*exp(ta/fuel_time)-darea;