$diffusortype
跳至導覽
跳至搜尋
$diffusortype is a special function to define the material parameters. Some materials are diffusive material so that we can apply the diffusor parameters.
The usage is
$diffusortype type_1 diffusion_length_1 type_2 diffusion_length_2 ... ... totalregions ... type_Nth diffusion_length_N
In side the diffusor, the program will decide if it will change location depending on diffusion length.
Type 1, random diffusion Type 2, cos dependent Type 3, cos^2 dependent
elseif(diffusortypess==1) then
I=(1-exp(-1.0*compare(3)*diffusorlength))
call random_number(diffusing)
if(diffusing<I)then
x=cx
y=cy
intersectionss=2
call random_number(angle)
vx=cos(angle*2*pi)
vy=sin(angle*2*pi)
end if
elseif(diffusortypess==2) then
I=(1-exp(-1.0*compare(3)*diffusorlength))
call random_number(diffusing)
if(diffusing<I)then
x=cx
y=cy
intersectionss=2
call random_number(angle)
theta = (1-cos(angle*pi/2) )*pi/2
call random_number(angle)
if(angle .ne.0.5) then
theta= theta*(angle-0.5)/abs(angle-0.5)
end if
oldvx=vx
oldvy=vy
if(oldvy>0) then
oldtheta=acos(oldvx/sqrt(oldvx*oldvx+oldvy*oldvy))
elseif(oldvy==0.0) then
if(oldvx >0.0) oldtheta=0.0
if(oldvx <0.0) oldtheta=pi
else
oldtheta=2*pi-acos(oldvx/sqrt(oldvx*oldvx+oldvy*oldvy))
end if
vx=cos(theta+oldtheta)
vy=sin(theta+oldtheta)
end if
elseif(diffusortypess==3) then
I=(1-exp(-1.0*compare(3)*diffusorlength))
call random_number(diffusing)
if(diffusing<I)then
x=cx
y=cy
intersectionss=2
call random_number(angle)
theta = (1-cos(angle*pi/2) )**2*pi/2
call random_number(angle)
if(angle .ne.0.5) then
theta= theta*(angle-0.5)/abs(angle-0.5)
end if
oldvx=vx
oldvy=vy
if(oldvy>0) then
oldtheta=acos(oldvx/sqrt(oldvx*oldvx+oldvy*oldvy))
elseif(oldvy==0.0) then
if(oldvx >0.0) oldtheta=0.0
if(oldvx <0.0) oldtheta=pi
else
oldtheta=2*pi-acos(oldvx/sqrt(oldvx*oldvx+oldvy*oldvy))
end if
vx=cos(theta+oldtheta)
vy=sin(theta+oldtheta)
end if
end if