Hi,

I ran your script and the first line output is:

SnakesStripe.py:31: RuntimeWarning: invalid value encountered in arctanh
  return -exp(-0.5j * phi * (xi - xj) * arctanh(((yi + yj)-2*45*sqrt(3))/smooth))

You are passing a number >1 to `arctanh`, most probably. You're using
Numpy's arctanh, which just shows a warning and returns `nan`, if I replace
`numpy.arctanh` with the `math` module's `atanh` I get

ValueError: math domain error

which corroborates my explanation.

Happy Kwanting,

Joe

On 10 May 2016 at 23:18, Sergey <sereza@gmail.com> wrote:
Hi Anton,
  Somehow I again start to get 'The cell Hamiltonian is not Hermitian.' error raised by  dispersion.py    (for band structure
of a lead).  Although I have ensured that hoppings are hermitian and respect the lead translation symmetry.
   I have not used any low-level functions,   so, it's a bit strange to get such a error.  Is that a tolerance issue?

Best wishes,
Sergey


On 06/05/16 10:24, Anton Akhmerov wrote:
Hi Sergey,

Let me put it differently: it is pretty much impossible to make a
hopping non-hermitian. If you set both the hopping (a, b) and (b, a)
then, the second one will just supercede the first. If you look at the
source code of Kwant, you'll see that exactly what you want is already
happening (only it doesn't check which site number is larger, but
checks which hopping was assigned directly (with the opposite hopping
being the hermitian conjugate). Additionally, pretty much every
tutorial sets hoppings in only one direction.

You write "And that clearly leads to errors." why are you sure? Did
you try to evaluate the system Hamiltonian and see if it is hermitian?

Cheers,
Anton

On Fri, May 6, 2016 at 12:28 AM, Sergey <sereza@gmail.com> wrote:
On 05/05/16 21:53, Anton Akhmerov wrote:
Hi Sergey,

Quoting from
http://kwant-project.org/doc/1/reference/generated/kwant.builder.Builder#kwant.builder.Builder:
Builder instances automatically ensure that every hopping is Hermitian,
so that if builder[a, b] has been set, there is no need to set builder[b,
a].
So you don't need to pay any extra effort to ensure hermiticity.
However your code has a different minor drawback. The order in which
the hoppings are evaluated in Kwant is not deterministic, so you will
get random results that you are unable to reevaluate. You could avoid
this by using the hash-based random number generators provided by
kwant.digest. See e.g. code here for an example of use
http://arxiv.org/src/1408.1563v2/anc/trijunction.py (the "disorder"
function).

Best,
Anton

On Thu, May 5, 2016 at 9:48 PM, Sergey <sereza@gmail.com> wrote:
Dear all,
    I want to model a random variation of hopping integrals.  Simply
writing:

def hopping(sitei, sitej):
      return -1 + random.gauss(0,0.2)

does not work  since this does not ensure that the hopping is Hermitian.
Is there a smart way to write something like:
def hopping(sitei, sitej):
      if sitei<sitej:
             return -1 + random.gauss(0,0.2)
else: return  Conjugate(hopping(sitej,sitei))

?
Thanks and best wishes,
Sergey