[Cellular Automata] Forest fires based on cellular automata

1. Definition and scope of application of cellular automata

Different from general dynamic models, cellular automata are not determined by strictly defined physical equations or functions, but are constituted by a series of model construction rules. Any model that satisfies these rules can be regarded as a cellular automata model. Therefore, cellular automata is a general term for a class of models, or a method framework. Its characteristic is that time, space, and state are all discrete, each variable takes only a finite number of states, and the rules for state change are local in time and space.

Cellular automata-applied to forest fire and infectious disease scenarios

Recently, I came into contact with the cellular automata model, did some data search, and studied it. I recommend this article, Australia has become Rinzhou, and koalas have become grilled! Why is Australian wildfire difficult to control?
Record what you have learned below.

The Principle of Cellular Automata of Forest Fire

In the cellular automata model, the space is discretized into grids, and each grid is called a cell. Forest fire cells have three states: tree, fire (burning tree) and empty (open space) state. The rules for updating the state of a cell at the next moment are as follows: The
tree turns into fire: If a tree has a state of fire up, down, left, and right, it will become fire in the next moment. Or when a tree meets lightning, it will turn into fire the next moment. Plight is very unlikely to catch fire due to lightning.

Fire becomes empty: Fire will become empty in the next moment.

Vacant tree: The next moment in the open space, a new tree will grow with a small probability of Pgrowth.

The improved model will consider whether the diagonal position of the tree is on fire. Or consider the wind direction (for example, if the wind blows from the east to the west), the probability of catching fire on the west side of the fire will increase (downwind), and the probability of catching fire on the east side of the fire will decrease (upwind). Here is a picture:
Insert picture description herePicture a It is the basic cellular automaton, Figure b is the cellular automaton considering the diagonal, and Figure c is the cellular automaton with westerly wind.
Here I simulate three models of basic cellular automata, cellular automata considering the diagonal situation, and cellular automata with westerly wind. The simulation results are as follows:
Insert picture description here
Insert picture description here
Insert picture description here

P=[];
for m=1:10
clear D T fire_time_lightning fire_time_itself aspect tdata Index;
%% Orginal 
%the first 3 dimension is RGB,R is the fire,G is the tree.
%Black is the meaning of no tree.
global n D T Y fire_time_lightning fire_time_itself fire_time_demend pull aspect count_1 tdata  Pull_times
n=500;      % the length of the forest matrix
D=zeros(n);
T=zeros(n);
Y=zeros(n,n,3);  % draw the picture by matrix Y(RGB) 
fire_time_lightning=0;
fire_time_itself=0;
fire_time_demend=0;
times=1;
pull=1/times;     % the rate of pull the fire out 
aspect=ceil(rand(1)*4);  % 1 is right,2 is up,3 is left and 4 is down.
count_1=0;
tdata=[];     % the day by each fire happened.
Pull_times=0;
f1=1/1000;     % f1 is the probability in ceil when it being struck by lightning. 
f2=1/500;     % f2 is the probability in ceil when it being fired itself. 
Z=Terrain();
[scale_b,S]=Forest(Z);
Tem=S;
Yi=imshow(Y);
set(gcf,'DoubleBuffer','on');
% set up the double cache to prevent the flash in palying animation constantly
t=0;
tp=title(['T = ',num2str(t)]);
%ap=title(['aspect = ',num2str(aspect)]);
%while 1
%    t=t+1;
for t=1:2400
%% Fire in the early time
if rem(t,50)==0&&t<1000
   Fire_Demand(S); 
end
%% Lightning
if rand<f1          %Is there happen sth with lightning?
    OriginFireLightning(S);     
    set(Yi,'CData',Y);
end
%% Fire itself
if t>10
    OriginFireCritical(S,t,f2);
    set(Yi,'CData',Y);
end
%% FireRule1
[a,b]=FireRule1(S);
%% FireRule2
S=FireRule2(S,a,b);

set(Yi,'CData',Y);
set(tp,'string',['T = ',num2str(fix(t/(24))),'D = ',num2str(t),'h '])
%set(ap,'string',['aspect = ',num2str(aspect)])
pause(2e-6)
end
scale_n=sum(sum(Y(:,:,2)));
fire_count=fire_time_itself+fire_time_lightning;
Lost_area=scale_b-scale_n;
Lost_rate_all=Lost_area/scale_b;
Lost_rate_average=Lost_rate_all/(fire_count);
Tem=Tem-S;
Tem=Tem.*Tem;
%Lost_Value=sum(sum(Tem));
%N=[pull Lost_rate_all Lost_rate_average fire_count]
P=[P;fire_time_demend Pull_times Lost_rate_all fire_time_itself fire_time_lightning]
%figure (2)
%plot(tdata(:,1),tdata(:,2));
end

Complete code or write on behalf of adding QQ1575304183

Past review>>>>>>

[Cellular Automata] Four-lane traffic flow based on cellular automata

[Cellular Automata] Two-lane traffic flow model based on cellular automata with matlab source code for driving on the right

[Cellular Automata] Matlab source code of crystal growth based on cellular automata

[Mathematical modeling] Queuing theory model and MATLAB implementation with GUI interface

[Cellular Automata] Based on the Cellular Automata, the study of the influence of the opening of urban districts on the traffic of surrounding roads is solved

[ Cellular Automata] Image processing matlab source code based on cellular automata

Guess you like

Origin blog.csdn.net/qq_34763204/article/details/113664990