Re: [Kwant] Want to know more about bulid_discretized

2019-03-29 Thread Bas Nijholt
Oops, never mind my remark about the documentation being incorrect!
It was just because discretize_symbolic returns a tuple which you fed as a
first argument to build_discretized.

On Fri, Mar 29, 2019 at 3:28 PM Bas Nijholt  wrote:

> It seems like the documentation here
> 
> is wrong because it expects a dictionary.
>
>
> I see that you do
>
> template = kwant.continuum.discretize_symbolic(hamiltonian)
> t = kwant.continuum.build_discretized(template, coords = ('x','y','z'))
>
> However, discretize_symbolic returns two variables. Instead do:
>
> template, coods = kwant.continuum.discretize_symbolic(hamiltonian)
> t = kwant.continuum.build_discretized(template, coords)
>
> The list of coods should be passed to discretize_symbolic. However, if
> you omit it, it will be inferred from your Hamiltonian’s k_{x, y, z}
> terms.
>
> Best, Bas
>
> On Fri, Mar 29, 2019 at 3:11 PM Naveen Yadav 
> wrote:
>
>> Hi Bas,
>>
>> Thanks for your reply.
>>
>> I have used the same syntax. But it is showing an Attribute Error: 'tuple
>> object has no attribute 'items'
>>
>> from __future__ import division
>> import kwant
>> import kwant.continuum
>> import scipy.sparse.linalg
>> import scipy.linalg
>> import numpy as np
>> import sympy
>> from math import sin, cos, sqrt, pi
>> import matplotlib.pyplot as plt
>> hamiltonian = ("""k_x**2 + k_y**2 + k_z**2""")
>> hamiltonian = kwant.continuum.sympify(hamiltonian)
>> template = kwant.continuum.discretize_symbolic(hamiltonian)
>> t = kwant.continuum.build_discretized(template, coords = ('x', 'y', 'z'))
>> print(t)
>>
>> AttributeErrorTraceback (most recent call 
>> last) in  11 hamiltonian = 
>> kwant.continuum.sympify(hamiltonian) 12 template = 
>> kwant.continuum.discretize_symbolic(hamiltonian)---> 13 t = 
>> kwant.continuum.build_discretized(template, coords = ('x','y','z')) 14 
>> print(t) 15 hamiltonian
>> /usr/local/lib/python3.6/dist-packages/kwant/continuum/discretizer.py in 
>> build_discretized(tb_hamiltonian, coords, grid_spacing, locals)281 
>> 282 with reraise_warnings():--> 283 for k, v in 
>> tb_hamiltonian.items():284 tb_hamiltonian[k] = sympify(v, 
>> locals)285
>> AttributeError: 'tuple' object has no attribute 'items'
>>
>> What should I do.
>>
>> Naveen
>>
>>
>> On Fri, Mar 29, 2019 at 5:37 PM Bas Nijholt  wrote:
>>
>>> Hi Naveen,
>>>
>>> In the documentation
>>> 
>>> you can see that coords require a sequence of strings, so for example:
>>>
>>> coords = ('x',)  # for 1D
>>> coords = ('x', 'y', 'z')  # for 3D
>>>
>>> Best, Bas
>>>
>>> On Fri, Mar 29, 2019 at 12:59 PM Naveen Yadav 
>>> wrote:
>>>
 I want to know more about the builid_discretized(tb_hamiltonian,
 coords).
 I did not undersand what should be the syntax to write the coords.Could
 you please help me by sending an example code for writing coords?

 Thanks in Advance.













 Naveen
 Department of Physics & Astrophysics
 University of Delhi
 110007

>>>
>>
>> --
>>
>>
>> With Best Regards
>> NAVEEN YADAV
>> Ph.D Research Scholar
>> Deptt. Of Physics & Astrophysics
>> University Of Delhi.
>>
>


Re: [Kwant] Want to know more about bulid_discretized

2019-03-29 Thread Bas Nijholt
It seems like the documentation here

is wrong because it expects a dictionary.


I see that you do

template = kwant.continuum.discretize_symbolic(hamiltonian)
t = kwant.continuum.build_discretized(template, coords = ('x','y','z'))

However, discretize_symbolic returns two variables. Instead do:

template, coods = kwant.continuum.discretize_symbolic(hamiltonian)
t = kwant.continuum.build_discretized(template, coords)

The list of coods should be passed to discretize_symbolic. However, if you
omit it, it will be inferred from your Hamiltonian’s k_{x, y, z} terms.

Best, Bas

On Fri, Mar 29, 2019 at 3:11 PM Naveen Yadav 
wrote:

> Hi Bas,
>
> Thanks for your reply.
>
> I have used the same syntax. But it is showing an Attribute Error: 'tuple
> object has no attribute 'items'
>
> from __future__ import division
> import kwant
> import kwant.continuum
> import scipy.sparse.linalg
> import scipy.linalg
> import numpy as np
> import sympy
> from math import sin, cos, sqrt, pi
> import matplotlib.pyplot as plt
> hamiltonian = ("""k_x**2 + k_y**2 + k_z**2""")
> hamiltonian = kwant.continuum.sympify(hamiltonian)
> template = kwant.continuum.discretize_symbolic(hamiltonian)
> t = kwant.continuum.build_discretized(template, coords = ('x', 'y', 'z'))
> print(t)
>
> AttributeErrorTraceback (most recent call 
> last) in  11 hamiltonian = 
> kwant.continuum.sympify(hamiltonian) 12 template = 
> kwant.continuum.discretize_symbolic(hamiltonian)---> 13 t = 
> kwant.continuum.build_discretized(template, coords = ('x','y','z')) 14 
> print(t) 15 hamiltonian
> /usr/local/lib/python3.6/dist-packages/kwant/continuum/discretizer.py in 
> build_discretized(tb_hamiltonian, coords, grid_spacing, locals)281 
> 282 with reraise_warnings():--> 283 for k, v in 
> tb_hamiltonian.items():284 tb_hamiltonian[k] = sympify(v, 
> locals)285
> AttributeError: 'tuple' object has no attribute 'items'
>
> What should I do.
>
> Naveen
>
>
> On Fri, Mar 29, 2019 at 5:37 PM Bas Nijholt  wrote:
>
>> Hi Naveen,
>>
>> In the documentation
>> 
>> you can see that coords require a sequence of strings, so for example:
>>
>> coords = ('x',)  # for 1D
>> coords = ('x', 'y', 'z')  # for 3D
>>
>> Best, Bas
>>
>> On Fri, Mar 29, 2019 at 12:59 PM Naveen Yadav 
>> wrote:
>>
>>> I want to know more about the builid_discretized(tb_hamiltonian, coords).
>>> I did not undersand what should be the syntax to write the coords.Could
>>> you please help me by sending an example code for writing coords?
>>>
>>> Thanks in Advance.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Naveen
>>> Department of Physics & Astrophysics
>>> University of Delhi
>>> 110007
>>>
>>
>
> --
>
>
> With Best Regards
> NAVEEN YADAV
> Ph.D Research Scholar
> Deptt. Of Physics & Astrophysics
> University Of Delhi.
>


Re: [Kwant] Want to know more about bulid_discretized

2019-03-29 Thread Bas Nijholt
Hi Naveen,

In the documentation

you can see that coords require a sequence of strings, so for example:

coords = ('x',)  # for 1D
coords = ('x', 'y', 'z')  # for 3D

Best, Bas

On Fri, Mar 29, 2019 at 12:59 PM Naveen Yadav 
wrote:

> I want to know more about the builid_discretized(tb_hamiltonian, coords).
> I did not undersand what should be the syntax to write the coords.Could
> you please help me by sending an example code for writing coords?
>
> Thanks in Advance.
>
>
>
>
>
>
>
>
>
>
>
>
>
> Naveen
> Department of Physics & Astrophysics
> University of Delhi
> 110007
>


[Kwant] Want to know more about bulid_discretized

2019-03-29 Thread Naveen Yadav
I want to know more about the builid_discretized(tb_hamiltonian, coords).
I did not undersand what should be the syntax to write the coords.Could you
please help me by sending an example code for writing coords?

Thanks in Advance.













Naveen
Department of Physics & Astrophysics
University of Delhi
110007