cubic_spline_kernel Subroutine

public pure subroutine cubic_spline_kernel(skf, r, dx, w, dwdx)

Smoothed kernel function: Cubic spline
三次样条曲线 (monaghan 1985)
计算光滑函数 及其导数 的子例程

Arguments

Type IntentOptional Attributes Name
class(smoothed_kernel_function_type), intent(in) :: skf
real(kind=rk), intent(in) :: r

Euclidean distance between two points
欧氏距离

real(kind=rk), intent(in) :: dx(2)

Dimensional distance between two points
对应坐标轴距离

real(kind=rk), intent(out) :: w

kernel value
核函数值

real(kind=rk), intent(out) :: dwdx(2)

Derivative of kernel value
核函数导数


Contents

Source Code


Source Code

    pure subroutine cubic_spline_kernel(skf, r, dx, w, dwdx)
        class(smoothed_kernel_function_type), intent(in) :: skf
        real(rk), intent(in) :: r           !! Euclidean distance between two points <br>
                                            !! 欧氏距离
        real(rk), intent(in) :: dx(2)       !! Dimensional distance between two points <br>
                                            !! 对应坐标轴距离
        real(rk), intent(out) :: w          !! kernel value <br>
                                            !! 核函数值
        real(rk), intent(out) :: dwdx(2)    !! Derivative of kernel value <br>
                                            !! 核函数导数
        real(rk) :: q

        q = r/skf%hsml
        if (q <= 1.0_rk) then
            w = skf%factor*(r23 - q*q + q**3/2)
            dwdx = skf%factor*(-2.0_rk + 1.5_rk*q)*dx/(skf%hsml*skf%hsml)     ! 计算机原则,先乘后除
        else if (q > 1.0_rk) then
            w = skf%factor*(2.0_rk - q)**3/6.0_rk
            dwdx = -skf%factor*(2.0_rk - q)**2*dx/(2.0_rk*skf%hsml*r)
        end if

    end subroutine cubic_spline_kernel