new_dispersion_model Subroutine

public subroutine new_dispersion_model(error, d4, mol, model, ga, gc, wf)

Wrapper for creating a new dispersion model (D4 or D4S) from molecular structure input using a given model string. Defaults to D4 if no model is specified.

Arguments

Type IntentOptional Attributes Name
type(error_type), intent(out), allocatable :: error

Error handling

class(dispersion_model), intent(out), allocatable :: d4

Dispersion model to be returned

type(structure_type), intent(in) :: mol

Molecular structure data

character(len=*), intent(in), optional :: model

Dispersion model to be used

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


Source Code

subroutine new_dispersion_model(error, d4, mol, model, ga, gc, wf)

   !> Error handling
   type(error_type), allocatable, intent(out) :: error

   !> Dispersion model to be returned
   class(dispersion_model), allocatable, intent(out) :: d4

   !> Molecular structure data
   type(structure_type), intent(in) :: mol

   !> Dispersion model to be used
   character(len=*), intent(in), optional :: model

   !> 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

   character(len=:), allocatable :: mdl

   if (present(model)) then
      mdl = lowercase(trim(model)) 
   else
      mdl = "d4"
   end if

   if(mdl == "d4") then
      block 
         type(d4_model), allocatable :: tmp
         allocate(tmp)
         call new_d4_model(error, tmp, mol, ga=ga, gc=gc, wf=wf)
         call move_alloc(tmp, d4)
      end block 
   else if(mdl == "d4s") then
      block 
         type(d4s_model), allocatable :: tmp
         allocate(tmp)
         call new_d4s_model(error, tmp, mol, ga=ga, gc=gc)
         call move_alloc(tmp, d4)
      end block
   else
      call fatal_error(error, "Unknown model selected")
   end if

end subroutine new_dispersion_model