3 #include "sll_errors.h"
4 #include "sll_memory.h"
5 #include "sll_working_precision.h"
52 sll_real64,
intent(in) :: dt
53 sll_int32,
intent(in) :: num_time_points
54 sll_real64,
dimension(:),
intent(out) :: time_points
58 if (
size(time_points) < num_time_points)
then
59 print *,
'#bad size for time_points'
60 print *,
'#at line/file:', __line__, __file__
63 do i = 1, num_time_points
64 time_points(i) = real(i - 1, f64)*dt
80 sll_real64,
intent(in) :: r0
81 sll_int32,
intent(in) :: num_time_points
82 sll_real64,
intent(in) :: psipr
83 sll_real64,
intent(in) :: f0
84 sll_real64,
intent(in) :: smallr
85 sll_real64,
dimension(:),
intent(in) :: time_points
86 sll_real64,
dimension(:),
intent(out) :: theta
87 sll_real64,
dimension(:),
intent(out) :: phi
88 sll_real64,
intent(in) :: theta0
89 sll_real64,
intent(in) :: phi0
99 do i = 1, num_time_points - 1
100 dt = time_points(i + 1) - time_points(i)
101 bigr = r0 + smallr*cos(theta(i))
102 theta(i + 1) = theta(i) - psipr/smallr*dt
103 phi(i + 1) = phi(i) + f0/bigr*dt
120 sll_real64,
intent(in) :: r0
121 sll_int32,
intent(in) :: num_time_points
122 sll_real64,
intent(in) :: psipr
123 sll_real64,
intent(in) :: f0
124 sll_real64,
intent(in) :: smallr
125 sll_real64,
dimension(:),
intent(in) :: time_points
126 sll_real64,
dimension(:),
intent(out) :: theta
127 sll_real64,
dimension(:),
intent(out) :: phi
128 sll_real64,
intent(in) :: theta0
129 sll_real64,
intent(in) :: phi0
131 sll_real64 :: params1(2)
133 sll_real64 :: params2(3)
151 do i = 1, num_time_points - 1
152 dt = time_points(i + 1) - time_points(i)
153 k1(1) = func1(theta(i), phi(i), params1)
154 k2(1) = func2(theta(i), phi(i), params2)
155 k1(2) = func1(theta(i) + 0.5_f64*dt*k1(1), phi(i) + 0.5_f64*dt*k2(1), params1)
156 k2(2) = func2(theta(i) + 0.5_f64*dt*k1(1), phi(i) + 0.5_f64*dt*k2(1), params2)
157 k1(3) = func1(theta(i) + 0.5_f64*dt*k1(2), phi(i) + 0.5_f64*dt*k2(2), params1)
158 k2(3) = func2(theta(i) + 0.5_f64*dt*k1(2), phi(i) + 0.5_f64*dt*k2(2), params2)
159 k1(4) = func1(theta(i) + dt*k1(3), phi(i) + dt*k2(3), params1)
160 k2(4) = func2(theta(i) + dt*k1(3), phi(i) + dt*k2(3), params2)
161 theta(i + 1) = theta(i) + (dt/6._f64)*(k1(1) + 2._f64*(k1(2) + k1(3)) + k1(4))
162 phi(i + 1) = phi(i) + (dt/6._f64)*(k2(1) + 2._f64*(k2(2) + k2(3)) + k2(4))
169 sll_real64,
intent(in) :: theta
170 sll_real64,
intent(in) :: phi
171 sll_real64,
dimension(:),
intent(in) :: params
186 sll_real64,
intent(in) :: theta
187 sll_real64,
intent(in) :: phi
188 sll_real64,
dimension(:),
intent(in) :: params
199 bigr = r0 + smallr*cos(theta)
217 sll_real64,
intent(in) :: r0
218 sll_int32,
intent(in) :: num_time_points
219 sll_real64,
intent(in) :: psipr
220 sll_real64,
intent(in) :: f0
221 sll_real64,
intent(in) :: smallr
222 sll_real64,
dimension(:),
intent(in) :: time_points
223 sll_real64,
dimension(:),
intent(out) :: theta
224 sll_real64,
dimension(:),
intent(out) :: phi
225 sll_real64,
intent(in) :: theta0
226 sll_real64,
intent(in) :: phi0
234 do i = 1, num_time_points
235 theta(i) = theta0 - psipr/smallr*(time_points(i) - time_points(1))
243 sll_real64,
intent(in) :: r0
244 sll_real64,
intent(in) :: smallr
245 sll_real64,
intent(in) :: x
254 k = real(floor(xx), f64)
256 if (alpha < 1.e-12)
then
259 res = tan((-0.5_f64 + alpha)*
sll_p_pi)
260 res = atan((r0 - smallr)/sqrt(r0**2 - smallr**2)*res)
263 res = 2._f64/(sqrt(r0**2 - smallr**2))*res
269 sll_real64,
intent(in) :: r0
270 sll_real64,
intent(in) :: smallr
271 sll_real64,
intent(in) :: x
279 xx = 0.5_f64*x*sqrt(r0**2 - smallr**2)
281 k = real(floor(xx), f64)
283 if (alpha < 1.e-12)
then
286 res = tan((-0.5_f64 + alpha)*
sll_p_pi)
287 res = atan(sqrt(r0**2 - smallr**2)/(r0 - smallr)*res)
295 sll_real64,
intent(inout) :: x
296 sll_real64,
intent(in) :: l
299 x = x - real(floor(x), f64)
305 sll_real64,
dimension(:),
intent(in) :: in
306 sll_real64,
dimension(:),
intent(out) :: out
307 sll_int32,
intent(in) :: num_points
308 sll_real64,
intent(in) :: l
312 if (
size(in) < num_points)
then
313 print *,
'#problem of size of in',
size(in), num_points
314 print *,
'#at line/file', __line__, __file__
317 if (
size(out) < num_points)
then
318 print *,
'#problem of size of out',
size(out), num_points
319 print *,
'#at line/file', __line__, __file__
331 sll_real64,
dimension(:, :),
intent(inout) :: inout
332 sll_int32,
intent(in) :: num_points1
333 sll_int32,
intent(in) :: num_points2
334 sll_real64,
intent(in) :: l
339 if (
size(inout, 1) < num_points1)
then
340 print *,
'#problem of size1 of inout',
size(inout, 1), num_points1
341 print *,
'#at line/file', __line__, __file__
344 if (
size(inout, 2) < num_points2)
then
345 print *,
'#problem of size2 of inout',
size(inout, 2), num_points2
346 print *,
'#at line/file', __line__, __file__
350 do i2 = 1, num_points2
351 do i1 = 1, num_points1
359 sll_real64,
dimension(:),
intent(out) :: array
360 sll_real64,
intent(in) :: xmin
361 sll_real64,
intent(in) :: xmax
362 sll_int32,
intent(in) :: npts
367 dx = (xmax - xmin)/real(npts - 1, f64)
370 array(i) = xmin + real(i - 1, f64)*dx
376 sll_real64,
dimension(:),
intent(in) :: theta_in
377 sll_real64,
dimension(:),
intent(in) :: phi_in
378 sll_int32,
intent(in) :: num_points1
379 sll_int32,
intent(in) :: num_points2
380 sll_real64,
intent(in) :: dt
381 sll_real64,
dimension(:),
intent(in) :: params
382 sll_real64,
dimension(:, :),
intent(out) :: theta_out
383 sll_real64,
dimension(:, :),
intent(out) :: phi_out
396 if (
size(params) < 4)
then
397 print *,
'#size of params not good',
size(params)
398 print *,
'#at line/file', __line__, __file__
407 do j = 1, num_points2
408 do i = 1, num_points1
409 bigr = r0 + smallr*cos(theta_in(i))
410 theta_out(i, j) = theta_in(i) - psipr/smallr*dt
411 phi_out(i, j) = phi_in(j) + f0/bigr*dt
418 sll_real64,
dimension(:),
intent(in) :: theta_in
419 sll_real64,
dimension(:),
intent(in) :: phi_in
420 sll_int32,
intent(in) :: num_points1
421 sll_int32,
intent(in) :: num_points2
422 sll_real64,
intent(in) :: dt
423 sll_real64,
dimension(:),
intent(in) :: params
424 sll_real64,
dimension(:, :),
intent(out) :: theta_out
425 sll_real64,
dimension(:, :),
intent(out) :: phi_out
439 sll_real64 :: params1(2)
441 sll_real64 :: params2(3)
445 if (
size(params) < 4)
then
446 print *,
'#size of params not good',
size(params)
447 print *,
'#at line/file', __line__, __file__
464 do j = 1, num_points2
465 do i = 1, num_points1
466 k1(1) = func1(theta_in(i), phi_in(j), params1)
467 k2(1) = func2(theta_in(i), phi_in(j), params2)
468 k1(2) = func1(theta_in(i) + 0.5_f64*dt*k1(1), phi_in(j) + 0.5_f64*dt*k2(1), params1)
469 k2(2) = func2(theta_in(i) + 0.5_f64*dt*k1(1), phi_in(j) + 0.5_f64*dt*k2(1), params2)
470 k1(3) = func1(theta_in(i) + 0.5_f64*dt*k1(2), phi_in(j) + 0.5_f64*dt*k2(2), params1)
471 k2(3) = func2(theta_in(i) + 0.5_f64*dt*k1(2), phi_in(j) + 0.5_f64*dt*k2(2), params2)
472 k1(4) = func1(theta_in(i) + dt*k1(3), phi_in(j) + dt*k2(3), params1)
473 k2(4) = func2(theta_in(i) + dt*k1(3), phi_in(j) + dt*k2(3), params2)
474 theta_out(i, j) = theta_in(i) + (dt/6._f64)*(k1(1) + 2._f64*(k1(2) + k1(3)) + k1(4))
475 phi_out(i, j) = phi_in(j) + (dt/6._f64)*(k2(1) + 2._f64*(k2(2) + k2(3)) + k2(4))
482 sll_real64,
dimension(:),
intent(in) :: theta_in
483 sll_real64,
dimension(:),
intent(in) :: phi_in
484 sll_int32,
intent(in) :: num_points1
485 sll_int32,
intent(in) :: num_points2
486 sll_real64,
intent(in) :: dt
487 sll_real64,
dimension(:),
intent(in) :: params
488 sll_real64,
dimension(:, :),
intent(out) :: theta_out
489 sll_real64,
dimension(:, :),
intent(out) :: phi_out
502 if (
size(params) < 4)
then
503 print *,
'#size of params not good',
size(params)
504 print *,
'#at line/file', __line__, __file__
513 do j = 1, num_points2
514 do i = 1, num_points1
515 bigr = r0 + smallr*cos(theta_in(i))
516 theta_out(i, j) = theta_in(i) - psipr/smallr*dt
517 phi_out(i, j) = phi_in(j) &
518 - f0*smallr/psipr*( &
534 sll_int32,
intent(in) :: num_points1
535 sll_int32,
intent(in) :: num_points2
536 sll_real64,
dimension(:, :),
intent(in) :: eta1
537 sll_real64,
dimension(:, :),
intent(in) :: eta2
538 sll_real64,
dimension(:, :),
intent(in) :: data_in
539 sll_real64,
dimension(num_points1, num_points2) :: data_out
540 sll_real64,
dimension(:),
intent(in) :: params
546 sll_int32 :: hermite_p
551 sll_real64,
dimension(:, :, :),
allocatable :: hermite_buf
554 sll_real64 :: eta1_min
555 sll_real64 :: eta1_max
556 sll_real64 :: eta2_min
557 sll_real64 :: eta2_max
560 sll_real64,
dimension(:),
allocatable :: lag_buf
561 sll_real64,
dimension(:),
allocatable :: lag_x
562 sll_real64 :: eta1_loc
563 sll_real64 :: eta2_loc
581 hermite_p = int(params(5), i32)
582 lag_r = int(params(6), i32)
583 lag_s = int(params(7), i32)
586 eta2_min = params(10)
587 eta2_max = params(11)
589 lag_p = lag_s - lag_r
591 sll_allocate(hermite_buf(3, num_points1, num_points2), ierr)
603 sll_allocate(lag_buf(lag_r:lag_s), ierr)
604 sll_allocate(lag_x(lag_r:lag_s), ierr)
606 lag_x(i) = real(i, f64)
609 tmp1 = (eta2_max - eta2_min)/real(num_points2 - 1, f64)*(-psipr)/(f0*smallr)
610 do j = 1, num_points2
611 do i = 1, num_points1
612 eta2_loc = eta2(i, j)
615 tmp2 = tmp2 - eta2_loc*tmp1
617 j0_loc = modulo(j0 + jj + num_points2 - 1, num_points2 - 1) + 1
623 w(1) = (2._f64*eta1_loc + 1)*(1._f64 - eta1_loc)*(1._f64 - eta1_loc)
624 w(2) = eta1_loc*eta1_loc*(3._f64 - 2._f64*eta1_loc)
625 w(3) = eta1_loc*(1._f64 - eta1_loc)*(1._f64 - eta1_loc)
626 w(4) = eta1_loc*eta1_loc*(eta1_loc - 1._f64)
631 lag_buf(jj) = w(1)*hermite_buf(1, i0, j0_loc) &
632 + w(2)*hermite_buf(1, i0 + 1, j0_loc) &
633 + w(3)*hermite_buf(2, i0, j0_loc) &
634 + w(4)*hermite_buf(3, i0, j0_loc)
645 lag_x(lag_r:lag_s), &
646 lag_buf(lag_r:lag_s))
660 sll_real64,
dimension(:, :, :),
intent(out) :: w
661 sll_int32,
dimension(:, :),
intent(out) :: w_cell
662 sll_int32,
intent(in) :: num_points1
663 sll_int32,
intent(in) :: r
664 sll_int32,
intent(in) :: s
665 sll_real64,
dimension(:, :),
intent(in) :: eta1_pos
666 sll_real64,
intent(in) :: eta1_min
667 sll_real64,
intent(in) :: eta1_max
671 sll_real64 :: w_loc_tmp(r:s)
672 sll_real64 :: w_loc(s - r)
674 sll_real64 :: eta1_loc
675 sll_real64 :: w_basis(4)
677 character(len=*),
parameter :: fun =
"compute_w_hermite_aligned"
679 if (r > 0 .or. s < 0)
then
680 print *,
'#r,s=', r, s
681 print *,
'#not treated'
682 sll_error(fun,
'#bad value of r and s')
684 if (
size(w, 1) < 4)
then
685 sll_error(fun,
'#bad size1 for w')
687 if (
size(w, 2) < s - r)
then
688 sll_error(fun,
'#bad size2 for w')
690 if (
size(w, 3) < num_points1)
then
691 sll_error(fun,
'#bad size3 for w')
693 if (
size(eta1_pos, 1) < s - r)
then
694 sll_error(fun,
'#bad size1 for eta1_pos')
696 if (
size(eta1_pos, 2) < num_points1)
then
697 sll_error(fun,
'#bad size2 for eta1_pos')
701 w_loc(1:-r) = w_loc_tmp(r:-1)
702 w_loc(-r + 1:s) = w_loc_tmp(1:s)
704 do i = 1, num_points1
706 eta1_loc = eta1_pos(ell, i)
710 w_basis(1) = (2._f64*eta1_loc + 1)*(1._f64 - eta1_loc)*(1._f64 - eta1_loc)
711 w_basis(2) = eta1_loc*eta1_loc*(3._f64 - 2._f64*eta1_loc)
712 w_basis(3) = eta1_loc*(1._f64 - eta1_loc)*(1._f64 - eta1_loc)
713 w_basis(4) = eta1_loc*eta1_loc*(eta1_loc - 1._f64)
715 w(ii, ell, i) = w_loc(ell)*w_basis(ii)
728 w_cell_aligned_left, &
730 w_cell_aligned_right, &
732 sll_real64,
dimension(:, :),
intent(in) :: f
733 sll_int32,
intent(in) :: num_points1
734 sll_int32,
intent(in) :: num_points2
735 sll_int32,
intent(in) :: p1
736 sll_real64,
dimension(:, :, :),
intent(in) :: w_aligned_left
737 sll_real64,
dimension(:, :, :),
intent(in) :: w_aligned_right
738 sll_int32,
dimension(:, :),
intent(in) :: w_cell_aligned_left
739 sll_int32,
dimension(:, :),
intent(in) :: w_cell_aligned_right
740 sll_real64,
dimension(:, :, :),
intent(out) :: buf
742 sll_real64 :: w_left(-p1/2:(p1 + 1)/2)
743 sll_real64 :: w_right((-p1 + 1)/2:p1/2 + 1)
756 r_right = (-p1 + 1)/2
759 if (((2*p1/2) - p1) == 0)
then
760 w_right(r_right:s_right) = w_left(r_left:s_left)
762 w_right(r_right:s_right) = -w_left(s_left:r_left:-1)
766 do j = 1, num_points2
767 do i = 1, num_points1
768 buf(1, i, j) = f(i, j)
770 do ii = r_left, s_left
771 ind = modulo(i + ii - 2 + num_points1, num_points1 - 1) + 1
772 tmp = tmp + w_left(ii)*f(ind, j)
776 do ii = r_right, s_right
777 ind = modulo(i + ii - 2 + num_points1, num_points1 - 1) + 1
778 tmp = tmp + w_right(ii)*f(ind, j)
787 print *, w_aligned_left, &
788 w_cell_aligned_left, &
Fortran module where set some physical and mathematical constants.
real(kind=f64), parameter, public sll_p_pi
subroutine, public sll_s_compute_time_points(dt, num_time_points, time_points)
real(kind=f64) function, dimension(num_points1, num_points2), public sll_f_interpolate2d_toroidal(num_points1, num_points2, data_in, eta1, eta2, params)
subroutine, public sll_s_compute_analytic_field(R0, time_points, num_time_points, psipr, F0, smallr, theta, phi, theta0, phi0)
subroutine, public sll_s_compute_modulo_vect(in, out, num_points, L)
subroutine, public sll_s_compute_linspace(array, xmin, xmax, Npts)
real(kind=f64) function toroidal_1(theta, phi, params)
subroutine, public sll_s_compute_feet_rk4(theta_in, phi_in, num_points1, num_points2, dt, params, theta_out, phi_out)
real(kind=f64) function, public sll_f_compute_inverse_invr_integral(R0, smallr, x)
real(kind=f64) function, public sll_f_compute_invr_integral(R0, smallr, x)
subroutine, public sll_s_compute_feet_euler(theta_in, phi_in, num_points1, num_points2, dt, params, theta_out, phi_out)
subroutine, public sll_s_compute_modulo_vect2d_inplace(inout, num_points1, num_points2, L)
subroutine, public sll_s_compute_rk4_field(R0, time_points, num_time_points, psipr, F0, smallr, theta, phi, theta0, phi0)
subroutine compute_modulo(x, L)
subroutine, public sll_s_compute_euler_field(R0, time_points, num_time_points, psipr, F0, smallr, theta, phi, theta0, phi0)
subroutine compute_hermite_derivatives_aligned(f, num_points1, num_points2, p1, w_aligned_left, w_cell_aligned_left, w_aligned_right, w_cell_aligned_right, buf)
subroutine, public sll_s_compute_feet_analytic(theta_in, phi_in, num_points1, num_points2, dt, params, theta_out, phi_out)
subroutine compute_w_hermite_aligned(w, w_cell, num_points1, r, s, eta1_pos, eta1_min, eta1_max)
real(kind=f64) function toroidal_2(theta, phi, params)
subroutine, public sll_s_localize_per(i, x, xmin, xmax, N)
subroutine, public sll_s_compute_hermite_derivatives_periodic1(f, num_points1, num_points2, p, buf)
subroutine, public sll_s_compute_w_hermite(w, r, s)
real(kind=f64) function, public sll_f_lagrange_interpolate(x, degree, xi, yi)