Dániel Varjas (f48a4da7) at 08 Jul 14:00
print transpose and adjoint in nonhermitian PGE
Dániel Varjas (c19bd3a4) at 08 Jul 10:31
remove R assignment that is unnecessary
... and 2 more commits
There are several options, a class is I think the most natural indeed.
How do you implement something that works with this syntax? Would model.block
be a new class with its own __getitem__
method?
Another option (used e.g. in pandas) is to use a separate method, model.block[0:2, 2:]
.
It would be convenient if Model
object could be sliced the same way as arrays, to get a block of the Hamiltonian for example. The nontrivial part of this, is that the __getitem__
([key]
) functionality is currently used as for dicts to extract the matrix coefficient of the symbolic expression key
. Deducing whether something is a coefficient or an index/slice based on its type is complicated by the fact that the key 1
is used to refer to the constant part, but it also could be an index.
I propose the following syntax:
[]
be interpreted as a symbolic coefficientThis would be backward compatible, and should allow operations like model[:, 0:2, 2:4]
to cut out a block of the Model
while keeping all the symbolic dependence.
Does anyone see a potential problem with this proposal?
It would be great if one could create a Kwant system by filling a Qsymm model with position dependent parameters. The motivation for this is to study defects in systems with Hamiltonians that break particular symmetries.
Things to consider:
The workhorse that converts onsites and hoppings to Kwant value functions is Model.lambdify . That's over here.
Unlike kwant.continuum, which knows how to treat position dependence, Model.lambdify does not know that
So a minimal change that would allow to create models with position dependence would be to:
Dániel Varjas (0b434519) at 11 Jan 00:49
optimize period finding
Addresses #38
Dániel Varjas (a983184c) at 08 Jan 16:36
finish implementation of automatic candidate finding
... and 2 more commits
The goal is to find a set of lattice vectors that is guaranteed to span the full lattice. This shows that any longer path connecting sites on the same sublattice is given as the linear combination of shorter paths between sites on the same sublattice.
already included in the lattice vectors obtained from shorter paths
Why is this part guaranteed? Why should there be a shorter path?
The answer: it is enough to go up to n_sublattices neighbors away. There is no longer path that doesn't visit the same sublattice twice, and the displacement for the portion of the path that goes between the same sublattice is a lattice vector, and already included in the lattice vectors obtained from shorter paths. So exploring the graph up to n_sublattices hoppings will surely give a set of lattice vectors that spans the full lattice, after this one just needs to find a primitive set of lattice vectors. Finding a primitive set of lattice vectors from an arbitrary set of lattice vectors spanning the same lattice can be done by Smith or Hermite normal form.
At the moment I'm stuck here: Assume I have a polyatomic lattice (i.e. several sites per unit cell (sublattices) at different positions, with translation invariance) but I only know the relative positions of sites in the tight-binding model that are connected by hoppings, and want to find out what are the lattice vectors and the positions of the sites within the unit cell. Assuming that the TB model defines a connected graph, one can iteratively build a database of relative positions between each pair of sublattices, and if we do it long enough, we are sure to visit the site in the neighboring unit cell sooner or later, and that will give us a primitive lattice vector. But what is not clear to me, is how do we know when we iterated this process long enough? For example think of a 1D model which only has 9th and 7th neighbor hoppings, takes quite a few hoppings to get to the nearest neighbor. Could of course look at the greatest common denominator of the two translations, and that would immediately give me the 1st neighbor translation. But if there are sereral sublattices, how do I know that I couldn't find a lattice vector with even smaller gcd hopping through the other sublattices?
Now kwant.qsymm.model_to_builder
takes lattice vectors and site positions as input, but this information is typically already encoded in the Bloch Hamiltonian written in the real space convention, so we could make these arguments optional and automate this step. Also useful for finding the Brillouin-zone of BlochModel
s, which in turn would allow automating finding candidates for spatial symmetries.
Dániel Varjas (9f0319ac) at 06 Jan 16:53
add hermitian_adjoint constructor
With sympy=1.5
the BlochModel
returned by kwant.qsymm.builder_to_model
has momenta
as strings, while these should be sympy.Symbol
s. The reason is all(m in qsymm.model._commutative_momenta for m in ('k_x', 'k_y'))
(where _commutative_momenta
is a list of sympy.Symbol
s) evaluates to True in 1.5, it is False in all other versions I tried. We should require sympy==1.5.1
for example, or rewrite this check in some more failsafe way.
After a second check, I can't reproduce this on qsymm 1.3.0 (released to update dependencies). Here's what I see:
anton@ottawa ~/B/c/qsymm (master)> ipython -c "import sympy, qsymm; sympy.__version__, qsymm.__version__" (py38)
Out[1]: ('1.7', '1.4.0-dev1+g56be9ec')
anton@ottawa ~/B/c/qsymm (master)> py.test (py38)
=========================================================================================== test session starts ===========================================================================================
platform linux -- Python 3.8.3, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/anton/Bot/coding/qsymm, configfile: pytest.ini
plugins: cov-2.10.1, jupyter-server-1.0.10, tornasync-0.6.0.post2, dash-1.18.1, flakes-4.0.3
collected 26 items
qsymm/tests/test_hamiltonian_generator.py ........ [ 30%]
qsymm/tests/test_model.py ......... [ 65%]
qsymm/tests/test_mutual.py . [ 69%]
qsymm/tests/test_symmetry_finder.py ...... [ 92%]
qsymm/tests/test_util.py .. [100%]
=========================================================================================== 26 passed in 32.35s ===========================================================================================