[Kwant] semicon
Hello 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. Best regards, Ali import kwant import numpy as np import scipy.linalg as la import scipy.sparse.linalg as sla import semicon import sympy import matplotlib.pyplot as plt grid_spacing = 0.5 widths = [1, 1.1, 1, 1] gamma_0 = 1.0 bands = ['gamma_6c', 'gamma_8v', 'gamma_7v'] hamiltonian = semicon.models.foreman( components=['foreman'], bands=bands, coords='xz', ) AlSb = semicon.parameters.bulk('lawaetz', 'AlSb', gamma_0, valence_band_offset=0.0) InAs = semicon.parameters.bulk('lawaetz', 'InAs', gamma_0) GaSb = semicon.parameters.bulk('lawaetz', 'GaSb', gamma_0, valence_band_offset=.53) two_deg_params, walls = semicon.parameters.two_deg( parameters = [AlSb, InAs, GaSb, AlSb], widths = widths, grid_spacing=grid_spacing, extra_constants=semicon.parameters.constants, ) template = kwant.continuum.discretize(hamiltonian, coords='xz', grid_spacing=grid_spacing) print(template) L=10 * grid_spacing #shape = lambda site: (0 - grid_spacing / 2 < site.pos[1] < sum(widths)) and (0 <= site.pos[0] < L) #lead_shape = lambda site: site.pos[0] <= 0 and (0 - grid_spacing / 2 < site.pos[1] < sum(widths)) H = sum(widths) def shape(site): (x, z) = site.pos return (0 <= z < H and 0 <= x < L) def lead_shape(site): (x, z) = site.pos return (0 <= z < H) syst = kwant.Builder() syst.fill(template, shape, (0, 0)) lead = kwant.Builder(kwant.TranslationalSymmetry([-grid_spacing, 0])) lead.fill(template, lead_shape, (0, 0)) syst.attach_lead(lead) syst.attach_lead(lead.reversed()) syst = syst.finalized() for ie in range(100): energy = ie * 0.01 # compute the scattering matrix at a given energy p = {'k_y': 0, **two_deg_params} smatrix = kwant.smatrix(syst, energy, params=p) # compute the transmission probability from lead 0 to # lead 1 energies.append(energy) data.append(smatrix.transmission(1, 0)) plt.figure() plt.plot(energies, data) plt.xlabel("energy [t]") plt.ylabel("conductance [e^2/h]") plt.show()
Re: [Kwant] semicon
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
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
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
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
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
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
Hi, two_deg_params is a helper I wrote to handle two-dimensional heterostructures. It is materials are translation invariant in two-dimensions and different materials are stacked along the third dimension -> therefore output parameter functions depend on one coordinate coords in semicon.models.foreman will set which parameter it is (the above) coords in kwant.continuum.discretize will specify dimensionality of kwant system, one of this coordinates, specified above, will be fed to the parameter functions. After modifying your hamiltonian definition to hamiltonian = semicon.models.foreman( components=['foreman'], bands=bands, coords='z', ) and adding two missing arrays before the loop at the end of your code energies = [] data = [] for ie in range(100): energy = ie * 0.01 # compute the scattering matrix at a given energy p = {'k_y': 0, **two_deg_params} smatrix = kwant.smatrix(syst, energy, params=p) # compute the transmission probability from lead 0 to # lead 1 energies.append(energy) data.append(smatrix.transmission(1, 0)) I obtained the following Figure. [image: image.png] 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:43, Ali Asgharpour wrote: > 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 < > r.j.skolasin...@gmail.com> 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 /ho
Re: [Kwant] semicon
Thanks a lot! On Wed, Dec 5, 2018 at 2:13 AM Rafal Skolasinski wrote: > Hi, > > two_deg_params is a helper I wrote to handle two-dimensional > heterostructures. > It is materials are translation invariant in two-dimensions and different > materials are stacked along the third dimension -> therefore output > parameter functions depend on one coordinate > > coords in semicon.models.foreman will set which parameter it is (the > above) > > coords in kwant.continuum.discretize will specify dimensionality of kwant > system, one of this coordinates, specified above, will be fed to the > parameter functions. > > After modifying your hamiltonian definition to > > hamiltonian = semicon.models.foreman( > components=['foreman'], > bands=bands, > coords='z', > ) > > and adding two missing arrays before the loop at the end of your code > > energies = [] > data = [] > for ie in range(100): > energy = ie * 0.01 > # compute the scattering matrix at a given energy > p = {'k_y': 0, **two_deg_params} > smatrix = kwant.smatrix(syst, energy, params=p) > > # compute the transmission probability from lead 0 to > # lead 1 > energies.append(energy) > data.append(smatrix.transmission(1, 0)) > > I obtained the following Figure. > > [image: image.png] > > 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:43, Ali Asgharpour > wrote: > >> 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 < >> r.j.skolasin...@gmail.com> 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, ene