Navigation Menu

Skip to content

Commit

Permalink
Merge commit '812b0fa306da73e35371012638b39c'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeezley committed Nov 15, 2009
2 parents ced9731 + 812b0fa commit aa4ddf0
Show file tree
Hide file tree
Showing 15 changed files with 697 additions and 65 deletions.
91 changes: 91 additions & 0 deletions other/Matlab/vis3d/frame3d.m
@@ -0,0 +1,91 @@
function frame3d(swind,amin,amax,astep,qstep,qs,...
fxlong,fxlat,xlong,xlat,zsf,fgrnhfx,uf,vf,u,v,w,ph,phb,hgt)

clf,hold off

r = size(fxlong)./(size(xlong)+1); % refinement ratio
ideal = all(xlong ==0); % not populated in ideal case

if ideal,
% do not have xlong and xlat in ideal case, but we made the coordinates up
% for fxlong and fxlat, so interpolate
n=size(xlong);
[xa,ya]=ndgrid(r(1)*[1/2:1:n(1)],r(2)*[1/2:1:n(2)]); % centers of atm cells in fire grid
axlong = interp2(fxlong,xa,ya); % fake coordinates for display
axlat = interp2(fxlat,xa,ya); % fake coordinates for display
xscale=1;
yscale=1;
else
axlong=xlong; axlat=xlat; % in real case, xlong xlat populated
er=6378e3; % earth radius in m
deg2rad=2*pi/360; % 1 degree in radians
% degrees to meters, long and lat
lat_deg2m=er*deg2rad;
long_deg2m=er*deg2rad*cos(deg2rad*mean(xlat(find(xlat))));
xscale=1/long_deg2m;
yscale=1/lat_deg2m;
end
aspect_ratio = [xscale yscale 1];

% compute the corresponding part of the fire grid
dmin=1+r.*(amin(1:2)-1);
dmax=r.*amax(1:2);

% surface colored by heat flux
i=dmin(1):dmax(1);j=dmin(2):dmax(2);
hs=surf(fxlong(i,j),fxlat(i,j),zsf(i,j),fgrnhfx(i,j),'EdgeColor','none','FaceAlpha',0.7);
caxis([0,1e6]); % for heat flux color
axis tight, colorbar
hold on
[c,hc]=contour3(fxlong(i,j),fxlat(i,j),zsf(i,j));
for h=hc(:)', set(h,'EdgeColor','black');end % color the contours black


% surface wind arrows
if swind,
ii=dmin(1):qstep(1):dmax(1);jj=dmin(2):qstep(2):dmax(2);
hq=quiver3(fxlong(ii,jj),fxlat(ii,jj),zsf(ii,jj),xscale*uf(ii,jj),yscale*vf(ii,jj),zeros(size(vf(ii,jj))),qs);
set(hq,'Color','black')
end

% geopotential altitude of the centers of lower cell face
% ph is perturbation from the background phb
% note ph and phb are staggered just as w
a = (ph+phb)/9.81;
% check if the lowest background geopotential height is terrain height
err_hgt = big(hgt-phb(:,:,1)/9.81)
% interpolate the geopotential and w velocity from staggered grid to cell centers
ac = (a(:,:,1:end-1)+a(:,:,2:end))/2;
wc = (w(:,:,1:end-1)+w(:,:,2:end))/2;
% interpolate u and v components of wind velocity from staggered grid to cell centers
uc = (u(1:end-1,:,:)+u(2:end,:,:))/2; % from front and rear face to the center
vc = (v(:,1:end-1,:)+v(:,2:end,:))/2; % from front and rear face to the center

% atmosphere wind arrows
ia=amin(1):astep(1):amax(1);
ja=amin(2):astep(2):amax(2);
colors={'white','red','green','blue','black'};
for k=amin(3):astep(3):amax(3),
q1=u(ia,ja,k)*xscale;
q2=v(ia,ja,k)*yscale;
q3=w(ia,ja,k);
hqa=quiver3(axlong(ia,ja),axlat(ia,ja),ac(ia,ja,k),q1,q2,q3,qs);
set(gca,'DataAspectRatio',[xscale yscale 1]);
i=1+mod(k-1,length(colors));
set(hqa,'Color',colors{i});
end

if ideal
xlabel('x (m)')
ylabel('y (m)')
else
% set(gca,'PlotBoxAspectRatioMode','auto');
xlabel('longitude (deg)')
ylabel('latitutude (deg)')
end
zlabel('z (m)')
set(gca,'DataAspectRatio',[xscale yscale 1]);
hold off
drawnow

end
33 changes: 33 additions & 0 deletions other/Matlab/vis3d/hillframe.m
@@ -0,0 +1,33 @@
disp('1. install mexnc under the same directory as wrf-fire, then')
disp('2. start matlab in wrf/WRFV3/test/em_fire to set up the paths properly')
disp(' or cd there and run startup while in the directory')
disp('3. read a wrfrst file into the workspace as in')
disp(' >> ncload wrfrst_d01_0001-01-01_00:01:00')

% note the variables are read here without the WRF permutation of dimensions
ideal=1;
rst=1;

if rst,
u=u_2;
v=v_2;
w=w_2;
ph = ph_2;
end

clf
amin=[15,15,1]; % the atm grid part to show
amax=[30,30,2];
amin=[1,1,1]; % the atm grid part to show
amax=[41,41,2];

qstep=[5,5]; % quiver step for wind on the surface fire grid
astep=[1,1,1]; % quiver step for wind on the atmosphere grid
qs=1.5; % scaling for quiver arrows
r=[10,10]; % refinement factor
swind=1; % plot surface wind

%-------------------------------------------------

frame3d(swind,amin,amax,astep,qstep,qs,...
fxlong,fxlat,xlong,xlat,zsf,fgrnhfx,uf,vf,u,v,w,ph,phb,hgt)
48 changes: 48 additions & 0 deletions other/Matlab/vis3d/wrfout2frame3d.m
@@ -0,0 +1,48 @@
% function wrfout2frame3d(file,steps)
disp('1. file=''wrfout file''')
disp('2. steps=[1:20] % time steps to display')
disp('3. wrfout2frame3d')

fxlong =ncread(file,'FXLONG');
fxlat =ncread(file,'FXLAT');
xlong =ncread(file,'XLONG');
xlat =ncread(file,'XLAT');
zsf =ncread(file,'ZSF');
fgrnhfx=ncread(file,'FGRNHFX');
uf =ncread(file,'UF');
vf =ncread(file,'VF');
u =ncread(file,'U');
v =ncread(file,'V');
w =ncread(file,'W');
ph =ncread(file,'PH');
phb =ncread(file,'PHB');
hgt =ncread(file,'HGT');
itimestep=ncread(file,'ITIMESTEP');


% note the variables are read here without the WRF permutation of dimensions

amin=[15,15,1]; % the atm grid part to show
amax=[30,30,2];
amin=[10,10,1]; % the atm grid part to show
amax=[30,30,1];

qstep=[20,20]; % quiver step for wind on the surface fire grid
astep=[2,2,1]; % quiver step for wind on the atmosphere grid
qs=1e-3; % scaling for quiver arrows
swind=0; % do not display surface wind

%-------------------------------------------------

a=avifile('fire.avi');
for k=steps,
frame3d(swind,amin,amax,astep,qstep,qs,...
fxlong(:,:,k),fxlat(:,:,k),xlong(:,:,k),xlat(:,:,k),...
zsf(:,:,k),fgrnhfx(:,:,k),uf(:,:,k),vf(:,:,k),...
u(:,:,:,k),v(:,:,:,k),w(:,:,:,k),...
ph(:,:,:,k),phb(:,:,:,k),hgt(:,:,k))
title(['Timestep ',num2str(itimestep(k))])
F=getframe(gcf);
a=addframe(a,F);
end
a=close(a);
20 changes: 10 additions & 10 deletions wrfv2_fire/Registry/registry.fire
Expand Up @@ -59,33 +59,33 @@ rconfig integer ifire namelist,fire max_domains
rconfig integer fire_boundary_guard namelist,fire max_domains 2 - "fire_boundary_guard" "cells to stop when fire close to domain boundary"
# ignition for sfire
rconfig integer fire_num_ignitions namelist,fire max_domains 0. - "fire_num_ignitions" "number of ignition lines"
rconfig real fire_ignition_start_long1 namelist,fire max_domains 0. - "fire_ignition_start_long1" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lon1 namelist,fire max_domains 0. - "fire_ignition_start_long1" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lat1 namelist,fire max_domains 0. - "fire_ignition_start_lat1" "lat coord of start of ignition line" "m"
rconfig real fire_ignition_end_long1 namelist,fire max_domains 0. - "fire_ignition_end_long1" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lon1 namelist,fire max_domains 0. - "fire_ignition_end_long1" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lat1 namelist,fire max_domains 0. - "fire_ignition_end_lat1" "lat coord of end of ignition line" "m"
rconfig real fire_ignition_radius1 namelist,fire max_domains 0. - "fire_ignition_radius1" "ignite all within the radius" "m"
rconfig real fire_ignition_time1 namelist,fire max_domains 0. - "fire_ignition_time1" "ignition time" "s"
rconfig real fire_ignition_start_long2 namelist,fire max_domains 0. - "fire_ignition_start_long2" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lon2 namelist,fire max_domains 0. - "fire_ignition_start_long2" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lat2 namelist,fire max_domains 0. - "fire_ignition_start_lat2" "lat coord of start of ignition line" "m"
rconfig real fire_ignition_end_long2 namelist,fire max_domains 0. - "fire_ignition_end_long2" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lon2 namelist,fire max_domains 0. - "fire_ignition_end_long2" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lat2 namelist,fire max_domains 0. - "fire_ignition_end_lat2" "lat coord of end of ignition line" "m"
rconfig real fire_ignition_radius2 namelist,fire max_domains 0. - "fire_ignition_radius2" "ignite all within the radius" "m"
rconfig real fire_ignition_time2 namelist,fire max_domains 0. - "fire_ignition_time2" "ignition time" "s"
rconfig real fire_ignition_start_long3 namelist,fire max_domains 0. - "fire_ignition_start_long3" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lon3 namelist,fire max_domains 0. - "fire_ignition_start_long3" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lat3 namelist,fire max_domains 0. - "fire_ignition_start_lat3" "lat coord of start of ignition line" "m"
rconfig real fire_ignition_end_long3 namelist,fire max_domains 0. - "fire_ignition_end_long3" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lon3 namelist,fire max_domains 0. - "fire_ignition_end_long3" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lat3 namelist,fire max_domains 0. - "fire_ignition_end_lat3" "lat coord of end of ignition line" "m"
rconfig real fire_ignition_radius3 namelist,fire max_domains 0. - "fire_ignition_radius3" "ignite all within the radius" "m"
rconfig real fire_ignition_time3 namelist,fire max_domains 0. - "fire_ignition_time3" "ignition time" "s"
rconfig real fire_ignition_start_long4 namelist,fire max_domains 0. - "fire_ignition_start_long4" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lon4 namelist,fire max_domains 0. - "fire_ignition_start_long4" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lat4 namelist,fire max_domains 0. - "fire_ignition_start_lat4" "lat coord of start of ignition line" "m"
rconfig real fire_ignition_end_long4 namelist,fire max_domains 0. - "fire_ignition_end_long4" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lon4 namelist,fire max_domains 0. - "fire_ignition_end_long4" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lat4 namelist,fire max_domains 0. - "fire_ignition_end_lat4" "lat coord of end of ignition line" "m"
rconfig real fire_ignition_radius4 namelist,fire max_domains 0. - "fire_ignition_radius4" "ignite all within the radius" "m"
rconfig real fire_ignition_time4 namelist,fire max_domains 0. - "fire_ignition_time4" "ignition time" "s"
rconfig real fire_ignition_start_long5 namelist,fire max_domains 0. - "fire_ignition_start_long5" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lon5 namelist,fire max_domains 0. - "fire_ignition_start_long5" "long coord of start of ignition line" "m"
rconfig real fire_ignition_start_lat5 namelist,fire max_domains 0. - "fire_ignition_start_lat5" "lat coord of start of ignition line" "m"
rconfig real fire_ignition_end_long5 namelist,fire max_domains 0. - "fire_ignition_end_long5" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lon5 namelist,fire max_domains 0. - "fire_ignition_end_long5" "long coord of end of ignition line" "m"
rconfig real fire_ignition_end_lat5 namelist,fire max_domains 0. - "fire_ignition_end_lat5" "lat coord of end of ignition line" "m"
rconfig real fire_ignition_radius5 namelist,fire max_domains 0. - "fire_ignition_radius5" "ignite all within the radius" "m"
rconfig real fire_ignition_time5 namelist,fire max_domains 0. - "fire_ignition_time5" "ignition time" "s"
Expand Down
54 changes: 33 additions & 21 deletions wrfv2_fire/phys/module_fr_sfire_driver.F
Expand Up @@ -25,17 +25,29 @@
! propagation by tracers and was coupled with the Clark-Hall
! atmospheric code, described in [2]. For WRF documentation see [3].

! Acknowledgements: Contributions to the level set method by Mijeong
! Kim. The fire physics is adapted from an earlier code by Terry
! Acknowledgements
!
! Contributions to development of the level set
! method by Mijeong Kim. Contribution to fuel calculation by Volodymyr
! Kondratenko.
!
! The fire physics is adapted from an earlier code by Terry
! L. Clark, Janice L. Coen, and Don Latham. The coupling with WRF is
! adapted from a code by Ned Patton for coupling of the earlier fire
! model with WRF, with contributions by Jonathan D. Beezley. The
! WRF build and execution environment was set up by Jonathan Beezley.
! model with WRF. The changes in WRF infrastructure and support of
! refined fire grid was provided by John Michalakes.

! Jonathan D. Beezley has set up and maintained the WRF build and
! execution environment, provided software engineering infrastructure
! including synchronization with the WRF repository, and was responsibe
! for all aspects of WRF modification.

! Refefences
!
! [1] Jan Mandel, Jonathan D. Beezley, Janice L. Coen, and Minjeong Kim,
! Data Asimilation for Wildland Fires: Ensemble Kalman filters in
! coupled atmosphere-surface models, IEEE Control Systems Magazine,
! submitted, 2007
! coupled atmosphere-surface models, IEEE Control Systems Magazine 29,
! Issue 3, June 2009, 47-65.

! [2] T. L. Clark, J. Coen, and D. Latham, Description of a coupled
! atmosphere-fire model, Intl. J. Wildland Fire, vol. 13, pp. 49-64,
Expand All @@ -47,7 +59,7 @@

module module_fr_sfire_driver

use module_model_constants, only: cp,xlv
use module_model_constants, only: cp,xlv,reradius,pi2
use module_fr_sfire_model
use module_fr_sfire_phys
use module_fr_sfire_atm
Expand Down Expand Up @@ -244,8 +256,8 @@ subroutine sfire_driver_em ( grid , config_flags &
lat_ctr=config_flags%cen_lat
lon_ctr=config_flags%cen_lon
! 1 degree in m (approximate OK)
unit_fxlat=6378e3*2*3.14159/360. ! earth circumference in m / 360 degrees
unit_fxlong=cos(lat_ctr*3.14159/180.)*unit_fxlat ! latitude
unit_fxlat=pi2/(360.*reradius) ! earth circumference in m / 360 degrees
unit_fxlong=cos(lat_ctr*pi2/360.)*unit_fxlat ! latitude
endif

! refinement r
Expand Down Expand Up @@ -861,7 +873,7 @@ subroutine fire_ignition_convert (config_flags,fire_max_ignitions,ignition_longl
if(fire_max_ignitions.lt.5)call crash('fire_max_ignitions too small')
! figure out which kind of coordinates from the first given
ideal=config_flags%fire_ignition_start_x1 .ne.0. .or. config_flags%fire_ignition_start_y1 .ne. 0.
real=config_flags%fire_ignition_start_long1 .ne. 0. .or. config_flags%fire_ignition_start_lat1 .ne. 0.
real=config_flags%fire_ignition_start_lon1 .ne. 0. .or. config_flags%fire_ignition_start_lat1 .ne. 0.
if(ideal)call message('Using ideal ignition coordinates, m from the lower left domain corner')
if(real)call message('Using real ignition coordinates, longitude and latitude')
if(ideal.and.real)call crash('Only one of the ideal or real coordinates may be given')
Expand Down Expand Up @@ -893,26 +905,26 @@ subroutine fire_ignition_convert (config_flags,fire_max_ignitions,ignition_longl
if(real)then
! use values from _long and _lat
ignition_longlat=1
fire_ignition_start_x(1)=config_flags%fire_ignition_start_long1
fire_ignition_start_x(1)=config_flags%fire_ignition_start_lon1
fire_ignition_start_y(1)=config_flags%fire_ignition_start_lat1
fire_ignition_end_x(1)=config_flags%fire_ignition_end_long1
fire_ignition_end_x(1)=config_flags%fire_ignition_end_lon1
fire_ignition_end_y(1)=config_flags%fire_ignition_end_lat1
fire_ignition_start_x(2)=config_flags%fire_ignition_start_long2
fire_ignition_start_x(2)=config_flags%fire_ignition_start_lon2
fire_ignition_start_y(2)=config_flags%fire_ignition_start_lat2
fire_ignition_end_x(2)=config_flags%fire_ignition_end_long2
fire_ignition_end_x(2)=config_flags%fire_ignition_end_lon2
fire_ignition_end_y(2)=config_flags%fire_ignition_end_lat2
fire_ignition_start_x(3)=config_flags%fire_ignition_start_long3
fire_ignition_start_x(3)=config_flags%fire_ignition_start_lon3
fire_ignition_start_y(3)=config_flags%fire_ignition_start_lat3
fire_ignition_end_x(3)=config_flags%fire_ignition_end_long3
fire_ignition_end_x(3)=config_flags%fire_ignition_end_lon3
fire_ignition_end_y(3)=config_flags%fire_ignition_end_lat3
fire_ignition_start_x(4)=config_flags%fire_ignition_start_long4
fire_ignition_start_x(4)=config_flags%fire_ignition_start_lon4
fire_ignition_start_y(4)=config_flags%fire_ignition_start_lat4
fire_ignition_end_x(4)=config_flags%fire_ignition_end_long4
fire_ignition_end_x(4)=config_flags%fire_ignition_end_lon4
fire_ignition_end_y(4)=config_flags%fire_ignition_end_lat4
fire_ignition_start_x(5)=config_flags%fire_ignition_start_long5
fire_ignition_start_x(5)=config_flags%fire_ignition_start_lon5
fire_ignition_start_y(5)=config_flags%fire_ignition_start_lat5
fire_ignition_end_x(5)=config_flags%fire_ignition_end_long3
fire_ignition_end_y(5)=config_flags%fire_ignition_end_lat3
fire_ignition_end_x(5)=config_flags%fire_ignition_end_lon5
fire_ignition_end_y(5)=config_flags%fire_ignition_end_lat5
endif
! common to both cases
fire_ignition_radius(1)=config_flags%fire_ignition_radius1
Expand Down
1 change: 1 addition & 0 deletions wrfv2_fire/test/em_fire/hill/ideal.exe

0 comments on commit aa4ddf0

Please sign in to comment.