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

New functionality for generating slab consistent bulk model #134

Merged

Conversation

AkashHiregange
Copy link
Collaborator

No description provided.

The file name for slab model was incorrect in the previous version. Corrected it
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

Attention: Patch coverage is 98.38710% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 88.23%. Comparing base (2dc2644) to head (7f9bcb2).

Files Patch % Lines
carmm/build/slab_consistent_bulk_generator.py 97.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #134      +/-   ##
==========================================
+ Coverage   88.03%   88.23%   +0.19%     
==========================================
  Files          78       80       +2     
  Lines        3202     3264      +62     
==========================================
+ Hits         2819     2880      +61     
- Misses        383      384       +1     
Flag Coverage Δ
unittests 88.23% <98.38%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@OscarvanVuren
Copy link
Collaborator

Surely there must be a Numpy function to check if a float is close to an integer within tolerance? Perhaps I expect too much from Numpy though

Copy link
Owner

@logsdail logsdail left a comment

Choose a reason for hiding this comment

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

Added some high-level comments. Functionality looks great, my comments are mainly around programming practice.


# This functionality will help to generate a bulk model from a slab.

from ase import Atoms
Copy link
Owner

Choose a reason for hiding this comment

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

Imports should be in functions where used, not at the class level.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will change it!!

from ase import Atoms


def is_close_to_integer(arr, tolerance=1e-5):
Copy link
Owner

Choose a reason for hiding this comment

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

Is this supposed to be a private routine to help the work flow? I might make this private with _ at the front, and also move down the file (as lower priority than the function below it)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good. Thanks.

return close_to_integer


def bulk_identifier(slab: Atoms, cutoff_distance=10.0):
Copy link
Owner

Choose a reason for hiding this comment

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

Is the slab: Atoms definition needed? Can't we just check the type when received?

Copy link
Owner

Choose a reason for hiding this comment

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

This would remove the need for the import outside a function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. This will make the code look tidy and more readable I guess. Thanks

carmm/build/slab_consistent_bulk_generator.py Show resolved Hide resolved
carmm/build/slab_consistent_bulk_generator.py Outdated Show resolved Hide resolved
examples/build_slab_consistent_bulk.py Outdated Show resolved Hide resolved
from carmm.build.slab_consistent_bulk_generator import bulk_identifier
from ase.io import read
from ase.formula import Formula
slab = read('data/slab_consistent_bulk/geometry_CoO_111_slab_model.in')
Copy link
Owner

Choose a reason for hiding this comment

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

Can we use an existing surface model in the repository? No problem to keep this, but just cautious of us introducing a new model for each test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about that. I didn't find any existing surface model in the examples/data folder of CARMM

Copy link
Owner

Choose a reason for hiding this comment

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

You can just use the ASE slab generating functions to create one?

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

@AkashHiregange AkashHiregange Feb 6, 2024

Choose a reason for hiding this comment

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

That is true. However, the whole idea of writing this script was to generate bulk for surfaces where the basis vectors are transformed while generating desired surfaces (like pymatgen). ASE on the other hand does not transform the basis vectors. Hence, I believe the tests will be reliable if the checks are made against surfaces generated by pymatgen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can use the pymatgen functionality to create a slab for test. This might help avoid the use of geometry file altogether

Copy link
Owner

Choose a reason for hiding this comment

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

Works for me, though you’ll have to introduce PyMatgen into the testing infrastructure (as currently it is not included).

Also, do you need to state this is the purpose in the function preamble?

Copy link
Owner

Choose a reason for hiding this comment

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

I know you have lots of detail, but telling the user what it is supposed to work with is probably very useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that makes sense. I will add a bit more detail to the docstring.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made the suggested changes.

@logsdail
Copy link
Owner

logsdail commented Nov 14, 2023 via email

@AkashHiregange
Copy link
Collaborator Author

Surely there must be a Numpy function to check if a float is close to an integer within tolerance? Perhaps I expect too much from Numpy though

I tried to search for such functionality within numpy, but couldn't find one.

@OscarvanVuren
Copy link
Collaborator

I tried to search for such functionality within numpy, but couldn't find one.

Fair. I had a look too and failed to find such a routine.

Copy link
Owner

@logsdail logsdail left a comment

Choose a reason for hiding this comment

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

Added a further comment, overall looks very good.

from carmm.build.slab_consistent_bulk_generator import bulk_identifier
from ase.io import read
from ase.formula import Formula
slab = read('data/slab_consistent_bulk/geometry_CoO_111_slab_model.in')
Copy link
Owner

Choose a reason for hiding this comment

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

I know you have lots of detail, but telling the user what it is supposed to work with is probably very useful.

AkashHiregange and others added 2 commits February 8, 2024 11:35
…he geometry file from examples folder and modified the test to make use of existing infrastructure.
@GaryLZW
Copy link
Collaborator

GaryLZW commented Mar 8, 2024

Looks good to me!

@AkashHiregange AkashHiregange merged commit c286940 into logsdail:main Mar 8, 2024
4 checks passed
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.

5 participants