48 spline_environment_type,&
54 #include "./base/base_uses.f90"
59 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pair_potential'
60 REAL(KIND=
dp),
PARAMETER,
PRIVATE :: min_hicut_value = 1.0e-15_dp, &
61 default_hicut_value = 1.0e3_dp
62 INTEGER,
PARAMETER,
PRIVATE :: MAX_POINTS = 2000000
78 TYPE(pair_potential_pp_type),
POINTER :: potparm
79 INTEGER,
INTENT(IN) :: ntype
81 CHARACTER(len=*),
PARAMETER :: routinen =
'init_genpot'
83 INTEGER :: handle, i, j, k, ngp
84 TYPE(pair_potential_single_type),
POINTER :: pot
86 CALL timeset(routinen, handle)
93 pot => potparm%pot(i, j)%pot
94 ngp = ngp + count(pot%type ==
gp_type)
101 pot => potparm%pot(i, j)%pot
102 DO k = 1,
SIZE(pot%type)
103 IF (pot%type(k) ==
gp_type)
THEN
105 pot%set(k)%gp%myid = ngp
106 CALL parsef(ngp, trim(pot%set(k)%gp%potential), pot%set(k)%gp%parameters)
111 CALL timestop(handle)
135 eps_spline, max_energy, rlow_nb, emax_spline, npoints, iw, iw2, iw3, do_zbl, &
136 shift_cutoff, nonbonded_type)
138 TYPE(spline_environment_type),
POINTER :: spline_env
139 TYPE(pair_potential_pp_type),
POINTER :: potparm
140 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
141 REAL(kind=
dp),
INTENT(IN) :: eps_spline, max_energy, rlow_nb, &
143 INTEGER,
INTENT(IN) :: npoints, iw, iw2, iw3
144 LOGICAL,
INTENT(IN) :: do_zbl, shift_cutoff
145 CHARACTER(LEN=*),
INTENT(IN) :: nonbonded_type
147 CHARACTER(len=*),
PARAMETER :: routinen =
'spline_nonbond_control'
149 INTEGER :: handle, i, ip, j, k, n, ncount, &
150 npoints_spline, ntype
151 LOGICAL :: found_locut
152 REAL(kind=
dp) :: energy_cutoff, hicut, hicut0, locut
153 TYPE(pair_potential_single_type),
POINTER :: pot
158 ntype =
SIZE(atomic_kind_set)
159 CALL timeset(routinen, handle)
161 WRITE (iw3,
"(/,T2,A,I0,A,I0,A)") &
162 "SPLINE_INFO| Generating ", (ntype*(ntype + 1))/2,
" splines for "// &
163 trim(adjustl(nonbonded_type))//
" interactions "
164 WRITE (iw3,
"(T2,A,I0,A)") &
165 " Due to ", ntype,
" different atomic kinds"
172 pot => potparm%pot(i, j)%pot
173 IF (iw3 > 0 .AND. iw <= 0)
THEN
174 IF (mod(i*(i - 1)/2 + j, max(1, (ntype*(ntype + 1))/(2*10))) == 0)
THEN
175 WRITE (unit=iw3, advance=
"NO", fmt=
'(2X,A3,I0)')
'...', i*(i - 1)/2 + j
186 DO k = 1,
SIZE(pot%type)
187 SELECT CASE (pot%type(k))
206 SELECT CASE (pot%type(k))
213 IF (.NOT. pot%undef) cycle
215 n = spline_env%spltab(i, j)
217 hicut0 = sqrt(pot%rcutsq)
218 IF (abs(hicut0) <= min_hicut_value) hicut0 = default_hicut_value
219 hicut = hicut0/sqrt(pot%spl_f%rcutsq_f)
221 energy_cutoff = pot%spl_f%cutoff
224 CALL get_spline_cutoff(hicut, locut, found_locut, pot, do_zbl, &
225 energy_cutoff, emax_spline)
226 locut = max(locut*sqrt(pot%spl_f%rcutsq_f), rlow_nb)
229 npoints_spline = npoints
230 CALL generate_spline_low(spline_env%spl_pp(n)%spl_p, npoints_spline, locut, &
231 hicut, eps_spline, iw, iw2, i, j, n, ncount, max_energy, pot, &
232 energy_cutoff, found_locut, do_zbl, atomic_kind_set, &
237 IF (
SIZE(pot%type) == 1)
THEN
241 pot%set(1)%lj%sigma6 = pot%set(1)%lj%sigma6*pot%spl_f%rscale(1)**3
242 pot%set(1)%lj%sigma12 = pot%set(1)%lj%sigma6**2
243 pot%set(1)%lj%epsilon = pot%set(1)%lj%epsilon*pot%spl_f%fscale(1)
248 IF (shift_cutoff)
THEN
249 pot%spl_f%cutoff = pot%spl_f%cutoff*pot%spl_f%fscale(1) - &
257 WRITE (iw,
'(/,T2,A,I0)') &
258 "SPLINE_INFO| Number of pair potential splines allocated: ", maxval(spline_env%spltab)
261 WRITE (iw3,
'(/,T2,A,I0,/,T2,A)') &
262 "SPLINE_INFO| Number of unique splines computed: ", maxval(spline_env%spltab), &
266 CALL timestop(handle)
284 SUBROUTINE get_spline_cutoff(hicut, locut, found_locut, pot, do_zbl, &
285 energy_cutoff, emax_spline)
287 REAL(kind=
dp),
INTENT(IN) :: hicut
288 REAL(kind=
dp),
INTENT(INOUT) :: locut
289 LOGICAL,
INTENT(OUT) :: found_locut
290 TYPE(pair_potential_single_type),
OPTIONAL, &
292 LOGICAL,
INTENT(IN) :: do_zbl
293 REAL(kind=
dp),
INTENT(IN) :: energy_cutoff, emax_spline
295 INTEGER :: ilevel, jx
296 REAL(kind=
dp) :: dx2, e, locut_found, x
298 dx2 = (hicut - locut)
301 found_locut = .false.
309 IF (abs(e) > emax_spline)
THEN
320 END SUBROUTINE get_spline_cutoff
346 SUBROUTINE generate_spline_low(spl_p, npoints, locut, hicut, eps_spline, &
347 iw, iw2, i, j, n, ncount, max_energy, pot, energy_cutoff, &
348 found_locut, do_zbl, atomic_kind_set, nonbonded_type)
350 TYPE(spline_data_p_type),
DIMENSION(:),
POINTER :: spl_p
351 INTEGER,
INTENT(INOUT) :: npoints
352 REAL(kind=
dp),
INTENT(IN) :: locut, hicut, eps_spline
353 INTEGER,
INTENT(IN) :: iw, iw2, i, j, n, ncount
354 REAL(kind=
dp),
INTENT(IN) :: max_energy
355 TYPE(pair_potential_single_type),
POINTER :: pot
356 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: energy_cutoff
357 LOGICAL,
INTENT(IN) :: found_locut, do_zbl
358 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
359 CHARACTER(LEN=*),
INTENT(IN) :: nonbonded_type
361 CHARACTER(LEN=2*default_string_length) :: message, tmp
362 CHARACTER(LEN=default_path_length) :: file_name
363 INTEGER :: ix, jx, mfac, nppa, nx, unit_number
364 LOGICAL :: fixed_spline_points
365 REAL(kind=
dp) :: df, dg, dh, diffmax, dx, dx2, e, &
366 e_spline, f, g, h, r, rcut, x, x2, &
368 TYPE(cp_logger_type),
POINTER :: logger
369 TYPE(spline_data_type),
POINTER :: spline_data
370 TYPE(spline_factor_type),
POINTER :: spl_f
372 NULLIFY (logger, spl_f)
377 IF (npoints > 0)
THEN
378 fixed_spline_points = .true.
380 fixed_spline_points = .false.
382 IF (.NOT. found_locut) npoints = 2
384 spline_data => spl_p(1)%spline_data
387 dx2 = (1.0_dp/locut**2 - 1.0_dp/hicut**2)/real(npoints, kind=
dp)
390 DO jx = 1, npoints + 1
397 spline_data%y(jx) = e
402 dx2 = (hicut - locut)/real(mfac*npoints + 1, kind=
dp)
407 IF (fixed_spline_points)
EXIT
408 DO jx = 1, mfac*npoints
414 IF (abs(e) < max_energy)
THEN
415 xdum1 = abs(e -
potential_s(spl_p, x*x, xdum, spl_f, logger))
416 diffmax = max(diffmax, xdum1)
422 IF (npoints > max_points)
THEN
423 WRITE (message,
'(A,I8,A,G12.6,A)')
"SPLINE_INFO| Number of points: ", npoints, &
424 " obtained accuracy ", diffmax,
". MM SPLINE: no convergence on required"// &
425 " accuracy (adjust EPS_SPLINE and rerun)"
426 CALL cp_abort(__location__, trim(message))
429 IF (diffmax > eps_spline .OR. diffmax < 0.0_dp)
THEN
430 npoints = ceiling(1.2_dp*real(npoints, kind=
dp))
438 fmt=
"(/,A,I0,/,A,I0,/,A,I0,1X,I0,/,A,/,A,I0,2(/,A,ES13.6),2(/,A,2ES13.6))") &
439 " SPLINE_INFO| Spline number: ", ncount, &
440 " SPLINE_INFO| Unique spline number: ", n, &
441 " SPLINE_INFO| Atomic kind numbers: ", i, j, &
442 " SPLINE_INFO| Atomic kind names: "//trim(adjustl(atomic_kind_set(i)%name))//
" "// &
443 trim(adjustl(atomic_kind_set(j)%name)), &
444 " SPLINE_INFO| Number of spline points: ", npoints, &
445 " SPLINE_INFO| Requested accuracy [Hartree]: ", eps_spline, &
446 " SPLINE_INFO| Achieved accuracy [Hartree]: ", diffmax, &
447 " SPLINE_INFO| Spline range [bohr]: ", locut, hicut, &
448 " SPLINE_INFO| Spline range used to achieve accuracy [bohr]:", xsav, hicut
449 dx2 = (hicut - locut)/real(npoints + 1, kind=
dp)
451 WRITE (unit=iw, fmt=
'(A,ES17.9)') &
452 " SPLINE_INFO| Spline value at RMIN [Hartree]: ",
potential_s(spl_p, x*x, xdum, spl_f, logger), &
453 " SPLINE_INFO| Spline value at RMAX [Hartree]: ",
potential_s(spl_p, hicut*hicut, xdum, spl_f, logger), &
454 " SPLINE_INFO| Non-bonded energy cutoff [Hartree]: ", energy_cutoff
460 dx =
bohr/real(nppa, kind=
dp)
463 tmp = adjustl(cp_to_string(n))
464 WRITE (unit=file_name, fmt=
"(A,I0,A)") &
465 trim(adjustl(nonbonded_type))//
"_SPLINE_"//trim(tmp)//
"_"// &
466 trim(adjustl(atomic_kind_set(i)%name))//
"_"// &
467 trim(adjustl(atomic_kind_set(j)%name))
469 file_status=
"UNKNOWN", &
470 file_form=
"FORMATTED", &
471 file_action=
"WRITE", &
472 unit_number=unit_number)
473 WRITE (unit=unit_number, &
474 fmt=
"(2(A,I0,/),A,I0,1X,I0,/,A,/,A,I0,2(/,A,ES13.6),2(/,A,2ES13.6),/,A,ES13.6,/,A,I0,A,/,A)") &
475 "# Spline number: ", ncount, &
476 "# Unique spline number: ", n, &
477 "# Atomic kind numbers: ", i, j, &
478 "# Atomic kind names: "//trim(adjustl(atomic_kind_set(i)%name))//
" "// &
479 trim(adjustl(atomic_kind_set(j)%name)), &
480 "# Number of spline points: ", npoints, &
481 "# Requested accuracy [eV]: ", eps_spline*
evolt, &
482 "# Achieved accuracy [eV]: ", diffmax*
evolt, &
483 "# Spline range [Angstrom]: ", locut/
bohr, hicut/
bohr, &
484 "# Spline range used to achieve accuracy [Angstrom]:", xsav/
bohr, hicut/
bohr, &
485 "# Non-bonded energy cutoff [eV]: ", energy_cutoff*
evolt, &
486 "# Test spline using ", nppa,
" points per Angstrom:", &
487 "# Abscissa [Angstrom] Energy [eV] Splined energy [eV] Derivative [eV/Angstrom]"// &
488 " |Energy error| [eV]"
491 IF (x > hicut) x = hicut
494 IF (do_zbl) e = e +
ener_zbl(pot, x)
495 e_spline =
potential_s(spl_p, x*x, xdum, spl_f, logger)
496 WRITE (unit=unit_number, fmt=
"(5ES25.12)") &
503 WRITE (unit=file_name, fmt=
"(A,I0,A)") &
505 trim(adjustl(atomic_kind_set(i)%name))//
"_"// &
506 trim(adjustl(atomic_kind_set(j)%name))//
".xvg"
508 file_status=
"UNKNOWN", &
509 file_form=
"FORMATTED", &
510 file_action=
"WRITE", &
511 unit_number=unit_number)
514 rcut = 0.1_dp*hicut/
bohr
517 IF (x > hicut) x = hicut
520 WRITE (unit=unit_number, fmt=
"(7ES25.12)") &
523 e_spline =
potential_s(spl_p, x*x, xdum, spl_f, logger)
526 g = -1.0_dp/r**6 + 1.0_dp/rcut**6
530 WRITE (unit=unit_number, fmt=
"(7ES25.12)") &
542 END SUBROUTINE generate_spline_low
556 TYPE(spline_environment_type),
POINTER :: spline_env
557 TYPE(pair_potential_pp_type),
POINTER :: potparm
558 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
559 LOGICAL,
INTENT(IN) :: do_zbl, shift_cutoff
561 CHARACTER(len=*),
PARAMETER :: routinen =
'get_nonbond_storage'
563 INTEGER :: handle, i, idim, iend, istart, j, k, &
564 locij, n, ndim, nk, ntype, nunique, &
565 nvar, pot_target, tmpij(2), tmpij0(2)
566 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iwork1, iwork2, my_index
567 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: tmp_index
568 LOGICAL :: at_least_one, check
569 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: cwork, rwork, wtmp
570 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: pot_par
572 CALL timeset(routinen, handle)
574 ntype =
SIZE(atomic_kind_set)
577 potparm%pot(i, j)%pot%undef = .false.
580 ALLOCATE (tmp_index(ntype, ntype))
588 IF (
SIZE(potparm%pot(i, j)%pot%type) /= 1) cycle
589 IF (potparm%pot(i, j)%pot%type(1) == pot_target)
THEN
598 SELECT CASE (pot_target)
643 ALLOCATE (my_index(ndim))
649 IF (
SIZE(potparm%pot(i, j)%pot%type) /= 1) cycle
650 IF (potparm%pot(i, j)%pot%type(1) == pot_target)
THEN
657 ALLOCATE (pot_par(ndim, nvar))
663 IF (
SIZE(potparm%pot(i, j)%pot%type) /= 1) cycle
664 IF (potparm%pot(i, j)%pot%type(1) == pot_target)
THEN
667 SELECT CASE (pot_target)
669 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%lj%epsilon
670 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%lj%sigma6
671 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%lj%sigma12
673 pot_par(nk, 1) =
str2id(potparm%pot(i, j)%pot%set(1)%gp%potential)
674 pot_par(nk, 2) =
str2id(potparm%pot(i, j)%pot%set(1)%gp%variables)
676 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%willis%a
677 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%willis%b
678 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%willis%c
680 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%goodwin%vr0
681 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%goodwin%m
682 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%goodwin%mc
683 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%goodwin%d
684 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%goodwin%dc
686 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%eam%drar
687 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%eam%drhoar
688 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%eam%acutal
689 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%eam%npoints
691 pot_par(nk, 1) =
str2id( &
692 trim(potparm%pot(i, j)%pot%set(1)%quip%quip_file_name)// &
693 trim(potparm%pot(i, j)%pot%set(1)%quip%init_args)// &
694 trim(potparm%pot(i, j)%pot%set(1)%quip%calc_args))
696 pot_par(nk, 1) =
str2id( &
697 trim(potparm%pot(i, j)%pot%set(1)%nequip%nequip_file_name))
699 pot_par(nk, 1) =
str2id( &
700 trim(potparm%pot(i, j)%pot%set(1)%allegro%allegro_file_name))
702 pot_par(nk, 1) =
str2id( &
703 trim(potparm%pot(i, j)%pot%set(1)%deepmd%deepmd_file_name))
704 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%deepmd%atom_deepmd_type
706 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%ft%A
707 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%ft%B
708 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%ft%C
709 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%ft%D
711 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%ftd%A
712 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%ftd%B
713 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%ftd%C
714 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%ftd%D
715 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%ftd%BD(1)
716 pot_par(nk, 6) = potparm%pot(i, j)%pot%set(1)%ftd%BD(2)
718 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%ipbv%rcore
719 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%ipbv%m
720 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%ipbv%b
722 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%buck4r%a
723 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%buck4r%b
724 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%buck4r%c
725 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%buck4r%r1
726 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%buck4r%r2
727 pot_par(nk, 6) = potparm%pot(i, j)%pot%set(1)%buck4r%r3
729 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%buckmo%f0
730 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%buckmo%a1
731 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%buckmo%a2
732 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%buckmo%b1
733 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%buckmo%b2
734 pot_par(nk, 6) = potparm%pot(i, j)%pot%set(1)%buckmo%c
735 pot_par(nk, 7) = potparm%pot(i, j)%pot%set(1)%buckmo%d
736 pot_par(nk, 8) = potparm%pot(i, j)%pot%set(1)%buckmo%r0
737 pot_par(nk, 9) = potparm%pot(i, j)%pot%set(1)%buckmo%beta
739 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%tersoff%A
740 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%tersoff%B
741 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%tersoff%lambda1
742 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%tersoff%lambda2
743 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%tersoff%alpha
744 pot_par(nk, 6) = potparm%pot(i, j)%pot%set(1)%tersoff%beta
745 pot_par(nk, 7) = potparm%pot(i, j)%pot%set(1)%tersoff%n
746 pot_par(nk, 8) = potparm%pot(i, j)%pot%set(1)%tersoff%c
747 pot_par(nk, 9) = potparm%pot(i, j)%pot%set(1)%tersoff%d
748 pot_par(nk, 10) = potparm%pot(i, j)%pot%set(1)%tersoff%h
749 pot_par(nk, 11) = potparm%pot(i, j)%pot%set(1)%tersoff%lambda3
750 pot_par(nk, 12) = potparm%pot(i, j)%pot%set(1)%tersoff%bigR
751 pot_par(nk, 13) = potparm%pot(i, j)%pot%set(1)%tersoff%bigD
753 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%siepmann%B
754 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%siepmann%D
755 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%siepmann%E
756 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%siepmann%F
757 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%siepmann%beta
759 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%gal%epsilon
760 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%gal%bxy
761 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%gal%bz
762 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%gal%r1
763 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%gal%r2
764 pot_par(nk, 6) = potparm%pot(i, j)%pot%set(1)%gal%a1
765 pot_par(nk, 7) = potparm%pot(i, j)%pot%set(1)%gal%a2
766 pot_par(nk, 8) = potparm%pot(i, j)%pot%set(1)%gal%a3
767 pot_par(nk, 9) = potparm%pot(i, j)%pot%set(1)%gal%a4
768 pot_par(nk, 10) = potparm%pot(i, j)%pot%set(1)%gal%a
769 pot_par(nk, 11) = potparm%pot(i, j)%pot%set(1)%gal%b
770 pot_par(nk, 12) = potparm%pot(i, j)%pot%set(1)%gal%c
772 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%gal21%epsilon1
773 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%gal21%epsilon2
774 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%gal21%epsilon3
775 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%gal21%bxy1
776 pot_par(nk, 5) = potparm%pot(i, j)%pot%set(1)%gal21%bxy2
777 pot_par(nk, 6) = potparm%pot(i, j)%pot%set(1)%gal21%bz1
778 pot_par(nk, 7) = potparm%pot(i, j)%pot%set(1)%gal21%bz2
779 pot_par(nk, 8) = potparm%pot(i, j)%pot%set(1)%gal21%r1
780 pot_par(nk, 9) = potparm%pot(i, j)%pot%set(1)%gal21%r2
781 pot_par(nk, 10) = potparm%pot(i, j)%pot%set(1)%gal21%a11
782 pot_par(nk, 11) = potparm%pot(i, j)%pot%set(1)%gal21%a12
783 pot_par(nk, 12) = potparm%pot(i, j)%pot%set(1)%gal21%a13
784 pot_par(nk, 13) = potparm%pot(i, j)%pot%set(1)%gal21%a21
785 pot_par(nk, 14) = potparm%pot(i, j)%pot%set(1)%gal21%a22
786 pot_par(nk, 15) = potparm%pot(i, j)%pot%set(1)%gal21%a23
787 pot_par(nk, 16) = potparm%pot(i, j)%pot%set(1)%gal21%a31
788 pot_par(nk, 17) = potparm%pot(i, j)%pot%set(1)%gal21%a32
789 pot_par(nk, 18) = potparm%pot(i, j)%pot%set(1)%gal21%a33
790 pot_par(nk, 19) = potparm%pot(i, j)%pot%set(1)%gal21%a41
791 pot_par(nk, 20) = potparm%pot(i, j)%pot%set(1)%gal21%a42
792 pot_par(nk, 21) = potparm%pot(i, j)%pot%set(1)%gal21%a43
793 pot_par(nk, 22) = potparm%pot(i, j)%pot%set(1)%gal21%AO1
794 pot_par(nk, 23) = potparm%pot(i, j)%pot%set(1)%gal21%AO2
795 pot_par(nk, 24) = potparm%pot(i, j)%pot%set(1)%gal21%BO1
796 pot_par(nk, 25) = potparm%pot(i, j)%pot%set(1)%gal21%BO2
797 pot_par(nk, 26) = potparm%pot(i, j)%pot%set(1)%gal21%c
798 pot_par(nk, 27) = potparm%pot(i, j)%pot%set(1)%gal21%AH1
799 pot_par(nk, 28) = potparm%pot(i, j)%pot%set(1)%gal21%AH2
800 pot_par(nk, 29) = potparm%pot(i, j)%pot%set(1)%gal21%BH1
801 pot_par(nk, 30) = potparm%pot(i, j)%pot%set(1)%gal21%BH2
803 pot_par(nk, 1) = potparm%pot(i, j)%pot%set(1)%tab%dr
804 pot_par(nk, 2) = potparm%pot(i, j)%pot%set(1)%tab%rcut
805 pot_par(nk, 3) = potparm%pot(i, j)%pot%set(1)%tab%npoints
806 pot_par(nk, 4) = potparm%pot(i, j)%pot%set(1)%tab%index
813 pot_par(nk, :) = real(pot_target, kind=
dp)
819 ALLOCATE (rwork(ndim))
820 ALLOCATE (iwork1(ndim))
821 ALLOCATE (iwork2(ndim))
822 ALLOCATE (wtmp(nvar))
823 CALL sort(pot_par(:, 1), ndim, iwork1)
826 rwork(:) = pot_par(:, k)
828 pot_par(i, k) = rwork(iwork1(i))
833 my_index(i) = iwork2(iwork1(i))
837 wtmp(1:k - 1) = pot_par(1, 1:k - 1)
839 at_least_one = .false.
841 rwork(j) = pot_par(j, k)
842 IF (all(pot_par(j, 1:k - 1) == wtmp(1:k - 1))) cycle
844 wtmp(1:k - 1) = pot_par(j, 1:k - 1)
848 idim = iend - istart + 1
849 CALL sort(rwork(istart:iend), idim, iwork1(istart:iend))
850 iwork1(istart:iend) = iwork1(istart:iend) - 1 + istart
851 IF (idim /= 1) at_least_one = .true.
855 idim = iend - istart + 1
856 CALL sort(rwork(istart:iend), idim, iwork1(istart:iend))
857 iwork1(istart:iend) = iwork1(istart:iend) - 1 + istart
858 IF (idim /= 1) at_least_one = .true.
859 pot_par(:, k) = rwork
860 IF (.NOT. at_least_one)
EXIT
863 rwork(:) = pot_par(:, j)
865 pot_par(i, j) = rwork(iwork1(i))
870 my_index(i) = iwork2(iwork1(i))
880 ALLOCATE (cwork(nvar))
881 cwork(:) = pot_par(1, :)
883 CALL get_indexes(locij, ntype, tmpij0)
888 CALL get_indexes(locij, ntype, tmpij)
889 SELECT CASE (pot_target)
893 CALL compare_pot(potparm%pot(tmpij(1), tmpij(2))%pot, &
894 potparm%pot(tmpij0(1), tmpij0(2))%pot, &
898 IF (
ASSOCIATED(potparm%pot(tmpij(1), tmpij(2))%pot%set(1)%gp%parameters) .AND. &
899 ASSOCIATED(potparm%pot(tmpij0(1), tmpij0(2))%pot%set(1)%gp%parameters))
THEN
900 IF (
SIZE(potparm%pot(tmpij(1), tmpij(2))%pot%set(1)%gp%parameters) == &
901 SIZE(potparm%pot(tmpij0(1), tmpij0(2))%pot%set(1)%gp%parameters))
THEN
902 IF (any(potparm%pot(tmpij(1), tmpij(2))%pot%set(1)%gp%parameters /= &
903 potparm%pot(tmpij0(1), tmpij0(2))%pot%set(1)%gp%parameters)) check = .false.
906 IF (
ASSOCIATED(potparm%pot(tmpij(1), tmpij(2))%pot%set(1)%gp%values) .AND. &
907 ASSOCIATED(potparm%pot(tmpij0(1), tmpij0(2))%pot%set(1)%gp%values))
THEN
908 IF (
SIZE(potparm%pot(tmpij(1), tmpij(2))%pot%set(1)%gp%values) == &
909 SIZE(potparm%pot(tmpij0(1), tmpij0(2))%pot%set(1)%gp%values))
THEN
910 IF (any(potparm%pot(tmpij(1), tmpij(2))%pot%set(1)%gp%values /= &
911 potparm%pot(tmpij0(1), tmpij0(2))%pot%set(1)%gp%values)) check = .false.
917 IF (all(cwork == pot_par(j, :)) .AND. check) cycle
918 cwork(:) = pot_par(j, :)
919 nunique = nunique + 1
921 CALL set_potparm_index(potparm, my_index(istart:iend), pot_target, &
922 ntype, tmpij, atomic_kind_set, shift_cutoff, do_zbl)
926 CALL get_indexes(locij, ntype, tmpij)
927 tmp_index(tmpij(1), tmpij(2)) = nunique
928 tmp_index(tmpij(2), tmpij(1)) = nunique
932 CALL get_indexes(locij, ntype, tmpij0)
934 nunique = nunique + 1
936 CALL set_potparm_index(potparm, my_index(istart:iend), pot_target, &
937 ntype, tmpij, atomic_kind_set, shift_cutoff, do_zbl)
940 CALL get_indexes(locij, ntype, tmpij)
941 tmp_index(tmpij(1), tmpij(2)) = nunique
942 tmp_index(tmpij(2), tmpij(1)) = nunique
947 nunique = nunique + 1
948 CALL set_potparm_index(potparm, my_index, pot_target, ntype, tmpij, &
949 atomic_kind_set, shift_cutoff, do_zbl)
951 DEALLOCATE (my_index)
958 IF (
SIZE(potparm%pot(i, j)%pot%type) == 1) cycle
959 nunique = nunique + 1
960 tmp_index(i, j) = nunique
961 tmp_index(j, i) = nunique
963 CALL set_potparm_index(potparm, (/n/),
multi_type, ntype, tmpij, &
964 atomic_kind_set, shift_cutoff, do_zbl)
968 ALLOCATE (spline_env)
970 spline_env%spltab = tmp_index
971 DEALLOCATE (tmp_index)
972 CALL timestop(handle)
988 SUBROUTINE set_potparm_index(potparm, my_index, pot_target, ntype, tmpij_out, &
989 atomic_kind_set, shift_cutoff, do_zbl)
991 TYPE(pair_potential_pp_type),
POINTER :: potparm
992 INTEGER,
INTENT(IN) :: my_index(:), pot_target, ntype
993 INTEGER,
INTENT(OUT) :: tmpij_out(2)
994 TYPE(atomic_kind_type),
DIMENSION(:),
POINTER :: atomic_kind_set
995 LOGICAL,
INTENT(IN) :: shift_cutoff, do_zbl
997 CHARACTER(len=*),
PARAMETER :: routinen =
'set_potparm_index'
999 INTEGER :: handle, i, min_val, nvalues, tmpij(2), &
1001 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: wrk
1003 REAL(kind=
dp) :: hicut0, l_epsilon, l_sigma6, m_epsilon, &
1004 m_sigma6, min_sigma6, rcovi, rcovj
1005 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: sigma6
1006 TYPE(atomic_kind_type),
POINTER :: atomic_kind
1007 TYPE(pair_potential_single_type),
POINTER :: pot, pot_ref
1009 CALL timeset(routinen, handle)
1011 NULLIFY (pot, pot_ref)
1012 nvalues =
SIZE(my_index)
1014 ALLOCATE (sigma6(nvalues))
1015 ALLOCATE (wrk(nvalues))
1016 min_sigma6 = huge(0.0_dp)
1017 m_epsilon = -huge(0.0_dp)
1020 CALL get_indexes(
value, ntype, tmpij)
1021 pot => potparm%pot(tmpij(1), tmpij(2))%pot
1023 check =
SIZE(pot%type) == 1
1026 sigma6(i) = pot%set(1)%lj%sigma6
1027 l_epsilon = pot%set(1)%lj%epsilon
1028 IF (sigma6(i) /= 0.0_dp) min_sigma6 = min(min_sigma6, sigma6(i))
1029 IF (sigma6(i) == 0.0_dp) sigma6(i) = -huge(0.0_dp)
1030 IF (l_epsilon /= 0.0_dp) m_epsilon = max(m_epsilon, l_epsilon)
1032 CALL sort(sigma6, nvalues, wrk)
1033 min_val = my_index(wrk(nvalues))
1034 m_sigma6 = sigma6(nvalues)
1036 IF (m_sigma6 == -huge(0.0_dp)) m_sigma6 = 1.0_dp
1037 IF (m_epsilon == -huge(0.0_dp)) m_epsilon = 0.0_dp
1038 IF (min_sigma6 == huge(0.0_dp)) min_sigma6 = 0.0_dp
1042 min_val = minval(my_index(:))
1044 CALL get_indexes(min_val, ntype, tmpij)
1046 pot => potparm%pot(tmpij(1), tmpij(2))%pot
1048 IF (shift_cutoff)
THEN
1049 hicut0 = sqrt(pot%rcutsq)
1050 IF (abs(hicut0) <= min_hicut_value) hicut0 = default_hicut_value
1056 CALL get_indexes(
value, ntype, tmpij)
1057 pot => potparm%pot(tmpij(1), tmpij(2))%pot
1059 pot%spl_f%rcutsq_f = 1.0_dp
1060 pot%spl_f%rscale = 1.0_dp
1061 pot%spl_f%fscale = 1.0_dp
1067 CALL get_indexes(
value, ntype, tmpij)
1068 pot => potparm%pot(tmpij(1), tmpij(2))%pot
1070 check =
SIZE(pot%type) == 1
1074 l_sigma6 = pot%set(1)%lj%sigma6
1075 l_epsilon = pot%set(1)%lj%epsilon
1078 pot%set(1)%lj%sigma6 = m_sigma6
1079 pot%set(1)%lj%sigma12 = m_sigma6**2
1080 pot%set(1)%lj%epsilon = m_epsilon
1082 pot%spl_f%rscale(1) = 1.0_dp
1083 pot%spl_f%fscale(1) = 0.0_dp
1084 IF (l_sigma6*l_epsilon /= 0.0_dp)
THEN
1085 pot%spl_f%rcutsq_f = (min_sigma6/m_sigma6)**(1.0_dp/3.0_dp)
1086 pot%spl_f%rscale(1) = (l_sigma6/m_sigma6)**(1.0_dp/3.0_dp)
1087 pot%spl_f%fscale(1) = l_epsilon/m_epsilon
1095 CALL get_indexes(
value, ntype, tmpij)
1096 pot => potparm%pot(tmpij(1), tmpij(2))%pot
1099 atomic_kind => atomic_kind_set(tmpij(1))
1101 atomic_kind => atomic_kind_set(tmpij(2))
1107 pot%spl_f%dscale = pot%spl_f%fscale/pot%spl_f%rscale
1109 IF (shift_cutoff)
THEN
1111 pot%spl_f%cutoff =
ener_pot(pot, hicut0, 0.0_dp)
1116 IF (shift_cutoff)
THEN
1117 pot_ref => potparm%pot(tmpij_out(1), tmpij_out(2))%pot
1120 CALL get_indexes(
value, ntype, tmpij)
1121 pot => potparm%pot(tmpij(1), tmpij(2))%pot
1122 IF (
value == min_val) cycle
1124 pot%spl_f%cutoff = pot_ref%spl_f%cutoff*pot%spl_f%fscale(1) - pot%spl_f%cutoff
1129 CALL timestop(handle)
1131 END SUBROUTINE set_potparm_index
1140 SUBROUTINE get_indexes(Inind, ndim, ij)
1141 INTEGER,
INTENT(IN) :: inind, ndim
1142 INTEGER,
DIMENSION(2),
INTENT(OUT) :: ij
1150 IF (tmp >= inind)
THEN
1152 ij(2) = inind - tmp + i
1156 END SUBROUTINE get_indexes
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
This public domain function parser module is intended for applications where a set of mathematical ex...
subroutine, public finalizef()
...
subroutine, public initf(n)
...
subroutine, public parsef(i, FuncStr, Var)
Parse ith function string FuncStr and compile it into bytecode.
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
integer, parameter, public default_path_length
integer, dimension(21), parameter, public list_pot
integer, parameter, public lj_charmm_type
integer, parameter, public allegro_type
integer, parameter, public bm_type
integer, parameter, public gal_type
integer, parameter, public nequip_type
integer, parameter, public wl_type
integer, parameter, public ft_type
integer, parameter, public tab_type
integer, parameter, public ftd_type
integer, parameter, public ip_type
integer, parameter, public lj_type
integer, parameter, public deepmd_type
integer, parameter, public nn_type
integer, parameter, public multi_type
integer, parameter, public quip_type
integer, parameter, public gp_type
integer, parameter, public siepmann_type
subroutine, public compare_pot(pot1, pot2, compare)
compare two different potentials
integer, parameter, public gw_type
integer, parameter, public b4_type
integer, parameter, public gal21_type
integer, dimension(2), public potential_single_allocation
integer, parameter, public ea_type
integer, parameter, public tersoff_type
real(kind=dp) function, public ener_zbl(pot, r)
Evaluates the ZBL scattering potential, very short range Only shell-model for interactions among pair...
real(kind=dp) function, public ener_pot(pot, r, energy_cutoff)
Evaluates the nonbond potential energy for the implemented FF kinds.
subroutine, public zbl_matching_polinomial(pot, rcov1, rcov2, z1, z2)
Determine the polinomial coefficients used to set to zero the zbl potential at the cutoff radius,...
subroutine, public spline_nonbond_control(spline_env, potparm, atomic_kind_set, eps_spline, max_energy, rlow_nb, emax_spline, npoints, iw, iw2, iw3, do_zbl, shift_cutoff, nonbonded_type)
creates the splines for the potentials
subroutine, public get_nonbond_storage(spline_env, potparm, atomic_kind_set, do_zbl, shift_cutoff)
Prescreening of the effective bonds evaluations. linear scaling algorithm.
subroutine, public init_genpot(potparm, ntype)
Initialize genpot.
Definition of physical constants:
real(kind=dp), parameter, public evolt
real(kind=dp), parameter, public kjmol
real(kind=dp), parameter, public bohr
routines for handling splines
pure subroutine, public init_splinexy(spl, nn)
allocates storage for function table to be interpolated both x and y are allocated
pure subroutine, public init_spline(spl, dx, y1a, y1b)
allocates storage for y2 table calculates y2 table and other spline parameters
real(kind=dp) function, public potential_s(spl_p, xxi, y1, spl_f, logger)
calculates the potential interpolated with splines value at a given point and the first derivative....
routines for handling splines_types
subroutine, public spline_factor_release(spline_factor)
releases spline_factor
subroutine, public spline_factor_create(spline_factor)
releases spline_factor
subroutine, public spline_env_create(spline_env, ntype, ntab_in)
Data-structure that holds all needed information about a specific spline interpolation.
generates a unique id number for a string (str2id) that can be used two compare two strings....
integer function, public str2id(str)
returns a unique id for a given string, and stores the string for later retrieval using the id.
All kind of helpful little routines.