Closed brandimarte closed 6 years ago
I tried to find the culprit and look's like the problem is in the myUnique
call. I think it was suppose to sort the coordinates first in x, then in y, then z, but this does not happen, but I'm not sure if this was really the intention there, was it? @mpn2?
Adding the following lines just after myUnique
call seems to solve the problem:
# sort along the x component
possible.view('f8,f8,f8').sort(order=['f0'], axis=0)
If you attach an example geometry which gives the error I can have a look. I don't remember too much ...
I think the stress test still sometimes fails, i.e., try python Symmetry.py (outside the Inelastica directory) and it randomly used to fail after a few hundred tries ...
Hi @mpn2 !
Thanks, it would be great if you could have a look at it. My guess is that in findLattice
method when you perform the loop
while i1<NP-2 and not done:
you are somehow expecting that the set should be ordered in the first dimension x
, that's why I included this sort in the myUnique
call, which sort the set by distance instead. In the attached file there is an example where the Bandstructures
script fails.
Best!
I updated the module such that the torture test is executed with a script like this:
import Inelastica.Symmetry as SYM
SYM.test()
But I can confirm that this test still sometimes fails (in a first run after 5 steps and in the second after 435):
Running test no. 435
Symmetry: Lattice structure
4 atoms in the basis
a1 = (-1.450211,-0.772012,-1.816834), N1=5
a2 = (1.375195,-0.902704,-1.814929), N2=2
a3 = (-0.059729,-1.282632,0.592693), N3=9
b1 = (-0.357864,-0.088333,-0.227223)
b2 = (0.348487,-0.121006,-0.226747)
b3 = (-0.029865,-0.641317,0.296347)
Shifting coordinates by : [ 0.01261967 0.61510764 0.7335724 ]
Symmetry: ERROR! Inconsistent number of basis atoms. Probably bug in program.
Symmetry error
As @tfrederiksen point out in the comment on 9f67bcc, including the sorting over x do not fix the issue, since running the torture test it fails right way.
Nevertheless, this error in the torture test above might be pointing to a different issue, because here looks like the error happens after it finds the lattice.
Best!
Hi @mpn2 and @brandimarte,
Just to add some details: To test Pedro's slabGe
example try this:
Bandstructures --TSdir=<slabGe_dir> <dest_dir>
This generates IndexError: index 119 is out of bounds for axis 0 with size 119
. It appears to me that this is may be a bug in the function increase(i1,i2,i3,NP,incindx)
(it should never return an index equal to the array length NP
). In the example we have NP=119
.
Indeed @tfrederiksen! For instance if it happens that i2==i3==NP-1
and incindx==2
than i3
will be assign to NP+1
.
Hi again!
I think I started to understand a bit the idea of the algorithm at findLattice
. The sort in myUnique
call is done by distance since one wants to find the "smaller" lattice vectors, so it starts with the smaller set possible. In the example slabGe
above it turns out that the third lattice vector a3
is the largest possible which might explain why it goes out of bounds. Maybe changing the last lines of increase
function as:
i2 = min(max(i1+1, i2),NP-1)
i3 = min(max(i2+1, i3),NP-1)
#if incindx<=1: print i1, i2, i3
return i1, i2, i3
But still in this case the torture test fails. I think it would require a careful look at checkLattice
though to understand how incindx
is defined. Maybe one should get first all a1,a2,a3
valid candidates and then choose those that gives the smaller volume.
I have no idea of how git works yet ... this fixes the increase function so that it works as designed. The problem was that if i3>=NP -> i3=i2+2; i2=i2+1 ... now if i3 was NP-1 and i2 NP-2, i3 would increase too much. That is now fixed. Can someone add this. The fix above from brandimarte could work but I'm not a 100% sure.
def increase(i1, i2, i3, NP, incindx):
# Keep track of indices
if incindx<2:
i3=0
if incindx<1:
i2=0
if incindx==2:
i3=(i3+1)%NP
if i3==0:
i3=(i2+2)%NP
incindx=1
if incindx==1:
i2=(i2+1)%(NP-1)
if i2==0:
i2=(i1+2)%(NP-1)
incindx=0
if incindx==0: i1+=1
i2 = max(i1+1, i2)
i3 = max(i2+1, i3)
#if incindx<=1: print i1, i2, i3
return i1, i2, i3
About the slabGa exampe: There is no symmetry above the unitcell for this example (at the default accuracy of the Symmetry function=0.0001 Å). I think there should always be the option of setting the accuracy for the symmetry accuracy because of the approximate relaxed geometries that Siesta gives.
I'll look at the torture test ...
Hi @mpn2 ,
We could commit it, yes, but why not try out these simple steps yourself to get started?
git clone git@github.com:tfrederiksen/inelastica.git
cd inelastica/Inelastica
# edit Symmetry.py
git add Symmetry.py
git commit -m "bug: fixed increase(...) function"
git push
Great @mpn2 !
My idea above was only a "maybe". :-) I'll include the fix, but here are the steps I will do in my local machine to give an idea how is the workflow with git:
cd /path/to/inelastica
git fetch
git pull
# edit the code
git add Inelastica/Symmetry.py
git commit -m "Include fix to #26 by Magnus"
git push
Best!
Yep!! @mpn2 go ahead and commit it! :-)
I assume this is fixed now. The failure of the tourture test is a separate issue which I will fix if someone actually finds a real example where the issue appears.
Depending on how the atoms are defined with respect to the cell origin, one can get an error when trying to find the lattice parameters.