Comments (13)
Historically, I have had to toggle some of the defaults to get CrystalNN to play nicely with MOF linkers, which I imagine was the source of the motivation for @fxcoudert's question. I can dig up the arguments, if it would be helpful. Of course, one would hope the defaults would suffice...
from pymatgen.
Historically, I have had to toggle some of the defaults to get CrystalNN to play nicely with MOF linkers, which I imagine was the source of the motivation for fxcoudert's question
No I didn't know (or didn't remember) that. I just wanted to play with CrystalNN and see what it gave. I have seen it used on MOFs in a couple of papers, though:
- https://pubs.acs.org/doi/full/10.1021/acs.jctc.0c01229
- https://www.nature.com/articles/s41524-022-00796-6
- https://pubs.acs.org/doi/full/10.1021/acs.chemmater.1c02439
- https://pubs.acs.org/doi/full/10.1021/acs.jcim.1c01124
@Andrew-S-Rosen if you know what parameters can give good results for MOFs, I'd be interested, indeed
from pymatgen.
No I didn't know (or didn't remember) that. I just wanted to play with CrystalNN and see what it gave.
Ah, I was unclear in my phrasing. I meant that you were probably asking about an organic molecule because you're interested in MOF linkers. :) Edit: I now see you were indeed referring to a MOF! I only saw the image at first. This is what I get for responding to GitHub issues from my phone...
if you know what parameters can give good results for MOFs, I'd be interested, indeed
I did some digging and noticed that for the MOF Explorer App on the Materials Project, we used the following:
cnn = CrystalNN(porous_adjustment=True, x_diff_weight=1.5, search_cutoff=4.5)
StructureGraph.with_local_env_strategy(structure, cnn).to_json()
So, we were playing around with x_diff_weight
and search_cutoff
to address some issues with the organics. That said, the behavior reported in this issue is indeed odd. I would not rule out a bug or problem in general here, although I personally do not have time to look into the issue further. Hopefully someone else can!
from pymatgen.
I would like to add an additional weird behaviour of one of the other algorithms from the same module which relies on the MinimumDistance. It could be related as many functionalities are shared between the two classes.
from pymatgen.core.structure import Structure
from pymatgen.analysis.local_env import JmolNN, CrystalNN, MinimumDistanceNN, VoronoiNN, MinimumOKeeffeNN
from collections import Counter
structure = Structure.from_file("MOF-71.cif")
nn = MinimumDistanceNN(0.5)
bonded_struct = nn.get_bonded_structure(structure)
len_neighbors = []
import numpy as np
for n, site in enumerate(bonded_struct.structure.sites):
connected_sites = len(bonded_struct.get_connected_sites(n))
if np.abs(site.coords[0] - 4.63463478) < 0.01 and np.abs(site.coords[1] - 1.18568268) < 0.01 and np.abs(
site.coords[2] - 8.95930359) < 0.01:
print(connected_sites)
print(bonded_struct.get_connected_sites(n))
len_neighbors.append(connected_sites)
counter = Counter(len_neighbors)
I only get the 2nd C if I add a very large tolerance criterion, which is very weird. And the weight is much lower. The weights are different for the different C atoms even so it is a purely distance-based metric.
from pymatgen.
Hi @fxcoudert ,
have you tested some of other algorithms in the same module as well? I fear CrystalNN might be optimized mostly for typical inorganic crystals.
Just a reminder: the alogrithm uses Voronoi partitioning, solid angles/distances, electronegativities and so on. I would assume the H atoms are not found, right?
from pymatgen.
JMolNN()
seems to work at least for the C atoms mentioned above in that example. However, I would not trust the radii in there (they are horribly far away from the atomic radii in P, for example). You might want to provide a list of radii and tolerances yourself (e.g., atomic radii). I would assume that it should work very efficiently for molecular crystals. I am not sure there is currently any implementation directly in pymatgen or related package optimized for molecular crystals. (cc @Andrew-S-Rosen ?)
from pymatgen.
@fxcoudert should we add more documentation to the module and the respective classes to make clear that this is likely only working for inorganic/ionic crystals? If you look at the CrystalNN benchmark, it's also clear that it has never been benchmarked against molecular crystals (see https://pubs.acs.org/doi/10.1021/acs.inorgchem.0c02996)
from pymatgen.
Historically, I have had to toggle some of the defaults to get CrystalNN to play nicely with MOF linkers, which I imagine was the source of the motivation for @fxcoudert's question. I can dig up the arguments, if it would be helpful. Of course, one would hope the defaults would suffice...
Ah, I see! Sorry that I did not know that! At least, I figured out who to ping 😅.
from pymatgen.
After looking again: I find it still puzzling that it does not consider the second C despite the fact that the bond lengths should be extremely similar.
from pymatgen.
This is only tangentially related, but it also implies issues with C and CrystalNN
(but this time on an inorganic surface): #2618
from pymatgen.
I think I have a idea: it's due to the bonded structure.
from pymatgen.core.structure import Structure
from pymatgen.analysis.local_env import JmolNN, CrystalNN, MinimumDistanceNN, VoronoiNN, MinimumOKeeffeNN
from collections import Counter
structure = Structure.from_file("MOF-71.cif")
nn =MinimumDistance()
print(nn.get_cn(structure, 76))
As expected, this gives 1. Same for CrystalNN() btw.
I am not entirely sure where this comes from but potentially that both algorithms detect a bond from one side but not the other. Thus, changing the cutoffs should likely be enough. (Tested, nn =CrystalNN( x_diff_weight=1.5, search_cutoff=4.5)
and it seems to work for this example as well)
My hypothesis for now:
If you use the CN tools, you get 1. Thus, some cutoff cuts off the C-C bonds for this particular C. One of the neighboring Cs has a bond to it... (the one bonded to 3Cs) but not the other (2Cs and 1 H) Then, in the graph, you will get a 2-fold coordination.... The graph should probably be a directed one but the output doesn't seem to care.
from pymatgen.
@fxcoudert I hope my answer is clear and helps. I don't think it is a bug. Just suboptimal weights for the C-H vs. C-C bond case.
from pymatgen.
I have closed this issue now with an update to the documentation. Let us know if there are still any problems.
from pymatgen.
Related Issues (20)
- Collect possible issues might come with Python 3.12
- Incompatibility Issue with ALGO Parameter in Incar and Vasprun Classes
- Periodic boundary condition is not considered in the interpolator of VolumetricData HOT 1
- [Dev] `datetime.datetime.utcnow()` deprecated and replacement breaks `strptime`
- Read in POSCAR with `Structure.from_file` seems slow? HOT 3
- `get_points_in_sphere()` has inconsistent return types HOT 1
- Monthly issue metrics report
- StructureMatcher might be wrong when used to check if two structures are equal. HOT 3
- Error in CP2K output parser structure parsing
- Bug in `core.composition` comparison
- Argument `check_occu` is not working as intended (in `_get_structure` and `parse_structures`) HOT 15
- Check inputs provided to MPRester functions
- `.as_dict()` method on `VaspInput` causes an `AttributeError`
- A minor document error in `POTCAR Setup`.
- Incorrect letter cases for memory in `core.units`
- GaussianOutput.read_excitation_energies() method for obtaining TDDFT results ([(energie (eV), lambda (nm), oscillatory strength), ... ]) error
- Adapt LobsterSets to latest potcars
- Support parsing of NBANDS from a VASP OUTCAR file
- determine crystal space group error
- Incorrect SpaceGroup symbol attribute for 16 space group types HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pymatgen.