adding drawfire
[wrf-fire-matlab.git] / vis3d / plot_fuel.m
blob1ee1f144b939a7f3ce8b9b0ff6c4d7b0ec0c2f64
1 function plot_fuel(f,units,scale)
2 % plot_fuel(f)
3 % plot_fuel(f,units)
4 % plot_fuel(f,units,logscale)
5 % arguments
6 % f     fuel structure, as created by fuels.m
7 % units 'metric' (default)
8 %       'Scott-Burgan' (same as 'sb') ch/h and mi/h
9 % scale 'direct' (default)
10 %       'log'  for loglog plots
11 % plot rate of spread against wind speed and slope 
12 % from fuels.m produced by wrf-fire
13 % example: fuels; plot_fuel(fuel(3))
15 name=['Fuel model ',f.fuel_name];
17 disp(f.fuel_name)
18 fprintf('%s fgi = %g\n',f.fgi_descr,f.fgi)
19 fprintf('%s fuelmc_g = %g\n',f.fuelmc_g_descr,f.fuelmc_g)
20 fprintf('%s cmbcnst = %g\n',f.cmbcnst_descr,f.cmbcnst)
21 fprintf('%s weight = %g\n',f.weight_descr,f.weight)
23 fprintf('\n*** without for evaporation heat of moisture ***\n')
24 h = f.cmbcnst/(1+f.fuelmc_g);
25 fprintf('specific heat contents of fuel (J/kg) %g\n',h) 
26 hd=f.fgi*h;
27 fprintf('heat density (J/m^2) %g\n',hd)
28 Tf=f.weight/0.8514; % fuel burns as exp(-t/Tf)
29 fprintf('initial slope of mass-loss curve (1/s) %g\n',1/Tf)
30 fprintf('maximal heat flux density (J/m^2/s) %g\n',hd/Tf)
31 fprintf('\n*** with correction for evaporation of moisture ***\n')
32 Lw=2.5e6;
33 fprintf('latent heat of moisure (J/kg) %g\n',Lw)
34 hw = (f.cmbcnst - Lw*f.fuelmc_g) /(1+f.fuelmc_g);
35 fprintf('specific heat contents of fuel (J/kg) %g\n',hw)
36 fprintf('relative correction due to evaporation %g%%\n',100*(hw/h-1)) 
37 hd=f.fgi*hw;
38 fprintf('heat density (J/m^2) %g\n',hd)
39 Tf=f.weight/0.8514; % fuel burns as exp(-t/Tf)
40 fprintf('initial slope of mass-loss curve (1/s) %g\n',1/Tf)
41 fprintf('maximal heat flux density (J/m^2/s) %g\n',hd/Tf)
44 Tf=f.weight/0.8514; % fuel burns as exp(-t/Tf)
47 if ~exist('units'),
48     units='metric';
49 end
51 if ~exist('scale'),
52     scale='direct';
53 end
54 if isempty(units),
55     units='metric';
56 end
58 switch scale
59     case {'log','LOG','loglog'}
60         logscale=1;
61     otherwise
62         logscale=0;
63 end
66 switch units
67     case {'SB','sb','Scott-Burgan'}
68         wind_unit='20ft (mi/h)';
69         ros_unit='ch/h';
70         wind_conv=3600/1609.344;
71         ros_conv=3600/20.1168;
72     otherwise
73         wind_unit='6.1m (m/s)';
74         ros_unit='m/s';
75         wind_conv=1;
76         ros_conv=1;
77 end
81 figure(1) % wind dependence
82 for i=1:length(f.wind),
83     ros_wind(i) = fire_ros(f,f.wind(i),0);
84 end
85 err_wind=big(ros_wind-f.ros_wind)
86 if logscale,
87     loglog(f.wind*wind_conv,ros_wind*ros_conv,'r',f.wind*wind_conv,f.ros_wind*ros_conv,'b')
88 else
89     plot(f.wind*wind_conv,ros_wind*ros_conv,'r',f.wind*wind_conv,f.ros_wind*ros_conv,'b')
90 end
91 xlabel(['wind speed at ',wind_unit,')'])
92 ylabel(['rate of spread (',ros_unit,')'])
93 title(name)
94 grid
96 figure(2) % slope dependence
97 for i=1:length(f.slope),
98     ros_slope(i) = fire_ros(f,0,f.slope(i));
99 end
100 err_slope=big(ros_slope-f.ros_slope)
101 if logscale
102     loglog(f.slope,ros_slope*ros_conv,'r',f.slope,f.ros_slope*ros_conv,'b')
103 else
104     plot(f.slope,ros_slope*ros_conv,'r',f.slope,f.ros_slope*ros_conv,'b')
106 xlabel('slope (1)')
107 ylabel(['rate of spread (',ros_unit,')'])
108 name=['Fuel model ',f.fuel_name];
109 title(name)
110 grid
112 figure(3)
113 if(isfield(f,'fmc_g')),
114     fmc_g=f.fmc_g;
115 else
116     nsteps=100;
117     fmc_g=f.fuelmce*[0:nsteps-1]/nsteps-2;
119 for i=1:length(fmc_g),
120     ros_fmc_g(i) = fire_ros(f,0,0,fmc_g(i));
122 if(isfield(f,'fmc_g')),
123     err_fmc_g=big(ros_fmc_g-f.ros_fmc_g)
124     plot(fmc_g,ros_fmc_g*ros_conv,'r',f.fmc_g,f.ros_fmc_g*ros_conv,'b',...
125         f.fuelmc_g,interp1(fmc_g,ros_fmc_g*ros_conv,f.fuelmc_g),'+k')
126 else
127     plot(fmc_g,ros_fmc_g*ros_conv,'b')
129 xlabel('ground fuel moisture content (1)')
130 ylabel(['rate of spread (',ros_unit,')'])
131 name=['Fuel model ',f.fuel_name];
132 title(name)
133 grid
135 fprintf('\nzero wind rate of spread %g %s\n',fire_ros(f,0,0)*ros_conv,ros_unit')
138 fprintf('\nzero wind rate of spread %g %s\n',fire_ros(f,0,0)*ros_conv,ros_unit')
142 err=big(check_ros(f));
143 fprintf('\nmax rel err in rate of spread between WRF-Fire and fire_ros.m %g\n',err)