3 次 Hermite 補間した S(z) と、同じ多項式の微分 dS/dz。電場は電位の勾配と一致する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(periodic_shell_mean_plan_type), | intent(in) | :: | plan | |||
| type(periodic_shell_mean_state_type), | intent(in) | :: | state | |||
| real(kind=dp), | intent(in) | :: | z | |||
| real(kind=dp), | intent(out) | :: | value | |||
| real(kind=dp), | intent(out) | :: | slope |
pure subroutine eval_periodic_shell_mean(plan, state, z, value, slope) type(periodic_shell_mean_plan_type), intent(in) :: plan type(periodic_shell_mean_state_type), intent(in) :: state real(dp), intent(in) :: z real(dp), intent(out) :: value, slope integer(i32) :: k real(dp) :: t, t2, t3, h00, h10, h01, h11, d00, d10, d01, d11 value = 0.0_dp slope = 0.0_dp if (.not. plan%ready .or. .not. allocated(state%value)) return t = (z - plan%z0)/plan%dz k = min(max(int(floor(t), i32), 0_i32), plan%nz - 2_i32) t = min(max(t - real(k, dp), 0.0_dp), 1.0_dp) k = k + 1_i32 t2 = t*t t3 = t2*t h00 = 2.0_dp*t3 - 3.0_dp*t2 + 1.0_dp h10 = t3 - 2.0_dp*t2 + t h01 = -2.0_dp*t3 + 3.0_dp*t2 h11 = t3 - t2 d00 = 6.0_dp*t2 - 6.0_dp*t d10 = 3.0_dp*t2 - 4.0_dp*t + 1.0_dp d01 = -6.0_dp*t2 + 6.0_dp*t d11 = 3.0_dp*t2 - 2.0_dp*t value = h00*state%value(k) + h10*plan%dz*state%slope(k) + h01*state%value(k + 1_i32) + & h11*plan%dz*state%slope(k + 1_i32) slope = (d00*state%value(k) + d01*state%value(k + 1_i32))/plan%dz + d10*state%slope(k) + & d11*state%slope(k + 1_i32) end subroutine eval_periodic_shell_mean