@@ -49,7 +49,7 @@ A struct representing a soft-sphere interaction model where particles interact v
4949- `rcut::T`: Cutoff distance matrix beyond which interactions are neglected.
5050- `shift::T`: Shift matrix to ensure the potential is zero at the cutoff distance.
5151"""
52- struct SoftSpheres{T<: AbstractArray , N<: Number } <: DiscreteModel
52+ struct SoftSpheres{T<: AbstractFloat , N<: Number } <: DiscreteModel
5353 name:: String
5454 ϵ:: T
5555 σ:: T
@@ -61,9 +61,9 @@ struct SoftSpheres{T<:AbstractArray, N<:Number} <: DiscreteModel
6161 shift:: T
6262end
6363
64- function SoftSpheres (ϵ, σ, n; rcut= 2.5 * σ, name= " SoftSpheres" )
65- σ2 = σ ^ 2
66- rcut2 = rcut ^ 2
64+ function SoftSpheres (ϵ, σ, n; rcut= 2.5 * σ, name= " SoftSpheres" )
65+ σ2 = σ^ 2
66+ rcut2 = rcut^ 2
6767 ndiv2 = isodd (n) ? n / 2 : n ÷ 2
6868 shift = inverse_power (rcut2, ϵ, σ2, ndiv2)
6969 return SoftSpheres (name, ϵ, σ, σ2, n, ndiv2, rcut, rcut2, shift)
7676function BHHP ()
7777 ϵ = [1.0 1.0 ; 1.0 1.0 ]
7878 σ = [1.0 1.2 ; 1.2 1.4 ]
79- LJ_11 = SoftSpheres (ϵ[1 ,1 ], σ[1 ,1 ], 12 )
80- LJ_12 = SoftSpheres (ϵ[1 ,2 ], σ[1 ,2 ], 12 )
81- LJ_21 = SoftSpheres (ϵ[2 ,1 ], σ[2 ,1 ], 12 )
82- LJ_22 = SoftSpheres (ϵ[2 ,2 ], σ[2 ,2 ], 12 )
79+ LJ_11 = SoftSpheres (ϵ[1 , 1 ], σ[1 , 1 ], 12 )
80+ LJ_12 = SoftSpheres (ϵ[1 , 2 ], σ[1 , 2 ], 12 )
81+ LJ_21 = SoftSpheres (ϵ[2 , 1 ], σ[2 , 1 ], 12 )
82+ LJ_22 = SoftSpheres (ϵ[2 , 2 ], σ[2 , 2 ], 12 )
8383 return [LJ_11 LJ_12; LJ_21 LJ_22]
8484end
8585
@@ -107,9 +107,9 @@ struct LennardJones{T<:AbstractFloat} <: DiscreteModel
107107 shift:: T
108108end
109109
110- function LennardJones (ϵ, σ; rcut= 2.5 * σ, name= " LennardJones" , shift_potential= true )
111- σ2 = σ ^ 2
112- rcut2 = rcut ^ 2
110+ function LennardJones (ϵ, σ; rcut= 2.5 * σ, name= " LennardJones" , shift_potential= true )
111+ σ2 = σ^ 2
112+ rcut2 = rcut^ 2
113113 if shift_potential
114114 shift = lennard_jones (rcut2, 4 ϵ, σ2)
115115 else
@@ -125,10 +125,10 @@ end
125125function KobAndersen ()
126126 ϵ = [1.0 1.5 ; 1.5 0.5 ]
127127 σ = [1.0 0.8 ; 0.8 0.88 ]
128- LJ_11 = LennardJones (ϵ[1 ,1 ], σ[1 ,1 ])
129- LJ_12 = LennardJones (ϵ[1 ,2 ], σ[1 ,2 ])
130- LJ_21 = LennardJones (ϵ[2 ,1 ], σ[2 ,1 ])
131- LJ_22 = LennardJones (ϵ[2 ,2 ], σ[2 ,2 ])
128+ LJ_11 = LennardJones (ϵ[1 , 1 ], σ[1 , 1 ])
129+ LJ_12 = LennardJones (ϵ[1 , 2 ], σ[1 , 2 ])
130+ LJ_21 = LennardJones (ϵ[2 , 1 ], σ[2 , 1 ])
131+ LJ_22 = LennardJones (ϵ[2 , 2 ], σ[2 , 2 ])
132132 return [LJ_11 LJ_12; LJ_21 LJ_22]
133133end
134134
@@ -147,18 +147,18 @@ struct SmoothLennardJones{T<:AbstractFloat} <: DiscreteModel
147147 rcut2:: T
148148end
149149
150- function SmoothLennardJones (ϵ:: T , σ:: T ; rcut:: T = 2.5 * σ, name = " SmoothLennardJones" ) where T <: AbstractFloat
150+ function SmoothLennardJones (ϵ:: T , σ:: T ; rcut:: T = 2.5 * σ, name= " SmoothLennardJones" ) where T<: AbstractFloat
151151 C0 = T (0.04049023795 )
152152 C2 = T (- 0.00970155098 )
153153 C4 = T (0.00062012616 )
154- σ2= σ ^ 2
154+ σ2 = σ^ 2
155155 C2_σ2 = C2 / σ2
156- C4_σ4 = C4 / σ2 ^ 2
157- rcut2= rcut^ 2
156+ C4_σ4 = C4 / σ2^ 2
157+ rcut2 = rcut^ 2
158158 return SmoothLennardJones (name, ϵ, σ, 4 ϵ, σ2, C0, C2_σ2, C4_σ4, rcut, rcut2)
159159end
160160
161- function potential (r2:: T , model:: SmoothLennardJones ) where T <: AbstractFloat
161+ function potential (r2:: T , model:: SmoothLennardJones ) where T<: AbstractFloat
162162 ϵ4 = model. ϵ4
163163 lj = lennard_jones (r2, ϵ4, model. σ2)
164164 shift = ϵ4 * (model. C0 + r2 * muladd (r2, model. C4_σ4, model. C2_σ2))
@@ -168,13 +168,13 @@ end
168168function JBB ()
169169 ϵ = [1.0 1.5 0.75 ; 1.5 0.5 1.5 ; 0.75 1.5 0.75 ]
170170 σ = [1.0 0.8 0.9 ; 0.8 0.88 0.8 ; 0.9 0.8 0.94 ]
171- JBB_11 = SmoothLennardJones (ϵ[1 ,1 ], σ[1 ,1 ])
172- JBB_12 = SmoothLennardJones (ϵ[1 ,2 ], σ[1 ,2 ])
173- JBB_13 = SmoothLennardJones (ϵ[1 ,3 ], σ[1 ,3 ])
174- JBB_22 = SmoothLennardJones (ϵ[2 ,2 ], σ[2 ,2 ])
175- JBB_23 = SmoothLennardJones (ϵ[2 ,3 ], σ[2 ,3 ])
176- JBB_33 = SmoothLennardJones (ϵ[3 ,3 ], σ[3 ,3 ])
177- return SMatrix {3, 3, typeof(JBB_11), 9} ([JBB_11 JBB_12 JBB_13; JBB_12 JBB_22 JBB_23; JBB_13 JBB_23 JBB_33])
171+ JBB_11 = SmoothLennardJones (ϵ[1 , 1 ], σ[1 , 1 ])
172+ JBB_12 = SmoothLennardJones (ϵ[1 , 2 ], σ[1 , 2 ])
173+ JBB_13 = SmoothLennardJones (ϵ[1 , 3 ], σ[1 , 3 ])
174+ JBB_22 = SmoothLennardJones (ϵ[2 , 2 ], σ[2 , 2 ])
175+ JBB_23 = SmoothLennardJones (ϵ[2 , 3 ], σ[2 , 3 ])
176+ JBB_33 = SmoothLennardJones (ϵ[3 , 3 ], σ[3 , 3 ])
177+ return SMatrix {3,3, typeof(JBB_11),9} ([JBB_11 JBB_12 JBB_13; JBB_12 JBB_22 JBB_23; JBB_13 JBB_23 JBB_33])
178178 # return [JBB_11 JBB_12 JBB_13; JBB_12 JBB_22 JBB_23; JBB_13 JBB_23 JBB_33]
179179end
180180
@@ -201,12 +201,12 @@ end
201201
202202function GeneralKG (ϵ, σ, k, r0; rcut= 2 ^ (1 / 6 ) * σ, ϵbond= ϵ, σbond= σ, rcutbond= rcut)
203203 name = " GeneralKG"
204- r02 = r0 ^ 2
205- rcut2 = rcut ^ 2
206- rcut2bond = rcutbond ^ 2
207- kr02 = - k * r02 / 2
208- σ2 = σ ^ 2
209- σ2bond = σbond ^ 2
204+ r02 = r0^ 2
205+ rcut2 = rcut^ 2
206+ rcut2bond = rcutbond^ 2
207+ kr02 = - k * r02 / 2
208+ σ2 = σ^ 2
209+ σ2bond = σbond^ 2
210210 shift = lennard_jones (rcut2, 4 ϵ, σ2)
211211 shiftbond = lennard_jones (rcut2bond, 4 ϵbond, σ2bond)
212212 return GeneralKG (name, ϵ, 4 ϵ, ϵbond, 4 ϵbond, σ2, σ2bond, shift, shiftbond, k, kr02, r02, rcut, rcut2, rcutbond, rcut2bond)
220220 u_fene = r2 ≤ model. r02 ? fene (r2, model. kr02, model. r02) : Inf
221221 u_lj = 0.0
222222 if r2 ≤ model. rcut2bond
223- u_lj += lennard_jones (r2, model. ϵ4bond, model. σ2bond) - model. shiftbond
223+ u_lj += lennard_jones (r2, model. ϵ4bond, model. σ2bond) - model. shiftbond
224224 end
225225 return u_fene + u_lj
226226end
@@ -229,16 +229,16 @@ cutoff(model::DiscreteModel) = model.rcut
229229cutoff2 (model:: DiscreteModel ) = model. rcut2
230230
231231function Trimer ()
232- ϵ = SMatrix {3, 3, Float64} ([1.0 1.0 1.0 ; 1.0 1.0 1.0 ; 1.0 1.0 1.0 ])
233- σ = SMatrix {3, 3, Float64} ([0.9 0.95 1.0 ; 0.95 1.0 1.05 ; 1.0 1.05 1.1 ])
234- k = SMatrix {3, 3, Float64} ([0.0 33.241 30.0 ; 33.241 0.0 27.210884 ; 30.0 27.210884 0.0 ])
235- r0 = SMatrix {3, 3, Float64} ([0.0 1.425 1.5 ; 1.425 0.0 1.575 ; 1.5 1.575 0.0 ])
236- KG_11 = GeneralKG (ϵ[1 ,1 ], σ[1 ,1 ], k[1 ,1 ], r0[1 ,1 ])
237- KG_12 = GeneralKG (ϵ[1 ,2 ], σ[1 ,2 ], k[1 ,2 ], r0[1 ,2 ])
238- KG_13 = GeneralKG (ϵ[1 ,3 ], σ[1 ,3 ], k[1 ,3 ], r0[1 ,3 ])
239- KG_22 = GeneralKG (ϵ[2 ,2 ], σ[2 ,2 ], k[2 ,2 ], r0[2 ,2 ])
240- KG_23 = GeneralKG (ϵ[2 ,3 ], σ[2 ,3 ], k[2 ,3 ], r0[2 ,3 ])
241- KG_33 = GeneralKG (ϵ[3 ,3 ], σ[3 ,3 ], k[3 ,3 ], r0[3 ,3 ])
242- return SMatrix {3, 3, typeof(KG_11), 9} ([KG_11 KG_12 KG_13; KG_12 KG_22 KG_23; KG_13 KG_23 KG_33])
232+ ϵ = SMatrix {3,3, Float64} ([1.0 1.0 1.0 ; 1.0 1.0 1.0 ; 1.0 1.0 1.0 ])
233+ σ = SMatrix {3,3, Float64} ([0.9 0.95 1.0 ; 0.95 1.0 1.05 ; 1.0 1.05 1.1 ])
234+ k = SMatrix {3,3, Float64} ([0.0 33.241 30.0 ; 33.241 0.0 27.210884 ; 30.0 27.210884 0.0 ])
235+ r0 = SMatrix {3,3, Float64} ([0.0 1.425 1.5 ; 1.425 0.0 1.575 ; 1.5 1.575 0.0 ])
236+ KG_11 = GeneralKG (ϵ[1 , 1 ], σ[1 , 1 ], k[1 , 1 ], r0[1 , 1 ])
237+ KG_12 = GeneralKG (ϵ[1 , 2 ], σ[1 , 2 ], k[1 , 2 ], r0[1 , 2 ])
238+ KG_13 = GeneralKG (ϵ[1 , 3 ], σ[1 , 3 ], k[1 , 3 ], r0[1 , 3 ])
239+ KG_22 = GeneralKG (ϵ[2 , 2 ], σ[2 , 2 ], k[2 , 2 ], r0[2 , 2 ])
240+ KG_23 = GeneralKG (ϵ[2 , 3 ], σ[2 , 3 ], k[2 , 3 ], r0[2 , 3 ])
241+ KG_33 = GeneralKG (ϵ[3 , 3 ], σ[3 , 3 ], k[3 , 3 ], r0[3 , 3 ])
242+ return SMatrix {3,3, typeof(KG_11),9} ([KG_11 KG_12 KG_13; KG_12 KG_22 KG_23; KG_13 KG_23 KG_33])
243243end
244244# ##############################################################################
0 commit comments