tsdev / spinw

SpinW Matlab library for spin wave calculation
www.psi.ch/spinw
GNU General Public License v3.0
30 stars 35 forks source link

spinw.gencoupling() generates negative hMax2 which causes an error #38

Open rockspore opened 7 years ago

rockspore commented 7 years ago

I think hMax2 = sum(obj.basisvector,2); can be replaced with hMax2 = abs(sum(obj.basisvector,2)); to solve this problem.

tsdev commented 7 years ago

Thank you for reporting this. Can you provide an example script that shows the bug?

rockspore commented 7 years ago

Thanks for the response.

cnn = spinw;
lc = [9.551 5.43683 16.75890];
agl = [90 125.6860 90];
cnn.genlattice('lat_const',lc,'angled',agl,'sym',14);
cnn.addatom('r',[0   0   0],'S',1,'label','M');
cnn.gencoupling('maxDistance',15);

The code above will trigger the error message saying index exceeds the dimension of cMat. As I said, my understanding is for certain basis vectors, hMax2 can have negative values and so do nC and cDim. This results in empty atom1 and atom2 which eventually reduces the dimension of cMat.

tsdev commented 6 years ago

I fixed the bug in 5a4097ce7c44e85ed69913f148d575a1638ececf using your suggestions, thanks!