-
Notifications
You must be signed in to change notification settings - Fork 18
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
New functionality for generating slab consistent bulk model #134
Conversation
The file name for slab model was incorrect in the previous version. Corrected it
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the suggested changes.
Ah OK, so perhaps my comment makes no difference. I thought it was a bonding distance cutoff.
________________________________
From: AkashHiregange ***@***.***>
Sent: 14 November 2023 15:13
To: logsdail/carmm ***@***.***>
Cc: Andrew Logsdail ***@***.***>; Comment ***@***.***>
Subject: Re: [logsdail/carmm] New functionality for generating slab consistent bulk model (PR #134)
External email to Cardiff University - Take care when replying/opening attachments or links.
Nid ebost mewnol o Brifysgol Caerdydd yw hwn - Cymerwch ofal wrth ateb/agor atodiadau neu ddolenni.
@AkashHiregange commented on this pull request.
________________________________
In carmm/build/slab_consistent_bulk_generator.py<#134 (comment)>:
+ bulk atoms in a slab structure. This new bulk structure will be consistent with the slab model and the
+ computed bulk energy for this structure will help to obtain surface energies that are convergent with
+ increasing slab thickness. Further detailed information is available in the following literature article.
+ Schultz, Peter A.
+ "First-principles calculations of metal surfaces. I. Slab-consistent bulk reference for convergent surface
+ properties." Physical Review B 103.19 (2021): 195426.
+
+ How this functionality works:
+ 1. the difference between the x,y and z coordinates of an atom and its corresponding periodic image will be a linear
+ combination of the cell vectors a,b and c.
+ 2. This idea is extended here in case of a slab model where the linear combination check
+ is considered only w.r.t to the a and b vectors
+
+ Args:
+ - slab: ASE Atoms object representing the slab structure
+ - cutoff_distance: Cutoff distance for identifying neighboring atoms (default is 10.0). This will be used to
This is the distance that is used to check the co-ordination environment of a given atom. For example, the distances between a given atom and all other atoms that lie within a 10 angstrom radius is checked. But since the atoms at the bottom of the slab have no atoms below it, I had to force it check for atoms that have a z-coordinate value great than current atom that is being checked (dist <= cutoff_distance and slab[ind].position[2] / atom_i.position[2] >= 0.9999]). But, I will have a chat with Harry to look into it
—
Reply to this email directly, view it on GitHub<#134 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AFMK4M7TF7SBS7QYY2CMCBTYEODC5AVCNFSM6AAAAAA7K2JBJKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMRZHE4DQOBYG4>.
You are receiving this because you commented.Message ID: ***@***.***>
|
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. |
There was a problem hiding this 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') |
There was a problem hiding this comment.
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.
…he geometry file from examples folder and modified the test to make use of existing infrastructure.
Looks good to me! |
No description provided.