Module that contains some useful utilities.
More...
|
pure real(kind=real64) function, dimension(3) | pbc (a, box) |
| Corrects for the periodic boundary condition. More...
|
|
pure real(kind=real64) function, dimension(3) | cross (a, b) |
| Performs cross product between two vectors. More...
|
|
pure real(kind=real64) function | distance2 (a, b, box) |
| Calculates the distance squared between two points. More...
|
|
pure real(kind=real64) function | distance (a, b, box) |
| Calculates the distance between two points. More...
|
|
pure real(kind=real64) function, dimension(3) | bond_vector (a, b, box) |
| Calculates the bond vector between two points. More...
|
|
pure real(kind=real64) function | magnitude (a) |
| Calculates the magnitude of a vector. More...
|
|
pure real(kind=real64) function | bond_angle (a, b, c, box) |
| Calculates the bond angle between two vectors. More...
|
|
pure real(kind=real64) function | dihedral_angle (i, j, k, l, box) |
| Calculates the dihedral angle between two planes formed by four atoms. More...
|
|
Module that contains some useful utilities.
◆ bond_angle()
pure real(kind=real64) function dcdfort_utils::bond_angle |
( |
real(kind=real64), dimension(3), intent(in) |
a, |
|
|
real(kind=real64), dimension(3), intent(in) |
b, |
|
|
real(kind=real64), dimension(3), intent(in) |
c, |
|
|
real(kind=real64), dimension(6), intent(in) |
box |
|
) |
| |
Calculates the bond angle between two vectors.
Calculates the angle between the vector formed by a-b and b-c.
- Parameters
-
[in] | a | first point |
[in] | b | middle point |
[in] | c | third point |
[in] | box | box, if pbc to be accounted for |
- Returns
- bond angle between a-b-c
229 real(kind=real64) :: bond_angle
230 real(kind=real64),
intent(in),
dimension(3) :: a, b, c
231 real(kind=real64),
intent(in) :: box(6)
232 real(kind=real64),
dimension(3) :: bond1, bond2
234 bond1 = bond_vector(b, a, box)
235 bond2 = bond_vector(b, c, box)
237 bond_angle = dacos(dot_product(bond1, bond2)/(magnitude(bond1)*magnitude(bond2)))
◆ bond_vector()
pure real(kind=real64) function, dimension(3) dcdfort_utils::bond_vector |
( |
real(kind=real64), dimension(3), intent(in) |
a, |
|
|
real(kind=real64), dimension(3), intent(in) |
b, |
|
|
real(kind=real64), dimension(6), intent(in) |
box |
|
) |
| |
Calculates the bond vector between two points.
- Parameters
-
[in] | a | first point |
[in] | b | second point |
[in] | box | box, if pbc to be accounted for |
- Returns
- bond vector pointing from a to b
198 real(kind=real64) :: bond_vector(3)
199 real(kind=real64),
intent(in),
dimension(3) :: a, b
200 real(kind=real64),
intent(in) :: box(6)
202 bond_vector = pbc(a-b, box)
◆ cross()
pure real(kind=real64) function, dimension(3) dcdfort_utils::cross |
( |
real(kind=real64), dimension(3), intent(in) |
a, |
|
|
real(kind=real64), dimension(3), intent(in) |
b |
|
) |
| |
Performs cross product between two vectors.
- Parameters
-
[in] | a | first vector |
[in] | b | second vector |
- Returns
- resulting cross product
139 real(kind=real64) :: cross(3)
140 real(kind=real64),
intent(in),
dimension(3) :: a, b
142 cross(1) = a(2) * b(3) - a(3) * b(2)
143 cross(2) = a(3) * b(1) - a(1) * b(3)
144 cross(3) = a(1) * b(2) - a(2) * b(1)
◆ dihedral_angle()
pure real(kind=real64) function dcdfort_utils::dihedral_angle |
( |
real(kind=real64), dimension(3), intent(in) |
i, |
|
|
real(kind=real64), dimension(3), intent(in) |
j, |
|
|
real(kind=real64), dimension(3), intent(in) |
k, |
|
|
real(kind=real64), dimension(3), intent(in) |
l, |
|
|
real(kind=real64), dimension(6), intent(in) |
box |
|
) |
| |
Calculates the dihedral angle between two planes formed by four atoms.
Calculates the dihedral angle between the vectors formed by i-j, j-k, k-l
- Parameters
-
[in] | i | first point |
[in] | j | middle point |
[in] | k | third point |
[in] | l | fourth point |
[in] | box | box, if pbc to be accounted for |
- Returns
- dihedral angle forms by i-j-k-l
252 real(kind=real64) :: dihedral_angle
253 real(kind=real64),
intent(in),
dimension(3) :: i, j, k, l
254 real(kind=real64),
intent(in),
dimension(6) :: box
255 real(kind=real64) :: A_mag, B_mag, G_mag
256 real(kind=real64),
dimension(3) :: H, G, F, A, B, cross_BA
258 h = bond_vector(k, l, box)
259 g = bond_vector(k, j, box)
260 f = bond_vector(j, i, box)
263 cross_ba = cross(b, a)
268 dihedral_angle = atan2(dot_product(cross_ba, g) / (a_mag*b_mag*g_mag), dot_product(a, b) / (a_mag*b_mag))
◆ distance()
pure real(kind=real64) function dcdfort_utils::distance |
( |
real(kind=real64), dimension(3), intent(in) |
a, |
|
|
real(kind=real64), dimension(3), intent(in) |
b, |
|
|
real(kind=real64), dimension(6), intent(in), optional |
box |
|
) |
| |
Calculates the distance between two points.
- Parameters
-
[in] | a | first point |
[in] | b | second point |
[in] | box | box, if pbc to be accounted for |
- Returns
- distance
178 real(kind=real64) :: distance
179 real(kind=real64),
intent(in),
dimension(3) :: a, b
180 real(kind=real64),
intent(in),
optional :: box(6)
182 if (
present(box))
then 183 distance = dsqrt(distance2(a, b, box))
185 distance = dsqrt(distance2(a, b))
◆ distance2()
pure real(kind=real64) function dcdfort_utils::distance2 |
( |
real(kind=real64), dimension(3), intent(in) |
a, |
|
|
real(kind=real64), dimension(3), intent(in) |
b, |
|
|
real(kind=real64), dimension(6), intent(in), optional |
box |
|
) |
| |
Calculates the distance squared between two points.
- Parameters
-
[in] | a | first point |
[in] | b | second point |
[in] | box | box, if pbc to be accounted for |
- Returns
- distance squared
156 real(kind=real64) :: distance2
157 real(kind=real64),
intent(in),
dimension(3) :: a, b
158 real(kind=real64) :: c(3)
159 real(kind=real64),
intent(in),
optional :: box(6)
161 if (
present(box))
then 166 distance2 = dot_product(c, c)
◆ magnitude()
pure real(kind=real64) function dcdfort_utils::magnitude |
( |
real(kind=real64), dimension(3), intent(in) |
a | ) |
|
Calculates the magnitude of a vector.
- Parameters
-
- Returns
- magnitude of a
212 real(kind=real64) :: magnitude
213 real(kind=real64),
intent(in) :: a(3)
215 magnitude = dsqrt(dot_product(a, a))
◆ pbc()
pure real(kind=real64) function, dimension(3) dcdfort_utils::pbc |
( |
real(kind=real64), dimension(3), intent(in) |
a, |
|
|
real(kind=real64), dimension(6), intent(in) |
box |
|
) |
| |
Corrects for the periodic boundary condition.
Moves particle (or vector) the distance of half the box if it is more than half the distance of the box
- Parameters
-
[in] | a | original coordinates |
[in] | box | simulation box |
- Returns
- the shifted coordinates
57 real(kind=real64),
intent(in) :: a(3), box(6)
58 real(kind=real64) :: pbc(3), tbox(3,3)
59 integer(kind=int32) :: shift
87 tbox(1,2) = box(2)*box(6)
93 tbox(1,3) = box(3)*box(5)
98 tbox(2,2) = dsqrt(box(2)**2-tbox(1,2)**2)
103 tbox(2,3) = (box(2)*box(3)*box(4) - tbox(1,2)*tbox(1,3))/tbox(2,2)
107 tbox(3,3) = dsqrt(box(3)**2-tbox(1,3)**2-tbox(2,3)**2)
112 shift = nint(pbc(3) / tbox(3,3))
113 if (shift .ne. 0)
then 114 pbc(3) = pbc(3) - tbox(3,3) * shift
115 pbc(2) = pbc(2) - tbox(2,3) * shift
116 pbc(1) = pbc(1) - tbox(1,3) * shift
119 shift = nint(pbc(2) / tbox(2,2))
120 if (shift .ne. 0)
then 121 pbc(2) = pbc(2) - tbox(2,2) * shift
122 pbc(1) = pbc(1) - tbox(1,2) * shift
125 shift = nint(pbc(1) / tbox(1,1))
126 if (shift .ne. 0)
then 127 pbc(1) = pbc(1) - tbox(1,1) * shift