Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/IO/IO.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -360,4 +362,4 @@ function Arianna.store_lastframe(io, system::Molecules, t, format::Arianna.Forma
return nothing
end

end # module IO
end # module IO
10 changes: 7 additions & 3 deletions src/models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
###############################################################################
###############################################################################