Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrogantGao committed Jan 16, 2025
1 parent 4cf9d44 commit fb3afa0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/ICM/ICM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ function ICM_Ewald2D_force(interaction::IcmEwald2DInteraction{T}, position::Vect
return force_short + force_long
end

function IcmEwald3DInteraction(n_atoms::Int, s::T, α::T, γ::Tuple{T, T}, L::NTuple{3,T}, N_image::Int, N_pad::Int; ϵ::T = one(T)) where{T}
function IcmEwald3DInteraction(n_atoms::Int, s::T, α::T, γ::Tuple{T, T}, L::NTuple{3,T}, N_image::Int, N_pad::TP; ϵ::T = one(T)) where{T, TP}
r_c = s / α
k_c = 2 * α * s
k_set = k_set_3D(k_c, (L[1], L[2], (2 * N_pad + 1) * L[3]))
return IcmEwald3DInteraction(n_atoms, ϵ, α, r_c, k_c, γ, L, N_image, N_pad, k_set)
end

function ICM_Ewald3D_energy(interaction::IcmEwald3DInteraction{T}, position::Vector{Point{3, T}}, q::Vector{T}) where{T}
function ICM_Ewald3D_energy(interaction::IcmEwald3DInteraction{T, TP}, position::Vector{Point{3, T}}, q::Vector{T}) where{T, TP}

ref_pos, ref_q = ICM_reflect(interaction.γ, interaction.L, interaction.N_image, position, q)

Expand All @@ -47,7 +47,7 @@ function ICM_Ewald3D_energy(interaction::IcmEwald3DInteraction{T}, position::Vec
return Es + El + E_slab
end

function ICM_Ewald3D_force(interaction::IcmEwald3DInteraction{T}, position::Vector{Point{3, T}}, q::Vector{T}) where{T}
function ICM_Ewald3D_force(interaction::IcmEwald3DInteraction{T, TP}, position::Vector{Point{3, T}}, q::Vector{T}) where{T, TP}

ref_pos, ref_q = ICM_reflect(interaction.γ, interaction.L, interaction.N_image, position, q)

Expand Down
14 changes: 7 additions & 7 deletions src/ICM/ICM_long.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function ICM_Ewald2D_long_force_k0!(interaction::IcmEwald2DInteraction{T}, posit
end


function ICM_Ewald3D_long_energy(interaction::IcmEwald3DInteraction{T}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T}
function ICM_Ewald3D_long_energy(interaction::IcmEwald3DInteraction{T, TP}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T, TP}

energy = Atomic{T}(zero(T))

Expand All @@ -116,7 +116,7 @@ function ICM_Ewald3D_long_energy(interaction::IcmEwald3DInteraction{T}, ref_posi
return energy[] / (4π * interaction.ϵ)
end

function ICM_Ewald3D_long_energy_k(K::Tuple{T, T, T, T}, interaction::IcmEwald3DInteraction{T}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T}
function ICM_Ewald3D_long_energy_k(K::Tuple{T, T, T, T}, interaction::IcmEwald3DInteraction{T, TP}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T, TP}
k_x, k_y, k_z, k = K
L_x, L_y, L_z = interaction.L
α = interaction.α
Expand All @@ -141,7 +141,7 @@ function ICM_Ewald3D_long_energy_k(K::Tuple{T, T, T, T}, interaction::IcmEwald3D
return sum_k
end

function ICM_Ewald3D_long_force(interaction::IcmEwald3DInteraction{T}, position::Vector{Point{3, T}}, charge::Vector{T}) where{T}
function ICM_Ewald3D_long_force(interaction::IcmEwald3DInteraction{T, TP}, position::Vector{Point{3, T}}, charge::Vector{T}) where{T, TP}

n_atoms = interaction.n_atoms
force_long = [Point(zero(T), zero(T), zero(T)) for _=1:n_atoms]
Expand All @@ -153,13 +153,13 @@ function ICM_Ewald3D_long_force(interaction::IcmEwald3DInteraction{T}, position:
return force_long
end

function ICM_Ewald3D_long_force_k!(K::Tuple{T, T, T, T}, interaction::IcmEwald3DInteraction{T}, position::Vector{Point{3, T}}, charge::Vector{T}, force_long::Vector{Point{3, T}}) where{T}
function ICM_Ewald3D_long_force_k!(K::Tuple{T, T, T, T}, interaction::IcmEwald3DInteraction{T, TP}, position::Vector{Point{3, T}}, charge::Vector{T}, force_long::Vector{Point{3, T}}) where{T, TP}
k_x, k_y, k_z, k = K
L_x, L_y, L_z = interaction.L
α = interaction.α
N_pad = interaction.N_pad

ρ_k = zero(ComplexF64)
ρ_k = zero(Complex{T})
for j in 1:length(charge)
x_j, y_j, z_j = position[j]
ρ_k += charge[j] * exp(1.0im * (k_x * x_j + k_y * y_j + k_z * z_j))
Expand All @@ -173,7 +173,7 @@ function ICM_Ewald3D_long_force_k!(K::Tuple{T, T, T, T}, interaction::IcmEwald3D
return nothing
end

function ICM_Ewald3D_long_energy_slab(interaction::IcmEwald3DInteraction{T}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T}
function ICM_Ewald3D_long_energy_slab(interaction::IcmEwald3DInteraction{T, TP}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T, TP}

L_x, L_y, L_z = interaction.L
energy = zero(T)
Expand All @@ -194,7 +194,7 @@ function ICM_Ewald3D_long_energy_slab(interaction::IcmEwald3DInteraction{T}, ref
return energy / (4π * interaction.ϵ)
end

function ICM_Ewald3D_long_force_slab(interaction::IcmEwald3DInteraction{T}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T}
function ICM_Ewald3D_long_force_slab(interaction::IcmEwald3DInteraction{T, TP}, ref_position::Vector{Point{3, T}}, ref_charge::Vector{T}) where{T, TP}

L_x, L_y, L_z = interaction.L
N_pad = interaction.N_pad
Expand Down
4 changes: 2 additions & 2 deletions src/ICM/ICM_short.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function CellListICM(reflect_position::Vector{Point{3, T}}, L::NTuple{3, T}, r_c
return rr_list, ri_list
end

function ICM_Ewald_short_energy(interaction::Union{IcmEwald2DInteraction{T}, IcmEwald3DInteraction{T}}, ref_pos::Vector{Point{3, T}}, ref_q::Vector{T}) where{T}
function ICM_Ewald_short_energy(interaction::Union{IcmEwald2DInteraction{T}, IcmEwald3DInteraction{T, TP}}, ref_pos::Vector{Point{3, T}}, ref_q::Vector{T}) where{T, TP}

rr_list, ri_list = CellListICM(ref_pos, interaction.L, interaction.r_c, interaction.N_image, interaction.n_atoms)

Expand Down Expand Up @@ -44,7 +44,7 @@ function ICM_Ewald_short_energy(interaction::Union{IcmEwald2DInteraction{T}, Icm
return energy_short[] / (4π * interaction.ϵ)
end

function ICM_Ewald_short_force(interaction::Union{IcmEwald2DInteraction{T}, IcmEwald3DInteraction{T}}, ref_pos::Vector{Point{3, T}}, ref_q::Vector{T}) where{T}
function ICM_Ewald_short_force(interaction::Union{IcmEwald2DInteraction{T}, IcmEwald3DInteraction{T, TP}}, ref_pos::Vector{Point{3, T}}, ref_q::Vector{T}) where{T, TP}

force_short = [Point(zero(T), zero(T), zero(T)) for _=1:interaction.n_atoms]

Expand Down
4 changes: 2 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end

Base.show(io::IO, interaction::IcmEwald2DInteraction) = print(io, "IcmEwald2DInteraction(n_atoms = $(interaction.n_atoms), ϵ = $(interaction.ϵ), α = $(interaction.α), r_c = $(interaction.r_c), k_c = $(interaction.k_c), γ = $(interaction.γ), L = $(interaction.L), N_image = $(interaction.N_image))")

struct IcmEwald3DInteraction{T} <: ExTinyMD.AbstractInteraction
struct IcmEwald3DInteraction{T, TP} <: ExTinyMD.AbstractInteraction
n_atoms::Int
ϵ::T
α::T
Expand All @@ -46,7 +46,7 @@ struct IcmEwald3DInteraction{T} <: ExTinyMD.AbstractInteraction
γ::Tuple{T, T}
L::NTuple{3,T}
N_image::Int # layer of the image charges
N_pad::Int # layer of the z padding, L_z_pad = (2 * N_pad + 1) * L_z
N_pad::TP # layer of the z padding, L_z_pad = (2 * N_pad + 1) * L_z
k_set::Vector{Tuple{T, T, T, T}}
end

Expand Down

0 comments on commit fb3afa0

Please sign in to comment.