Skip to content

Commit

Permalink
refactor alphagamma function
Browse files Browse the repository at this point in the history
  • Loading branch information
m-julian committed Oct 15, 2024
1 parent ca3bce6 commit f8eccf1
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions ichor_core/ichor/core/multipoles/hexadecapole.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,20 @@ def get_alphagamma(alpha: int, gamma: int) -> int:
:return: the remaining term
"""

for i in range(3):
if (i != alpha) and (i != gamma):
return i
if alpha == 0 and gamma == 1:
return 2
elif alpha == 0 and gamma == 2:
return 1
elif alpha == 1 and gamma == 0:
return 2
elif alpha == 1 and gamma == 2:
return 0
elif alpha == 2 and gamma == 0:
return 1
elif alpha == 2 and gamma == 1:
return 0
else:
raise ValueError("The function should have returned the last index already.")


def sorting_function(alpha: int, beta: int, gamma: int, chi: int):
Expand Down Expand Up @@ -471,7 +482,6 @@ def G(alpha, beta, gamma, chi, dipole, quadrupole, octupole, displacement_vector
alpha, beta, gamma = sorting_function(alpha, beta, gamma, chi)

onealpha, twoalpha = get_other_alphas(alpha)
alphagamma = get_alphagamma(alpha, gamma)

if (alpha == beta) and (beta == gamma):

Expand Down Expand Up @@ -506,6 +516,8 @@ def G(alpha, beta, gamma, chi, dipole, quadrupole, octupole, displacement_vector

elif (alpha == beta) and (beta != gamma):

alphagamma = get_alphagamma(alpha, gamma)

term1 = 10.5 * f3(
gamma, alpha, alpha, alpha, dipole, octupole, displacement_vector
)
Expand All @@ -528,6 +540,8 @@ def G(alpha, beta, gamma, chi, dipole, quadrupole, octupole, displacement_vector

elif (alpha != beta) and (beta == gamma):

alphagamma = get_alphagamma(alpha, gamma)

term1 = 18 * (
f3(alpha, alpha, gamma, gamma, dipole, octupole, displacement_vector)
+ f3(gamma, gamma, alpha, alpha, dipole, octupole, displacement_vector)
Expand Down Expand Up @@ -577,7 +591,7 @@ def G(alpha, beta, gamma, chi, dipole, quadrupole, octupole, displacement_vector

return term1 - term2 + term3 - term4 + term5 + term6 - term7

else:
elif (alpha != beta) and (beta != gamma):

term1 = 18 * f3(
alpha, alpha, beta, gamma, dipole, octupole, displacement_vector
Expand Down

0 comments on commit f8eccf1

Please sign in to comment.