Comments (10)
@stefsmeets I just wanted to mention that this might be problematic for very large structures. There are only 26 letters in the alphabet. With exception to this drawback, such a solution would be nice.
from pymatgen.
I'd be happy to have a go at this
from pymatgen.
One of the reasons labels should be unique: they are used to indicate bonding (and angles, torsions, etc). If they are not unique, this information is useless. (And I am working on a PR to add that capability to pymatgen.)
from pymatgen.
I can confirm that this is likely a bug (in terms of having agreement with the CIF spec).
from pymatgen.
The bug may not necessarily be in the CifWriter itself. Pymatgen expands the structure to P1 when reading a cif file (symmetry information gets lost). This includes duplicating the labels.
from pymatgen.
Does pymatgen require labels to be unique? I do not know. If so, the bug is in the symmetry expansion. But what is sure is that labels in a CIF file should be unique (whether pymatgen accepts duplicate labels or not).
from pymatgen.
No, pymatgen does not require unique labels. The duplication of labels happens when the symmetry is expanded in the CifParser:
Lines 1003 to 1011 in 0e57abf
One way to solve would be to ensure labels are suffixed 'abcde...' when the symmetry gets expanded there. Although this can also be a check on the CifWriter side.
from pymatgen.
@stefsmeets sound great. (cc @janosh)
from pymatgen.
Some options:
CifWriter
raisesValueError
if Structure contains duplicate label -> user is forced to correct itCifWriter
raisesUserWarning
if Structure contains duplicate label -> user can choose to correct itCifWriter
overwrites labels to fix the issue -> less hassle for the users, but can lead to unexpected labels in CIF fileCifParser.parse_structures()
ensures unique labels when reading CIF -> if the user modifies the sites, they may still end up with duplicate labels
I want to avoid agressively/automatically relabelling, because I know that this can lead to unexpected results which can be frustrating. So I'm leaning towards 1 or 2.
To help with 1 or 2, I want to add a method: Structure.relabel_sites()
to give users some room to quickly relabel a large number of sites and ensure uniqueness. I think this can be useful to add regardless.
Let me know what you think.
from pymatgen.
- Option 1: sadly, there are CIF files (mostly from computational tools) that have this problem, so I think that is not viable.
- Option 2: sounds nice, but does not account for situations where pymatgen itself is creating label duplicates (when lowering symmetry). How about an option to
CifWriter
to make labels unique.
from pymatgen.
Related Issues (20)
- [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
- Why does OUTCAR only parse the final magnetic moments? HOT 1
- Species.full_electronic_structure is incorrect HOT 2
- electronic_structure energy ordering is incorrect HOT 1
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.