Re: [Kwant] semicon

2018-12-04 Thread Joseph Weston
Thanks for the information!

> Thank you for your quick response. I am using kwant 1.3.3 version and
> semicon 0.1.0 version. I think the error is related to calling
> parameters function which are stored as a tuple. By the way, this is
> the error I encountered:
>
> TypeError Traceback (most recent call last)
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
> hamiltonian(self, i, j, params, *args)
> 1995 try:
> -> 1996value = value(self.sites[i], **params)
> 1997 except Exception as exc:
>
>  in onsite(site, Delta_0, E_0, E_v, P, gamma_0, gamma_1, gamma_2, 
> hbar,
> k_y, m_0)
>
> TypeError: __call__() takes 2 positional arguments but 3 were given
>
> The above exception was the direct cause of the following exception:
>
> UserCodeError Traceback (most recent call last)
>  in ()
> 59 # compute the scattering matrix at a given energy
> 60 p = {'k_y': 0, **two_deg_params}
> ---> 61smatrix = kwant.smatrix(syst, energy, params=p)
> 62 
> 63 # compute the transmission probability from lead 0 to
>
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
> smatrix(self, sys, energy, args, out_leads, in_leads,
> check_hermiticity, params)
> 370 linsys, lead_info = self._make_linear_sys(syst, in_leads, energy, 
> args,
> 371   check_hermiticity, 
> False,
> --> 372params=params) 373 
> 374 kept_vars = np.concatenate([coords for i, coords in
>
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
> _make_linear_sys(self, sys, in_leads, energy, args, check_hermiticity,
> realspace, params)
> 162 lhs, norb = syst.hamiltonian_submatrix(args, sparse=True,
> 163return_norb=True,
> --> 164params=params)[:2] 165 lhs = getattr(lhs, 'to' + 
> self.lhsformat)()
> 166 lhs = lhs - energy * sp.identity(lhs.shape[0], 
> format=self.lhsformat)
>
> kwant/_system.pyx in kwant._system.hamiltonian_submatrix()
>
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
> hamiltonian(self, i, j, params, *args)
> 1996 value = value(self.sites[i], **params)
> 1997 except Exception as exc:
> -> 1998_raise_user_error(exc, value)
> 1999 else:
> 2000 try:
>
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
> _raise_user_error(exc, func)
> 1883 msg = ('Error occurred in user-supplied value function "{0}".\n'
> 1884'See the upper part of the above backtrace for more 
> information.')
> -> 1885raise UserCodeError(msg.format(func.__name__)) from exc
> 1886 
> 1887 
>
> UserCodeError: Error occurred in user-supplied value function "onsite".
> See the upper part of the above backtrace for more information.


this certainly looks like a bug in semicon. I've managed to reproduce
the bug, but I don't understand why it occurs. I inspected what was
happening using the Python debugger and it seems to me that everything
should work (but clearly it doesn't!).


Unfortunately the author of semicon is no longer working in academia,
and the semicon project is currently without a maintainer (and it's not
even v1.0!), so I am not sure what the best course of action is going
forward.


Happy Kwanting,


Joe



signature.asc
Description: OpenPGP digital signature


Re: [Kwant] semicon

2018-12-04 Thread Ali Asgharpour
Dear Rafal,

Ok, thanks! But, if I just set coords of semicon.models.foreman to the
single coordinate along which I want to
change my parameters and use discretization in two dimensions, Is
everything ok? I mean, I can see reducing of some factors in onsite and
hopping functions. I think I will miss some information, don't you think
so? In my opinion, creating parameter functions seems fine, but I do not
know how I can merge it to two_deg_params. Would you please give me a hint?
Thanks in advance.

Best regards,

Ali

On Tue, Dec 4, 2018 at 7:23 PM Rafal Skolasinski 
wrote:

> Hi Ali,
>
> A quick reply from my side. This
>
> hamiltonian = semicon.models.foreman(
> components=['foreman'],
> bands=bands,
> coords='xz',
> )
>
> specify what will be spatial dependence of the parameters in the symbolic
> Hamiltonian that is used.
> As far as I remember, two_deg_params provides you a single coordinate
> dependent parameters.
> I suggest you either create parameter functions returned by two_deg_params
> by hand or
> try to set coords of semicon.models.foreman to the single coordinate
> along which you want to
> vary your parameters.
>
> I will be able to look more in details into that next week.
>
> Regards,
> Rafal
>
>
>
> --
> Rafał Skolasiński
> Software Engineer
>
> GitHub: https://github.com/RafalSkolasinski
> Kwant GitLab: https://gitlab.kwant-project.org/r-j-skolasinski
>
>
> On Tue, 4 Dec 2018 at 16:14, Ali Asgharpour 
> wrote:
>
>> Thanks for the feedback! If you find the bug, would you please let me
>> know? Thanks in advance. By the way, I am also trying to code it myself
>> from the beginning. Thanks again.
>>
>> Best regards,
>>
>> Ali
>>
>> On Tue, Dec 4, 2018 at 6:57 PM Joseph Weston 
>> wrote:
>>
>>> Thanks for the information!
>>>
>>> Thank you for your quick response. I am using kwant 1.3.3 version and
>>> semicon 0.1.0 version. I think the error is related to calling parameters
>>> function which are stored as a tuple. By the way, this is the error I
>>> encountered:
>>>
>>> TypeError Traceback (most recent call 
>>> last)/home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
>>> hamiltonian(self, i, j, params, *args)   1995 try:-> 
>>> 1996 value = value(self.sites[i], **params)   1997  
>>>except Exception as exc:
>>>  in onsite(site, Delta_0, E_0, E_v, P, gamma_0, gamma_1, gamma_2, 
>>> hbar, k_y, m_0)
>>> TypeError: __call__() takes 2 positional arguments but 3 were given
>>>
>>> The above exception was the direct cause of the following exception:
>>> UserCodeError Traceback (most recent call 
>>> last) in () 59 # compute the 
>>> scattering matrix at a given energy 60 p = {'k_y': 0, 
>>> **two_deg_params}---> 61 smatrix = kwant.smatrix(syst, energy, 
>>> params=p) 62  63 # compute the transmission probability from 
>>> lead 0 to
>>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
>>> smatrix(self, sys, energy, args, out_leads, in_leads, check_hermiticity, 
>>> params)370 linsys, lead_info = self._make_linear_sys(syst, 
>>> in_leads, energy, args,371  
>>>  check_hermiticity, False,--> 372   
>>> params=params)373 374 kept_vars = 
>>> np.concatenate([coords for i, coords in
>>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
>>> _make_linear_sys(self, sys, in_leads, energy, args, check_hermiticity, 
>>> realspace, params)162 lhs, norb = 
>>> syst.hamiltonian_submatrix(args, sparse=True,163
>>> return_norb=True,--> 164
>>> params=params)[:2]165 lhs = getattr(lhs, 
>>> 'to' + self.lhsformat)()166 lhs = lhs - energy * 
>>> sp.identity(lhs.shape[0], format=self.lhsformat)
>>> kwant/_system.pyx in kwant._system.hamiltonian_submatrix()
>>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
>>> hamiltonian(self, i, j, params, *args)   1996 value 
>>> = value(self.sites[i], **params)   1997 except 
>>> Exception as exc:-> 1998 _raise_user_error(exc, 
>>> value)   1999 else:   2000 try:
>>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
>>> _raise_user_error(exc, func)   1883 msg = ('Error occurred in 
>>> user-supplied value function "{0}".\n'   1884'See the upper 
>>> part of the above backtrace for more information.')-> 1885 raise 
>>> UserCodeError(msg.format(func.__name__)) from exc   18861887
>>> UserCodeError: Error occurred in user-supplied value function "onsite".
>>> See the upper part of the above backtrace for more information.

Re: [Kwant] semicon

2018-12-04 Thread Rafal Skolasinski
Hi Ali,

A quick reply from my side. This

hamiltonian = semicon.models.foreman(
components=['foreman'],
bands=bands,
coords='xz',
)

specify what will be spatial dependence of the parameters in the symbolic
Hamiltonian that is used.
As far as I remember, two_deg_params provides you a single coordinate
dependent parameters.
I suggest you either create parameter functions returned by two_deg_params
by hand or
try to set coords of semicon.models.foreman to the single coordinate along
which you want to
vary your parameters.

I will be able to look more in details into that next week.

Regards,
Rafal



--
Rafał Skolasiński
Software Engineer

GitHub: https://github.com/RafalSkolasinski
Kwant GitLab: https://gitlab.kwant-project.org/r-j-skolasinski


On Tue, 4 Dec 2018 at 16:14, Ali Asgharpour 
wrote:

> Thanks for the feedback! If you find the bug, would you please let me
> know? Thanks in advance. By the way, I am also trying to code it myself
> from the beginning. Thanks again.
>
> Best regards,
>
> Ali
>
> On Tue, Dec 4, 2018 at 6:57 PM Joseph Weston 
> wrote:
>
>> Thanks for the information!
>>
>> Thank you for your quick response. I am using kwant 1.3.3 version and
>> semicon 0.1.0 version. I think the error is related to calling parameters
>> function which are stored as a tuple. By the way, this is the error I
>> encountered:
>>
>> TypeError Traceback (most recent call 
>> last)/home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
>> hamiltonian(self, i, j, params, *args)   1995 try:-> 
>> 1996 value = value(self.sites[i], **params)   1997   
>>   except Exception as exc:
>>  in onsite(site, Delta_0, E_0, E_v, P, gamma_0, gamma_1, gamma_2, 
>> hbar, k_y, m_0)
>> TypeError: __call__() takes 2 positional arguments but 3 were given
>>
>> The above exception was the direct cause of the following exception:
>> UserCodeError Traceback (most recent call 
>> last) in () 59 # compute the 
>> scattering matrix at a given energy 60 p = {'k_y': 0, 
>> **two_deg_params}---> 61 smatrix = kwant.smatrix(syst, energy, params=p) 
>> 62  63 # compute the transmission probability from lead 0 to
>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
>> smatrix(self, sys, energy, args, out_leads, in_leads, check_hermiticity, 
>> params)370 linsys, lead_info = self._make_linear_sys(syst, 
>> in_leads, energy, args,371   
>> check_hermiticity, False,--> 372 
>>   params=params)373 374 kept_vars = 
>> np.concatenate([coords for i, coords in
>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
>> _make_linear_sys(self, sys, in_leads, energy, args, check_hermiticity, 
>> realspace, params)162 lhs, norb = 
>> syst.hamiltonian_submatrix(args, sparse=True,163 
>>return_norb=True,--> 164  
>>   params=params)[:2]165 lhs = getattr(lhs, 'to' 
>> + self.lhsformat)()166 lhs = lhs - energy * 
>> sp.identity(lhs.shape[0], format=self.lhsformat)
>> kwant/_system.pyx in kwant._system.hamiltonian_submatrix()
>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
>> hamiltonian(self, i, j, params, *args)   1996 value 
>> = value(self.sites[i], **params)   1997 except Exception 
>> as exc:-> 1998 _raise_user_error(exc, value)   1999  
>>else:   2000 try:
>> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
>> _raise_user_error(exc, func)   1883 msg = ('Error occurred in 
>> user-supplied value function "{0}".\n'   1884'See the upper part 
>> of the above backtrace for more information.')-> 1885 raise 
>> UserCodeError(msg.format(func.__name__)) from exc   18861887
>> UserCodeError: Error occurred in user-supplied value function "onsite".
>> See the upper part of the above backtrace for more information.
>>
>>
>> this certainly looks like a bug in semicon. I've managed to reproduce the
>> bug, but I don't understand why it occurs. I inspected what was happening
>> using the Python debugger and it seems to me that everything should work
>> (but clearly it doesn't!).
>>
>>
>> Unfortunately the author of semicon is no longer working in academia, and
>> the semicon project is currently without a maintainer (and it's not even
>> v1.0!), so I am not sure what the best course of action is going forward.
>>
>>
>> Happy Kwanting,
>>
>>
>> Joe
>>
>


Re: [Kwant] semicon

2018-12-04 Thread Ali Asgharpour
Thanks for the feedback! If you find the bug, would you please let me know?
Thanks in advance. By the way, I am also trying to code it myself from the
beginning. Thanks again.

Best regards,

Ali

On Tue, Dec 4, 2018 at 6:57 PM Joseph Weston 
wrote:

> Thanks for the information!
>
> Thank you for your quick response. I am using kwant 1.3.3 version and
> semicon 0.1.0 version. I think the error is related to calling parameters
> function which are stored as a tuple. By the way, this is the error I
> encountered:
>
> TypeError Traceback (most recent call 
> last)/home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
> hamiltonian(self, i, j, params, *args)   1995 try:-> 1996 
> value = value(self.sites[i], **params)   1997 
> except Exception as exc:
>  in onsite(site, Delta_0, E_0, E_v, P, gamma_0, gamma_1, gamma_2, 
> hbar, k_y, m_0)
> TypeError: __call__() takes 2 positional arguments but 3 were given
>
> The above exception was the direct cause of the following exception:
> UserCodeError Traceback (most recent call 
> last) in () 59 # compute the 
> scattering matrix at a given energy 60 p = {'k_y': 0, 
> **two_deg_params}---> 61 smatrix = kwant.smatrix(syst, energy, params=p)  
>62  63 # compute the transmission probability from lead 0 to
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
> smatrix(self, sys, energy, args, out_leads, in_leads, check_hermiticity, 
> params)370 linsys, lead_info = self._make_linear_sys(syst, 
> in_leads, energy, args,371
>check_hermiticity, False,--> 372   
> params=params)373 374 kept_vars = 
> np.concatenate([coords for i, coords in
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py in 
> _make_linear_sys(self, sys, in_leads, energy, args, check_hermiticity, 
> realspace, params)162 lhs, norb = 
> syst.hamiltonian_submatrix(args, sparse=True,163  
>   return_norb=True,--> 164
> params=params)[:2]165 lhs = getattr(lhs, 'to' + 
> self.lhsformat)()166 lhs = lhs - energy * 
> sp.identity(lhs.shape[0], format=self.lhsformat)
> kwant/_system.pyx in kwant._system.hamiltonian_submatrix()
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
> hamiltonian(self, i, j, params, *args)   1996 value = 
> value(self.sites[i], **params)   1997 except Exception as 
> exc:-> 1998 _raise_user_error(exc, value)   1999  
>else:   2000 try:
> /home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in 
> _raise_user_error(exc, func)   1883 msg = ('Error occurred in 
> user-supplied value function "{0}".\n'   1884'See the upper part 
> of the above backtrace for more information.')-> 1885 raise 
> UserCodeError(msg.format(func.__name__)) from exc   18861887
> UserCodeError: Error occurred in user-supplied value function "onsite".
> See the upper part of the above backtrace for more information.
>
>
> this certainly looks like a bug in semicon. I've managed to reproduce the
> bug, but I don't understand why it occurs. I inspected what was happening
> using the Python debugger and it seems to me that everything should work
> (but clearly it doesn't!).
>
>
> Unfortunately the author of semicon is no longer working in academia, and
> the semicon project is currently without a maintainer (and it's not even
> v1.0!), so I am not sure what the best course of action is going forward.
>
>
> Happy Kwanting,
>
>
> Joe
>


Re: [Kwant] semicon

2018-12-04 Thread Ali Asgharpour
Thank you for your quick response. I am using kwant 1.3.3 version and
semicon 0.1.0 version. I think the error is related to calling parameters
function which are stored as a tuple. By the way, this is the error I
encountered:

TypeError Traceback (most recent call
last)/home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py
in hamiltonian(self, i, j, params, *args)   1995
try:-> 1996 value = value(self.sites[i],
**params)   1997 except Exception as exc:
 in onsite(site, Delta_0, E_0, E_v, P, gamma_0, gamma_1,
gamma_2, hbar, k_y, m_0)
TypeError: __call__() takes 2 positional arguments but 3 were given

The above exception was the direct cause of the following exception:
UserCodeError Traceback (most recent call
last) in () 59 # compute
the scattering matrix at a given energy 60 p = {'k_y': 0,
**two_deg_params}---> 61 smatrix = kwant.smatrix(syst, energy,
params=p) 62  63 # compute the transmission probability
from lead 0 to
/home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py
in smatrix(self, sys, energy, args, out_leads, in_leads,
check_hermiticity, params)370 linsys, lead_info =
self._make_linear_sys(syst, in_leads, energy, args,371
  check_hermiticity, False,--> 372
  params=params)
373 374 kept_vars = np.concatenate([coords for i, coords
in
/home/ali/anaconda3/lib/python3.6/site-packages/kwant/solvers/common.py
in _make_linear_sys(self, sys, in_leads, energy, args,
check_hermiticity, realspace, params)162 lhs, norb =
syst.hamiltonian_submatrix(args, sparse=True,163
 return_norb=True,--> 164
  params=params)[:2]165 lhs =
getattr(lhs, 'to' + self.lhsformat)()166 lhs = lhs -
energy * sp.identity(lhs.shape[0], format=self.lhsformat)
kwant/_system.pyx in kwant._system.hamiltonian_submatrix()
/home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in
hamiltonian(self, i, j, params, *args)   1996
value = value(self.sites[i], **params)   1997
except Exception as exc:-> 1998
_raise_user_error(exc, value)   1999 else:   2000
   try:
/home/ali/anaconda3/lib/python3.6/site-packages/kwant/builder.py in
_raise_user_error(exc, func)   1883 msg = ('Error occurred in
user-supplied value function "{0}".\n'   1884'See the
upper part of the above backtrace for more information.')-> 1885
raise UserCodeError(msg.format(func.__name__)) from exc   18861887
UserCodeError: Error occurred in user-supplied value function "onsite".
See the upper part of the above backtrace for more information.



On Tue, Dec 4, 2018 at 3:21 PM Joseph Weston 
wrote:

> Hi Ali,
>
>
> > I want to find conductance of a heterostructure using semicon library.
> > When I just use coords='z', everything is OK. But, when I want to
> > change it to two dimensions like 'xz', I encounter an error. Would you
> > please tell me how I can fix it? I hope it is not just a
> > simple mistake which I am not aware. Your time and consideration are
> > greatly appreciated in advance. Please find attached the code
> > correspondent to what I mentioned above.
>
>
> Thanks for posting the script, but you'll need to give more information
> before anyone else can help you:
>
>
> + what version of Kwant and semicon are you using
>
> + what error was produced? Please provide a full traceback
>
>
> Happy Kwanting,
>
>
> Joe
>
>


Re: [Kwant] semicon

2018-12-04 Thread Joseph Weston
Hi Ali,


> I want to find conductance of a heterostructure using semicon library.
> When I just use coords='z', everything is OK. But, when I want to
> change it to two dimensions like 'xz', I encounter an error. Would you
> please tell me how I can fix it? I hope it is not just a
> simple mistake which I am not aware. Your time and consideration are
> greatly appreciated in advance. Please find attached the code
> correspondent to what I mentioned above.


Thanks for posting the script, but you'll need to give more information
before anyone else can help you:


+ what version of Kwant and semicon are you using

+ what error was produced? Please provide a full traceback


Happy Kwanting,


Joe