% calculates combustion completeness (CC, also called combustion factor or combustion efficiency)

% fuel is split into live wood, live leaves (includes grass), fine litter and coarse litter (cwd)
% 
%   min CC  max CC  fuel type
CC=[0.2     0.3     % live wood
    0.8     1.0     % live leaves 
    0.9     1.0     % fine litter 
    0.2     0.4];   % coarse litter

% scaling is as follows: for live material the CC is scaled linear with the NPP moisture scalar,
% dead material is scaled using the PPT over PET ratio, with a running mean to include some memory, which is greater
% for CWD (larger volume to surface area ratio, dries more slowly).
%
% biomass CC:
fid=2*NPPmoist(:,month)-1;          % NPP moisture scalar runs from 0.5-1, corrected to go from 0-1
fid=ones(numberOfGridCells,1)-fid;

ccWood(:,month)          = CC(1,1)+(CC(1,2)-CC(1,1)).*fid;
ccLeaf(:,month)          = CC(2,1)+(CC(2,2)-CC(2,1)).*fid;

% litter CC:
PET_current=PET;
PET_current(PET_current==0)=0.1;  % prevent dividing by 0
CCratio_current = ppt(:,month) ./ PET_current;
CCratio_current(CCratio_current>1) = 1;
CCratio_current = ones(numberOfGridCells,1) - CCratio_current;

ccFineLitter(:,month) = 0.1.*(CC(3,1)+(CC(3,2)-CC(3,1)).*CCratio_previous)+0.9.*(CC(3,1)+(CC(3,2)-CC(3,1)).*CCratio_current);
ccCwd(:,month)        = 0.4.*(CC(4,1)+(CC(4,2)-CC(4,1)).*CCratio_previous)+0.6.*(CC(4,1)+(CC(4,2)-CC(4,1)).*CCratio_current);

CCratio_previous = CCratio_current;  % set current PET for next month's run 

% Fire induced mortality rates; In general the mortality rate in tropical
% forests is high, especially at the second or third fire (50-80%) while
% tree mortality in savannas is very low as a thin bark and low flames
% protects the trees (set to 1% in our scheme below).
% live wood and tree-leaves
mortality_tree = 0.01 + (0.59 ./ (1+exp((60-100*perc_tree) *0.25)));

% belowground herbaceous roots (they usually survive, and die only when the
% fire is extremely hot)
mortality_hfroot = 0.1;


