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
268subroutine allocate_model(nsph, x, y, z, rvdw, model, lmax, ngrid, force, fmm, pm, &
269 & pl, se, eta, eps, kappa, matvecmem, maxiter, jacobi_ndiis, nproc, &
270 & output_filename, switching, ddx_data, ddx_error)
273 integer,
intent(in) :: nsph, model, lmax, force, fmm, pm, pl, &
274 & matvecmem, maxiter, jacobi_ndiis, &
275 & ngrid, nproc, switching
276 real(dp),
intent(in):: x(nsph), y(nsph), z(nsph), &
277 & rvdw(nsph), se, eta, eps, kappa
278 character(len=255),
intent(in) :: output_filename
280 type(
ddx_type),
target,
intent(out) :: ddx_data
281 type(ddx_error_type),
intent(inout) :: ddx_error
283 real(dp),
allocatable :: csph(:, :)
285 if (ddx_error % flag .ne. 0)
then
286 call update_error(ddx_error,
"allocate_model received input in error state, " // &
291 allocate(csph(3, nsph), stat=istatus)
292 if (istatus .ne. 0)
then
293 call update_error(ddx_error,
"Allocation failed in allocate_model")
299 call params_init(model, force, eps, kappa, eta, se, lmax, ngrid, &
300 & matvecmem, maxiter, jacobi_ndiis, fmm, pm, pl, nproc, nsph, &
301 & csph, rvdw, output_filename, switching, ddx_data % params, &
303 if (ddx_error % flag .ne. 0)
then
304 call update_error(ddx_error,
"params_init returned an error, exiting")
307 call constants_init(ddx_data % params, ddx_data % constants, ddx_error)
308 if (ddx_error % flag .ne. 0)
then
309 call update_error(ddx_error,
"constants_init returned an error, exiting")
313 & ddx_data % workspace, ddx_error)
314 if (ddx_error % flag .ne. 0)
then
315 call update_error(ddx_error,
"workspace_init returned an error, exiting")
318 deallocate(csph, stat=istatus)
319 if (istatus .ne. 0)
then
320 call update_error(ddx_error,
"Deallocation failed in allocate_model")
334 type(
ddx_type),
intent(inout) :: ddx_data
335 type(ddx_error_type),
intent(inout) :: ddx_error
356 type(ddx_error_type),
intent(inout) :: ddx_error
362 if (params % model .eq. 3)
then
363 if (params % force .eq. 1)
then
364 electrostatics % do_phi = .true.
365 electrostatics % do_e = .true.
366 electrostatics % do_g = .true.
368 electrostatics % do_phi = .true.
369 electrostatics % do_e = .true.
370 electrostatics % do_g = .false.
373 if (params % force .eq. 1)
then
374 electrostatics % do_phi = .true.
375 electrostatics % do_e = .true.
376 electrostatics % do_g = .false.
378 electrostatics % do_phi = .true.
379 electrostatics % do_e = .false.
380 electrostatics % do_g = .false.
385 if (electrostatics % do_phi)
then
386 allocate(electrostatics % phi_cav(constants % ncav), stat=info)
387 if (info .ne. 0)
then
388 call update_error(ddx_error, &
389 &
"Allocation failed in allocate_electrostatics")
393 if (electrostatics % do_e)
then
394 allocate(electrostatics % e_cav(3, constants % ncav), stat=info)
395 if (info .ne. 0)
then
396 call update_error(ddx_error, &
397 &
"Allocation failed in allocate_electrostatics")
401 if (electrostatics % do_g)
then
402 allocate(electrostatics % g_cav(3, 3, constants % ncav), stat=info)
403 if (info .ne. 0)
then
404 call update_error(ddx_error, &
405 &
"Allocation failed in allocate_electrostatics")
420 type(ddx_error_type),
intent(inout) :: ddx_error
426 if (
allocated(electrostatics % phi_cav))
then
427 deallocate(electrostatics % phi_cav, stat=info)
428 if (info .ne. 0)
then
429 call update_error(ddx_error, &
430 &
"Deallocation failed in deallocate_electrostatics")
433 if (
allocated(electrostatics % e_cav))
then
434 deallocate(electrostatics % e_cav, stat=info)
435 if (info .ne. 0)
then
436 call update_error(ddx_error, &
437 &
"Deallocation failed in deallocate_electrostatics")
440 if (
allocated(electrostatics % g_cav))
then
441 deallocate(electrostatics % g_cav, stat=info)
442 if (info .ne. 0)
then
443 call update_error(ddx_error, &
444 &
"Deallocation failed in deallocate_electrostatics")
462 type(ddx_error_type),
intent(inout) :: ddx_error
465 state % rhs_done = .false.
466 state % adjoint_rhs_done = .false.
467 state % guess_done = .false.
468 state % solved = .false.
469 state % adjoint_guess_done = .false.
470 state % adjoint_solved = .false.
472 allocate(state % psi(constants % nbasis, params % nsph), stat=istatus, source=0.0_dp)
473 if (istatus .ne. 0)
then
474 call update_error(ddx_error,
"allocate_state: `psi` allocation failed")
477 allocate(state % phi_cav(constants % ncav), stat=istatus, source=0.0_dp)
478 if (istatus .ne. 0)
then
479 call update_error(ddx_error,
"allocate_state: `phi_cav` allocation failed")
482 allocate(state % gradphi_cav(3, constants % ncav), stat=istatus, source=0.0_dp)
483 if (istatus .ne. 0)
then
484 call update_error(ddx_error, &
485 &
"allocate_state: `gradphi_cav` allocation failed")
488 allocate(state % q(constants % nbasis, &
489 & params % nsph), stat=istatus, source=0.0_dp)
490 if (istatus .ne. 0)
then
491 call update_error(ddx_error,
"allocate_state: `q` " // &
492 &
"allocation failed")
497 if (params % model .eq. 1)
then
498 allocate(state % phi_grid(params % ngrid, &
499 & params % nsph), stat=istatus, source=0.0_dp)
500 if (istatus .ne. 0)
then
501 call update_error(ddx_error,
"allocate_state: `phi_grid` " // &
502 &
"allocation failed")
505 allocate(state % phi(constants % nbasis, &
506 & params % nsph), stat=istatus, source=0.0_dp)
507 if (istatus .ne. 0)
then
508 call update_error(ddx_error,
"allocate_state: `phi` " // &
509 &
"allocation failed")
512 allocate(state % xs(constants % nbasis, &
513 & params % nsph), stat=istatus, source=0.0_dp)
514 if (istatus .ne. 0)
then
515 call update_error(ddx_error,
"allocate_state: `xs` " // &
516 &
"allocation failed")
519 allocate(state % xs_rel_diff(params % maxiter), &
520 & stat=istatus, source=0.0_dp)
521 if (istatus .ne. 0)
then
522 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
523 &
"allocation failed")
526 allocate(state % s(constants % nbasis, &
527 & params % nsph), stat=istatus, source=0.0_dp)
528 if (istatus .ne. 0)
then
529 call update_error(ddx_error,
"allocate_state: `s` " // &
530 &
"allocation failed")
533 allocate(state % s_rel_diff(params % maxiter), &
534 & stat=istatus, source=0.0_dp)
535 if (istatus .ne. 0)
then
536 call update_error(ddx_error,
"allocate_state: `s_rel_diff` " // &
537 &
"allocation failed")
540 allocate(state % sgrid(params % ngrid, &
541 & params % nsph), stat=istatus, source=0.0_dp)
542 if (istatus .ne. 0)
then
543 call update_error(ddx_error,
"allocate_state: `sgrid` " // &
544 &
"allocation failed")
547 allocate(state % zeta(constants % ncav), stat=istatus, source=0.0_dp)
548 if (istatus .ne. 0)
then
549 call update_error(ddx_error,
"allocate_state: `zeta` " // &
550 &
"allocation failed")
554 else if (params % model .eq. 2)
then
555 allocate(state % phi_grid(params % ngrid, &
556 & params % nsph), stat=istatus, source=0.0_dp)
557 if (istatus .ne. 0)
then
558 call update_error(ddx_error,
"allocate_state: `phi_grid` " // &
559 &
"allocation failed")
562 allocate(state % phi(constants % nbasis, &
563 & params % nsph), stat=istatus, source=0.0_dp)
564 if (istatus .ne. 0)
then
565 call update_error(ddx_error,
"allocate_state: `phi` " // &
566 &
"allocation failed")
569 allocate(state % phiinf(constants % nbasis, &
570 & params % nsph), stat=istatus, source=0.0_dp)
571 if (istatus .ne. 0)
then
572 call update_error(ddx_error,
"allocate_state: `phiinf` " // &
573 &
"allocation failed")
576 allocate(state % phieps(constants % nbasis, &
577 & params % nsph), stat=istatus, source=0.0_dp)
578 if (istatus .ne. 0)
then
579 call update_error(ddx_error,
"allocate_state: `phieps` " // &
580 &
"allocation failed")
583 allocate(state % phieps_rel_diff(params % maxiter), &
584 & stat=istatus, source=0.0_dp)
585 if (istatus .ne. 0)
then
586 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
587 &
"allocation failed")
590 allocate(state % xs(constants % nbasis, &
591 & params % nsph), stat=istatus, source=0.0_dp)
592 if (istatus .ne. 0)
then
593 call update_error(ddx_error,
"allocate_state: `xs` " // &
594 &
"allocation failed")
597 allocate(state % xs_rel_diff(params % maxiter), &
598 & stat=istatus, source=0.0_dp)
599 if (istatus .ne. 0)
then
600 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
601 &
"allocation failed")
604 allocate(state % s(constants % nbasis, &
605 & params % nsph), stat=istatus, source=0.0_dp)
606 if (istatus .ne. 0)
then
607 call update_error(ddx_error,
"allocate_state: `s` " // &
608 &
"allocation failed")
611 allocate(state % s_rel_diff(params % maxiter), &
612 & stat=istatus, source=0.0_dp)
613 if (istatus .ne. 0)
then
614 call update_error(ddx_error,
"allocate_state: `xs_rel_diff` " // &
615 &
"allocation failed")
618 allocate(state % sgrid(params % ngrid, &
619 & params % nsph), stat=istatus, source=0.0_dp)
620 if (istatus .ne. 0)
then
621 call update_error(ddx_error,
"allocate_state: `sgrid` " // &
622 &
"allocation failed")
625 allocate(state % y(constants % nbasis, &
626 & params % nsph), stat=istatus, source=0.0_dp)
627 if (istatus .ne. 0)
then
628 call update_error(ddx_error,
"allocate_state: `y` " // &
629 &
"allocation failed")
632 allocate(state % y_rel_diff(params % maxiter), &
633 & stat=istatus, source=0.0_dp)
634 if (istatus .ne. 0)
then
635 call update_error(ddx_error,
"allocate_state: `y_rel_diff` " // &
636 &
"allocation failed")
639 allocate(state % ygrid(params % ngrid, &
640 & params % nsph), stat=istatus, source=0.0_dp)
641 if (istatus .ne. 0)
then
642 call update_error(ddx_error,
"allocate_state: `ygrid` " // &
643 &
"allocation failed")
646 allocate(state % g(constants % nbasis, &
647 & params % nsph), stat=istatus, source=0.0_dp)
648 if (istatus .ne. 0)
then
649 call update_error(ddx_error,
"allocate_state: `g` " // &
650 &
"allocation failed")
653 allocate(state % qgrid(params % ngrid, &
654 & params % nsph), stat=istatus, source=0.0_dp)
655 if (istatus .ne. 0)
then
656 call update_error(ddx_error,
"allocate_state: `qgrid` " // &
657 &
"allocation failed")
660 allocate(state % zeta(constants % ncav), stat=istatus, source=0.0_dp)
661 if (istatus .ne. 0)
then
662 call update_error(ddx_error,
"allocate_state: `zeta` " // &
663 &
"allocation failed")
667 else if (params % model .eq. 3)
then
668 allocate(state % phi_grid(params % ngrid, &
669 & params % nsph), stat=istatus, source=0.0_dp)
670 if (istatus .ne. 0)
then
671 call update_error(ddx_error,
"allocate_state: `phi_grid` " // &
672 &
"allocation failed")
675 allocate(state % phi(constants % nbasis, &
676 & params % nsph), stat=istatus, source=0.0_dp)
677 if (istatus .ne. 0)
then
678 call update_error(ddx_error,
"allocate_state: `phi` " // &
679 &
"allocation failed")
682 allocate(state % zeta(constants % ncav), stat=istatus, source=0.0_dp)
683 if (istatus .ne. 0)
then
684 call update_error(ddx_error,
"allocate_state: `zeta` " // &
685 &
"allocation failed")
689 allocate(state % x_lpb_rel_diff(params % maxiter), &
690 & stat=istatus, source=0.0_dp)
691 if (istatus .ne. 0)
then
692 call update_error(ddx_error,
"allocate_state: `x_lpb_rel_diff` " // &
693 &
"allocation failed")
696 allocate(state % rhs_lpb(constants % nbasis, &
697 & params % nsph, 2), &
698 & stat=istatus, source=0.0_dp)
699 if (istatus .ne. 0)
then
700 call update_error(ddx_error,
"allocate_state: `rhs_lpb` " // &
701 &
"allocation failed")
704 allocate(state % rhs_adj_lpb(constants % nbasis, &
705 & params % nsph, 2), &
706 & stat=istatus, source=0.0_dp)
707 if (istatus .ne. 0)
then
708 call update_error(ddx_error,
"allocate_state: `rhs_adj_lpb` " // &
709 &
"allocation failed")
712 allocate(state % x_lpb(constants % nbasis, &
713 & params % nsph, 2), &
714 & stat=istatus, source=0.0_dp)
715 if (istatus .ne. 0)
then
716 call update_error(ddx_error,
"allocate_state: `x_lpb` " // &
717 &
"allocation failed")
720 allocate(state % x_adj_lpb(constants % nbasis, &
721 & params % nsph, 2), stat=istatus, source=0.0_dp)
722 if (istatus .ne. 0)
then
723 call update_error(ddx_error,
"allocate_state: `x_adj_lpb` " // &
724 &
"allocation failed")
727 allocate(state % x_adj_lpb_rel_diff(params % maxiter), &
728 & stat=istatus, source=0.0_dp)
729 if (istatus .ne. 0)
then
730 call update_error(ddx_error, &
731 &
"allocate_state: `x_adj_lpb_rel_diff` allocation failed")
734 allocate(state % g_lpb(params % ngrid, &
735 & params % nsph), stat=istatus, source=0.0_dp)
736 if (istatus .ne. 0)
then
737 call update_error(ddx_error,
"allocate_state: `g_lpb` " // &
738 &
"allocation failed")
741 allocate(state % f_lpb(params % ngrid, &
742 & params % nsph), stat=istatus, source=0.0_dp)
743 if (istatus .ne. 0)
then
744 call update_error(ddx_error,
"allocate_state: `f_lpb` " // &
745 &
"allocation failed")
748 allocate(state % zeta_dip(3, constants % ncav), stat=istatus, source=0.0_dp)
749 if (istatus .ne. 0)
then
750 call update_error(ddx_error,
"allocate_state: `zeta_dip` " // &
751 &
"allocation failed")
754 allocate(state % x_adj_re_grid(params % ngrid, params % nsph), &
755 & stat=istatus, source=0.0_dp)
756 if (istatus .ne. 0)
then
757 call update_error(ddx_error,
"allocate_state: `x_adj_re_grid` " // &
758 &
"allocation failed")
761 allocate(state % x_adj_r_grid(params % ngrid, params % nsph), &
762 & stat=istatus, source=0.0_dp)
763 if (istatus .ne. 0)
then
764 call update_error(ddx_error,
"allocate_state: `x_adj_r_grid` " // &
765 &
"allocation failed")
768 allocate(state % x_adj_e_grid(params % ngrid, params % nsph), &
769 & stat=istatus, source=0.0_dp)
770 if (istatus .ne. 0)
then
771 call update_error(ddx_error,
"allocate_state: `x_adj_e_grid` " // &
772 &
"allocation failed")
775 allocate(state % phi_n(params % ngrid, params % nsph), &
776 & stat=istatus, source=0.0_dp)
777 if (istatus .ne. 0)
then
778 call update_error(ddx_error,
"allocate_state: `phi_n` " // &
779 &
"allocation failed")
795 type(ddx_error_type),
intent(inout) :: ddx_error
798 if (
allocated(state % phi_cav))
then
799 deallocate(state % phi_cav, stat=istatus)
800 if (istatus .ne. 0)
then
801 call update_error(ddx_error,
"`phi_cav` deallocation failed!")
805 if (
allocated(state % gradphi_cav))
then
806 deallocate(state % gradphi_cav, stat=istatus)
807 if (istatus .ne. 0)
then
808 call update_error(ddx_error,
"`gradphi_cav` deallocation failed!")
812 if (
allocated(state % psi))
then
813 deallocate(state % psi, stat=istatus)
814 if (istatus .ne. 0)
then
815 call update_error(ddx_error,
"`psi` deallocation failed!")
819 if (
allocated(state % phi_grid))
then
820 deallocate(state % phi_grid, stat=istatus)
821 if (istatus .ne. 0)
then
822 call update_error(ddx_error,
"`phi_grid` deallocation failed!")
826 if (
allocated(state % phi))
then
827 deallocate(state % phi, stat=istatus)
828 if (istatus .ne. 0)
then
829 call update_error(ddx_error,
"`phi` deallocation failed!")
832 if (
allocated(state % phiinf))
then
833 deallocate(state % phiinf, stat=istatus)
834 if (istatus .ne. 0)
then
835 call update_error(ddx_error,
"`phiinf` deallocation failed!")
838 if (
allocated(state % phieps))
then
839 deallocate(state % phieps, stat=istatus)
840 if (istatus .ne. 0)
then
841 call update_error(ddx_error,
"`phieps` deallocation failed!")
844 if (
allocated(state % phieps_rel_diff))
then
845 deallocate(state % phieps_rel_diff, stat=istatus)
846 if (istatus .ne. 0)
then
847 call update_error(ddx_error,
"`phieps_rel_diff` deallocation failed!")
850 if (
allocated(state % xs))
then
851 deallocate(state % xs, stat=istatus)
852 if (istatus .ne. 0)
then
853 call update_error(ddx_error,
"`xs` deallocation failed!")
856 if (
allocated(state % xs_rel_diff))
then
857 deallocate(state % xs_rel_diff, stat=istatus)
858 if (istatus .ne. 0)
then
859 call update_error(ddx_error,
"`xs_rel_diff` deallocation failed!")
862 if (
allocated(state % s))
then
863 deallocate(state % s, stat=istatus)
864 if (istatus .ne. 0)
then
865 call update_error(ddx_error,
"`s` deallocation failed!")
868 if (
allocated(state % s_rel_diff))
then
869 deallocate(state % s_rel_diff, stat=istatus)
870 if (istatus .ne. 0)
then
871 call update_error(ddx_error,
"`s_rel_diff` deallocation failed!")
874 if (
allocated(state % sgrid))
then
875 deallocate(state % sgrid, stat=istatus)
876 if (istatus .ne. 0)
then
877 call update_error(ddx_error,
"`sgrid` deallocation failed!")
880 if (
allocated(state % y))
then
881 deallocate(state % y, stat=istatus)
882 if (istatus .ne. 0)
then
883 call update_error(ddx_error,
"`y` deallocation failed!")
886 if (
allocated(state % y_rel_diff))
then
887 deallocate(state % y_rel_diff, stat=istatus)
888 if (istatus .ne. 0)
then
889 call update_error(ddx_error,
"`y_rel_diff` deallocation failed!")
892 if (
allocated(state % ygrid))
then
893 deallocate(state % ygrid, stat=istatus)
894 if (istatus .ne. 0)
then
895 call update_error(ddx_error,
"`ygrid` deallocation failed!")
898 if (
allocated(state % g))
then
899 deallocate(state % g, stat=istatus)
900 if (istatus .ne. 0)
then
901 call update_error(ddx_error,
"`g` deallocation failed!")
904 if (
allocated(state % q))
then
905 deallocate(state % q, stat=istatus)
906 if (istatus .ne. 0)
then
907 call update_error(ddx_error,
"`q` deallocation failed!")
910 if (
allocated(state % qgrid))
then
911 deallocate(state % qgrid, stat=istatus)
912 if (istatus .ne. 0)
then
913 call update_error(ddx_error,
"`qgrid` deallocation failed!")
916 if (
allocated(state % zeta))
then
917 deallocate(state % zeta, stat=istatus)
918 if (istatus .ne. 0)
then
919 call update_error(ddx_error,
"`zeta` deallocation failed!")
922 if (
allocated(state % x_lpb))
then
923 deallocate(state % x_lpb, stat=istatus)
924 if (istatus .ne. 0)
then
925 call update_error(ddx_error,
"`x_lpb` deallocation failed!")
928 if (
allocated(state % x_lpb_rel_diff))
then
929 deallocate(state % x_lpb_rel_diff, stat=istatus)
930 if (istatus .ne. 0)
then
931 call update_error(ddx_error,
"`x_lpb_rel_diff` deallocation failed!")
934 if (
allocated(state % x_adj_lpb))
then
935 deallocate(state % x_adj_lpb, stat=istatus)
936 if (istatus .ne. 0)
then
937 call update_error(ddx_error,
"x_adj_lpb deallocation failed!")
940 if (
allocated(state % x_adj_lpb_rel_diff))
then
941 deallocate(state % x_adj_lpb_rel_diff, stat=istatus)
942 if (istatus .ne. 0)
then
943 call update_error(ddx_error,
"`x_adj_lpb_rel_diff` deallocation failed!")
946 if (
allocated(state % g_lpb))
then
947 deallocate(state % g_lpb, stat=istatus)
948 if (istatus .ne. 0)
then
949 call update_error(ddx_error,
"`g_lpb` deallocation failed!")
952 if (
allocated(state % f_lpb))
then
953 deallocate(state % f_lpb, stat=istatus)
954 if (istatus .ne. 0)
then
955 call update_error(ddx_error,
"`f_lpb` deallocation failed!")
958 if (
allocated(state % rhs_lpb))
then
959 deallocate(state % rhs_lpb, stat=istatus)
960 if (istatus .ne. 0)
then
961 call update_error(ddx_error,
"`rhs_lpb` deallocation failed!")
964 if (
allocated(state % rhs_adj_lpb))
then
965 deallocate(state % rhs_adj_lpb, stat=istatus)
966 if (istatus .ne. 0)
then
967 call update_error(ddx_error,
"`rhs_adj_lpb` deallocation failed!")
970 if (
allocated(state % zeta_dip))
then
971 deallocate(state % zeta_dip, stat=istatus)
972 if (istatus .ne. 0)
then
973 call update_error(ddx_error,
"`zeta_dip` deallocation failed!")
976 if (
allocated(state % x_adj_re_grid))
then
977 deallocate(state % x_adj_re_grid, stat=istatus)
978 if (istatus .ne. 0)
then
979 call update_error(ddx_error,
"`x_adj_re_grid` deallocation failed!")
982 if (
allocated(state % x_adj_r_grid))
then
983 deallocate(state % x_adj_r_grid, stat=istatus)
984 if (istatus .ne. 0)
then
985 call update_error(ddx_error,
"`x_adj_r_grid` deallocation failed!")
988 if (
allocated(state % x_adj_e_grid))
then
989 deallocate(state % x_adj_e_grid, stat=istatus)
990 if (istatus .ne. 0)
then
991 call update_error(ddx_error,
"`x_adj_e_grid` deallocation failed!")
994 if (
allocated(state % phi_n))
then
995 deallocate(state % phi_n, stat=istatus)
996 if (istatus .ne. 0)
then
997 call update_error(ddx_error,
"`phi_n` deallocation failed!")
1017 character (len=*),
intent(in) :: label
1018 integer,
intent(in) :: nbasis, lmax, ncol, icol, iunit
1019 real(dp),
intent(in) :: x(nbasis, ncol)
1021 integer :: l, m, ind, noff, nprt, ic, j
1023 if (ncol .eq. 1)
then
1024 write (iunit,
'(3x,a,1x,a,i4,a)') label,
"(column ", icol,
")"
1026 write (iunit,
'(3x,a)') label
1029 if (ncol .eq. 1)
then
1033 write(iunit,1000) l, m, x(ind+m, 1)
1038 nprt = max(ncol-noff, 0)
1040 write(iunit,1010) (j, j = ic, ic+4)
1044 write(iunit,1020) l, m, x(ind+m, ic:ic+4)
1048 write (iunit,1010) (j, j = nprt+1, nprt+noff)
1052 write(iunit,1020) l, m, x(ind+m, nprt+1:nprt+noff)
1056 1000
format(1x,i3,i4,f14.8)
1057 1010
format(8x,5i14)
1058 1020
format(1x,i3,i4,5f14.8)
1074 character (len=*),
intent(in) :: label
1075 integer,
intent(in) :: ngrid, ncol, icol, iunit
1076 real(dp),
intent(in) :: x(ngrid, ncol)
1078 integer :: ig, noff, nprt, ic, j
1080 if (ncol .eq. 1)
then
1081 write (iunit,
'(3x,a,1x,a,i4,a)') label,
"(column ", icol,
")"
1083 write (iunit,
'(3x,a)') label
1086 if (ncol .eq. 1)
then
1088 write(iunit,1000) ig, x(ig, 1)
1092 nprt = max(ncol-noff, 0)
1094 write(iunit,1010) (j, j = ic, ic+4)
1096 write(iunit,1020) ig, x(ig, ic:ic+4)
1099 write (iunit,1010) (j, j = nprt+1, nprt+noff)
1101 write(iunit,1020) ig, x(ig, nprt+1:nprt+noff)
1105 1000
format(1x,i5,f14.8)
1106 1010
format(6x,5i14)
1107 1020
format(1x,i5,5f14.8)
1120 type(
ddx_type),
intent(in) :: ddx_data
1121 character(len=*) :: label
1122 real(dp) :: vector(ddx_data % constants % nbasis, ddx_data % params % nsph)
1126 do isph = 1, ddx_data % params % nsph
1127 do lm = 1, ddx_data % constants % nbasis
1128 write(6,
'(F15.8)') vector(lm,isph)
1150subroutine ddintegrate(nsph, nbasis, ngrid, vwgrid, ldvwgrid, x_grid, x_lm)
1153 integer,
intent(in) :: nsph, nbasis, ngrid, ldvwgrid
1154 real(dp),
intent(in) :: vwgrid(ldvwgrid, ngrid)
1155 real(dp),
intent(in) :: x_grid(ngrid, nsph)
1157 real(dp),
intent(out) :: x_lm(nbasis, nsph)
1159 call dgemm(
'N',
'N', nbasis, nsph, ngrid, one, vwgrid, ldvwgrid, x_grid, &
1160 & ngrid, zero, x_lm, nbasis)
1178subroutine dbasis(params, constants, x, basloc, dbsloc, vplm, vcos, vsin)
1182 real(dp),
dimension(3),
intent(in) :: x
1183 real(dp),
dimension(constants % nbasis),
intent(inout) :: basloc, vplm
1184 real(dp),
dimension(3, constants % nbasis),
intent(inout) :: dbsloc
1185 real(dp),
dimension(params % lmax+1),
intent(inout) :: vcos, vsin
1186 integer :: l, m, ind
1187 real(dp) :: cthe, sthe, cphi, sphi, plm, fln, pp1, pm1, pp, VC, VS
1188 real(dp) :: et(3), ep(3)
1193 sthe = sqrt(one - cthe*cthe)
1195 if ( sthe.ne.zero )
then
1208 if( sthe.ne.zero )
then
1222 call polleg_work( cthe, sthe, params % lmax, vplm, vcos )
1229 if ( sthe.ne.zero )
then
1230 call trgev( cphi, sphi, params % lmax, vcos, vsin )
1241 do l = 0, params % lmax
1244 fln = constants % vscales(ind)
1245 basloc(ind) = fln*vplm(ind)
1247 dbsloc(:,ind) = fln*vplm(ind+1)*et(:)
1249 dbsloc(:,ind) = zero
1252 fln = constants % vscales(ind+m)
1253 plm = fln*vplm(ind+m)
1255 if (m.lt.l) pp1 = -pt5*vplm(ind+m+1)
1256 pm1 = pt5*(dble(l+m)*dble(l-m+1)*vplm(ind+m-1))
1262 basloc(ind+m) = plm*vcos(m+1)
1265 if ( sthe.ne.zero )
then
1267 dbsloc(:,ind+m) = -fln*pp*vcos(m+1)*et(:) - dble(m)*plm*vsin(m+1)*ep(:)
1273 dbsloc(:,ind+m) = -fln*pp*vcos(m+1)*et(:) - fln*pp*ep(:)*vc
1281 basloc(ind-m) = plm*vsin(m+1)
1284 if ( sthe.ne.zero )
then
1286 dbsloc(:,ind-m) = -fln*pp*vsin(m+1)*et(:) + dble(m)*plm*vcos(m+1)*ep(:)
1291 dbsloc(:,ind-m) = -fln*pp*vsin(m+1)*et(:) - fln*pp*ep(:)*vs
1309real(dp) function intmlp(params, constants, t, sigma, basloc )
1314 real(dp),
intent(in) :: t
1315 real(dp),
dimension(constants % nbasis),
intent(in) :: sigma, basloc
1318 real(dp) :: tt, ss, fac
1329 do l = 0, params % lmax
1334 fac = tt / constants % vscales(ind)**2
1337 ss = ss + fac * dot_product( basloc(ind-l:ind+l), &
1338 sigma( ind-l:ind+l) )
1355subroutine wghpot(ncav, phi_cav, nsph, ngrid, ui, phi_grid, g)
1358 integer,
intent(in) :: ncav, nsph, ngrid
1359 real(dp),
intent(in) :: phi_cav(ncav), ui(ngrid, nsph)
1361 real(dp),
intent(out) :: g(ngrid, nsph), phi_grid(ngrid, nsph)
1363 integer isph, igrid, icav
1374 if (ui(igrid, isph) .ne. zero)
then
1377 phi_grid(igrid, isph) = phi_cav(icav)
1379 g(igrid, isph) = -ui(igrid, isph) * phi_cav(icav)
1388 integer,
intent(in) :: lmax, nbasis
1389 real(dp),
dimension(nbasis),
intent(in) :: u
1390 real(dp),
intent(inout) :: unorm
1391 integer :: l, m, ind
1397 fac = one/(one + dble(l))
1399 unorm = unorm + fac*u(ind+m)*u(ind+m)
1407real(dp) function hnorm(lmax, nbasis, nsph, x)
1409 integer,
intent(in) :: lmax, nbasis, nsph
1410 real(dp),
dimension(nbasis, nsph),
intent(in) :: x
1412 real(dp) :: vrms, fac
1418 call hsnorm(lmax, nbasis, x(:,isph), fac)
1419 vrms = vrms + fac*fac
1421 hnorm = sqrt(vrms/dble(nsph))
1424real(dp) function rmsnorm(lmax, nbasis, nsph, x)
1427 integer,
intent(in) :: lmax, nbasis, nsph
1428 real(dp),
dimension(nbasis, nsph),
intent(in) :: x
1430 real(dp) :: vrms, vmax
1432 if (lmax.eq.0)
continue
1434 call rmsvec(n,x,vrms,vmax)
1441 integer,
intent(in) :: n
1442 real(dp),
dimension(n),
intent(in) :: v
1443 real(dp),
intent(inout) :: vrms, vmax
1449 vmax = max(vmax,abs(v(i)))
1450 vrms = vrms + v(i)*v(i)
1453 vrms = sqrt(vrms/dble(n))
1456subroutine adjrhs(params, constants, isph, xi, vlm, work)
1460 integer,
intent(in) :: isph
1461 real(dp),
dimension(params % ngrid, params % nsph),
intent(in) :: xi
1462 real(dp),
dimension(constants % nbasis),
intent(inout) :: vlm
1463 real(dp),
dimension(params % lmax+1),
intent(inout) :: work
1465 integer :: ij, jsph, ig
1466 real(dp) :: vji(3), vvji, tji, xji, oji, fac, d_j, f_j, thigh
1468 thigh = one + (params % se+one)/two*params % eta
1470 if (params%switching.eq.0)
then
1471 do ij = constants % inl(isph), constants % inl(isph+1)-1
1472 jsph = constants % nl(ij)
1473 do ig = 1, params % ngrid
1474 vji = params % csph(:,jsph) + params % rsph(jsph)* &
1475 & constants % cgrid(:,ig) - params % csph(:,isph)
1476 vvji = sqrt(dot_product(vji,vji))
1477 tji = vvji/params % rsph(isph)
1478 if (tji.lt.thigh)
then
1479 xji =
fsw(tji, params % se, params % eta)
1480 if (constants % fi(ig,jsph).gt.one)
then
1481 oji = xji/ constants % fi(ig,jsph)
1485 fac = constants % wgrid(ig) * xi(ig,jsph) * oji
1487 & params % lmax, constants % vscales_rel, one, vlm, work)
1492 do ij = constants % inl(isph), constants % inl(isph+1)-1
1493 jsph = constants % nl(ij)
1494 do ig = 1, params % ngrid
1495 vji = params % csph(:,jsph) + params % rsph(jsph)* &
1496 & constants % cgrid(:,ig) - params % csph(:,isph)
1497 vvji = sqrt(dot_product(vji,vji))
1498 tji = vvji/params % rsph(isph)
1499 if (tji.lt.thigh)
then
1500 d_j = constants%switching%d_ni(ig,jsph)
1501 f_j = constants%switching%f_ni(ig,jsph)
1502 xji =
fsw(tji, params % se, params % eta)
1504 fac = constants % wgrid(ig) * xi(ig,jsph) * oji
1506 & params % lmax, constants % vscales_rel, one, vlm, work)
1511end subroutine adjrhs
1513subroutine calcv(params, constants, isph, pot, sigma, work)
1517 integer,
intent(in) :: isph
1518 real(dp),
dimension(constants % nbasis, params % nsph),
intent(in) :: sigma
1519 real(dp),
dimension(params % ngrid),
intent(inout) :: pot
1520 real(dp),
dimension(params % lmax+1),
intent(inout) :: work
1522 integer :: its, ij, jsph
1524 real(dp) :: vvij, tij, xij, oij, thigh, d_i, f_i
1526 thigh = one + pt5*(params % se + one)*params % eta
1530 if (params%switching.eq.0)
then
1532 do its = 1, params % ngrid
1534 if (constants % ui(its,isph).lt.one)
then
1536 do ij = constants % inl(isph), constants % inl(isph+1)-1
1537 jsph = constants % nl(ij)
1539 vij = params % csph(:,isph) + params % rsph(isph)* &
1540 & constants % cgrid(:,its) - params % csph(:,jsph)
1541 vvij = sqrt( dot_product( vij, vij ) )
1542 tij = vvij / params % rsph(jsph)
1544 if (tij.lt.thigh)
then
1545 xij =
fsw(tij, params % se, params % eta)
1546 if (constants % fi(its,isph).gt.one)
then
1547 oij = xij / constants % fi(its,isph)
1551 call fmm_l2p_work(vij, params % rsph(jsph), params % lmax, &
1552 & constants % vscales_rel, oij, sigma(:, jsph), one, &
1560 do its = 1, params % ngrid
1562 if (constants%ui(its,isph).lt.one)
then
1563 d_i = constants%switching%d_ni(its,isph)
1564 f_i = constants%switching%f_ni(its,isph)
1566 do ij = constants % inl(isph), constants % inl(isph+1)-1
1567 jsph = constants % nl(ij)
1569 vij = params % csph(:,isph) + params % rsph(isph)* &
1570 & constants % cgrid(:,its) - params % csph(:,jsph)
1571 vvij = sqrt(vij(1)*vij(1) + vij(2)*vij(2) + vij(3)*vij(3))
1572 tij = vvij / params % rsph(jsph)
1574 if (tij.lt.thigh)
then
1575 xij =
fsw(tij, params % se, params % eta)
1576 oij = xij/(d_i + f_i)
1577 call fmm_l2p_work(vij, params % rsph(jsph), params % lmax, &
1578 & constants % vscales_rel, oij, sigma(:, jsph), one, &
1595 real(dp),
intent(in) :: alpha, x_sph(constants % nbasis, params % nsph), &
1598 real(dp),
intent(inout) :: x_grid(params % ngrid, params % nsph)
1601 & constants % vgrid, constants % vgrid_nbasis, alpha, x_sph, beta, &
1609 & x_sph, beta, x_grid)
1612 integer,
intent(in) :: nbasis, ngrid, nsph, ldvgrid
1613 real(dp),
intent(in) :: vgrid(ldvgrid, ngrid), alpha, &
1614 & x_sph(nbasis, nsph), beta
1616 real(dp),
intent(inout) :: x_grid(ngrid, nsph)
1620 call dgemm(
'T',
'N', ngrid, nsph, nbasis, alpha, vgrid, ldvgrid, x_sph, &
1621 & nbasis, beta, x_grid, ngrid)
1630 real(dp),
intent(in) :: alpha, x_grid(params % ngrid, params % nsph), &
1633 real(dp),
intent(inout) :: x_sph(constants % nbasis, params % nsph)
1636 & params % nsph, constants % vwgrid, constants % vgrid_nbasis, alpha, &
1637 & x_grid, beta, x_sph)
1642 & x_grid, beta, x_sph)
1645 integer,
intent(in) :: nbasis, ngrid, nsph, ldvwgrid
1646 real(dp),
intent(in) :: vwgrid(ldvwgrid, ngrid), alpha, &
1647 & x_grid(ngrid, nsph), beta
1649 real(dp),
intent(inout) :: x_sph(nbasis, nsph)
1652 call dgemm(
'N',
'N', nbasis, nsph, ngrid, alpha, vwgrid, ldvwgrid, &
1653 & x_grid, ngrid, beta, x_sph, nbasis)
1664 real(dp),
intent(in) :: x_cav(constants % ncav)
1666 real(dp),
intent(inout) :: x_grid(params % ngrid, params % nsph)
1669 & constants % icav_ia, constants % icav_ja, x_cav, x_grid)
1679 integer,
intent(in) :: ngrid, nsph, ncav
1680 integer,
intent(in) :: icav_ia(nsph+1), icav_ja(ncav)
1681 real(dp),
intent(in) :: x_cav(ncav)
1683 real(dp),
intent(out) :: x_grid(ngrid, nsph)
1685 integer :: isph, icav, igrid, igrid_old
1690 do icav = icav_ia(isph), icav_ia(isph+1)-1
1691 igrid = icav_ja(icav)
1692 x_grid(igrid_old+1:igrid-1, isph) = zero
1693 x_grid(igrid, isph) = x_cav(icav)
1696 x_grid(igrid+1:ngrid, isph) = zero
1708 real(dp),
intent(in) :: s(constants%nbasis, params%nsph)
1709 real(dp),
intent(out) :: xi(constants%ncav)
1710 integer :: its, isph, ii
1712 do isph = 1, params%nsph
1713 do its = 1, params%ngrid
1714 if (constants%ui(its, isph) .gt. zero)
then
1716 xi(ii) = constants%ui(its, isph)*dot_product( &
1717 & constants%vwgrid(:constants % nbasis, its), s(:, isph))
1732 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1734 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1748 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1750 real(dp),
intent(out) :: work(6*params % pm**2 + 19*params % pm + 8)
1753 real(dp) :: c1(3), c(3), r1, r
1757 do i = constants % nclusters, 1, -1
1759 if (constants % children(1, i) == 0) cycle
1760 c = constants % cnode(:, i)
1761 r = constants % rnode(i)
1763 j = constants % children(1, i)
1764 c1 = constants % cnode(:, j)
1765 r1 = constants % rnode(j)
1769 & constants % vscales, &
1770 & constants % vcnk, one, &
1771 & node_m(:, j), zero, node_m(:, i), work)
1773 do j = constants % children(1, i)+1, constants % children(2, i)
1774 c1 = constants % cnode(:, j)
1775 r1 = constants % rnode(j)
1778 & constants % vscales, constants % vcnk, one, &
1779 & node_m(:, j), one, node_m(:, i), work)
1793 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1810 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1812 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1813 complex(dp) :: work_complex(2*params % pm+1)
1816 real(dp) :: c1(3), c(3), r1, r
1818 do i = constants % nclusters, 1, -1
1820 if (constants % children(1, i) == 0) cycle
1821 c = constants % cnode(:, i)
1822 r = constants % rnode(i)
1824 j = constants % children(1, i)
1825 c1 = constants % cnode(:, j)
1826 r1 = constants % rnode(j)
1827 c1 = params % kappa*(c1 - c)
1829 & constants % SK_rnode(:, j), constants % SK_rnode(:, i), &
1830 & params % pm, constants % vscales, one, node_m(:, j), zero, &
1831 & node_m(:, i), work, work_complex)
1833 do j = constants % children(1, i)+1, constants % children(2, i)
1834 c1 = constants % cnode(:, j)
1835 r1 = constants % rnode(j)
1836 c1 = params % kappa*(c1 - c)
1838 & constants % SK_rnode(:, j), constants % SK_rnode(:, i), &
1839 & params % pm, constants % vscales, one, node_m(:, j), one, &
1840 & node_m(:, i), work, work_complex)
1854 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1856 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1870 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1872 real(dp),
intent(out) :: work(6*params % pm**2 + 19*params % pm + 8)
1875 real(dp) :: c1(3), c(3), r1, r
1877 do i = 2, constants % nclusters
1878 j = constants % parent(i)
1879 c = constants % cnode(:, j)
1880 r = constants % rnode(j)
1881 c1 = constants % cnode(:, i)
1882 r1 = constants % rnode(i)
1885 & constants % vscales, constants % vcnk, one, node_m(:, j), one, &
1886 & node_m(:, i), work)
1898 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1913 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
1915 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
1916 complex(dp) :: work_complex(2*params % pm+1)
1919 real(dp) :: c1(3), c(3)
1921 do i = 2, constants % nclusters
1922 j = constants % parent(i)
1923 c = constants % cnode(:, j)
1924 c1 = constants % cnode(:, i)
1925 c1 = params % kappa*(c1 - c)
1928 & constants % SK_rnode(:, j), params % pm, constants % vscales, &
1929 & one, node_m(:, j), one, node_m(:, i), work, work_complex)
1942 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1944 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
1958 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
1960 real(dp),
intent(out) :: work(6*params % pl**2 + 19*params % pl + 8)
1963 real(dp) :: c1(3), c(3), r1, r
1967 do i = 2, constants % nclusters
1968 j = constants % parent(i)
1969 c = constants % cnode(:, j)
1970 r = constants % rnode(j)
1971 c1 = constants % cnode(:, i)
1972 r1 = constants % rnode(i)
1975 & constants % vscales, constants % vfact, one, &
1976 & node_l(:, j), one, node_l(:, i), work)
1989 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
2006 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
2008 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
2009 complex(dp) :: work_complex(2*params % pl+1)
2012 real(dp) :: c_child(3), c_parent(3), c_diff(3)
2014 do i = 2, constants % nclusters
2015 j = constants % parent(i)
2016 c_child = constants % cnode(:, j)
2017 c_parent = constants % cnode(:, i)
2018 c_diff = params % kappa*(c_child - c_parent)
2020 & constants % si_rnode(:, j), constants % si_rnode(:, i), &
2021 & params % pl, constants % vscales, one, &
2022 & node_l(:, j), one, node_l(:, i), work, work_complex)
2035 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
2037 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
2051 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
2053 real(dp),
intent(out) :: work(6*params % pl**2 + 19*params % pl + 8)
2056 real(dp) :: c1(3), c(3), r1, r
2058 do i = constants % nclusters, 1, -1
2060 if (constants % children(1, i) == 0) cycle
2061 c = constants % cnode(:, i)
2062 r = constants % rnode(i)
2064 j = constants % children(1, i)
2065 c1 = constants % cnode(:, j)
2066 r1 = constants % rnode(j)
2069 & constants % vscales, constants % vfact, one, &
2070 & node_l(:, j), zero, node_l(:, i), work)
2072 do j = constants % children(1, i)+1, constants % children(2, i)
2073 c1 = constants % cnode(:, j)
2074 r1 = constants % rnode(j)
2077 & constants % vscales, constants % vfact, one, &
2078 & node_l(:, j), one, node_l(:, i), work)
2092 real(dp),
intent(inout) :: node_l((params % pl+1)**2, constants % nclusters)
2094 real(dp) :: work(6*params % pl**2 + 19*params % pl + 8)
2095 complex(dp) :: work_complex(2*params % pl+1)
2098 real(dp) :: c_parent(3), c_child(3), c_diff(3)
2100 do i = constants % nclusters, 1, -1
2101 c_child = constants % cnode(:, i)
2102 j = constants % parent(i)
2104 c_parent = constants % cnode(:, j)
2105 c_diff = params % kappa*(c_parent - c_child)
2107 & constants % si_rnode(:, i), constants % si_rnode(:, j), &
2108 & params % pl, constants % vscales, one, &
2109 & node_l(:, i), one, node_l(:, j), work, work_complex)
2121 real(dp),
intent(in) :: node_m((params % pm+1)**2, constants % nclusters)
2123 real(dp),
intent(out) :: node_l((params % pl+1)**2, constants % nclusters)
2125 real(dp) :: work(6*max(params % pm, params % pl)**2 + &
2126 & 19*max(params % pm, params % pl) + 8)
2129 real(dp) :: c1(3), c(3), r1, r
2133 do i = 1, constants % nclusters
2135 if (constants % nfar(i) .eq. 0)
then
2139 c = constants % cnode(:, i)
2140 r = constants % rnode(i)
2142 k = constants % far(constants % sfar(i))
2143 c1 = constants % cnode(:, k)
2144 r1 = constants % rnode(k)
2147 & constants % vscales, constants % m2l_ztranslate_coef, one, &
2148 & node_m(:, k), zero, node_l(:, i), work)
2149 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2150 k = constants % far(j)
2151 c1 = constants % cnode(:, k)
2152 r1 = constants % rnode(k)
2155 & params % pl, constants % vscales, &
2156 & constants % m2l_ztranslate_coef, one, node_m(:, k), one, &
2157 & node_l(:, i), work)
2171 real(dp),
intent(in) :: node_m((params % pm+1)**2, constants % nclusters)
2173 real(dp),
intent(out) :: node_l((params % pl+1)**2, constants % nclusters)
2175 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
2176 complex(dp) :: work_complex(2*params % pm+1)
2179 real(dp) :: c1(3), c(3), r1, r
2183 do i = 1, constants % nclusters
2185 if (constants % nfar(i) .eq. 0)
then
2189 c = constants % cnode(:, i)
2190 r = constants % rnode(i)
2192 k = constants % far(constants % sfar(i))
2193 c1 = constants % cnode(:, k)
2194 r1 = constants % rnode(k)
2195 c1 = params % kappa*(c1 - c)
2197 & constants % SK_rnode(:, k), constants % SI_rnode(:, i), &
2199 & constants % vscales, one, &
2200 & node_m(:, k), zero, node_l(:, i), work, work_complex)
2201 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2202 k = constants % far(j)
2203 c1 = constants % cnode(:, k)
2204 r1 = constants % rnode(k)
2205 c1 = params % kappa*(c1 - c)
2207 & constants % SI_rnode(:, i), params % pm, &
2208 & constants % vscales, one, &
2209 & node_m(:, k), one, node_l(:, i), work, work_complex)
2221 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2223 real(dp),
intent(inout) :: node_m((params % pm+1)**2, constants % nclusters)
2237 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2239 real(dp),
intent(out) :: node_m((params % pm+1)**2, constants % nclusters)
2241 real(dp) :: work(6*params % pm**2 + 19*params % pm + 8)
2242 complex(dp) :: work_complex(2*params % pm+1)
2245 real(dp) :: c1(3), c(3), r
2249 do i = 1, constants % nclusters
2251 if (constants % nfar(i) .eq. 0)
then
2254 c = constants % cnode(:, i)
2255 r = constants % rnode(i)
2257 k = constants % far(constants % sfar(i))
2258 c1 = constants % cnode(:, k)
2259 c1 = params % kappa*(c - c1)
2261 & constants % SK_rnode(:, i), params % pm, constants % vscales, &
2262 & one, node_l(:, k), one, node_m(:, i), work, work_complex)
2263 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2264 k = constants % far(j)
2265 c1 = constants % cnode(:, k)
2266 c1 = params % kappa*(c - c1)
2268 & constants % SI_rnode(:, k), constants % SK_rnode(:, i), &
2269 & params % pm, constants % vscales, one, node_l(:, k), &
2270 & one, node_m(:, i), work, work_complex)
2283 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2285 real(dp),
intent(out) :: node_m((params % pm+1)**2, constants % nclusters)
2288 real(dp) :: c1(3), c(3), r1, r
2292 do i = 1, constants % nclusters
2294 if (constants % nfar(i) .eq. 0)
then
2297 c = constants % cnode(:, i)
2298 r = constants % rnode(i)
2300 k = constants % far(constants % sfar(i))
2301 c1 = constants % cnode(:, k)
2302 r1 = constants % rnode(k)
2305 & constants % vscales, constants % m2l_ztranslate_adj_coef, one, &
2306 & node_l(:, k), one, node_m(:, i))
2307 do j = constants % sfar(i)+1, constants % sfar(i+1)-1
2308 k = constants % far(j)
2309 c1 = constants % cnode(:, k)
2310 r1 = constants % rnode(k)
2313 & constants % vscales, constants % m2l_ztranslate_adj_coef, one, &
2314 & node_l(:, k), one, node_m(:, i))
2322subroutine tree_l2p(params, constants, alpha, node_l, beta, grid_v, sph_l)
2327 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters), &
2330 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2332 real(dp),
intent(out) :: sph_l((params % pl+1)**2, params % nsph)
2339 if (beta .eq. zero)
then
2342 grid_v = beta * grid_v
2347 do isph = 1, params % nsph
2348 sph_l(:, isph) = node_l(:, constants % snode(isph))
2351 call dgemm(
'T',
'N', params % ngrid, params % nsph, &
2352 & (params % pl+1)**2, alpha, constants % vgrid2, &
2353 & constants % vgrid_nbasis, sph_l, (params % pl+1)**2, beta, grid_v, &
2366 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters), &
2369 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2371 real(dp) :: sph_l((params % pl+1)**2, params % nsph)
2375 if (beta .eq. zero)
then
2378 grid_v = beta * grid_v
2383 do isph = 1, params % nsph
2384 sph_l(:, isph) = node_l(:, constants % snode(isph))
2387 call dgemm(
'T',
'N', params % ngrid, params % nsph, &
2388 & (params % pl+1)**2, alpha, constants % vgrid, &
2389 & constants % vgrid_nbasis, sph_l, (params % pl+1)**2, beta, grid_v, &
2396subroutine tree_l2p_adj(params, constants, alpha, grid_v, beta, node_l, sph_l)
2401 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2404 real(dp),
intent(inout) :: node_l((params % pl+1)**2, &
2405 & constants % nclusters)
2407 real(dp),
intent(out) :: sph_l((params % pl+1)**2, params % nsph)
2409 integer :: isph, inode
2412 if (beta .eq. zero)
then
2415 node_l = beta * node_l
2418 call dgemm(
'N',
'N', (params % pl+1)**2, params % nsph, &
2419 & params % ngrid, one, constants % vgrid2, constants % vgrid_nbasis, &
2420 & grid_v, params % ngrid, zero, sph_l, &
2421 & (params % pl+1)**2)
2425 do isph = 1, params % nsph
2426 inode = constants % snode(isph)
2427 node_l(:, inode) = node_l(:, inode) + alpha*sph_l(:, isph)
2439 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2442 real(dp),
intent(inout) :: node_l((params % pl+1)**2, &
2443 & constants % nclusters)
2445 real(dp) :: sph_l((params % pl+1)**2, params % nsph)
2446 integer :: isph, inode
2449 if (beta .eq. zero)
then
2452 node_l = beta * node_l
2455 call dgemm(
'N',
'N', (params % pl+1)**2, params % nsph, &
2456 & params % ngrid, one, constants % vgrid, constants % vgrid_nbasis, &
2457 & grid_v, params % ngrid, zero, sph_l, &
2458 & (params % pl+1)**2)
2462 do isph = 1, params % nsph
2463 inode = constants % snode(isph)
2464 node_l(:, inode) = node_l(:, inode) + alpha*sph_l(:, isph)
2471subroutine tree_m2p(params, constants, p, alpha, sph_m, beta, grid_v)
2476 integer,
intent(in) :: p
2477 real(dp),
intent(in) :: sph_m((p+1)**2, params % nsph), alpha, beta
2479 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2481 integer :: isph, inode, jnear, jnode, jsph, igrid
2484 real(dp) :: work(p+1)
2486 if (beta .eq. zero)
then
2489 grid_v = beta * grid_v
2495 do isph = 1, params % nsph
2497 inode = constants % snode(isph)
2498 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2501 jnode = constants % near(jnear)
2502 jsph = constants % order(constants % cluster(1, jnode))
2504 if(isph .eq. jsph) cycle
2506 do igrid = 1, params % ngrid
2507 if(constants % ui(igrid, isph) .eq. zero) cycle
2508 c = constants % cgrid(:, igrid)*params % rsph(isph) - &
2509 & params % csph(:, jsph) + params % csph(:, isph)
2511 & constants % vscales_rel, alpha, sph_m(:, jsph), one, &
2512 & grid_v(igrid, isph), work)
2526 integer,
intent(in) :: p, sph_p
2527 real(dp),
intent(in) :: sph_m((sph_p+1)**2, params % nsph), alpha, beta
2529 real(dp),
intent(inout) :: grid_v(params % ngrid, params % nsph)
2531 integer :: isph, inode, jnear, jnode, jsph, igrid
2534 real(dp) :: work(p+1)
2535 complex(dp) :: work_complex(p+1)
2537 if (beta .eq. zero)
then
2540 grid_v = beta * grid_v
2546 do isph = 1, params % nsph
2548 inode = constants % snode(isph)
2549 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2552 jnode = constants % near(jnear)
2553 jsph = constants % order(constants % cluster(1, jnode))
2557 do igrid = 1, params % ngrid
2558 if(constants % ui(igrid, isph) .eq. zero) cycle
2559 c = constants % cgrid(:, igrid)*params % rsph(isph) - &
2560 & params % csph(:, jsph) + params % csph(:, isph)
2561 c = c * params % kappa
2563 & constants % SK_ri(:, jsph), alpha, sph_m(:, jsph), one, &
2564 & grid_v(igrid, isph), work_complex, work)
2578 integer,
intent(in) :: p
2579 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2582 real(dp),
intent(inout) :: sph_m((p+1)**2, params % nsph)
2584 real(dp) :: work(p+1)
2586 integer :: isph, inode, jnear, jnode, jsph, igrid
2589 if (beta .eq. zero)
then
2592 sph_m = beta * sph_m
2598 do isph = 1, params % nsph
2600 inode = constants % snode(isph)
2601 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2604 jnode = constants % near(jnear)
2605 jsph = constants % order(constants % cluster(1, jnode))
2607 if(isph .eq. jsph) cycle
2609 do igrid = 1, params % ngrid
2610 if(constants % ui(igrid, jsph) .eq. zero) cycle
2611 c = constants % cgrid(:, igrid)*params % rsph(jsph) - &
2612 & params % csph(:, isph) + params % csph(:, jsph)
2614 & params % rsph(isph), p, constants % vscales_rel, one, &
2615 & sph_m(:, isph), work)
2630 integer,
intent(in) :: p, sph_p
2631 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2634 real(dp),
intent(inout) :: sph_m((sph_p+1)**2, params % nsph)
2637 integer :: isph, inode, jnear, jnode, jsph, igrid
2640 if (beta .eq. zero)
then
2643 sph_m = beta * sph_m
2649 do isph = 1, params % nsph
2651 inode = constants % snode(isph)
2652 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2655 jnode = constants % near(jnear)
2656 jsph = constants % order(constants % cluster(1, jnode))
2658 do igrid = 1, params % ngrid
2659 if(constants % ui(igrid, jsph) .eq. zero) cycle
2660 c = constants % cgrid(:, igrid)*params % rsph(jsph) - &
2661 & params % csph(:, isph) + params % csph(:, jsph)
2663 & params % rsph(isph), params % kappa, p, &
2664 & constants % vscales, one, sph_m(:, isph))
2679 integer,
intent(in) :: p, sph_p
2680 real(dp),
intent(in) :: grid_v(params % ngrid, params % nsph), alpha, &
2683 real(dp),
intent(inout) :: sph_m((sph_p+1)**2, params % nsph)
2685 integer :: isph, inode, jnear, jnode, jsph, igrid
2688 if (beta .eq. zero)
then
2691 sph_m = beta * sph_m
2694 do isph = 1, params % nsph
2696 inode = constants % snode(isph)
2697 do jnear = constants % snear(inode), constants % snear(inode+1)-1
2700 jnode = constants % near(jnear)
2701 jsph = constants % order(constants % cluster(1, jnode))
2703 if(isph .eq. jsph) cycle
2705 do igrid = 1, params % ngrid
2706 if(constants % ui(igrid, isph) .eq. zero) cycle
2707 c = constants % cgrid(:, igrid)*params % rsph(isph) - &
2708 & params % csph(:, jsph) + params % csph(:, isph)
2710 & params % rsph(jsph), params % kappa, p, constants % vscales, one, &
2725 real(dp),
intent(in) :: sph_m(constants % nbasis, params % nsph)
2727 real(dp),
intent(inout) :: sph_m_grad((params % lmax+2)**2, 3, &
2730 real(dp),
intent(inout) :: work((params % lmax+2)**2, params % nsph)
2732 integer :: isph, l, indi, indj, m
2733 real(dp) :: tmp1, tmp2
2734 real(dp),
dimension(3, 3) :: zx_coord_transform, zy_coord_transform
2736 zx_coord_transform = zero
2737 zx_coord_transform(3, 2) = one
2738 zx_coord_transform(2, 3) = one
2739 zx_coord_transform(1, 1) = one
2740 zy_coord_transform = zero
2741 zy_coord_transform(1, 2) = one
2742 zy_coord_transform(2, 1) = one
2743 zy_coord_transform(3, 3) = one
2745 sph_m_grad(1:constants % nbasis, 3, :) = sph_m
2746 do isph = 1, params % nsph
2748 & sph_m(:, isph), zero, sph_m_grad(1:constants % nbasis, 1, isph))
2750 & sph_m(:, isph), zero, sph_m_grad(1:constants % nbasis, 2, isph))
2756 do l = params % lmax+1, 1, -1
2759 tmp1 = sqrt(dble(2*l+1)) / sqrt(dble(2*l-1))
2761 tmp2 = sqrt(dble(l*l-m*m)) * tmp1
2762 sph_m_grad(indi+m, :, :) = tmp2 * sph_m_grad(indj+m, :, :)
2764 sph_m_grad(indi+l, :, :) = zero
2765 sph_m_grad(indi-l, :, :) = zero
2767 sph_m_grad(1, :, :) = zero
2770 do isph = 1, params % nsph
2771 sph_m_grad(:, 3, isph) = sph_m_grad(:, 3, isph) / params % rsph(isph)
2772 work(:, isph) = sph_m_grad(:, 1, isph) / params % rsph(isph)
2774 & work(:, isph), zero, sph_m_grad(:, 1, isph))
2775 work(:, isph) = sph_m_grad(:, 2, isph) / params % rsph(isph)
2777 & work(:, isph), zero, sph_m_grad(:, 2, isph))
2789 real(dp),
intent(in) :: node_l((params % pl+1)**2, constants % nclusters)
2791 real(dp),
intent(out) :: sph_l_grad((params % pl+1)**2, 3, params % nsph)
2793 real(dp),
intent(out) :: work((params % pl+1)**2, params % nsph)
2795 integer :: isph, inode, l, indi, indj, m
2796 real(dp) :: tmp1, tmp2
2797 real(dp),
dimension(3, 3) :: zx_coord_transform, zy_coord_transform
2800 if (params % pl .le. 0)
return
2802 zx_coord_transform = zero
2803 zx_coord_transform(3, 2) = one
2804 zx_coord_transform(2, 3) = one
2805 zx_coord_transform(1, 1) = one
2806 zy_coord_transform = zero
2807 zy_coord_transform(1, 2) = one
2808 zy_coord_transform(2, 1) = one
2809 zy_coord_transform(3, 3) = one
2811 do isph = 1, params % nsph
2812 inode = constants % snode(isph)
2813 sph_l_grad(:, 3, isph) = node_l(:, inode)
2815 & node_l(:, inode), zero, sph_l_grad(:, 1, isph))
2817 & node_l(:, inode), zero, sph_l_grad(:, 2, isph))
2823 do l = 1, params % pl
2826 tmp1 = -sqrt(dble(2*l-1)) / sqrt(dble(2*l+1))
2828 tmp2 = sqrt(dble(l*l-m*m)) * tmp1
2829 sph_l_grad(indj+m, :, :) = tmp2 * sph_l_grad(indi+m, :, :)
2834 do isph = 1, params % nsph
2835 sph_l_grad(1:params % pl**2, 3, isph) = &
2836 & sph_l_grad(1:params % pl**2, 3, isph) / params % rsph(isph)
2837 work(1:params % pl**2, isph) = &
2838 & sph_l_grad(1:params % pl**2, 1, isph) / params % rsph(isph)
2840 & work(1:params % pl**2, isph), zero, &
2841 & sph_l_grad(1:params % pl**2, 1, isph))
2842 work(1:params % pl**2, isph) = &
2843 & sph_l_grad(1:params % pl**2, 2, isph) / params % rsph(isph)
2845 & work(1:params % pl**2, isph), zero, &
2846 & sph_l_grad(1:params % pl**2, 2, isph))
2851 sph_l_grad(indi-l:indi+l, :, :) = zero
2861 character (len=2047),
intent(out) :: string
2862 character (len=10) :: vstr
2863 write(vstr, *)
"1.0.0"
2865 &
" +----------------------------------------------------------------+", &
2869 &
" | 888 888 Y8b d8Y |", &
2871 &
" | 888 888 Y8b d8Y |", &
2873 &
" | 888 888 Y8888Y |", &
2875 &
" | .d88888 .d88888 Y88Y |", &
2877 &
" | d88 888 d88 888 d88b |", &
2879 &
" | 888 888 888 888 d8888b |", &
2881 &
" | Y88b 888 Y88b 888 d8Y Y8b |", &
2883 &
" | Y88888 Y88888 d8Y Y8b |", &
2887 &
" | https://ddsolvation.github.io/ddX/ |", &
2889 &
" | Version:", vstr,
" |", &
2893 &
" +----------------------------------------------------------------+"
2913 real(dp),
intent(in) :: property_cav(constants % ncav)
2914 real(dp),
intent(out) :: property_sph(constants % nbasis, params % nsph)
2917 workspace % tmp_cav = property_cav * constants % ui_cav
2921 & constants % icav_ia, constants % icav_ja, workspace % tmp_cav, &
2922 & workspace % tmp_grid)
2925 call ddintegrate(params % nsph, constants % nbasis, &
2926 & params % ngrid, constants % vwgrid, constants % vgrid_nbasis, &
2927 & 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 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, switching, ddx_data, ddx_error)
Initialize ddX input with a full set of parameters.
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 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, switching, 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.