odf / gavrog

Generation, analysis and visualization of reticular ornaments using Gavrog.
http://www.gavrog.org
Apache License 2.0
33 stars 5 forks source link

NullPointerException (bug in handling of 1-periodic graph) #13

Closed paulneves77 closed 3 years ago

paulneves77 commented 3 years ago

Hi, I've been running a lot of automatically generated crystal nets through Systre (great program!), and I have run into some errors. I have included a graph that will reproduce this bug when run in Systre. Note also that it’s possible there is something wrong with my input graph.

The error printed to the .out file is:

==================================================
!!! ERROR (INTERNAL) - Unexpected java.lang.NullPointerException: null
!!!    In structure #1 - "mp-1226080_Pb_0".
!!!    Last status: Computing ideal symmetry group...
!!!    Stack trace:
!!!       java.lang.NullPointerException
!!!         at org.gavrog.jane.compounds.Matrix.setSubMatrix(Matrix.java:226)
!!!         at org.gavrog.joss.pgraphs.basic.PeriodicGraph.symmetries(PeriodicGraph.java:1621)
!!!         at org.gavrog.joss.pgraphs.basic.PeriodicGraph.symmetryOperators(PeriodicGraph.java:1665)
!!!         at org.gavrog.apps.systre.SystreCmdline.processGraph(SystreCmdline.java:249)
!!!         at org.gavrog.apps.systre.SystreCmdline.processDisconnectedGraph(SystreCmdline.java:676)
!!!         at org.gavrog.apps.systre.SystreCmdline.processGraph(SystreCmdline.java:194)
!!!         at org.gavrog.apps.systre.SystreCmdline.processDataFile(SystreCmdline.java:921)
!!!         at org.gavrog.apps.systre.SystreCmdline.run(SystreCmdline.java:1120)
!!!         at org.gavrog.apps.systre.SystreCmdline.main(SystreCmdline.java:1135)
==================================================

The graph that reproduces this error is:

PERIODIC_GRAPH
ID mp-1226080_Pb_0
EDGES
  0 1 0 0 0
  0 2 1 -1 0
  0 2 1 -1 1
END
odf commented 3 years ago

Thanks for bringing this to my attention. It seems that this issue and #14 are two incarnations of the same type of edge case, namely a 1-periodic structure that contains vertices of degree 1. A pair of minimal inputs that reproduce the error(s) are

PERIODIC_GRAPH
ID chain-a
EDGES
  0 1 0
  0 0 1
END
PERIODIC_GRAPH
ID chain-b
EDGES
  0 0 1
  0 1 0
END

Hopefully that will help you work around the problem for now. I currently don't have a computer available that can compile Java code, but that should change within the next few days.

odf commented 3 years ago

Fixed in https://github.com/odf/gavrog/commit/2d2d99fbcc309cb0be03a3d3614afd0fa0b13d27. Issue #14 is due to the same bug, only this one goes unnoticed for a tad longer.

The problem was literally that I handled 1-periodic nets as a special case in the symmetry computation and forgot to check for 0-length edges.