Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发现粘性力功率计算的实现和公式(4.59)有出入 #11

Closed
wants to merge 8 commits into from

Conversation

ZZPHUB
Copy link

@ZZPHUB ZZPHUB commented Dec 2, 2023

公式(4.59)中计算粘性力功率的项是:
$\frac{\mu_i}{2 \rho_i}\varepsilon_i^{\alpha \beta} \varepsilon_j^{\alpha \beta} $
但是在/src/single_step/internal_force.f90中的粘性力功率实现代码是:

do i = 1, ntotal
        !计算粘性力功率
        !     viscous entropy tds/dt = 1/2 eta/rho tab tab

        if (visc) then
        !visc = .true. : consider viscosity,
        !       .false.: no viscosity.
        !visc即是否考虑粘性
!这里计算是否不正确,和公式(4.59)也不相同---------------------------!
            if (dim == 1) then
                tdsdt(i) = txx(i)*txx(i)
            else if (dim == 2) then
                tdsdt(i) = txx(i)*txx(i) + 2._rk*txy(i)*txy(i) + tyy(i)*tyy(i)
            else if (dim == 3) then
                tdsdt(i) = txx(i)*txx(i) + 2._rk*txy(i)*txy(i) + 2._rk*txz(i)*txz(i) + &
                           tyy(i)*tyy(i) + 2._rk*tyz(i)*tyz(i) + tzz(i)*tzz(i)
!---------------------------------------------------------------------!
            end if
            tdsdt(i) = 0.5_rk*eta(i)/rho(i)*tdsdt(i)
        end if
end do

我认为应该修改为如下形式

   !粒子粘性力的功率和本身已经影响域内的粒子有关,而不是只和本身有关。且上述的写法和公式(4.59)也有出入。
    !我认为应该这么实现粘性力功率的计算
    !  if (visc) then
    !       do k=1,niac
    !          i = pair_i(k)
    !          j = pair_j(k)

    !          if (dim == 1) then
    !              tdsdt(i) = tdsdt(i) + txx(i)*txx(j)
    !              tdsdt(j) = tdsdt(j) + txx(j)*txx(i)
    !          else if (dim == 2) then
    !              tdsdt(i) = tdsdt(i) + txx(i)*txx(j) + 2._rk*txy(i)*txy(j) + tyy(i)*tyy(j)
    !              tdsdt(j) = tdsdt(j) + txx(i)*txx(j) + 2._rk*txy(i)*txy(j) + tyy(i)*tyy(j)
    !          else if (dim == 3) then
    !                  tdsdt(i) = tdsdt(i) + txx(i)*txx(j) + 2._rk*txy(i)*txy(j) + 2._rk*txz(i)*txz(j) + &
    !                             tyy(i)*tyy(j) + 2._rk*tyz(i)*tyz(j) + tzz(i)*tzz(j)
    !                  tdsdt(j) = tdsdt(j) + txx(i)*txx(j) + 2._rk*txy(i)*txy(j) + 2._rk*txz(i)*txz(j) + &
    !                             tyy(i)*tyy(j) + 2._rk*tyz(i)*tyz(j) + tzz(i)*tzz(j)
    !          end if
    !       end do 
    !       tdsdt(i) = 0.5_rk*eta(i)/rho(i)*tdsdt(i)
    !   end if

@zoziha
Copy link
Owner

zoziha commented Dec 4, 2023

@ZZP-DMU,感谢提出意见和修改,我将尽可能在这周内抽空探查所述问题。

! tdsdt(j) = tdsdt(j) + txx(i)*txx(j) + 2._rk*txy(i)*txy(j) + 2._rk*txz(i)*txz(j) + &
! tyy(i)*tyy(j) + 2._rk*tyz(i)*tyz(j) + tzz(i)*tzz(j)
! end if
! end do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,你应该是对的。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但由于这里只会影响能量守恒公式的计算结果(内能),不会影响程序的加速度求解,不知道粘性熵的具体公式,建议保持原状,保留你的注释。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tdsdt似乎是指粘性力功率,粘性力的公式书中在能量方程中分离出来了。不知道是否是指这个

! tyy(i)*tyy(j) + 2._rk*tyz(i)*tyz(j) + tzz(i)*tzz(j)
! end if
! end do
! tdsdt(i) = 0.5_rk*eta(i)/rho(i)*tdsdt(i)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段应该是:

do i = 1, ntotal
    tdsdt(i) = 0.5_rk*eta(i)/rho(i)*tdsdt(i)
end do

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,应该是这样的

@@ -53,6 +53,7 @@ subroutine kernel(r, dx, hsml, w, dwdx)
w = factor*1._rk/6._rk*(2._rk - q)**3
do d = 1, dim
dwdx(d) = -factor*1._rk/6._rk*3.*(2._rk - q)**2/hsml*(dx(d)/r)
!dwda(d) =-factor*(2._rk - q)**2/2*hsml*(dx(d)/r)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dwdx(d)应该没有问题?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原来的写着比较冗余,所以我简化了一下

@@ -82,6 +82,7 @@ subroutine direct_find(itimestep, ntotal, hsml, x, niac, pair_i, pair_j, w, dwdx
!> kernel and derivations of kernel

call kernel(r, dxiac, mhsml, w(niac), tdwdx)
!kernel(r, dx, hsml, w, dwdx)
do d = 1, dim
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的注释是?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个注释是kernel定义的形式,我在这边注释便于阅读

@@ -156,32 +156,62 @@ subroutine int_force(itimestep, dt, ntotal, hsml, mass, vx, niac, rho, eta, pair
hvcc = 0._rk
do d = 1, dim
hvcc = hvcc + dvx(d)*dwdx(d, k)
!看不懂hvcc&vcc到底是在计算什么东西
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实没有从函数中输出或者被使用

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在/src/sing_step/art_heat.f90中vcc&hvcc都出现了,应该和这里类似,表示速度的散度。但这里确实没有使用vcc&hvcc

do i = 1, ntotal
rho(i) = rho(i)/wi(i)
end do
end if
!?归一化,不太理解?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好像是某些无重力场景会涉及到归一化密度。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是修正后的密度求和公式吗?

@@ -52,6 +52,14 @@ subroutine ext_force(ntotal, mass, x, niac, pair_i, pair_j, itype, hsml, dvxdt)
do i = 1, ntotal
dvxdt(dim, i) = -9.8_rk
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可能写成:

dvxdt(dim, i) = dvxdt(dim, i) - 9.8_rk

但意义差不多,问题不大。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,dvxdt仅是输出的参数。
我之前的理解是:如果从外部传入的话,dvxdt可能会有非零初始值。

@ZZPHUB ZZPHUB closed this Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants