Skip to content

Commit

Permalink
Prepare cosmo implementation for use with post scf methods. (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
MtoLStoN authored Jul 13, 2022
1 parent 3915ff0 commit 9096eee
Show file tree
Hide file tree
Showing 7 changed files with 243 additions and 29 deletions.
66 changes: 66 additions & 0 deletions include/param_cosmo.fh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
type(gbsa_parameter),parameter :: gfn_cosmo = gbsa_parameter ( &
76.36000000_wp, &
18.00000000_wp, &
1.00000000_wp, &
1.00000000_wp, &
1.30000000_wp, &
0.00000000_wp, &
0.00000000_wp, &
0.00000000_wp, &
(/ -0.08499967_wp, 0.46780225_wp, -2.87013596_wp, -3.95935069_wp, -0.29783987_wp, &
-0.48323273_wp, 0.00133622_wp, 0.20448945_wp, 0.20150600_wp, 0.36379863_wp, &
-3.47082133_wp, -0.93451053_wp, -1.46342018_wp, -0.32774697_wp, -0.38015204_wp, &
-0.35311116_wp, -0.19972593_wp, -0.12891363_wp, -1.19450558_wp, -1.61289300_wp, &
-4.68022533_wp, 3.22705056_wp, -1.76349679_wp, -1.78246886_wp, -1.41389733_wp, &
-2.03424961_wp, -13.15585203_wp, -0.60232543_wp, -0.51255518_wp, -1.05389890_wp, &
-0.80992362_wp, -0.04534252_wp, -0.48402589_wp, -0.34738945_wp, -0.31467674_wp, &
-0.13545936_wp, -1.19984632_wp, -1.57439157_wp, -7.77905850_wp, -0.25386776_wp, &
-1.36181862_wp, -1.89986750_wp, -1.66264106_wp, 0.63693473_wp, -0.42449931_wp, &
-0.73041159_wp, -0.48383194_wp, -0.60860050_wp, -1.34579404_wp, -0.28314431_wp, &
-0.58997478_wp, -0.50506060_wp, -0.36680822_wp, -0.28828614_wp, -1.50384745_wp, &
-1.72772005_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, -0.95945946_wp, -0.97138135_wp, -2.83432331_wp, -2.01934203_wp, &
-1.19296724_wp, -0.73245256_wp, -0.58420150_wp, -0.43386368_wp, -0.70607621_wp, &
-0.73268812_wp, -1.00876694_wp, -0.52518304_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp /), &
(/ 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, 0.30000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp, &
0.80000000_wp, 0.80000000_wp, 0.80000000_wp, 0.80000000_wp /), &
(/ 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp, &
0.00000000_wp, 0.00000000_wp, 0.00000000_wp, 0.00000000_wp /) )
1 change: 1 addition & 0 deletions src/param/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ list(APPEND srcs
"${dir}/paulingen.f90"
"${dir}/sqrtzr4r2.f90"
"${dir}/vdwradd3.f90"
"${dir}/vdwradcosmo.f90"
)

set(srcs ${srcs} PARENT_SCOPE)
1 change: 1 addition & 0 deletions src/param/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ srcs += files(
'paulingen.f90',
'sqrtzr4r2.f90',
'vdwradd3.f90',
'vdwradcosmo.f90',
)
103 changes: 103 additions & 0 deletions src/param/vdwradcosmo.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
! This file is part of xtb.
!
! Copyright (C) 2019-2020 Sebastian Ehlert
!
! xtb is free software: you can redistribute it and/or modify it under
! the terms of the GNU Lesser General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! xtb is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public License
! along with xtb. If not, see <https://www.gnu.org/licenses/>.

!> Cosmo van-der-Waals radii

module xtb_param_vdwradcosmo
use xtb_mctc_accuracy, only : wp
use xtb_mctc_convert, only : aatoau
use xtb_mctc_symbols, only : toNumber
implicit none
private

public :: getVanDerWaalsRadCosmo, vanDerWaalsRadCosmo


!> Get van-der-Waals Rad for a species
interface getVanDerWaalsRadCosmo
module procedure :: getVanDerWaalsRadCosmoSymbol
module procedure :: getVanDerWaalsRadCosmoNumber
end interface getVanDerWaalsRadCosmo


!> Default value for unoptimized van-der-Waals radii
real(wp), parameter :: cosmostub = 2.223_wp

!> COSMO optimized van-der-Waals radii
real(wp), parameter :: vanDerWaalsRadCosmo(94) = aatoau * [ &
& 1.3000_wp, 1.6380_wp, 1.5700_wp, 1.0530_wp, & ! h-be
& 2.0480_wp, 2.0000_wp, 1.8300_wp, 1.7200_wp, & ! B-O
& 1.7200_wp, 1.8018_wp, 1.8000_wp, 1.6380_wp, & ! F-Mg
& 2.1530_wp, 2.2000_wp, 2.1060_wp, 2.1600_wp, & ! Al-S
& 2.0500_wp, 2.2000_wp, 2.2230_wp, cosmostub, & ! Cl-Ca
& cosmostub, 2.2930_wp, cosmostub, cosmostub, & ! Sc-Cr
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Mn-Ni
& cosmostub, 1.6260_wp, cosmostub, 2.7000_wp, & ! Cu-Ge
& 2.3500_wp, 2.2000_wp, 2.1600_wp, 2.3630_wp, & ! As-Kr
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Rb-Zr
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Nb-Ru
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Rh-Cd
& 2.2580_wp, 2.5500_wp, 2.4100_wp, 2.4100_wp, & ! In-Te
& 2.3200_wp, 2.5270_wp, cosmostub, cosmostub, & ! I-Ba
& cosmostub, cosmostub, cosmostub, cosmostub, & ! La-Nd
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Pm-Gd
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Tb-Er
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Tm-Hf
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Ta-Os
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Ir-Hg
& cosmostub, 2.3600_wp, 2.4220_wp, 2.3050_wp, & ! Tl-Po
& 2.3630_wp, 2.5740_wp, cosmostub, cosmostub, & ! At-Ra
& cosmostub, cosmostub, cosmostub, cosmostub, & ! Ac-U
& cosmostub, cosmostub] ! Np-Pu


contains


!> Get van-der-Waals radius for species with a given symbol
elemental function getVanDerWaalsRadCosmoSymbol(symbol) result(rad)

!> Element symbol
character(len=*), intent(in) :: symbol

!> van-der-Waals radius
real(wp) :: rad

rad = getVanDerWaalsRadCosmo(toNumber(symbol))

end function getVanDerWaalsRadCosmoSymbol


!> Get van-der-Waals radius for species with a given atomic number
elemental function getVanDerWaalsRadCosmoNumber(number) result(rad)

!> Atomic number
integer, intent(in) :: number

!> van-der-Waals radius
real(wp) :: rad

if (number > 0 .and. number <= size(vanDerWaalsRadCosmo, dim=1)) then
rad = vanDerWaalsRadCosmo(number)
else
rad = -1.0_wp
end if

end function getVanDerWaalsRadCosmoNumber


end module xtb_param_vdwradcosmo
49 changes: 46 additions & 3 deletions src/solv/model.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

! This file is part of xtb.
!
! Copyright (C) 2019-2020 Sebastian Ehlert
Expand All @@ -23,13 +24,15 @@ module xtb_solv_model
use xtb_mctc_strings, only : lowercase
use xtb_mctc_systools, only : rdpath
use xtb_param_vdwradd3, only : vanDerWaalsRadD3
use xtb_param_vdwradcosmo, only : vanDerWaalsRadCosmo
use xtb_solv_gbsa, only : TBorn, init_ => init
use xtb_solv_cosmo, only : TCosmo, init_ => init
use xtb_solv_input, only : TSolvInput
use xtb_solv_kernel, only : gbKernel
use xtb_solv_state, only : solutionState, getStateShift
use xtb_type_environment, only : TEnvironment
use xtb_type_solvation, only : TSolvation
use ieee_arithmetic, only : ieee_value,ieee_positive_inf
implicit none
private

Expand Down Expand Up @@ -143,6 +146,8 @@ module xtb_solv_model
include 'param_alpb_methanol.fh'
include 'param_alpb_ethanol.fh'

include 'param_cosmo.fh'

!> Solvent density (g/cm^3) and molar mass (g/mol)
real(wp), parameter :: molcm3toau = 8.92388e-2_wp

Expand Down Expand Up @@ -191,7 +196,7 @@ subroutine initSolvModel(self, env, input, level)
call getParamFile(env, solvent, 'cosmo', level, self%paramFile)
end if

if (.not.allocated(self%paramFile)) then
if (.not.allocated(self%paramFile) .and. (.not.input%cosmo)) then
call getParamFile(env, solvent, 'gbsa', level, self%paramFile)
end if

Expand Down Expand Up @@ -238,7 +243,12 @@ subroutine loadInternalParam(self, env, solvent, level)
!> Method level for solvation model
integer, intent(in) :: level

type(gbsa_parameter), allocatable :: param
!> I/O handling

integer :: iostat

type(gbsa_parameter), allocatable :: param, stub


select case(self%kernel)
case (gbKernel%still)
Expand Down Expand Up @@ -376,6 +386,34 @@ subroutine loadInternalParam(self, env, solvent, level)
param = gfn1_alpb_hexane
end select
end if

if (self%cosmo) then
if (allocated(param)) then
self%paramFile = self%paramFile//"+COSMO"
stub = param
param = gfn_cosmo
param%epsv = stub%epsv
param%smass = stub%smass
param%rhos = stub%rhos
param%gamscale = stub%gamscale
else if ((solvent .eq. "inf") .or. (solvent .eq. "infinity")) then
self%paramFile = "internal GFN-xTB/COSMO"
param = gfn_cosmo
param%epsv = ieee_value(param%epsv,ieee_positive_inf)
else
self%paramFile = "internal GFN-xTB/COSMO"
param = gfn_cosmo
read(solvent,*,iostat=iostat) param%epsv
if (iostat .ne. 0) then
Call env%error(solvent// " is neither a solvent name nor a dielectric constant.",source)
return
end if
if (param%epsv .eq. 0) then
Call env%error("You really chose 0 as your dielectric constant?",source)
return
end if
end if
end if

if (.not.allocated(param)) then
call env%error("solvent: '"//solvent//"' is not parametrized", source)
Expand Down Expand Up @@ -459,7 +497,12 @@ subroutine paramToModel(self, param)
self%bornOffset = param%soset * 0.1_wp*aatoau
self%probeRad = param%rprobe * aatoau

self%vdwRad = vanDerWaalsRadD3
if (self%cosmo) then
self%vdwRad=vanDerWaalsRadCosmo
else
self%vdwRad=vanDerWaalsRadD3
end if

self%surfaceTension = param%gamscale * fourpi*surfaceTension
self%descreening = param%sx
allocate(self%hBondStrength(size(param%tmp)))
Expand Down
26 changes: 13 additions & 13 deletions test/unit/test_gfn1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -874,23 +874,23 @@ subroutine test_gfn1_mindless_cosmo(error)
& "h2o", "chcl3", "thf", "acetonitrile", "toluene", &
& "ch2cl2", "ether", "methanol", "cs2", "dmso"]
real(wp), parameter :: ref_energies(10) = &
&[-33.068149119769_wp,-26.879297949029_wp,-25.848339775486_wp, &
& -24.920550779459_wp,-29.057643142396_wp,-20.616717615153_wp, &
& -35.781900213083_wp,-33.108563594503_wp,-21.434739333961_wp, &
& -26.668994477103_wp]
&[-33.086826283006_wp,-26.892421337119_wp,-25.862366080135_wp, &
& -24.929812068243_wp,-29.068535381601_wp,-20.631250827831_wp, &
& -35.780608195840_wp,-33.119209493948_wp,-21.444833411574_wp, &
& -26.674508354162_wp]
real(wp), parameter :: ref_gnorms(10) = &
&[0.048610989970_wp, 0.061037608875_wp, 0.051110430194_wp, &
& 0.093510458216_wp, 0.048462578319_wp, 0.056499605067_wp, &
& 0.062179565785_wp, 0.060672469106_wp, 0.041589454825_wp, &
& 0.042982140079_wp]
&[0.056910263744_wp, 0.059732400683_wp, 0.052197041661_wp, &
& 0.097844384419_wp, 0.047961348424_wp, 0.057230114090_wp, &
& 0.060889237549_wp, 0.068600226343_wp, 0.042102755940_wp, &
& 0.042610278777_wp]
real(wp), parameter :: ref_hlgaps(10) = &
&[3.512016853496_wp, 1.675002766293_wp, 2.500980871958_wp, &
& 1.659094616440_wp, 2.420893146112_wp, 3.802456715570_wp, &
& 2.599886803836_wp, 1.354752587871_wp, 4.107155093819_wp, &
& 1.379801456095_wp]
&[3.560961680882_wp, 1.701178515210_wp, 2.575575698307_wp, &
& 1.642444939544_wp, 2.389954524574_wp, 3.624912973388_wp, &
& 2.770751688023_wp, 1.357191094207_wp, 4.102623151933_wp, &
& 1.391461153653_wp]

call init(env)
do iMol = 1, 2
do iMol = 1,10

call getMolecule(mol, mindless(iMol))

Expand Down
26 changes: 13 additions & 13 deletions test/unit/test_gfn2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -793,23 +793,23 @@ subroutine test_gfn2_mindless_cosmo(error)
& "h2o", "chcl3", "thf", "acetonitrile", "toluene", &
& "ch2cl2", "ether", "methanol", "cs2", "dmso"]
real(wp), parameter :: ref_energies(10) = &
&[-30.376518115875_wp,-24.102578449616_wp,-23.754139493763_wp, &
& -22.766727017808_wp,-27.757889554228_wp,-18.587445483567_wp, &
& -33.445663939387_wp,-30.003461899598_wp,-20.573488191967_wp, &
& -25.670456523922_wp]
&[-30.398257570644_wp,-24.125868305041_wp,-23.787177902522_wp, &
& -22.779539008049_wp,-27.783054701847_wp,-18.610486346192_wp, &
& -33.456896298026_wp,-30.008556230192_wp,-20.588957648989_wp, &
& -25.684670492104_wp]
real(wp), parameter :: ref_gnorms(10) = &
&[0.065115699688_wp, 0.057742250527_wp, 0.041885898146_wp, &
& 0.072134973561_wp, 0.048230827198_wp, 0.052250268149_wp, &
& 0.045597725657_wp, 0.062065139853_wp, 0.054691676440_wp, &
& 0.045829509846_wp]
&[0.070117675966_wp, 0.060272066809_wp, 0.048063628868_wp, &
& 0.076296084561_wp, 0.050041916284_wp, 0.051542825738_wp, &
& 0.046066119467_wp, 0.060436009320_wp, 0.058023381592_wp, &
& 0.050440402702_wp]
real(wp), parameter :: ref_hlgaps(10) = &
&[2.608938030439_wp, 1.390465293950_wp, 0.169294532274_wp, &
& 1.254915268362_wp, 2.137937542332_wp, 2.267712835326_wp, &
& 2.669493177775_wp, 0.840230142925_wp, 3.341412667263_wp, &
& 0.393537743933_wp]
&[3.173028297842_wp, 1.553006040621_wp, 0.324761161079_wp, &
& 1.233091187215_wp, 1.918282889245_wp, 2.067664999523_wp, &
& 2.757505697757_wp, 0.846361565116_wp, 3.336544801399_wp, &
& 0.315118656281_wp]

call init(env)
do iMol = 1, 2
do iMol = 1, 10

call getMolecule(mol, mindless(iMol))

Expand Down

0 comments on commit 9096eee

Please sign in to comment.