Dear all,

I need to calculate a system with a variable number of 2D lattices. So, the pseudo code should look like:

for i in xrange(2,100):
   # Form a system with (i) number of lattices, with hoppings that depend on (i) in between the lattices
   # Calculate stuff, such as the transmission amplitude from lead f of lattice j to lead g of lattice k (j, k <= i)
   # plot calculated stuff as a function of i

I couldn't figure out a straight method to do it, as I have to pass (i) as a function variable when I'm forming the hoppings. That is, in the make_system part of the code, I need to say things like (again in pseudo code)

syst[(lat(i, x, y), lat(i+1, x, y) for x in ... for y in ...)] = hopping(i, i+1)

which is impossible because a) lattice definitions can only take in realspace coordinates and b) the function on the right side has to have two sites as its first two arguments and the rest will be provided in the solver part of the code.

I found two rather inelegant possible solutions to my problem. (I'm trying only the second one). What I'm asking is, is there a better solution?

Inelegant (and possibly wrong) solution 1: Make this a truly 3D rectangular prism system, with each layer corresponding to one lattice. This makes the problem of writing the hoppings trivial, but then how would I get the transmission amplitude from the left lead of 2D lattice number 35 to the right lead of 2D lattice number 67?

Inelegant solution 2: Code-generating code. This is what I've done. Essentially, I generate a .py file with 100 copies of the make_system function, each with different number of lattices. Later, in the main code, I import the appropriate make_system function from this .py file and solve my system.

Thank you all for your time and concern.

Cheers,

Baris P.