Skip to content

Commit

Permalink
Create a kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Leticia-maria committed Apr 20, 2024
1 parent defc2ef commit a20f3fe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/OohataHuzinaga.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export gaussianproduct
export normalization

export overlap
export Operator
export oei
export kinetic
export boys
export attraction
Expand Down
1 change: 0 additions & 1 deletion src/auxiliary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ end

function distance(Rᵢ, Rⱼ)
d = (Rᵢ[1] - Rⱼ[1])^2 + (Rᵢ[2] - Rⱼ[2])^2 + (Rᵢ[3] - Rⱼ[3])^2

return d
end

Expand Down
33 changes: 31 additions & 2 deletions src/kinetic.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,45 @@
struct Operator<:Function
end

function Kxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ, nᵢ, nⱼ)
K = αⱼ * (2 * (ℓⱼ + mⱼ + nⱼ) + 3) * Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ, nᵢ, nⱼ)
K -= (2 * (αⱼ^2)) * Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ + 2, mᵢ, mⱼ, nᵢ, nⱼ)
K -= (2 * (αⱼ^2)) * Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ + 2, nᵢ, nⱼ)
K -= (2 * (αⱼ^2)) * Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ, nᵢ, nⱼ + 2)

K -= (1 / 2) * (ℓⱼ * (ℓⱼ - 1)) * Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ - 2, mᵢ, mⱼ, nᵢ, nⱼ)
K -= (1 / 2) * (mⱼ * (mⱼ - 1)) * Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ - 2, nᵢ, nⱼ)
K -= (1 / 2) * (nⱼ * (nⱼ - 1)) * Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ, nᵢ, nⱼ - 2)

return K
end

function oei(basis, molecule::Molecule, integral::Operator)
n = length(basis)
O = zeros(n, n)
for c in CartesianIndices(O)
i, j = c[1], c[2]
basisᵢ, basisⱼ = basis[i], basis[j]
Rᵢ, Rⱼ = basisᵢ.R, basisⱼ.R
dist = distance(Rᵢ, Rⱼ)
m, p = basisᵢ.size, basisⱼ.size
ℓᵢ, mᵢ, nᵢ = basisᵢ.ℓ, basisᵢ.m, basisᵢ.n
ℓⱼ, mⱼ, nⱼ = basisⱼ.ℓ, basisⱼ.m, basisⱼ.n
for e in CartesianIndices((m, p))
k, l = e[1], e[2]
αᵢ = basisᵢ.α[k]
αⱼ = basisⱼ.α[l]
dᵢ, dⱼ = basisᵢ.d[k], basisⱼ.d[l]
Nᵢ, Nⱼ = basisᵢ.N[k], basisⱼ.N[l]
O[i, j] += (
exp(-αᵢ * αⱼ * dist / (αᵢ + αⱼ)) *
Nᵢ * Nⱼ * dᵢ * dⱼ *
integral.(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ, nᵢ, nⱼ)
)
end
end
return O
end

function kinetic(basis, molecule::Molecule)
n = length(basis)
T = zeros(n, n)
Expand Down
2 changes: 0 additions & 2 deletions src/overlap.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
function Sxyz(Rᵢ, Rⱼ, αᵢ, αⱼ, ℓᵢ, ℓⱼ, mᵢ, mⱼ, nᵢ, nⱼ)
Rₚ = gaussianproduct(αᵢ, Rᵢ, αⱼ, Rⱼ, αᵢ + αⱼ)

Sx = sᵢ(ℓᵢ, ℓⱼ, αᵢ + αⱼ, Rᵢ[1], Rⱼ[1], Rₚ[1])
Sy = sᵢ(mᵢ, mⱼ, αᵢ + αⱼ, Rᵢ[2], Rⱼ[2], Rₚ[2])
Sz = sᵢ(nᵢ, nⱼ, αᵢ + αⱼ, Rᵢ[3], Rⱼ[3], Rₚ[3])

return Sx * Sy * Sz
end

Expand Down

0 comments on commit a20f3fe

Please sign in to comment.