TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
135 stars 71 forks source link

TBLattice wrong init raises SegFault #910

Open the-hampel opened 11 months ago

the-hampel commented 11 months ago

With wrong input to TBLattice one can provoke a Segmentation Fault. For a two orbital model if one not specifies orbital positions, or defines them wrong is not protected by an error message:

from triqs.lattice.tight_binding import TBLattice
import numpy as np

t = 1.0

H_r = TBLattice(
    units=[
        (1.5, np.sqrt(3)/2, 0),
        (1.5, -np.sqrt(3)/2, 0),
    ],
    hoppings={
        (0, 0) : [[[0, -t], [-t, 0]]],
        (1, 0) : [[[0, -t], [0, 0]]],
        (-1, 0) : [[[0, 0], [-t, 0]]],
        (0, 1) : [[[0, -t], [0, 0]]],
        (0, -1) : [[[0, 0], [-t, 0]]],
    },
    orbital_positions=[(0, 0, 0)]
                )

gives:

Warning: could not identify MPI environment!
Starting serial run at: 2023-09-01 20:24:40.910407
Segmentation fault
HugoStrand commented 11 months ago

Also not giving a tuple in the hopping dictionary gives a hard segfault,

from triqs.lattice.tight_binding import TBLattice

H_r = TBLattice(
    units=[(1, 0, 0)],
    hoppings={
        (0) : [[1.]] # Key is missing a comma and is not a tuple, using (0,) works.
    },
    )
> python test.py 
Warning: could not identify MPI environment!
Starting serial run at: 2023-09-01 21:50:50.026024
zsh: segmentation fault  python test.py