Dear Nafise,

That is why I said it is a simple python problem.
You can for example from time to time copy the error message and put it in
google it will lead you usually to quick answer.


in your case, ax1 is a 1D array so you need just one index  (like vectors
in math). So ax1[2] will give you the result of the third component.

Regards,
Adel

On Sun, Dec 8, 2019 at 11:39 AM Nafise Nouri <nafise.n...@gmail.com> wrote:

> Dear Adel,
>
> At first thank you for your reply and your help. In fact I tried A[i,j] in
> the past but it does not work in my code. Please look at the following:
>
> import numpy as np
> import matplotlib.pyplot as plt
> from functools import partial
>
> import kwant
> from kwant.physics import dispersion
>
> def make_lead_with_crossing_bands():
>     lat = kwant.lattice.square(1)
>     sym = kwant.TranslationalSymmetry((-2, 0))
>     H = kwant.Builder(sym)
>     H[lat(0, 0)] = 0
>     H[lat(0, 1)] = 0
>     H[lat(1, 0)] = 0
>     H[lat(1, 0), lat(0, 0)] = 1
>     H[lat(2, 1), lat(0, 1)] = 1
>     H[lat(2, 0), lat(1, 0)] = 0.5
>     return H
>
> lead = make_lead_with_crossing_bands().finalized()
> bands = dispersion.Bands(lead)
>
> momenta = np.linspace(-np.pi,np.pi, 500)
> energies = [bands(k) for k in momenta]
> ax1=bands(-np.pi)
> print ('ax1=',ax1)
> print ('ax1=',ax1[0,1])
>
> here ax1 is a matrix with dimension 1*3. I want to use element ax1(1,2),
> But according to the ax1[0,1], it gives me an error with massage "too many
> indices for array". That is very kind of you if you help me.
>
> Best,
> Nafise
>
> On Sat, Dec 7, 2019 at 3:27 PM Abbout Adel <abbout.a...@gmail.com> wrote:
>
>> Dear Nafise,
>>
>> Your question is a python related question. You can find the answer in
>> any python documentation or forum.
>> So please, make an effort and search around you or by a quick check on
>> internet before posting a question in the kwant forum.
>> In fact, posting non kwant related questions in this forum, makes it a
>> general forum rather than a specialized one.
>>
>> So for your question if A is a matrix, the elements are A[i,j].
>> Example A=array([[1,2],[3,4]])   gives A[0,0]=1.
>> I hope this helps,
>> Ade
>>
>> On Sat, Dec 7, 2019 at 8:26 AM Nafise Nouri <nafise.n...@gmail.com>
>> wrote:
>>
>>> Dear all,
>>>
>>> Is there any one to know how we can use one element of matrix? For
>>> example we have matrix A as follows:
>>>
>>> A=[2 4;6,0]
>>>
>>> We have A matrix with dimension 2*2. If  we want to use one element of
>>> matrix such as A(2,1), (that is number 6 in the matrix), How we can write
>>> in kwant? Any help appreciate.
>>>
>>> Best,
>>> Nafise
>>>
>>
>>
>> --
>> Abbout Adel
>>
>

-- 
Abbout Adel

Reply via email to