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

'diff' parameter not working in StructureGraph.draw_graph_to_file #2542

Open
Anny-tech opened this issue Jun 5, 2022 · 3 comments
Open

'diff' parameter not working in StructureGraph.draw_graph_to_file #2542

Anny-tech opened this issue Jun 5, 2022 · 3 comments

Comments

@Anny-tech
Copy link

Describe the bug
'diff' parameter not working in 'draw_graph_to_file' from StructureGraph class of the pymatgen.analysis.graphs module

To Reproduce
Steps to reproduce the behavior:

  1. Generated structure using *.cif file
  2. Generated structuregraph using 'with_local_env_strategy', with strategy=CrystalNN() in the StructureGraph class.
  3. Tried to generate graph image using st1_1.draw_graph_to_file(filename='graph.png',diff=st2_1), where st1_1= structuregraph1 and st2_1=structuregraph2.
  4. Error: [TypeError: 'ValueError' object is not subscriptable]

Screenshots
image

Desktop (please complete the following information):

  • OS: [Linux]
  • Version [Ubuntu 20.04.4 LTS]
@mkhorton
Copy link
Member

mkhorton commented Jun 6, 2022

Hi @Anny-tech, thanks for the report. To be able to reproduce, could you supply the input structure too?

My suggestions are:

  1. Try st1_1.diff(st2_1) first. This calls the .diff() method which needs to work for the drawing method to work, and if this gives an error it may be more helpful.
  2. Bear in mind that the intent for this method is to compare different bonding strategies for the same structure. Trying to do a comparison between different structures will not be meaningful, since the nodes of the graph (atomic sites) are also different, not just the edges (bonds).

@Anny-tech
Copy link
Author

Hi @mkhorton , thanks for the reply.

  1. I tried this already. It works. As in gives a Valu
    st1.cif.txt
    st2.cif.txt
    eError, with the same statement you mentioned in point 2 above.
  2. That is exactly our aim. I derived the structures from another code. Wanted to check using pymatgen whether the structures are indeed different or not!
    I am attaching the input structures here.

@mkhorton
Copy link
Member

mkhorton commented Jun 6, 2022

Ok, for this application maybe StructureMatcher maybe more appropriate. This can compare structures based on atomic co-ordinates and tell you if they are the same structure or not. The StructureGraph.diff methods are more for differences in number of bonds; it's possible for two different polymorphs (with different symmetries) to have the same bonds/graphs if their respective atoms are in the same co-ordination environments.

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

No branches or pull requests

2 participants