Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JOSS] Coordination Numbers and Spheres #24

Closed
4 tasks done
RMeli opened this issue Mar 19, 2021 · 3 comments
Closed
4 tasks done

[JOSS] Coordination Numbers and Spheres #24

RMeli opened this issue Mar 19, 2021 · 3 comments
Assignees
Labels

Comments

@RMeli
Copy link
Contributor

RMeli commented Mar 19, 2021

getCoordinationNumberSpheres()

There seem to be some code duplication in getCoordinationNumberSpheres(). The code after scale= is the same for whichever scale is chosen. Additionally, cnsp is initialized and computed, but not used in the final result.

cnsp = np.zeros(shape=(nat,), dtype=np.float64)

I suggest to move the following code

for i in range(nat):
ia = at[i] - 1
for j in range(nat):
if i is j:
continue
ja = at[j] - 1
dx = coords[j][0] - coords[i][0]
dy = coords[j][1] - coords[i][1]
dz = coords[j][2] - coords[i][2]
rSquared = dx * dx + dy * dy + dz * dz
if rSquared > threshold:
continue
r = np.sqrt(rSquared)
rco = scale * (rcov[ia] + rcov[ja])
eni = pauling_en[ia]
enj = pauling_en[ja]
den = k4 * np.exp(-((np.abs(eni - enj) + k5) ** 2) / k6)
damp = den * 0.5 * (1 + special.erf(-kn * (r - rco) / rco))
cnsp[i] += damp

and call it with scale=2 and scale=3. With such changes, the code will better reflect the definition of CNSP_i^(3,2) given in the documentation.

getCoordinationNumbers()

There is some code duplication in getCoordinationNumbers

for i in range(nat):
ia = at[i] - 1
for j in range(nat):
if i is j:
continue
dx = coords[j][0] - coords[i][0]
dy = coords[j][1] - coords[i][1]
dz = coords[j][2] - coords[i][2]
rSquared = dx * dx + dy * dy + dz * dz
if rSquared > threshold:
continue
ja = at[j] - 1
r = np.sqrt(rSquared)
rco = rcov[ia] + rcov[ja]

However, writing a common function supporting all the different cntypes could possibly obfuscate the implementation so it is up to you if you want to unify them.

Documentation

In the documentation I'd mention how the parameters k0, k1, k2, k3 are obtained. Could you also link the following bit of text (see Applications part) to the corresponding section?

Suggested TODOs

  • Remove unused cnsp calculation in getCoordinationNumberSpheres()
  • Merge duplicate code in getCoordinationNumberSpheres()
  • Mention how the parameters k0, k1, k2, k3 are obtained (in the documentation)
  • Link the text (see Applications part) to the corresponding section

JOSS Review

@RMeli
Copy link
Contributor Author

RMeli commented Mar 19, 2021

Even better for getCoordinationNumberSpheres(), you could compute cnsp2 and cnsp3 within the same loop.

@f3rmion f3rmion self-assigned this Mar 19, 2021
@f3rmion f3rmion added the JOSS label Mar 19, 2021
@f3rmion f3rmion added this to In progress in Roadmap 2021 Mar 19, 2021
f3rmion added a commit that referenced this issue Mar 19, 2021
@f3rmion
Copy link
Member

f3rmion commented Mar 19, 2021

Hi @RMeli,

for a long time, I was also not really happy with the name of the CNSP, as the definition is not really a sphere but rather a shell. So I have now updated the name of this feature to be "Proximity Shell" (Prox) and also added the possibility of user input via the size flag (default: 2->3). In the documentation, I have separated the CN and the Prox part accordingly. In addition, I have added how the parameters of the CN have been fitted and cleaned up some sections in the code.

@RMeli
Copy link
Contributor Author

RMeli commented Mar 19, 2021

Less code and more general, that's great! ;)

@RMeli RMeli closed this as completed Mar 19, 2021
@f3rmion f3rmion moved this from In progress to Done in Roadmap 2021 Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants