diff --git a/src/IO/IO.jl b/src/IO/IO.jl index c956093..e4f6a43 100644 --- a/src/IO/IO.jl +++ b/src/IO/IO.jl @@ -3,7 +3,7 @@ module IO using ..ParticlesMC: Particles, Atoms, Molecules, System using ..ParticlesMC: fold_back, volume_sphere using ..ParticlesMC: EmptyList, LinkedList, CellList -using ..ParticlesMC: Model, GeneralKG, JBB, BHHP, SoftSpheres, KobAndersen, Trimer +using ..ParticlesMC: Model, GeneralKG, JBB, BHHP, SoftSpheres, KobAndersen, Trimer, LennardJones using Arianna using Distributions, LinearAlgebra, StaticArrays, Printf using DataStructures: OrderedDict @@ -131,7 +131,7 @@ function get_model(data, i::Int, j::Int) m = data[key] if m["name"] == "GeneralKG" rcut = get(m, "rcut", nothing) - + return GeneralKG(m["epsilon"], m["sigma"], m["k"], m["r0"]; filter_kwargs( :rcut => get(m, "rcut", nothing), @@ -146,7 +146,9 @@ function get_model(data, i::Int, j::Int) elseif m["name"] == "LennardJones" return LennardJones(m["epsilon"], m["sigma"]; filter_kwargs( - :rcut => get(m, "rcut", nothing))...) + :rcut => get(m, "rcut", nothing), + :shift_potential => get(m, "shift_potential", true), + )...) else error("Model $(m["name"]) is not implemented") return nothing @@ -156,7 +158,7 @@ end function read_bonds(data, N, format::Arianna.Format) selrow = get_selrow(format, N, 1) bonds_data = data[N+selrow:end] - + if length(bonds_data) == 0 error("No bonds found in the file") else @@ -306,7 +308,7 @@ function formatted_string(num::Real, digits::Integer) end function write_position(io, position, digits::Int) - for position_i in position + for position_i in position formatted_position_i = formatted_string(position_i, digits) print(io, " ") print(io, formatted_position_i) @@ -360,4 +362,4 @@ function Arianna.store_lastframe(io, system::Molecules, t, format::Arianna.Forma return nothing end -end # module IO \ No newline at end of file +end # module IO diff --git a/src/models.jl b/src/models.jl index 6ea5eca..388792f 100644 --- a/src/models.jl +++ b/src/models.jl @@ -107,10 +107,14 @@ struct LennardJones{T<:AbstractFloat} <: DiscreteModel shift::T end -function LennardJones(ϵ, σ; rcut=2.5*σ, name="LennardJones") +function LennardJones(ϵ, σ; rcut=2.5*σ, name="LennardJones", shift_potential=true) σ2 = σ ^ 2 rcut2 = rcut ^ 2 - shift = lennard_jones(rcut2, 4ϵ, σ2) + if shift_potential + shift = lennard_jones(rcut2, 4ϵ, σ2) + else + shift = 0.0 + end return LennardJones(name, ϵ, 4ϵ, σ, σ2, rcut, rcut2, shift) end @@ -237,4 +241,4 @@ function Trimer() KG_33 = GeneralKG(ϵ[3,3], σ[3,3], k[3,3], r0[3,3]) 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]) end -############################################################################### \ No newline at end of file +###############################################################################