Create new D4 dispersion model from molecular structure input
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(error_type), | intent(out), | allocatable | :: | error |
Error handling |
|
type(d4_model), | intent(out) | :: | d4 |
Instance of the dispersion model |
||
class(structure_type), | intent(in) | :: | mol |
Molecular structure data |
||
real(kind=wp), | intent(in), | optional | :: | ga |
Charge scaling height |
|
real(kind=wp), | intent(in), | optional | :: | gc |
Charge scaling steepness |
|
real(kind=wp), | intent(in), | optional | :: | wf |
Weighting factor for coordination number interpolation |
|
integer, | intent(in), | optional | :: | ref |
Reference charge selection |
subroutine new_d4_model_with_checks(error, d4, mol, ga, gc, wf, ref) !DEC$ ATTRIBUTES DLLEXPORT :: new_d4_model_with_checks !> Instance of the dispersion model type(d4_model), intent(out) :: d4 !> Molecular structure data class(structure_type), intent(in) :: mol !> Error handling type(error_type), allocatable, intent(out) :: error !> Charge scaling height real(wp), intent(in), optional :: ga !> Charge scaling steepness real(wp), intent(in), optional :: gc !> Weighting factor for coordination number interpolation real(wp), intent(in), optional :: wf !> Reference charge selection integer, intent(in), optional :: ref integer :: isp, izp, iref, jsp, jzp, jref integer :: mref, ref_charge real(wp) :: aiw(23), c6 real(wp), parameter :: thopi = 3.0_wp/pi ! check for unsupported elements (104 (Rf) - 111 (Rg)) do isp = 1, mol%nid if (mol%num(isp) > 103 .and. mol%num(isp) < 112) then call fatal_error(error, "Structure contains unsupported element '"//trim(mol%sym(isp))//"'") return end if end do d4%ncoup = 1 if (present(ref)) then ref_charge = ref else ref_charge = d4_ref%eeq end if if (present(ga)) then d4%ga = ga else d4%ga = ga_default end if if (present(gc)) then d4%gc = gc else d4%gc = gc_default end if if (present(wf)) then d4%wf = wf else d4%wf = wf_default end if allocate(d4%rcov(mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) d4%rcov(isp) = get_covalent_rad(izp) end do allocate(d4%en(mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) d4%en(isp) = get_electronegativity(izp) end do allocate(d4%zeff(mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) d4%zeff(isp) = get_effective_charge(izp) end do allocate(d4%eta(mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) d4%eta(isp) = get_hardness(izp) end do allocate(d4%r4r2(mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) d4%r4r2(isp) = get_r4r2_val(izp) end do allocate(d4%ref(mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) d4%ref(isp) = get_nref(izp) end do mref = maxval(d4%ref) allocate(d4%cn(mref, mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) call set_refcn(d4%cn(:, isp), izp) end do allocate(d4%q(mref, mol%nid)) allocate(d4%aiw(23, mref, mol%nid)) select case(ref_charge) case default call fatal_error(error, "Unsupported option for reference charges") return case(d4_ref%eeq) do isp = 1, mol%nid izp = mol%num(isp) call set_refq_eeq(d4%q(:, isp), izp) call set_refalpha_eeq(d4%aiw(:, :, isp), d4%ga, d4%gc, izp) end do case(d4_ref%gfn2) do isp = 1, mol%nid izp = mol%num(isp) call set_refq_gfn2(d4%q(:, isp), izp) call set_refalpha_gfn2(d4%aiw(:, :, isp), d4%ga, d4%gc, izp) end do end select allocate(d4%ngw(mref, mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) call set_refgw(d4%ngw(:, isp), izp) end do allocate(d4%c6(mref, mref, mol%nid, mol%nid)) do isp = 1, mol%nid izp = mol%num(isp) do jsp = 1, isp jzp = mol%num(jsp) do iref = 1, d4%ref(isp) do jref = 1, d4%ref(jsp) aiw(:) = d4%aiw(:, iref, isp) * d4%aiw(:, jref, jsp) c6 = thopi * trapzd(aiw) d4%c6(jref, iref, jsp, isp) = c6 d4%c6(iref, jref, isp, jsp) = c6 end do end do end do end do end subroutine new_d4_model_with_checks