42 real(dp),
allocatable :: psi(:, :)
45 real(dp),
allocatable :: phi_cav(:)
48 real(dp),
allocatable :: gradphi_cav(:, :)
50 real(dp),
allocatable :: phi_grid(:, :)
52 real(dp),
allocatable :: zeta(:)
54 real(dp) :: force_time
61 real(dp),
allocatable :: phi(:, :)
64 real(dp),
allocatable :: xs(:, :)
71 real(dp),
allocatable :: xs_rel_diff(:)
77 real(dp),
allocatable :: sgrid(:, :)
80 real(dp),
allocatable :: s(:, :)
87 real(dp),
allocatable :: s_rel_diff(:)
97 real(dp),
allocatable :: phiinf(:, :)
100 real(dp),
allocatable :: phieps(:, :)
103 integer :: phieps_niter
107 real(dp),
allocatable :: phieps_rel_diff(:)
110 real(dp) :: phieps_time
114 real(dp),
allocatable :: g(:, :)
117 real(dp),
allocatable :: y(:, :)
123 real(dp),
allocatable :: y_rel_diff(:)
128 real(dp),
allocatable :: ygrid(:, :)
132 real(dp),
allocatable :: q(:, :)
135 real(dp),
allocatable :: qgrid(:, :)
142 real(dp),
allocatable :: rhs_lpb(:,:,:)
145 real(dp),
allocatable :: rhs_adj_lpb(:,:,:)
148 real(dp),
allocatable :: x_lpb(:,:,:)
152 real(dp),
allocatable :: x_adj_lpb(:,:,:)
155 real(dp),
allocatable :: g_lpb(:,:)
158 real(dp),
allocatable :: f_lpb(:,:)
161 integer :: x_lpb_niter
164 integer :: x_adj_lpb_niter
167 real(dp) :: x_lpb_time
170 real(dp) :: x_adj_lpb_time
174 real(dp),
allocatable :: x_lpb_rel_diff(:)
178 real(dp),
allocatable :: x_adj_lpb_rel_diff(:)
181 real(dp),
allocatable :: zeta_dip(:, :)
182 real(dp),
allocatable :: x_adj_re_grid(:, :)
183 real(dp),
allocatable :: x_adj_r_grid(:, :)
184 real(dp),
allocatable :: x_adj_e_grid(:, :)
185 real(dp),
allocatable :: phi_n(:, :)
187 real(dp) :: hsp_adj_time
191 logical :: adjoint_rhs_done
192 logical :: guess_done
194 logical :: adjoint_guess_done
195 logical :: adjoint_solved
205 real(dp),
allocatable :: phi_cav(:)
208 real(dp),
allocatable :: e_cav(:, :)
211 real(dp),
allocatable :: g_cav(:, :, :)
213 logical :: do_phi = .false.
215 logical :: do_e = .false.
217 logical :: do_g = .false.
224 type(ddx_params_type) :: params
225 type(ddx_constants_type) :: constants
226 type(ddx_workspace_type) :: workspace
266subroutine allocate_model(nsph, x, y, z, rvdw, model, lmax, ngrid, force, fmm, pm, &
267 & pl, se, eta, eps, kappa, matvecmem, maxiter, jacobi_ndiis, nproc, &
268 & output_filename, ddx_data, ddx_error)
271 integer,
intent(in) :: nsph, model, lmax, force, fmm, pm, pl, &
272 & matvecmem, maxiter, jacobi_ndiis, &
274 real(dp),
intent(in):: x(nsph), y(nsph), z(nsph), &
275 & rvdw(nsph), se, eta, eps, kappa
276 character(len=255),
intent(in) :: output_filename
278 type(
ddx_type),
target,
intent(out) :: ddx_data
279 type(ddx_error_type),
intent(inout) :: ddx_error
281 real(dp),
allocatable :: csph(:, :)
283 if (ddx_error % flag .ne. 0)
then
284 call update_error(ddx_error,
"allocate_model received input in error state, " // &
289 allocate(csph(3, nsph), stat=istatus)
290 if (istatus .ne. 0)
then
291 call update_error(ddx_error,
"Allocation failed in allocate_model")
297 call params_init(model, force, eps, kappa, eta, se, lmax, ngrid, &
298 & matvecmem, maxiter, jacobi_ndiis, fmm, pm, pl, nproc, nsph, &
299 & csph, rvdw, output_filename, ddx_data % params, ddx_error)
300 if (ddx_error % flag .ne. 0)
then
301 call update_error(ddx_error,
"params_init returned an error, exiting")
304 call constants_init(ddx_data % params, ddx_data % constants, ddx_error)
305 if (ddx_error % flag .ne. 0)
then
306 call update_error(ddx_error,
"constants_init returned an error, exiting")
310 & ddx_data % workspace, ddx_error)
311 if (ddx_error % flag .ne. 0)
then
312 call update_error(ddx_error,
"workspace_init returned an error, exiting")
315 deallocate(csph, stat=istatus)
316 if (istatus .ne. 0)
then
317 call update_error(ddx_error,
"Deallocation failed in allocate_model")
331 type(
ddx_type),
intent(inout) :: ddx_data
332 type(ddx_error_type),
intent(inout) :: ddx_error
353 type(ddx_error_type),
intent(inout) :: ddx_error
359 if (params % model .eq. 3)
then
360 if (params % force .eq. 1)
then
361 electrostatics % do_phi = .true.
362 electrostatics % do_e = .true.
363 electrostatics % do_g = .true.
365 electrostatics % do_phi = .true.
366 electrostatics % do_e = .true.
367 electrostatics % do_g = .false.
370 if (params % force .eq. 1)
then
371 electrostatics % do_phi = .true.
372 electrostatics % do_e = .true.
373 electrostatics % do_g = .false.
375 electrostatics % do_phi = .true.
376 electrostatics % do_e = .false.
377 electrostatics % do_g = .false.
382 if (electrostatics % do_phi)
then
383 allocate(electrostatics % phi_cav(constants % ncav), stat=info)
384 if (info .ne. 0)
then
385 call update_error(ddx_error, &
386 &
"Allocation failed in allocate_electrostatics")
390 if (electrostatics % do_e)
then
391 allocate(electrostatics % e_cav(3, constants % ncav), stat=info)
392 if (info .ne. 0)
then
393 call update_error(ddx_error, &
394 &
"Allocation failed in allocate_electrostatics")
398 if (electrostatics % do_g)
then
399 allocate(electrostatics % g_cav(3, 3, constants % ncav), stat=info)
400 if (info .ne. 0)
then
401 call update_error(ddx_error, &
402 &
"Allocation failed in allocate_electrostatics")
417 type(ddx_error_type),
intent(inout) :: ddx_error
423 if (
allocated(electrostatics % phi_cav))
then
424 deallocate(electrostatics % phi_cav, stat=info)
425 if (info .ne. 0)
then
426 call update_error(ddx_error, &
427 &
"Deallocation failed in deallocate_electrostatics")
430 if (
allocated(electrostatics % e_cav))
then
431 deallocate(electrostatics % e_cav, stat=info)
432 if (info .ne. 0)
then
433 call update_error(ddx_error, &
434 &
"Deallocation failed in deallocate_electrostatics")
437 if (
allocated(electrostatics % g_cav))
then
438 deallocate(electrostatics % g_cav, stat=info)
439 if (info .ne. 0)
then
440 call update_error(ddx_error, &
441 &
"Deallocation failed in deallocate_electrostatics")
459 type(ddx_error_type),
intent(inout) :: ddx_error
462 state % rhs_done = .false.
463 state % adjoint_rhs_done = .false.
464 state % guess_done = .false.
465 state % solved = .false.
466 state % adjoint_guess_done = .false.
467 state % adjoint_solved = .false.
469 allocate(state % psi(constants % nbasis, params % nsph), stat=istatus, source=0.0_dp)
470 if (istatus .ne. 0)
then
471 call update_error(ddx_error,
"allocate_state: `psi` allocation failed")
474 allocate(state % phi_cav(constants % ncav), stat=istatus, source=0.0_dp)
475 if (istatus .ne. 0)
then
476 call update_error(ddx_error,
"allocate_state: `phi_cav` allocation failed")
479 allocate(state % gradphi_cav(3, constants % ncav), stat=istatus, source=0.0_dp)
480 if (istatus .ne. 0)
then
481 call update_error(ddx_error, &
482 &
"allocate_state: `gradphi_cav` allocation failed")
485 allocate(state % q(constants % nbasis, &
486 & params % nsph), stat=istatus, source=0.0_dp)
487 if (istatus .ne. 0)
then
488 call update_error(ddx_error,
"allocate_state: `q` " // &
489 &
"allocation failed")
494 if (params % model .eq. 1)
then
495 allocate(state % phi_grid(params % ngrid, &
496 & params % nsph), stat=istatus, source=0.0_dp)
497 if (istatus .ne. 0)
then
498 call update_error(ddx_error,
"allocate_state: `phi_grid` " // &
499 &
"allocation failed")
502 allocate(state % phi(constants % nbasis, &
503 & params % nsph), stat=istatus, source=0.0_dp)
504 if (istatus .ne. 0)
then
505 call update_error(ddx_error,
"allocate_state: `phi` " // &
506 &
"allocation failed")
509 allocate(state % xs(constants % nbasis, &
510 & params % nsph), stat=istatus, source=0.0_dp)
511 if (istatus .ne. 0)
then
512 call update_error(ddx_error,
"allocate_state: `xs` " // &
513 &
"allocation failed")
516 allocate(state % xs_rel_diff(params % maxiter), &
517 & stat=istatus, source=0.0_dp)
518 if (istatus .ne. 0)
then
519 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
520 &
"allocation failed")
523 allocate(state % s(constants % nbasis, &
524 & params % nsph), stat=istatus, source=0.0_dp)
525 if (istatus .ne. 0)
then
526 call update_error(ddx_error,
"allocate_state: `s` " // &
527 &
"allocation failed")
530 allocate(state % s_rel_diff(params % maxiter), &
531 & stat=istatus, source=0.0_dp)
532 if (istatus .ne. 0)
then
533 call update_error(ddx_error,
"allocate_state: `s_rel_diff` " // &
534 &
"allocation failed")
537 allocate(state % sgrid(params % ngrid, &
538 & params % nsph), stat=istatus, source=0.0_dp)
539 if (istatus .ne. 0)
then
540 call update_error(ddx_error,
"allocate_state: `sgrid` " // &
541 &
"allocation failed")
544 allocate(state % zeta(constants % ncav), stat=istatus, source=0.0_dp)
545 if (istatus .ne. 0)
then
546 call update_error(ddx_error,
"allocate_state: `zeta` " // &
547 &
"allocation failed")
551 else if (params % model .eq. 2)
then
552 allocate(state % phi_grid(params % ngrid, &
553 & params % nsph), stat=istatus, source=0.0_dp)
554 if (istatus .ne. 0)
then
555 call update_error(ddx_error,
"allocate_state: `phi_grid` " // &
556 &
"allocation failed")
559 allocate(state % phi(constants % nbasis, &
560 & params % nsph), stat=istatus, source=0.0_dp)
561 if (istatus .ne. 0)
then
562 call update_error(ddx_error,
"allocate_state: `phi` " // &
563 &
"allocation failed")
566 allocate(state % phiinf(constants % nbasis, &
567 & params % nsph), stat=istatus, source=0.0_dp)
568 if (istatus .ne. 0)
then
569 call update_error(ddx_error,
"allocate_state: `phiinf` " // &
570 &
"allocation failed")
573 allocate(state % phieps(constants % nbasis, &
574 & params % nsph), stat=istatus, source=0.0_dp)
575 if (istatus .ne. 0)
then
576 call update_error(ddx_error,
"allocate_state: `phieps` " // &
577 &
"allocation failed")
580 allocate(state % phieps_rel_diff(params % maxiter), &
581 & stat=istatus, source=0.0_dp)
582 if (istatus .ne. 0)
then
583 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
584 &
"allocation failed")
587 allocate(state % xs(constants % nbasis, &
588 & params % nsph), stat=istatus, source=0.0_dp)
589 if (istatus .ne. 0)
then
590 call update_error(ddx_error,
"allocate_state: `xs` " // &
591 &
"allocation failed")
594 allocate(state % xs_rel_diff(params % maxiter), &
595 & stat=istatus, source=0.0_dp)
596 if (istatus .ne. 0)
then
597 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
598 &
"allocation failed")
601 allocate(state % s(constants % nbasis, &
602 & params % nsph), stat=istatus, source=0.0_dp)
603 if (istatus .ne. 0)
then
604 call update_error(ddx_error,
"allocate_state: `s` " // &
605 &
"allocation failed")
608 allocate(state % s_rel_diff(params % maxiter), &
609 & stat=istatus, source=0.0_dp)
610 if (istatus .ne. 0)
then
611 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
612 &
"allocation failed")
615 allocate(state % sgrid(params % ngrid, &
616 & params % nsph), stat=istatus, source=0.0_dp)
617 if (istatus .ne. 0)
then
618 call update_error(ddx_error,
"allocate_state: `sgrid` " // &
619 &
"allocation failed")
622 allocate(state % y(constants % nbasis, &
623 & params % nsph), stat=istatus, source=0.0_dp)
624 if (istatus .ne. 0)
then
625 call update_error(ddx_error,
"allocate_state: `y` " // &
626 &
"allocation failed")
629 allocate(state % y_rel_diff(params % maxiter), &
630 & stat=istatus, source=0.0_dp)
631 if (istatus .ne. 0)
then
632 call update_error(ddx_error,
"allocate_state: `y_rel_diff` " // &
633 &
"allocation failed")
636 allocate(state % ygrid(params % ngrid, &
637 & params % nsph), stat=istatus, source=0.0_dp)
638 if (istatus .ne. 0)
then
639 call update_error(ddx_error,
"allocate_state: `ygrid` " // &
640 &
"allocation failed")
643 allocate(state % g(constants % nbasis, &
644 & params % nsph), stat=istatus, source=0.0_dp)
645 if (istatus .ne. 0)
then
646 call update_error(ddx_error,
"allocate_state: `g` " // &
647 &
"allocation failed")
650 allocate(state % qgrid(params % ngrid, &
651 & params % nsph), stat=istatus, source=0.0_dp)
652 if (istatus .ne. 0)
then
653 call update_error(ddx_error,
"allocate_state: `qgrid` " // &
654 &
"allocation failed")
657 allocate(state % zeta(constants % ncav), stat=istatus, source=0.0_dp)
658 if (istatus .ne. 0)
then
659 call update_error(ddx_error,
"allocate_state: `zeta` " // &
660 &
"allocation failed")
664 else if (params % model .eq. 3)
then
665 allocate(state % phi_grid(params % ngrid, &
666 & params % nsph), stat=istatus, source=0.0_dp)
667 if (istatus .ne. 0)
then
668 call update_error(ddx_error,
"allocate_state: `phi_grid` " // &
669 &
"allocation failed")
672 allocate(state % phi(constants % nbasis, &
673 & params % nsph), stat=istatus, source=0.0_dp)
674 if (istatus .ne. 0)
then
675 call update_error(ddx_error,
"allocate_state: `phi` " // &
676 &
"allocation failed")
679 allocate(state % zeta(constants % ncav), stat=istatus, source=0.0_dp)
680 if (istatus .ne. 0)
then
681 call update_error(ddx_error,
"allocate_state: `zeta` " // &
682 &
"allocation failed")
686 allocate(state % x_lpb_rel_diff(params % maxiter), &
687 & stat=istatus, source=0.0_dp)
688 if (istatus .ne. 0)
then
689 call update_error(ddx_error,
"allocate_state: `x_lpb_rel_diff` " // &
690 &
"allocation failed")
693 allocate(state % rhs_lpb(constants % nbasis, &
694 & params % nsph, 2), &
695 & stat=istatus, source=0.0_dp)
696 if (istatus .ne. 0)
then
697 call update_error(ddx_error,
"allocate_state: `rhs_lpb` " // &
698 &
"allocation failed")
701 allocate(state % rhs_adj_lpb(constants % nbasis, &
702 & params % nsph, 2), &
703 & stat=istatus, source=0.0_dp)
704 if (istatus .ne. 0)
then
705 call update_error(ddx_error,
"allocate_state: `rhs_adj_lpb` " // &
706 &
"allocation failed")
709 allocate(state % x_lpb(constants % nbasis, &
710 & params % nsph, 2), &
711 & stat=istatus, source=0.0_dp)
712 if (istatus .ne. 0)
then
713 call update_error(ddx_error,
"allocate_state: `x_lpb` " // &
714 &
"allocation failed")
717 allocate(state % x_adj_lpb(constants % nbasis, &
718 & params % nsph, 2), stat=istatus, source=0.0_dp)
719 if (istatus .ne. 0)
then
720 call update_error(ddx_error,
"allocate_state: `x_adj_lpb` " // &
721 &
"allocation failed")
724 allocate(state % x_adj_lpb_rel_diff(params % maxiter), &
725 & stat=istatus, source=0.0_dp)
726 if (istatus .ne. 0)
then
727 call update_error(ddx_error, &
728 &
"allocate_state: `x_adj_lpb_rel_diff` allocation failed")
731 allocate(state % g_lpb(params % ngrid, &
732 & params % nsph), stat=istatus, source=0.0_dp)
733 if (istatus .ne. 0)
then
734 call update_error(ddx_error,
"allocate_state: `g_lpb` " // &
735 &
"allocation failed")
738 allocate(state % f_lpb(params % ngrid, &
739 & params % nsph), stat=istatus, source=0.0_dp)
740 if (istatus .ne. 0)
then
741 call update_error(ddx_error,
"allocate_state: `f_lpb` " // &
742 &
"allocation failed")
745 allocate(state % zeta_dip(3, constants % ncav), stat=istatus, source=0.0_dp)
746 if (istatus .ne. 0)
then
747 call update_error(ddx_error,
"allocate_state: `zeta_dip` " // &
748 &
"allocation failed")
751 allocate(state % x_adj_re_grid(params % ngrid, params % nsph), &
752 & stat=istatus, source=0.0_dp)
753 if (istatus .ne. 0)
then
754 call update_error(ddx_error,
"allocate_state: `x_adj_re_grid` " // &
755 &
"allocation failed")
758 allocate(state % x_adj_r_grid(params % ngrid, params % nsph), &
759 & stat=istatus, source=0.0_dp)
760 if (istatus .ne. 0)
then
761 call update_error(ddx_error,
"allocate_state: `x_adj_r_grid` " // &
762 &
"allocation failed")
765 allocate(state % x_adj_e_grid(params % ngrid, params % nsph), &
766 & stat=istatus, source=0.0_dp)
767 if (istatus .ne. 0)
then
768 call update_error(ddx_error,
"allocate_state: `x_adj_e_grid` " // &
769 &
"allocation failed")
772 allocate(state % phi_n(params % ngrid, params % nsph), &
773 & stat=istatus, source=0.0_dp)
774 if (istatus .ne. 0)
then
775 call update_error(ddx_error,
"allocate_state: `phi_n` " // &
776 &
"allocation failed")
792 type(ddx_error_type),
intent(inout) :: ddx_error
795 if (
allocated(state % phi_cav))
then
796 deallocate(state % phi_cav, stat=istatus)
797 if (istatus .ne. 0)
then
798 call update_error(ddx_error,
"`phi_cav` deallocation failed!")
802 if (
allocated(state % gradphi_cav))
then
803 deallocate(state % gradphi_cav, stat=istatus)
804 if (istatus .ne. 0)
then
805 call update_error(ddx_error,
"`gradphi_cav` deallocation failed!")
809 if (
allocated(state % psi))
then
810 deallocate(state % psi, stat=istatus)
811 if (istatus .ne. 0)
then
812 call update_error(ddx_error,
"`psi` deallocation failed!")
816 if (
allocated(state % phi_grid))
then
817 deallocate(state % phi_grid, stat=istatus)
818 if (istatus .ne. 0)
then
819 call update_error(ddx_error,
"`phi_grid` deallocation failed!")
823 if (
allocated(state % phi))
then
824 deallocate(state % phi, stat=istatus)
825 if (istatus .ne. 0)
then
826 call update_error(ddx_error,
"`phi` deallocation failed!")
829 if (
allocated(state % phiinf))
then
830 deallocate(state % phiinf, stat=istatus)
831 if (istatus .ne. 0)
then
832 call update_error(ddx_error,
"`phiinf` deallocation failed!")
835 if (
allocated(state % phieps))
then
836 deallocate(state % phieps, stat=istatus)
837 if (istatus .ne. 0)
then
838 call update_error(ddx_error,
"`phieps` deallocation failed!")
841 if (
allocated(state % phieps_rel_diff))
then
842 deallocate(state % phieps_rel_diff, stat=istatus)
843 if (istatus .ne. 0)
then
844 call update_error(ddx_error,
"`phieps_rel_diff` deallocation failed!")
847 if (
allocated(state % xs))
then
848 deallocate(state % xs, stat=istatus)
849 if (istatus .ne. 0)
then
850 call update_error(ddx_error,
"`xs` deallocation failed!")
853 if (
allocated(state % xs_rel_diff))
then
854 deallocate(state % xs_rel_diff, stat=istatus)
855 if (istatus .ne. 0)
then
856 call update_error(ddx_error,
"`xs_rel_diff` deallocation failed!")
859 if (
allocated(state % s))
then
860 deallocate(state % s, stat=istatus)
861 if (istatus .ne. 0)
then
862 call update_error(ddx_error,
"`s` deallocation failed!")
865 if (
allocated(state % s_rel_diff))
then
866 deallocate(state % s_rel_diff, stat=istatus)
867 if (istatus .ne. 0)
then
868 call update_error(ddx_error,
"`s_rel_diff` deallocation failed!")
871 if (
allocated(state % sgrid))
then
872 deallocate(state % sgrid, stat=istatus)
873 if (istatus .ne. 0)
then
874 call update_error(ddx_error,
"`sgrid` deallocation failed!")
877 if (
allocated(state % y))
then
878 deallocate(state % y, stat=istatus)
879 if (istatus .ne. 0)
then
880 call update_error(ddx_error,
"`y` deallocation failed!")
883 if (
allocated(state % y_rel_diff))
then
884 deallocate(state % y_rel_diff, stat=istatus)
885 if (istatus .ne. 0)
then
886 call update_error(ddx_error,
"`y_rel_diff` deallocation failed!")
889 if (
allocated(state % ygrid))
then
890 deallocate(state % ygrid, stat=istatus)
891 if (istatus .ne. 0)
then
892 call update_error(ddx_error,
"`ygrid` deallocation failed!")
895 if (
allocated(state % g))
then
896 deallocate(state % g, stat=istatus)
897 if (istatus .ne. 0)
then
898 call update_error(ddx_error,
"`g` deallocation failed!")
901 if (
allocated(state % q))
then
902 deallocate(state % q, stat=istatus)
903 if (istatus .ne. 0)
then
904 call update_error(ddx_error,
"`q` deallocation failed!")
907 if (
allocated(state % qgrid))
then
908 deallocate(state % qgrid, stat=istatus)
909 if (istatus .ne. 0)
then
910 call update_error(ddx_error,
"`qgrid` deallocation failed!")
913 if (
allocated(state % zeta))
then
914 deallocate(state % zeta, stat=istatus)
915 if (istatus .ne. 0)
then
916 call update_error(ddx_error,
"`zeta` deallocation failed!")
919 if (
allocated(state % x_lpb))
then
920 deallocate(state % x_lpb, stat=istatus)
921 if (istatus .ne. 0)
then
922 call update_error(ddx_error,
"`x_lpb` deallocation failed!")
925 if (
allocated(state % x_lpb_rel_diff))
then
926 deallocate(state % x_lpb_rel_diff, stat=istatus)
927 if (istatus .ne. 0)
then
928 call update_error(ddx_error,
"`x_lpb_rel_diff` deallocation failed!")
931 if (
allocated(state % x_adj_lpb))
then
932 deallocate(state % x_adj_lpb, stat=istatus)
933 if (istatus .ne. 0)
then
934 call update_error(ddx_error,
"x_adj_lpb deallocation failed!")
937 if (
allocated(state % x_adj_lpb_rel_diff))
then
938 deallocate(state % x_adj_lpb_rel_diff, stat=istatus)
939 if (istatus .ne. 0)
then
940 call update_error(ddx_error,
"`x_adj_lpb_rel_diff` deallocation failed!")
943 if (
allocated(state % g_lpb))
then
944 deallocate(state % g_lpb, stat=istatus)
945 if (istatus .ne. 0)
then
946 call update_error(ddx_error,
"`g_lpb` deallocation failed!")
949 if (
allocated(state % f_lpb))
then
950 deallocate(state % f_lpb, stat=istatus)
951 if (istatus .ne. 0)
then
952 call update_error(ddx_error,
"`f_lpb` deallocation failed!")
955 if (
allocated(state % rhs_lpb))
then
956 deallocate(state % rhs_lpb, stat=istatus)
957 if (istatus .ne. 0)
then
958 call update_error(ddx_error,
"`rhs_lpb` deallocation failed!")
961 if (
allocated(state % rhs_adj_lpb))
then
962 deallocate(state % rhs_adj_lpb, stat=istatus)
963 if (istatus .ne. 0)
then
964 call update_error(ddx_error,
"`rhs_adj_lpb` deallocation failed!")
967 if (
allocated(state % zeta_dip))
then
968 deallocate(state % zeta_dip, stat=istatus)
969 if (istatus .ne. 0)
then
970 call update_error(ddx_error,
"`zeta_dip` deallocation failed!")
973 if (
allocated(state % x_adj_re_grid))
then
974 deallocate(state % x_adj_re_grid, stat=istatus)
975 if (istatus .ne. 0)
then
976 call update_error(ddx_error,
"`x_adj_re_grid` deallocation failed!")
979 if (
allocated(state % x_adj_r_grid))
then
980 deallocate(state % x_adj_r_grid, stat=istatus)
981 if (istatus .ne. 0)
then
982 call update_error(ddx_error,
"`x_adj_r_grid` deallocation failed!")
985 if (
allocated(state % x_adj_e_grid))
then
986 deallocate(state % x_adj_e_grid, stat=istatus)
987 if (istatus .ne. 0)
then
988 call update_error(ddx_error,
"`x_adj_e_grid` deallocation failed!")
991 if (
allocated(state % phi_n))
then
992 deallocate(state % phi_n, stat=istatus)
993 if (istatus .ne. 0)
then
994 call update_error(ddx_error,
"`phi_n` deallocation failed!")
1014 character (len=*),
intent(in) :: label
1015 integer,
intent(in) :: nbasis, lmax, ncol, icol, iunit
1016 real(dp),
intent(in) :: x(nbasis, ncol)
1018 integer :: l, m, ind, noff, nprt, ic, j
1020 if (ncol .eq. 1)
then
1021 write (iunit,
'(3x,a,1x,a,i4,a)') label,
"(column ", icol,
")"
1023 write (iunit,
'(3x,a)') label
1026 if (ncol .eq. 1)
then
1030 write(iunit,1000) l, m, x(ind+m, 1)
1035 nprt = max(ncol-noff, 0)
1037 write(iunit,1010) (j, j = ic, ic+4)
1041 write(iunit,1020) l, m, x(ind+m, ic:ic+4)
1045 write (iunit,1010) (j, j = nprt+1, nprt+noff)
1049 write(iunit,1020) l, m, x(ind+m, nprt+1:nprt+noff)
1053 1000
format(1x,i3,i4,f14.8)
1054 1010
format(8x,5i14)
1055 1020
format(1x,i3,i4,5f14.8)
1071 character (len=*),
intent(in) :: label
1072 integer,
intent(in) :: ngrid, ncol, icol, iunit
1073 real(dp),
intent(in) :: x(ngrid, ncol)
1075 integer :: ig, noff, nprt, ic, j
1077 if (ncol .eq. 1)
then
1078 write (iunit,
'(3x,a,1x,a,i4,a)') label,
"(column ", icol,
")"
1080 write (iunit,
'(3x,a)') label
1083 if (ncol .eq. 1)
then
1085 write(iunit,1000) ig, x(ig, 1)
1089 nprt = max(ncol-noff, 0)
1091 write(iunit,1010) (j, j = ic, ic+4)
1093 write(iunit,1020) ig, x(ig, ic:ic+4)
1096 write (iunit,1010) (j, j = nprt+1, nprt+noff)
1098 write(iunit,1020) ig, x(ig, nprt+1:nprt+noff)
1102 1000
format(1x,i5,f14.8)
1103 1010
format(6x,5i14)
1104 1020
format(1x,i5,5f14.8)
1117 type(
ddx_type),
intent(in) :: ddx_data
1118 character(len=*) :: label
1119 real(dp) :: vector(ddx_data % constants % nbasis, ddx_data % params % nsph)
1123 do isph = 1, ddx_data % params % nsph
1124 do lm = 1, ddx_data % constants % nbasis
1125 write(6,
'(F15.8)') vector(lm,isph)
1147subroutine ddintegrate(nsph, nbasis, ngrid, vwgrid, ldvwgrid, x_grid, x_lm)
1150 integer,
intent(in) :: nsph, nbasis, ngrid, ldvwgrid
1151 real(dp),
intent(in) :: vwgrid(ldvwgrid, ngrid)
1152 real(dp),
intent(in) :: x_grid(ngrid, nsph)
1154 real(dp),
intent(out) :: x_lm(nbasis, nsph)
1156 call dgemm(
'N',
'N', nbasis, nsph, ngrid, one, vwgrid, ldvwgrid, x_grid, &
1157 & ngrid, zero, x_lm, nbasis)
1175subroutine dbasis(params, constants, x, basloc, dbsloc, vplm, vcos, vsin)
1179 real(dp),
dimension(3),
intent(in) :: x
1180 real(dp),
dimension(constants % nbasis),
intent(inout) :: basloc, vplm
1181 real(dp),
dimension(3, constants % nbasis),
intent(inout) :: dbsloc
1182 real(dp),
dimension(params % lmax+1),
intent(inout) :: vcos, vsin
1183 integer :: l, m, ind
1184 real(dp) :: cthe, sthe, cphi, sphi, plm, fln, pp1, pm1, pp, VC, VS
1185 real(dp) :: et(3), ep(3)
1190 sthe = sqrt(one - cthe*cthe)
1192 if ( sthe.ne.zero )
then
1205 if( sthe.ne.zero )
then
1219 call polleg_work( cthe, sthe, params % lmax, vplm, vcos )
1226 if ( sthe.ne.zero )
then
1227 call trgev( cphi, sphi, params % lmax, vcos, vsin )
1238 do l = 0, params % lmax
1241 fln = constants % vscales(ind)
1242 basloc(ind) = fln*vplm(ind)
1244 dbsloc(:,ind) = fln*vplm(ind+1)*et(:)
1246 dbsloc(:,ind) = zero
1249 fln = constants % vscales(ind+m)
1250 plm = fln*vplm(ind+m)
1252 if (m.lt.l) pp1 = -pt5*vplm(ind+m+1)
1253 pm1 = pt5*(dble(l+m)*dble(l-m+1)*vplm(ind+m-1))
1259 basloc(ind+m) = plm*vcos(m+1)
1262 if ( sthe.ne.zero )
then
1264 dbsloc(:,ind+m) = -fln*pp*vcos(m+1)*et(:) - dble(m)*plm*vsin(m+1)*ep(:)
1270 dbsloc(:,ind+m) = -fln*pp*vcos(m+1)*et(:) - fln*pp*ep(:)*vc
1278 basloc(ind-m) = plm*vsin(m+1)
1281 if ( sthe.ne.zero )
then
1283 dbsloc(:,ind-m) = -fln*pp*vsin(m+1)*et(:) + dble(m)*plm*vcos(m+1)*ep(:)
1288 dbsloc(:,ind-m) = -fln*pp*vsin(m+1)*et(:) - fln*pp*ep(:)*vs
1306real(dp) function intmlp(params, constants, t, sigma, basloc )
1311 real(dp),
intent(in) :: t
1312 real(dp),
dimension(constants % nbasis),
intent(in) :: sigma, basloc
1315 real(dp) :: tt, ss, fac
1326 do l = 0, params % lmax
1331 fac = tt / constants % vscales(ind)**2
1334 ss = ss + fac * dot_product( basloc(ind-l:ind+l), &
1335 sigma( ind-l:ind+l) )
1352subroutine wghpot(ncav, phi_cav, nsph, ngrid, ui, phi_grid, g)
1355 integer,
intent(in) :: ncav, nsph, ngrid
1356 real(dp),
intent(in) :: phi_cav(ncav), ui(ngrid, nsph)
1358 real(dp),
intent(out) :: g(ngrid, nsph), phi_grid(ngrid, nsph)
1360 integer isph, igrid, icav
1371 if (ui(igrid, isph) .ne. zero)
then
1374 phi_grid(igrid, isph) = phi_cav(icav)
1376 g(igrid, isph) = -ui(igrid, isph) * phi_cav(icav)
1385 integer,
intent(in) :: lmax, nbasis
1386 real(dp),
dimension(nbasis),
intent(in) :: u
1387 real(dp),
intent(inout) :: unorm
1388 integer :: l, m, ind
1394 fac = one/(one + dble(l))
1396 unorm = unorm + fac*u(ind+m)*u(ind+m)
1404real(dp) function hnorm(lmax, nbasis, nsph, x)
1406 integer,
intent(in) :: lmax, nbasis, nsph
1407 real(dp),
dimension(nbasis, nsph),
intent(in) :: x
1409 real(dp) :: vrms, fac
1415 call hsnorm(lmax, nbasis, x(:,isph), fac)
1416 vrms = vrms + fac*fac
1418 hnorm = sqrt(vrms/dble(nsph))
1421real(dp) function rmsnorm(lmax, nbasis, nsph, x)
1424 integer,
intent(in) :: lmax, nbasis, nsph
1425 real(dp),
dimension(nbasis, nsph),
intent(in) :: x
1427 real(dp) :: vrms, vmax
1429 if (lmax.eq.0)
continue
1431 call rmsvec(n,x,vrms,vmax)
1438 integer,
intent(in) :: n
1439 real(dp),
dimension(n),
intent(in) :: v
1440 real(dp),
intent(inout) :: vrms, vmax
1446 vmax = max(vmax,abs(v(i)))
1447 vrms = vrms + v(i)*v(i)
1450 vrms = sqrt(vrms/dble(n))
1453subroutine adjrhs(params, constants, isph, xi, vlm, work)
1457 integer,
intent(in) :: isph
1458 real(dp),
dimension(params % ngrid, params % nsph),
intent(in) :: xi
1459 real(dp),
dimension(constants % nbasis),
intent(inout) :: vlm
1460 real(dp),
dimension(params % lmax+1),
intent(inout) :: work
1462 integer :: ij, jsph, ig
1463 real(dp) :: vji(3), vvji, tji, xji, oji, fac
1465 do ij = constants % inl(isph), constants % inl(isph+1)-1
1466 jsph = constants % nl(ij)
1467 do ig = 1, params % ngrid
1468 vji = params % csph(:,jsph) + params % rsph(jsph)* &
1469 & constants % cgrid(:,ig) - params % csph(:,isph)
1470 vvji = sqrt(dot_product(vji,vji))
1471 tji = vvji/params % rsph(isph)
1472 if ( tji.lt.( one + (params % se+one)/two*params % eta ) )
then
1473 xji =
fsw( tji, params % se, params % eta )
1474 if ( constants % fi(ig,jsph).gt.one )
then
1475 oji = xji/ constants % fi(ig,jsph)
1479 fac = constants % wgrid(ig) * xi(ig,jsph) * oji
1481 & params % lmax, constants % vscales_rel, one, vlm, work)
1485end subroutine adjrhs
1487subroutine calcv(params, constants, isph, pot, sigma, work)
1491 integer,
intent(in) :: isph
1492 real(dp),
dimension(constants % nbasis, params % nsph),
intent(in) :: sigma
1493 real(dp),
dimension(params % ngrid),
intent(inout) :: pot
1494 real(dp),
dimension(params % lmax+1),
intent(inout) :: work
1496 integer :: its, ij, jsph
1498 real(dp) :: vvij, tij, xij, oij, thigh
1500 thigh = one + pt5*(params % se + one)*params % eta
1503 do its = 1, params % ngrid
1505 if (constants % ui(its,isph).lt.one)
then
1507 do ij = constants % inl(isph), constants % inl(isph+1)-1
1508 jsph = constants % nl(ij)
1510 vij = params % csph(:,isph) + params % rsph(isph)* &
1511 & constants % cgrid(:,its) - params % csph(:,jsph)
1512 vvij = sqrt( dot_product( vij, vij ) )
1513 tij = vvij / params % rsph(jsph)
1515 if (tij.lt.thigh)
then
1516 xij =
fsw(tij, params % se, params % eta)
1517 if (constants % fi(its,isph).gt.one)
then
1518 oij = xij / constants % fi(its,isph)
1522 call fmm_l2p_work(vij, params % rsph(jsph), params % lmax, &
1523 & constants % vscales_rel, oij, sigma(:, jsph), one, &
1539 real(dp),
intent(in) :: alpha, x_sph(constants % nbasis, params % nsph), &
1542 real(dp),
intent(inout) :: x_grid(params % ngrid, params % nsph)
1545 & constants % vgrid, constants % vgrid_nbasis, alpha, x_sph, beta, &
1553 & x_sph, beta, x_grid)
1556 integer,
intent(in) :: nbasis, ngrid, nsph, ldvgrid
1557 real(dp),
intent(in) :: vgrid(ldvgrid, ngrid), alpha, &
1558 & x_sph(nbasis, nsph), beta
1560 real(dp),
intent(inout) :: x_grid(ngrid, nsph)
1564 call dgemm(
'T',
'N', ngrid, nsph, nbasis, alpha, vgrid, ldvgrid, x_sph, &
1565 & nbasis, beta, x_grid, ngrid)
1574 real(dp),
intent(in) :: alpha, x_grid(params % ngrid, params % nsph), &
1577 real(dp),
intent(inout) :: x_sph(constants % nbasis, params % nsph)
1580 & params % nsph, constants % vwgrid, constants % vgrid_nbasis, alpha, &
1581 & x_grid, beta, x_sph)
1586 & x_grid, beta, x_sph)
1589 integer,
intent(in) :: nbasis, ngrid, nsph, ldvwgrid
1590 real(dp),
intent(in) :: vwgrid(ldvwgrid, ngrid), alpha, &
1591 & x_grid(ngrid, nsph), beta
1593 real(dp),
intent(inout) :: x_sph(nbasis, nsph)
1596 call dgemm(
'N',
'N', nbasis, nsph, ngrid, alpha, vwgrid, ldvwgrid, &
1597 & x_grid, ngrid, beta, x_sph, nbasis)
1608 real(dp),
intent(in) :: x_cav(constants % ncav)
1610 real(dp),
intent(inout) :: x_grid(params % ngrid, params % nsph)
1613 & constants % icav_ia, constants % icav_ja, x_cav, x_grid)
1623 integer,
intent(in) :: ngrid, nsph, ncav
1624 integer,
intent(in) :: icav_ia(nsph+1), icav_ja(ncav)
1625 real(dp),
intent(in) :: x_cav(ncav)
1627 real(dp),
intent(out) :: x_grid(ngrid, nsph)
1629 integer :: isph, icav, igrid, igrid_old
1634 do icav = icav_ia(isph), icav_ia(isph+1)-1
1635 igrid = icav_ja(icav)
1636 x_grid(igrid_old+1:igrid-1, isph) = zero
1637 x_grid(igrid, isph) = x_cav(icav)
1640 x_grid(igrid+1:ngrid, isph) = zero
1652 real(dp),
intent(in) :: s(constants%nbasis, params%nsph)
1653 real(dp),
intent(out) :: xi(constants%ncav)
1654 integer :: its, isph, ii
1656 do isph = 1, params%nsph
1657 do its = 1, params%ngrid
1658 if (constants%ui(its, isph) .gt. zero)
then
1660 xi(ii) = constants%ui(its, isph)*dot_product( &
1661 & constants%vwgrid(:constants % nbasis, its), s(:, isph))
1676 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1678 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1692 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1694 real(dp),
intent(out) :: work(6*params % pm**2 + 19*params % pm + 8)
1697 real(dp) :: c1(3), c(3), r1, r
1701 do i = constants % nclusters, 1, -1
1703 if (constants % children(1, i) == 0) cycle
1704 c = constants % cnode(:, i)
1705 r = constants % rnode(i)
1707 j = constants % children(1, i)
1708 c1 = constants % cnode(:, j)
1709 r1 = constants % rnode(j)
1713 & constants % vscales, &
1714 & constants % vcnk, one, &
1715 & node_m(:, j), zero, node_m(:, i), work)
1717 do j = constants % children(1, i)+1, constants % children(2, i)
1718 c1 = constants % cnode(:, j)
1719 r1 = constants % rnode(j)
1722 & constants % vscales, constants % vcnk, one, &
1723 & node_m(:, j), one, node_m(:, i), work)
1737 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1754 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1756 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1757 complex(dp) :: work_complex(2*params % pm+1)
1760 real(dp) :: c1(3), c(3), r1, r
1762 do i = constants % nclusters, 1, -1
1764 if (constants % children(1, i) == 0) cycle
1765 c = constants % cnode(:, i)
1766 r = constants % rnode(i)
1768 j = constants % children(1, i)
1769 c1 = constants % cnode(:, j)
1770 r1 = constants % rnode(j)
1771 c1 = params % kappa*(c1 - c)
1773 & constants % SK_rnode(:, j), constants % SK_rnode(:, i), &
1774 & params % pm, constants % vscales, one, node_m(:, j), zero, &
1775 & node_m(:, i), work, work_complex)
1777 do j = constants % children(1, i)+1, constants % children(2, i)
1778 c1 = constants % cnode(:, j)
1779 r1 = constants % rnode(j)
1780 c1 = params % kappa*(c1 - c)
1782 & constants % SK_rnode(:, j), constants % SK_rnode(:, i), &
1783 & params % pm, constants % vscales, one, node_m(:, j), one, &
1784 & node_m(:, i), work, work_complex)
1798 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1800 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1814 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1816 real(dp),
intent(out) :: work(6*params % pm**2 + 19*params % pm + 8)
1819 real(dp) :: c1(3), c(3), r1, r
1821 do i = 2, constants % nclusters
1822 j = constants % parent(i)
1823 c = constants % cnode(:, j)
1824 r = constants % rnode(j)
1825 c1 = constants % cnode(:, i)
1826 r1 = constants % rnode(i)
1829 & constants % vscales, constants % vcnk, one, node_m(:, j), one, &
1830 & node_m(:, i), work)
1842 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1857 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1859 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1860 complex(dp) :: work_complex(2*params % pm+1)
1863 real(dp) :: c1(3), c(3)
1865 do i = 2, constants % nclusters
1866 j = constants % parent(i)
1867 c = constants % cnode(:, j)
1868 c1 = constants % cnode(:, i)
1869 c1 = params % kappa*(c1 - c)
1872 & constants % SK_rnode(:, j), params % pm, constants % vscales, &
1873 & one, node_m(:, j), one, node_m(:, i), work, work_complex)
1886 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1888 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
1902 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1904 real(dp),
intent(out) :: work(6*params % pl**2 + 19*params % pl + 8)
1907 real(dp) :: c1(3), c(3), r1, r
1911 do i = 2, constants % nclusters
1912 j = constants % parent(i)
1913 c = constants % cnode(:, j)
1914 r = constants % rnode(j)
1915 c1 = constants % cnode(:, i)
1916 r1 = constants % rnode(i)
1919 & constants % vscales, constants % vfact, one, &
1920 & node_l(:, j), one, node_l(:, i), work)
1933 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1950 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1952 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
1953 complex(dp) :: work_complex(2*params % pl+1)
1956 real(dp) :: c_child(3), c_parent(3), c_diff(3)
1958 do i = 2, constants % nclusters
1959 j = constants % parent(i)
1960 c_child = constants % cnode(:, j)
1961 c_parent = constants % cnode(:, i)
1962 c_diff = params % kappa*(c_child - c_parent)
1964 & constants % si_rnode(:, j), constants % si_rnode(:, i), &
1965 & params % pl, constants % vscales, one, &
1966 & node_l(:, j), one, node_l(:, i), work, work_complex)
1979 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1981 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
1995 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1997 real(dp),
intent(out) :: work(6*params % pl**2 + 19*params % pl + 8)
2000 real(dp) :: c1(3), c(3), r1, r
2002 do i = constants % nclusters, 1, -1
2004 if (constants % children(1, i) == 0) cycle
2005 c = constants % cnode(:, i)
2006 r = constants % rnode(i)
2008 j = constants % children(1, i)
2009 c1 = constants % cnode(:, j)
2010 r1 = constants % rnode(j)
2013 & constants % vscales, constants % vfact, one, &
2014 & node_l(:, j), zero, node_l(:, i), work)
2016 do j = constants % children(1, i)+1, constants % children(2, i)
2017 c1 = constants % cnode(:, j)
2018 r1 = constants % rnode(j)
2021 & constants % vscales, constants % vfact, one, &
2022 & node_l(:, j), one, node_l(:, i), work)
2036 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
2038 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
2039 complex(dp) :: work_complex(2*params % pl+1)
2042 real(dp) :: c_parent(3), c_child(3), c_diff(3)
2044 do i = constants % nclusters, 1, -1
2045 c_child = constants % cnode(:, i)
2046 j = constants % parent(i)
2048 c_parent = constants % cnode(:, j)
2049 c_diff = params % kappa*(c_parent - c_child)
2051 & constants % si_rnode(:, i), constants % si_rnode(:, j), &
2052 & params % pl, constants % vscales, one, &
2053 & node_l(:, i), one, node_l(:, j), work, work_complex)
2065 real(dp),
intent(in) :: node_m((params % pm+1)**2, constants % nclusters)
2067 real(dp),
intent(out) :: node_l((params % pl+1)**2, constants % nclusters)
2069 real(dp) :: work(6*max(params % pm, params % pl)**2 + &
2070 & 19*max(params % pm, params % pl) + 8)
2073 real(dp) :: c1(3), c(3), r1, r
2077 do i = 1, constants % nclusters
2079 if (constants % nfar(i) .eq. 0)
then
2083 c = constants % cnode(:, i)
2084 r = constants % rnode(i)
2086 k = constants % far(constants % sfar(i))
2087 c1 = constants % cnode(:, k)
2088 r1 = constants % rnode(k)
2091 & constants % vscales, constants % m2l_ztranslate_coef, one, &
2092 & node_m(:, k), zero, node_l(:, i), work)
2093 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2094 k = constants % far(j)
2095 c1 = constants % cnode(:, k)
2096 r1 = constants % rnode(k)
2099 & params % pl, constants % vscales, &
2100 & constants % m2l_ztranslate_coef, one, node_m(:, k), one, &
2101 & node_l(:, i), work)
2115 real(dp),
intent(in) :: node_m((params % pm+1)**2, constants % nclusters)
2117 real(dp),
intent(out) :: node_l((params % pl+1)**2, constants % nclusters)
2119 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
2120 complex(dp) :: work_complex(2*params % pm+1)
2123 real(dp) :: c1(3), c(3), r1, r
2127 do i = 1, constants % nclusters
2129 if (constants % nfar(i) .eq. 0)
then
2133 c = constants % cnode(:, i)
2134 r = constants % rnode(i)
2136 k = constants % far(constants % sfar(i))
2137 c1 = constants % cnode(:, k)
2138 r1 = constants % rnode(k)
2139 c1 = params % kappa*(c1 - c)
2141 & constants % SK_rnode(:, k), constants % SI_rnode(:, i), &
2143 & constants % vscales, one, &
2144 & node_m(:, k), zero, node_l(:, i), work, work_complex)
2145 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2146 k = constants % far(j)
2147 c1 = constants % cnode(:, k)
2148 r1 = constants % rnode(k)
2149 c1 = params % kappa*(c1 - c)
2151 & constants % SI_rnode(:, i), params % pm, &
2152 & constants % vscales, one, &
2153 & node_m(:, k), one, node_l(:, i), work, work_complex)
2165 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2167 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
2181 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2183 real(dp),
intent(out) :: node_m((params % pm+1)**2, constants % nclusters)
2185 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
2186 complex(dp) :: work_complex(2*params % pm+1)
2189 real(dp) :: c1(3), c(3), r
2193 do i = 1, constants % nclusters
2195 if (constants % nfar(i) .eq. 0)
then
2198 c = constants % cnode(:, i)
2199 r = constants % rnode(i)
2201 k = constants % far(constants % sfar(i))
2202 c1 = constants % cnode(:, k)
2203 c1 = params % kappa*(c - c1)
2205 & constants % SK_rnode(:, i), params % pm, constants % vscales, &
2206 & one, node_l(:, k), one, node_m(:, i), work, work_complex)
2207 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2208 k = constants % far(j)
2209 c1 = constants % cnode(:, k)
2210 c1 = params % kappa*(c - c1)
2212 & constants % SI_rnode(:, k), constants % SK_rnode(:, i), &
2213 & params % pm, constants % vscales, one, node_l(:, k), &
2214 & one, node_m(:, i), work, work_complex)
2227 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2229 real(dp),
intent(out) :: node_m((params % pm+1)**2, constants % nclusters)
2232 real(dp) :: c1(3), c(3), r1, r
2236 do i = 1, constants % nclusters
2238 if (constants % nfar(i) .eq. 0)
then
2241 c = constants % cnode(:, i)
2242 r = constants % rnode(i)
2244 k = constants % far(constants % sfar(i))
2245 c1 = constants % cnode(:, k)
2246 r1 = constants % rnode(k)
2249 & constants % vscales, constants % m2l_ztranslate_adj_coef, one, &
2250 & node_l(:, k), one, node_m(:, i))
2251 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2252 k = constants % far(j)
2253 c1 = constants % cnode(:, k)
2254 r1 = constants % rnode(k)
2257 & constants % vscales, constants % m2l_ztranslate_adj_coef, one, &
2258 & node_l(:, k), one, node_m(:, i))
2266subroutine tree_l2p(params, constants, alpha, node_l, beta, grid_v, sph_l)
2271 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters), &
2274 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2276 real(dp),
intent(out) :: sph_l((params % pl+1)**2, params % nsph)
2283 if (beta .eq. zero)
then
2286 grid_v = beta * grid_v
2291 do isph = 1, params % nsph
2292 sph_l(:, isph) = node_l(:, constants % snode(isph))
2295 call dgemm(
'T',
'N', params % ngrid, params % nsph, &
2296 & (params % pl+1)**2, alpha, constants % vgrid2, &
2297 & constants % vgrid_nbasis, sph_l, (params % pl+1)**2, beta, grid_v, &
2310 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters), &
2313 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2315 real(dp) :: sph_l((params % pl+1)**2, params % nsph)
2319 if (beta .eq. zero)
then
2322 grid_v = beta * grid_v
2327 do isph = 1, params % nsph
2328 sph_l(:, isph) = node_l(:, constants % snode(isph))
2331 call dgemm(
'T',
'N', params % ngrid, params % nsph, &
2332 & (params % pl+1)**2, alpha, constants % vgrid, &
2333 & constants % vgrid_nbasis, sph_l, (params % pl+1)**2, beta, grid_v, &
2340subroutine tree_l2p_adj(params, constants, alpha, grid_v, beta, node_l, sph_l)
2345 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2348 real(dp),
intent(inout) :: node_l((params % pl+1)**2, &
2349 & constants % nclusters)
2351 real(dp),
intent(out) :: sph_l((params % pl+1)**2, params % nsph)
2353 integer :: isph, inode
2356 if (beta .eq. zero)
then
2359 node_l = beta * node_l
2362 call dgemm(
'N',
'N', (params % pl+1)**2, params % nsph, &
2363 & params % ngrid, one, constants % vgrid2, constants % vgrid_nbasis, &
2364 & grid_v, params % ngrid, zero, sph_l, &
2365 & (params % pl+1)**2)
2369 do isph = 1, params % nsph
2370 inode = constants % snode(isph)
2371 node_l(:, inode) = node_l(:, inode) + alpha*sph_l(:, isph)
2383 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2386 real(dp),
intent(inout) :: node_l((params % pl+1)**2, &
2387 & constants % nclusters)
2389 real(dp) :: sph_l((params % pl+1)**2, params % nsph)
2390 integer :: isph, inode
2393 if (beta .eq. zero)
then
2396 node_l = beta * node_l
2399 call dgemm(
'N',
'N', (params % pl+1)**2, params % nsph, &
2400 & params % ngrid, one, constants % vgrid, constants % vgrid_nbasis, &
2401 & grid_v, params % ngrid, zero, sph_l, &
2402 & (params % pl+1)**2)
2406 do isph = 1, params % nsph
2407 inode = constants % snode(isph)
2408 node_l(:, inode) = node_l(:, inode) + alpha*sph_l(:, isph)
2415subroutine tree_m2p(params, constants, p, alpha, sph_m, beta, grid_v)
2420 integer,
intent(in) :: p
2421 real(dp),
intent(in) :: sph_m((p+1)**2, params % nsph), alpha, beta
2423 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2425 integer :: isph, inode, jnear, jnode, jsph, igrid
2428 real(dp) :: work(p+1)
2430 if (beta .eq. zero)
then
2433 grid_v = beta * grid_v
2439 do isph = 1, params % nsph
2441 inode = constants % snode(isph)
2442 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2445 jnode = constants % near(jnear)
2446 jsph = constants % order(constants % cluster(1, jnode))
2448 if(isph .eq. jsph) cycle
2450 do igrid = 1, params % ngrid
2451 if(constants % ui(igrid, isph) .eq. zero) cycle
2452 c = constants % cgrid(:, igrid)*params % rsph(isph) - &
2453 & params % csph(:, jsph) + params % csph(:, isph)
2455 & constants % vscales_rel, alpha, sph_m(:, jsph), one, &
2456 & grid_v(igrid, isph), work)
2470 integer,
intent(in) :: p, sph_p
2471 real(dp),
intent(in) :: sph_m((sph_p+1)**2, params % nsph), alpha, beta
2473 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2475 integer :: isph, inode, jnear, jnode, jsph, igrid
2478 real(dp) :: work(p+1)
2479 complex(dp) :: work_complex(p+1)
2481 if (beta .eq. zero)
then
2484 grid_v = beta * grid_v
2490 do isph = 1, params % nsph
2492 inode = constants % snode(isph)
2493 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2496 jnode = constants % near(jnear)
2497 jsph = constants % order(constants % cluster(1, jnode))
2501 do igrid = 1, params % ngrid
2502 if(constants % ui(igrid, isph) .eq. zero) cycle
2503 c = constants % cgrid(:, igrid)*params % rsph(isph) - &
2504 & params % csph(:, jsph) + params % csph(:, isph)
2505 c = c * params % kappa
2507 & constants % SK_ri(:, jsph), alpha, sph_m(:, jsph), one, &
2508 & grid_v(igrid, isph), work_complex, work)
2522 integer,
intent(in) :: p
2523 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2526 real(dp),
intent(inout) :: sph_m((p+1)**2, params % nsph)
2528 real(dp) :: work(p+1)
2530 integer :: isph, inode, jnear, jnode, jsph, igrid
2533 if (beta .eq. zero)
then
2536 sph_m = beta * sph_m
2542 do isph = 1, params % nsph
2544 inode = constants % snode(isph)
2545 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2548 jnode = constants % near(jnear)
2549 jsph = constants % order(constants % cluster(1, jnode))
2551 if(isph .eq. jsph) cycle
2553 do igrid = 1, params % ngrid
2554 if(constants % ui(igrid, jsph) .eq. zero) cycle
2555 c = constants % cgrid(:, igrid)*params % rsph(jsph) - &
2556 & params % csph(:, isph) + params % csph(:, jsph)
2558 & params % rsph(isph), p, constants % vscales_rel, one, &
2559 & sph_m(:, isph), work)
2574 integer,
intent(in) :: p, sph_p
2575 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2578 real(dp),
intent(inout) :: sph_m((sph_p+1)**2, params % nsph)
2581 integer :: isph, inode, jnear, jnode, jsph, igrid
2584 if (beta .eq. zero)
then
2587 sph_m = beta * sph_m
2593 do isph = 1, params % nsph
2595 inode = constants % snode(isph)
2596 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2599 jnode = constants % near(jnear)
2600 jsph = constants % order(constants % cluster(1, jnode))
2602 do igrid = 1, params % ngrid
2603 if(constants % ui(igrid, jsph) .eq. zero) cycle
2604 c = constants % cgrid(:, igrid)*params % rsph(jsph) - &
2605 & params % csph(:, isph) + params % csph(:, jsph)
2607 & params % rsph(isph), params % kappa, p, &
2608 & constants % vscales, one, sph_m(:, isph))
2623 integer,
intent(in) :: p, sph_p
2624 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2627 real(dp),
intent(inout) :: sph_m((sph_p+1)**2, params % nsph)
2629 integer :: isph, inode, jnear, jnode, jsph, igrid
2632 if (beta .eq. zero)
then
2635 sph_m = beta * sph_m
2638 do isph = 1, params % nsph
2640 inode = constants % snode(isph)
2641 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2644 jnode = constants % near(jnear)
2645 jsph = constants % order(constants % cluster(1, jnode))
2647 if(isph .eq. jsph) cycle
2649 do igrid = 1, params % ngrid
2650 if(constants % ui(igrid, isph) .eq. zero) cycle
2651 c = constants % cgrid(:, igrid)*params % rsph(isph) - &
2652 & params % csph(:, jsph) + params % csph(:, isph)
2654 & params % rsph(jsph), params % kappa, p, constants % vscales, one, &
2669 real(dp),
intent(in) :: sph_m(constants % nbasis, params % nsph)
2671 real(dp),
intent(inout) :: sph_m_grad((params % lmax+2)**2, 3, &
2674 real(dp),
intent(inout) :: work((params % lmax+2)**2, params % nsph)
2676 integer :: isph, l, indi, indj, m
2677 real(dp) :: tmp1, tmp2
2678 real(dp),
dimension(3, 3) :: zx_coord_transform, zy_coord_transform
2680 zx_coord_transform = zero
2681 zx_coord_transform(3, 2) = one
2682 zx_coord_transform(2, 3) = one
2683 zx_coord_transform(1, 1) = one
2684 zy_coord_transform = zero
2685 zy_coord_transform(1, 2) = one
2686 zy_coord_transform(2, 1) = one
2687 zy_coord_transform(3, 3) = one
2689 sph_m_grad(1:constants % nbasis, 3, :) = sph_m
2690 do isph = 1, params % nsph
2692 & sph_m(:, isph), zero, sph_m_grad(1:constants % nbasis, 1, isph))
2694 & sph_m(:, isph), zero, sph_m_grad(1:constants % nbasis, 2, isph))
2700 do l = params % lmax+1, 1, -1
2703 tmp1 = sqrt(dble(2*l+1)) / sqrt(dble(2*l-1))
2705 tmp2 = sqrt(dble(l*l-m*m)) * tmp1
2706 sph_m_grad(indi+m, :, :) = tmp2 * sph_m_grad(indj+m, :, :)
2708 sph_m_grad(indi+l, :, :) = zero
2709 sph_m_grad(indi-l, :, :) = zero
2711 sph_m_grad(1, :, :) = zero
2714 do isph = 1, params % nsph
2715 sph_m_grad(:, 3, isph) = sph_m_grad(:, 3, isph) / params % rsph(isph)
2716 work(:, isph) = sph_m_grad(:, 1, isph) / params % rsph(isph)
2718 & work(:, isph), zero, sph_m_grad(:, 1, isph))
2719 work(:, isph) = sph_m_grad(:, 2, isph) / params % rsph(isph)
2721 & work(:, isph), zero, sph_m_grad(:, 2, isph))
2733 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2735 real(dp),
intent(out) :: sph_l_grad((params % pl+1)**2, 3, params % nsph)
2737 real(dp),
intent(out) :: work((params % pl+1)**2, params % nsph)
2739 integer :: isph, inode, l, indi, indj, m
2740 real(dp) :: tmp1, tmp2
2741 real(dp),
dimension(3, 3) :: zx_coord_transform, zy_coord_transform
2744 if (params % pl .le. 0)
return
2746 zx_coord_transform = zero
2747 zx_coord_transform(3, 2) = one
2748 zx_coord_transform(2, 3) = one
2749 zx_coord_transform(1, 1) = one
2750 zy_coord_transform = zero
2751 zy_coord_transform(1, 2) = one
2752 zy_coord_transform(2, 1) = one
2753 zy_coord_transform(3, 3) = one
2755 do isph = 1, params % nsph
2756 inode = constants % snode(isph)
2757 sph_l_grad(:, 3, isph) = node_l(:, inode)
2759 & node_l(:, inode), zero, sph_l_grad(:, 1, isph))
2761 & node_l(:, inode), zero, sph_l_grad(:, 2, isph))
2767 do l = 1, params % pl
2770 tmp1 = -sqrt(dble(2*l-1)) / sqrt(dble(2*l+1))
2772 tmp2 = sqrt(dble(l*l-m*m)) * tmp1
2773 sph_l_grad(indj+m, :, :) = tmp2 * sph_l_grad(indi+m, :, :)
2778 do isph = 1, params % nsph
2779 sph_l_grad(1:params % pl**2, 3, isph) = &
2780 & sph_l_grad(1:params % pl**2, 3, isph) / params % rsph(isph)
2781 work(1:params % pl**2, isph) = &
2782 & sph_l_grad(1:params % pl**2, 1, isph) / params % rsph(isph)
2784 & work(1:params % pl**2, isph), zero, &
2785 & sph_l_grad(1:params % pl**2, 1, isph))
2786 work(1:params % pl**2, isph) = &
2787 & sph_l_grad(1:params % pl**2, 2, isph) / params % rsph(isph)
2789 & work(1:params % pl**2, isph), zero, &
2790 & sph_l_grad(1:params % pl**2, 2, isph))
2795 sph_l_grad(indi-l:indi+l, :, :) = zero
2805 character (len=2047),
intent(out) :: string
2806 character (len=10) :: vstr
2807 write(vstr, *)
"0.6.8"
2809 &
" +----------------------------------------------------------------+", &
2813 &
" | 888 888 Y8b d8Y |", &
2815 &
" | 888 888 Y8b d8Y |", &
2817 &
" | 888 888 Y8888Y |", &
2819 &
" | .d88888 .d88888 Y88Y |", &
2821 &
" | d88 888 d88 888 d88b |", &
2823 &
" | 888 888 888 888 d8888b |", &
2825 &
" | Y88b 888 Y88b 888 d8Y Y8b |", &
2827 &
" | Y88888 Y88888 d8Y Y8b |", &
2831 &
" | https://ddsolvation.github.io/ddX/ |", &
2833 &
" | Version:", vstr,
" |", &
2837 &
" +----------------------------------------------------------------+"
2857 real(dp),
intent(in) :: property_cav(constants % ncav)
2858 real(dp),
intent(out) :: property_sph(constants % nbasis, params % nsph)
2861 workspace % tmp_cav = property_cav * constants % ui_cav
2865 & constants % icav_ia, constants % icav_ja, workspace % tmp_cav, &
2866 & workspace % tmp_grid)
2869 call ddintegrate(params % nsph, constants % nbasis, &
2870 & params % ngrid, constants % vwgrid, constants % vgrid_nbasis, &
2871 & workspace % tmp_grid, property_sph)
subroutine allocate_electrostatics(params, constants, electrostatics, ddx_error)
Given the chosen model, find the required electrostatic properties, and allocate the arrays for them ...
subroutine deallocate_electrostatics(electrostatics, ddx_error)
Deallocate the electrostatic properties.
subroutine allocate_state(params, constants, state, ddx_error)
Initialize the ddx_state object.
subroutine deallocate_state(state, ddx_error)
Deallocate the ddx_state object.
subroutine get_banner(string)
Print the ddX logo.
subroutine constants_init(params, constants, ddx_error)
Compute all necessary constants.
subroutine constants_free(constants, ddx_error)
Deallocate the constants.
real(dp) function fsw(t, se, eta)
Switching function.
Core routines and parameters of the ddX software.
subroutine tree_l2l_rotation_adj_work(params, constants, node_l, work)
Adjoint transfer local coefficients over a tree.
subroutine deallocate_model(ddx_data, ddx_error)
Deallocate object with corresponding data.
subroutine tree_grad_l2l(params, constants, node_l, sph_l_grad, work)
TODO.
subroutine tree_l2p_bessel(params, constants, alpha, node_l, beta, grid_v)
TODO.
subroutine tree_l2p_bessel_adj(params, constants, alpha, grid_v, beta, node_l)
TODO.
subroutine tree_l2l_rotation(params, constants, node_l)
Transfer local coefficients over a tree.
subroutine tree_m2m_rotation(params, constants, node_m)
Transfer multipole coefficients over a tree.
subroutine tree_l2p(params, constants, alpha, node_l, beta, grid_v, sph_l)
TODO.
subroutine wghpot(ncav, phi_cav, nsph, ngrid, ui, phi_grid, g)
Weigh potential at cavity points by characteristic function TODO use cavity points in CSR format.
real(dp) function hnorm(lmax, nbasis, nsph, x)
Compute the global Sobolev H^(-1/2)-norm of x.
subroutine tree_l2p_adj(params, constants, alpha, grid_v, beta, node_l, sph_l)
TODO.
subroutine cav_to_spherical(params, constants, workspace, property_cav, property_sph)
Transform a function defined at the exposed cavity points (cav) to a spherical harmonics expansion....
subroutine tree_l2l_rotation_work(params, constants, node_l, work)
Transfer local coefficients over a tree.
subroutine tree_m2l_bessel_rotation(params, constants, node_m, node_l)
Transfer multipole local coefficients into local over a tree.
subroutine tree_m2m_bessel_rotation_adj(params, constants, node_m)
Adjoint transfer multipole coefficients over a tree.
subroutine rmsvec(n, v, vrms, vmax)
compute root-mean-square and max norm
subroutine print_nodes(iunit, label, ngrid, ncol, icol, x)
Print array of quadrature points.
subroutine tree_m2m_bessel_rotation_work(params, constants, node_m)
Transfer multipole coefficients over a tree.
subroutine ddeval_grid_work(nbasis, ngrid, nsph, vgrid, ldvgrid, alpha, x_sph, beta, x_grid)
Evaluate values of spherical harmonics at Lebedev grid points.
subroutine tree_m2l_rotation(params, constants, node_m, node_l)
Transfer multipole local coefficients into local over a tree.
subroutine ddintegrate_sph(params, constants, alpha, x_grid, beta, x_sph)
Integrate values at grid points into spherical harmonics.
subroutine tree_m2p(params, constants, p, alpha, sph_m, beta, grid_v)
TODO.
subroutine ddintegrate_sph_work(nbasis, ngrid, nsph, vwgrid, ldvwgrid, alpha, x_grid, beta, x_sph)
Integrate values at grid points into spherical harmonics.
subroutine tree_m2p_bessel(params, constants, p, alpha, sph_p, sph_m, beta, grid_v)
TODO.
subroutine tree_l2l_bessel_rotation_adj(params, constants, node_l)
Adjoint transfer local coefficients over a tree.
subroutine ddintegrate(nsph, nbasis, ngrid, vwgrid, ldvwgrid, x_grid, x_lm)
Integrate against spherical harmonics.
subroutine tree_l2l_bessel_rotation(params, constants, node_l)
Transfer local coefficients over a tree.
subroutine print_ddvector(ddx_data, label, vector)
Print dd Solution vector.
subroutine tree_l2l_bessel_rotation_work(params, constants, node_l)
Transfer local coefficients over a tree.
subroutine tree_m2p_bessel_nodiag_adj(params, constants, p, alpha, grid_v, beta, sph_p, sph_m)
TODO.
subroutine tree_m2l_bessel_rotation_adj(params, constants, node_l, node_m)
Adjoint transfer multipole local coefficients into local over a tree.
subroutine tree_m2m_rotation_work(params, constants, node_m, work)
Transfer multipole coefficients over a tree.
subroutine tree_grad_m2m(params, constants, sph_m, sph_m_grad, work)
TODO.
subroutine tree_m2p_adj(params, constants, p, alpha, grid_v, beta, sph_m)
TODO.
subroutine tree_m2p_bessel_adj(params, constants, p, alpha, grid_v, beta, sph_p, sph_m)
TODO.
subroutine hsnorm(lmax, nbasis, u, unorm)
Compute the local Sobolev H^(-1/2)-norm on one sphere of u.
subroutine tree_m2l_bessel_rotation_adj_work(params, constants, node_l, node_m)
Adjoint transfer multipole local coefficients into local over a tree.
subroutine tree_m2l_rotation_adj(params, constants, node_l, node_m)
Adjoint transfer multipole local coefficients into local over a tree.
subroutine tree_l2l_rotation_adj(params, constants, node_l)
Adjoint transfer local coefficients over a tree.
subroutine tree_m2m_rotation_adj(params, constants, node_m)
Adjoint transfer multipole coefficients over a tree.
subroutine ddproject_cav(params, constants, s, xi)
Integrate by a characteristic function at Lebedev grid points \xi(n,i) = sum w_n U_n^i Y_l^m(s_n) [S_...
subroutine ddeval_grid(params, constants, alpha, x_sph, beta, x_grid)
Evaluate values of spherical harmonics at Lebedev grid points.
subroutine ddcav_to_grid_work(ngrid, nsph, ncav, icav_ia, icav_ja, x_cav, x_grid)
Unwrap values at cavity points into values at all grid points.
subroutine tree_m2m_bessel_rotation(params, constants, node_m)
Transfer multipole coefficients over a tree.
subroutine tree_m2m_bessel_rotation_adj_work(params, constants, node_m)
Adjoint transfer multipole coefficients over a tree.
subroutine ddcav_to_grid(params, constants, x_cav, x_grid)
Unwrap values at cavity points into values at all grid points.
subroutine allocate_model(nsph, x, y, z, rvdw, model, lmax, ngrid, force, fmm, pm, pl, se, eta, eps, kappa, matvecmem, maxiter, jacobi_ndiis, nproc, output_filename, ddx_data, ddx_error)
Initialize ddX input with a full set of parameters.
subroutine tree_m2m_rotation_adj_work(params, constants, node_m, work)
Adjoint transfer multipole coefficients over a tree.
subroutine dbasis(params, constants, x, basloc, dbsloc, vplm, vcos, vsin)
Compute first derivatives of spherical harmonics.
subroutine print_spherical(iunit, label, nbasis, lmax, ncol, icol, x)
Print array of spherical harmonics.
real(dp) function intmlp(params, constants, t, sigma, basloc)
TODO.
Harmonics-related core routines.
subroutine fmm_l2p_adj_work(c, src_q, dst_r, p, vscales_rel, beta, dst_l, work)
Adjoint L2P.
subroutine fmm_m2m_bessel_rotation_adj_work(c, src_sk, dst_sk, p, vscales, alpha, src_m, beta, dst_m, work, work_complex)
Direct M2M translation by 4 rotations and 1 translation.
subroutine fmm_m2p_bessel_adj(c, src_q, dst_r, kappa, p, vscales, beta, dst_m)
Adjoint M2P operation.
subroutine polleg_work(ctheta, stheta, p, vplm, work)
Compute associated Legendre polynomials.
subroutine trgev(cphi, sphi, p, vcos, vsin)
Compute arrays of and .
subroutine fmm_m2p_adj_work(c, src_q, dst_r, p, vscales_rel, beta, dst_m, work)
Adjoint M2P operation.
subroutine fmm_l2l_bessel_rotation_adj_work(c, src_si, dst_si, p, vscales, alpha, src_l, beta, dst_l, work, work_complex)
Direct L2L translation by 4 rotations and 1 translation.
subroutine fmm_m2m_bessel_rotation_work(c, src_sk, dst_sk, p, vscales, alpha, src_m, beta, dst_m, work, work_complex)
Direct M2M translation by 4 rotations and 1 translation.
subroutine fmm_l2l_rotation_work(c, src_r, dst_r, p, vscales, vfact, alpha, src_l, beta, dst_l, work)
Direct L2L translation by 4 rotations and 1 translation.
subroutine fmm_m2p_work(c, src_r, p, vscales_rel, alpha, src_m, beta, dst_v, work)
Accumulate potential, induced by multipole spherical harmonics.
subroutine fmm_m2l_rotation_adj(c, src_r, dst_r, pl, pm, vscales, m2l_ztranslate_adj_coef, alpha, src_l, beta, dst_m)
Adjoint M2L translation by 4 rotations and 1 translation.
subroutine fmm_m2m_rotation_work(c, src_r, dst_r, p, vscales, vcnk, alpha, src_m, beta, dst_m, work)
Direct M2M translation by 4 rotations and 1 translation.
subroutine fmm_sph_transform(p, r1, alpha, src, beta, dst)
Transform coefficients of spherical harmonics to a new cartesion system.
subroutine fmm_m2l_rotation_work(c, src_r, dst_r, pm, pl, vscales, m2l_ztranslate_coef, alpha, src_m, beta, dst_l, work)
Direct M2L translation by 4 rotations and 1 translation.
subroutine fmm_l2l_rotation_adj_work(c, src_r, dst_r, p, vscales, vfact, alpha, src_l, beta, dst_l, work)
Adjoint L2L translation by 4 rotations and 1 translation.
subroutine fmm_m2l_bessel_rotation_work(c, src_sk, dst_si, p, vscales, alpha, src_m, beta, dst_l, work, work_complex)
Direct M2M translation by 4 rotations and 1 translation.
subroutine fmm_l2l_bessel_rotation_work(c, src_si, dst_si, p, vscales, alpha, src_l, beta, dst_l, work, work_complex)
Direct L2L translation by 4 rotations and 1 translation.
subroutine fmm_m2l_bessel_rotation_adj_work(c, src_sk, dst_si, p, vscales, alpha, src_m, beta, dst_l, work, work_complex)
Direct M2M translation by 4 rotations and 1 translation.
subroutine fmm_m2m_rotation_adj_work(c, src_r, dst_r, p, vscales, vcnk, alpha, src_m, beta, dst_m, work)
Adjoint M2M translation by 4 rotations and 1 translation.
subroutine fmm_m2p_bessel_work(c, p, vscales, SK_ri, alpha, src_m, beta, dst_v, work_complex, work)
Accumulate Bessel potential, induced by multipole spherical harmonics.
subroutine fmm_l2p_work(c, src_r, p, vscales_rel, alpha, src_l, beta, dst_v, work)
Accumulate potential, induced by local spherical harmonics.
Module to treat properly user input parameters.
subroutine params_free(params, ddx_error)
Deallocate the parameter object.
subroutine params_init(model, force, eps, kappa, eta, se, lmax, ngrid, matvecmem, maxiter, jacobi_ndiis, fmm, pm, pl, nproc, nsph, csph, rsph, output_filename, params, ddx_error)
Initialize and check input parameters.
Workspace for temporary buffers.
subroutine workspace_init(params, constants, workspace, ddx_error)
Initialize and allocate the temporary workspaces.
subroutine workspace_free(workspace, ddx_error)
Deallocate the temporary workspaces.
Container for precomputed constants.
Container for the electrostatic properties. Since different methods require different electrostatic p...
This defined type contains the primal and adjoint RHSs, the solution of the primal and adjoint linear...
Main ddX type that stores all the required information. Container for the params, contants and worksp...
Type to check and store user input parameters.
Container for temporary arrays.