general considerations of interface
Problem:
One of the last things that stops from having working alpha version of discretizer (at least I believe so) is deciding on convention of specifying on which coordinates discretizer should work and where to provide such input.
Current status:
So far discretization is peform with every momentum operator that enters Hamiltonian. General form of output is dictionary list of hoppings where key is an offset, with (0,0,0) standing for an hopping (so far) and value is corresponding hopping that I already can translate info a valid function, i. ex.
def _anonymous_func(site1, site2, p):
x, y, z = site2.pos
a = p.a
B, A = p.B, p.A
return (np.array([[-A(a/2 + x, y, z)/a**2, -I*B(x)/(2*a)], [-I*B(a + x)/(2*a), 0]]))
so basically deciding on the dimension of the output is not only an issue for a keys in the output dictionaries but also for a form of a function.
My initial suggestion:
My proposition would be to have input parameter that indicates which momenta are supposed to be discretized and basing on this information choose dimensionality. For example: discretizing kx and ky would end with an output of form
output = { (1, 0): hopx_function, (0, 1): hopy_function, ...}
with body of a function that contains line ``x, y = site.pos''.
For discretizing all three dimensions keys would be just (x, y, z) offsets.
For only kx I would propose to to keep keys of output dict as one element tuple, for a consistency of program.
For a discretization over only ky and kz variables for example (keeping kx as number) I would propose to use two dimensional tuples (y_ofset, z_ofset) as keys:
output = { (1, 0): hopy_function, (0, 1): hopz_function, ...}
and body of a function containing y, z = site.pos
.
In other words offset key would be of dimension of discrete variables in lexical order. This should be consistent and allow easily to create low dimension kwant systems (in example chain system when discretizing only kz momentum).
For completeness: sketch of interface
import sympy
import discretizer
from discretizer import do_magic
kx, ky, kz = discretizer.momentum_operators
x, y, z = discretizer.coord
A, B, C = sympy.symbols('A B C', commutative=False)
hamiltonian = kx * A * kx + (B * ky + ky * B)
output = do_magic(hamiltonian, space_dependent={A: (x,), B: (y,)})
And at this moment output
should be already a dict
which keys are offset and values corresponding hoppings.
Some issues that came in discussion with Anton
- Including (input?) parameter
symbol_assignments
to allow functionalities like
``mu = mu_average + barrier(x, y) + disorder(site, salt)``
- Reason of having information that parameters depends only on some coordinates
Personally I really believe that
>>> H1 = kx * A(y) * kx
>>> print(discretize(H1))
{(1, 0, 0): -A(y)/a**2, (-1, 0, 0): -A(y)/a**2, (0, 0, 0): 2*A(y)/a**2}
is better than
>>> H1 = kx * A(x, y) * kx
>>> print(discretize(H1))
{(1, 0, 0): -A(a/2 + x, y)/a**2, (-1, 0, 0): -A(-a/2 + x, y)/a**2, (0, 0, 0): A(-a/2 + x, y)/a**2 + A(a/2 + x, y)/a**2}