27 use,
intrinsic :: iso_fortran_env
42 real(real64),
pointer :: system_pos(:,:) => null()
43 real(real64),
public :: lj_epsilon
44 real(real64),
public :: lj_sigma
46 integer,
public :: partner_np = 0
47 real(real64),
allocatable,
public :: partner_pos(:,:)
64 class(interaction_partner_t),
target,
intent(inout) :: partner
65 class(lennard_jones_t),
pointer :: this
71 this%label =
"lennard_jones"
73 this%partner => partner
79 this%couplings_from_partner = [
position]
85 subroutine lennard_jones_init(this, dim, system_np, system_pos, system_eps, system_sigma)
86 class(lennard_jones_t),
intent(inout) :: this
87 integer,
intent(in) :: dim
88 integer,
intent(in) :: system_np
89 real(real64),
target,
intent(in) :: system_pos(:,:)
90 real(real64),
intent(in) :: system_eps
91 real(real64),
intent(in) :: system_sigma
96 this%system_np = system_np
97 safe_allocate(this%force(1:dim, 1:system_np))
100 this%lj_epsilon = system_eps
101 this%lj_sigma = system_sigma
103 this%system_pos => system_pos
110 class(lennard_jones_t),
intent(inout) :: this
113 real(real64) :: dist, rr(1:this%dim), lj_force
117 assert(
allocated(this%partner_pos))
119 do ip = 1, this%system_np
120 do jp = 1, this%partner_np
121 if (this%intra_interaction .and. ip == jp ) cycle
124 rr(1:this%dim) = this%system_pos(1:this%dim, ip) - this%partner_pos(1:this%dim, jp)
125 dist =
sqrt(sum(rr(1:this%dim)**2))
128 lj_force = 48.0_real64 * this%lj_epsilon * (this%lj_sigma**12 / dist**13 - &
129 m_half * this%lj_sigma**6 / dist**7)
133 this%force(1:this%dim, ip) = rr(1:this%dim) / dist * lj_force
149 assert(
allocated(this%partner_pos))
152 do ip = 1, this%system_np
153 do jp = 1, this%partner_np
154 if (this%intra_interaction .and. ip == jp ) cycle
156 dist =
sqrt(sum((this%system_pos(1:this%dim, ip) - this%partner_pos(1:this%dim, jp))**2)) +
m_epsilon
159 this%energy = this%energy +
m_two * this%lj_epsilon * ( (this%lj_sigma / dist)**12 - &
160 (this%lj_sigma / dist)**6 )
175 nullify(this%system_pos)
176 safe_deallocate_a(this%partner_pos)
177 safe_deallocate_a(this%force)
double sqrt(double __x) __attribute__((__nothrow__
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_epsilon
real(real64), parameter, public m_half
This module defines the abstract interaction_t class, and some auxiliary classes for interactions.
subroutine, public interaction_end(this)
This module defines classes and functions for interaction partners.
subroutine lennard_jones_calculate_energy(this)
subroutine lennard_jones_init(this, dim, system_np, system_pos, system_eps, system_sigma)
subroutine lennard_jones_calculate(this)
class(lennard_jones_t) function, pointer lennard_jones_constructor(partner)
subroutine lennard_jones_finalize(this)
This module defines the quantity_t class and the IDs for quantities, which can be exposed by a system...
integer, parameter, public position
Lennard-Jones interaction between two systems of particles.