1+ subroutine art_visc (ntotal ,hsml ,mass ,x ,vx ,niac ,rho ,c ,
2+ & pair_i ,pair_j ,w ,dwdx ,dvxdt ,dedt )
3+
4+ c ----------------------------------------------------------------------
5+ c Subroutine to calculate the artificial viscosity (Monaghan, 1992 )
6+ c See Equ.(4.66) Equ.(4.62)
7+
8+ c ntotal : Number of particles (including virtual particles) [in]
9+ c hsml : Smoothing Length [in]
10+ c mass : Particle masses [in]
11+ c x : Coordinates of all particles [in]
12+ c vx : Velocities of all particles [in]
13+ c niac : Number of interaction pairs [in]
14+ c rho : Density [in]
15+ c c : Temperature [in]
16+ c pair_i : List of first partner of interaction pair [in]
17+ c pair_j : List of second partner of interaction pair [in]
18+ c w : Kernel for all interaction pairs [in]
19+ c dwdx : Derivative of kernel with respect to x, y and z [in]
20+ c dvxdt : Acceleration with respect to x, y and z [out]
21+ c dedt : Change of specific internal energy [out]
22+
23+ implicit none
24+ include ' param.inc'
25+
26+ integer ntotal, niac, pair_i(max_interaction),
27+ & pair_j(max_interaction)
28+ double precision hsml(maxn), mass(maxn), x(dim,maxn),vx(dim,maxn),
29+ & rho(maxn), c(maxn), w(max_interaction),
30+ & dwdx(dim,max_interaction), dvxdt(dim,maxn), dedt(maxn)
31+ integer i,j,k,d
32+ double precision dx, dvx(dim), alpha, beta, etq, piv,
33+ & muv, vr, rr, h, mc, mrho, mhsml
34+
35+ c Parameter for the artificial viscosity:
36+ c Shear viscosity
37+ parameter ( alpha = 1.e0 )
38+
39+ c Bulk viscosity
40+ parameter ( beta = 1.e0 )
41+
42+ c Parameter to avoid singularities
43+ parameter ( etq = 0.1e0 )
44+
45+ do i= 1 ,ntotal
46+ do d= 1 ,dim
47+ dvxdt(d,i) = 0.e0
48+ enddo
49+ dedt(i) = 0.e0
50+ enddo
51+
52+ c Calculate SPH sum for artificial viscosity
53+
54+ do k= 1 ,niac
55+ i = pair_i(k)
56+ j = pair_j(k)
57+ mhsml= (hsml(i)+ hsml(j))/ 2 .
58+ vr = 0.e0
59+ rr = 0.e0
60+ do d= 1 ,dim
61+ dvx(d) = vx(d,i) - vx(d,j)
62+ dx = x(d,i) - x(d,j)
63+ vr = vr + dvx(d)* dx
64+ rr = rr + dx* dx
65+ enddo
66+
67+ c Artificial viscous force only if v_ij * r_ij < 0
68+
69+ if (vr.lt. 0.e0 ) then
70+
71+ c Calculate muv_ij = hsml v_ij * r_ij / ( r_ij^2 + hsml^2 etq^2 )
72+
73+ muv = mhsml* vr/ (rr + mhsml* mhsml* etq* etq)
74+
75+ c Calculate PIv_ij = (-alpha muv_ij c_ij + beta muv_ij^2) / rho_ij
76+
77+ mc = 0.5e0 * (c(i) + c(j))
78+ mrho = 0.5e0 * (rho(i) + rho(j))
79+ piv = (beta* muv - alpha* mc)* muv/ mrho
80+
81+ c Calculate SPH sum for artificial viscous force
82+
83+ do d= 1 ,dim
84+ h = - piv* dwdx(d,k)
85+ dvxdt(d,i) = dvxdt(d,i) + mass(j)* h
86+ dvxdt(d,j) = dvxdt(d,j) - mass(i)* h
87+ dedt(i) = dedt(i) - mass(j)* dvx(d)* h
88+ dedt(j) = dedt(j) - mass(i)* dvx(d)* h
89+ enddo
90+ endif
91+ enddo
92+
93+ c Change of specific internal energy:
94+
95+ do i= 1 ,ntotal
96+ dedt(i) = 0.5e0 * dedt(i)
97+ enddo
98+
99+ end
0 commit comments