


subroutine collesion(u,v,f,feq,rho,w,cx,cy,n,m,th,gbeta,force, omega, amiuf, fii, dp, visco, solid)
real f(0:8,0:n,0:m)
real feq(0:8,0:n,0:m),rho(0:n,0:m)
real w(0:8), cx(0:8),cy(0:8), force(0:1)
real u(0:n,0:m), v(0:n,0:m)
real th(0:n,0:m), solid(0:n,0:m)
tref=0.50
DO i=0,n
DO j=0,m
if (solid(i,j) .eq. 0) then 
curth=th(i,j)
Call viscalc(curth, fii, dp, viscorate)
!=================16.2 barabar ba lezjat EG
omega=1.0/(3.*viscorate/16.2+0.5)
t1=u(i,j)*u(i,j)+v(i,j)*v(i,j)
DO k=0,8
t2=u(i,j)*cx(k)+v(i,j)*cy(k)
forceterm=3.*w(k)*gbeta*(th(i,j)-tref)*rho(i,j)*(force(0)*cx(k)+force(1)*cy(k))
if(i.eq.0.or.i.eq.n) forceterm =0.0
if(j.eq.0.or.j.eq.m) forceterm =0.0
feq(k,i,j)=rho(i,j)*w(k)*(1.0+3.0*t2+4.50*t2*t2-1.50*t1)
f(k,i,j)=omega*feq(k,i,j)+(1.-omega)*f(k,i,j)+forceterm
END DO
End if
END DO
END DO
return
end




subroutine collt(u,v,g,geq,th,omegat,w,cx,cy,n,m, fii,dp, condf, rhoocpnf, solid)
real g(0:8,0:n,0:m),geq(0:8,0:n,0:m),th(0:n,0:m)
real w(0:8),cx(0:8),cy(0:8)
real u(0:n,0:m),v(0:n,0:m), solid(0:n,0:m)
do i=0,n
do j=0,m
if (solid(i,j) .eq. 0) then
curth=th(i,j)
call condcalc(curth,condrate, fii, dp)
condnf=condrate*condf
alphanf=condnf/rhoocpnf
omegat=1.0/(3.*alphanf+0.5)
do k=0,8
geq(k,i,j)=th(i,j)*w(k)*(1.0+3.0*(u(i,j)*cx(k)+v(i,j)*cy(k)))
g(k,i,j)=omegat*geq(k,i,j)+(1.0-omegat)*g(k,i,j)
end do
endif
end do
end do
return
end









