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

Improve of betacristabolite recipe #1124

Closed
wants to merge 13 commits into from

Conversation

daico007
Copy link
Member

@daico007 daico007 commented Jun 2, 2023

PR Summary:

Modify the Betacristobalite recipe so that it can be created with a custom size (with some borrow code from water_box recipe).

PR Checklist


  • Includes appropriate unit test(s)
  • Appropriate docstring(s) are added/updated
  • Code is (approximately) PEP8 compliant
  • Issue(s) raised/addressed?

@daico007
Copy link
Member Author

daico007 commented Jun 3, 2023

Bug fixed, pending test for new use case.

@codecov
Copy link

codecov bot commented Jun 3, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06 🎉

Comparison is base (54a6241) 87.11% compared to head (613aedd) 87.18%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1124      +/-   ##
==========================================
+ Coverage   87.11%   87.18%   +0.06%     
==========================================
  Files          62       62              
  Lines        6451     6483      +32     
==========================================
+ Hits         5620     5652      +32     
  Misses        831      831              
Impacted Files Coverage Δ
mbuild/lib/surfaces/betacristobalite.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.


# Bogus values provided
with pytest.raises(ValueError):
surface = Betacristobalite(dimensions="bogus")

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable surface is not used.
@chrisiacovella chrisiacovella self-requested a review June 14, 2023 19:52
Copy link
Contributor

@CalCraven CalCraven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the handling of decimal dimensions needs to be addressed. Otherwise, it looks goodl

scale_Lz = math.ceil(box.Lz / ref_dims[2])

silica_list = list()
for particle in list(betacristabolite.particles()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need to turn this into a list, can just use the particles iterable.

temp.translate(shift)
silica_list.append(temp)

self.add(silica_list)

count = 0
for particle in list(self.particles()):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also not generate the list first.


count = 0
for particle in list(self.particles()):
if particle.name.startswith("O") and particle.pos[2] > 1.0:
if particle.name.startswith("O") and particle.pos[2] >= box.Lz:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this line originally was so you could determine surface oxygens. But if we make the particles position have to be larger than the z dimension of the box, won't we generate zero ports? Seems like this should maybe be some fraction of the the box.Lz.

assert surface.n_bonds == 2400

# 2D dimension provided
surface = Betacristobalite(dimensions=(5.3888 * 1.2, 4.589110 * 1.25))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So something seems a bit off to me here based on these inputs. I'm worried about the bondlength distributions. What if a particle gets closely placed towards an edge and near a particle already at that edge? I'm not sure fractional values for dimensions should be allowed since this behavior could result.

I would suggest either making a smaller version of the surface so it's easier to tile with integer values, writing a call that instead of loading the mol2, actually does the carving of the amorphous surface which should account for the exact box size specified and not have this issue, or have some filter that removes particles that get within a certain cutoff radius.

# Bogus values provided
with pytest.raises(ValueError):
surface = Betacristobalite(dimensions="bogus")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add the test:

Suggested change
assert len(surface.available_ports()) > 1
distancesList = []
for particle in surface.particles():
assert len(
surface.particles_in_range(particle, dmax=0.001, max_particles=1)
) ==0
assert np.min(distancesList) > 0.001 # 1/1000 of a nm is too close

@daico007 daico007 closed this May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants