ValueError: Number of orbitals not defined.

Hello again, I am having trouble defining the nomber of orbitals in the current operator for an infinite system. --------------------------- model = tbmodels.Model.from_wannier_files( hr_file='seedname_hr.dat', wsvec_file='seedname_wsvec.dat', xyz_file='seedname_centres.xyz', win_file='seedname.win' ) def shape(p): x, y, z = p return -6*model.uc[0][0] < x < 6*model.uc[0][0] and -1*model.uc[1][1] < y < 1*model.uc[1][1] and 0 < z < 30 def lead_shape(p): x, y, z = p return -3*model.uc[0][0] < x < 1*model.uc[0][0] and -1*model.uc[1][1] < y < 1*model.uc[1][1] and 0 < z < 30 lattice = model.to_kwant_lattice() for x in lattice.sublattices: x.norbs=1 kwant_model = kwant.Builder() kwant_model[lattice.shape(shape, (0, 0, 15))] = 0 model.add_hoppings_kwant(kwant_model) sym_lead = kwant.TranslationalSymmetry(lattice.vec((-4, 0, 0))) lead = kwant.Builder(sym_lead) lead[lattice.shape(lead_shape, (0, 0, 15))] = 0 model.add_hoppings_kwant(lead) kwant_model.attach_lead(lead) kwant_model.attach_lead(lead.reversed()) kwant_sys = kwant_model.finalized() psi = kwant.wave_function(kwant_sys)(0)[0] J = kwant.operator.Current(kwant_sys) current = sum(J(p) for p in psi) ValueError Traceback (most recent call last) <ipython-input-37-4d2b8ea6f8e4> in <module>() 1 psi = kwant.wave_function(kwant_sys)(0)[0] ----> 2 J = kwant.operator.Current(kwant_sys) 3 current = sum(J(p) for p in psi) 4 kwant\operator.pyx in kwant.operator.Current.__init__() kwant\operator.pyx in kwant.operator._LocalOperator.__init__() ValueError: Number of orbitals not defined. Declare the number of orbitals using the `norbs` keyword argument when constructing the site families (lattices). for x in lattice.sublattices: print(x.norbs) 1 1 1 1 1 1 1 1 1.... ------------------------------------------------ This worked for a closed system. Regards, -- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109

I was able to solve this using: ----------------------------------------- for x in kwant_model.sites(): x.family.norbs=1 for x in lead.sites(): x.family.norbs=1 kwant_model.attach_lead(lead) kwant_model.attach_lead(lead.reversed()) kwant_sys = kwant_model.finalized() ----------------------------------------------------- Regards, Eleni Quoting elchatz@auth.gr:
Hello again,
I am having trouble defining the nomber of orbitals in the current operator for an infinite system.
--------------------------- model = tbmodels.Model.from_wannier_files( hr_file='seedname_hr.dat', wsvec_file='seedname_wsvec.dat', xyz_file='seedname_centres.xyz', win_file='seedname.win' )
def shape(p): x, y, z = p return -6*model.uc[0][0] < x < 6*model.uc[0][0] and -1*model.uc[1][1] < y < 1*model.uc[1][1] and 0 < z < 30
def lead_shape(p): x, y, z = p return -3*model.uc[0][0] < x < 1*model.uc[0][0] and -1*model.uc[1][1] < y < 1*model.uc[1][1] and 0 < z < 30
lattice = model.to_kwant_lattice()
for x in lattice.sublattices: x.norbs=1
kwant_model = kwant.Builder() kwant_model[lattice.shape(shape, (0, 0, 15))] = 0 model.add_hoppings_kwant(kwant_model)
sym_lead = kwant.TranslationalSymmetry(lattice.vec((-4, 0, 0))) lead = kwant.Builder(sym_lead) lead[lattice.shape(lead_shape, (0, 0, 15))] = 0 model.add_hoppings_kwant(lead)
kwant_model.attach_lead(lead) kwant_model.attach_lead(lead.reversed())
kwant_sys = kwant_model.finalized() psi = kwant.wave_function(kwant_sys)(0)[0] J = kwant.operator.Current(kwant_sys) current = sum(J(p) for p in psi)
ValueError Traceback (most recent call last) <ipython-input-37-4d2b8ea6f8e4> in <module>() 1 psi = kwant.wave_function(kwant_sys)(0)[0] ----> 2 J = kwant.operator.Current(kwant_sys) 3 current = sum(J(p) for p in psi) 4
kwant\operator.pyx in kwant.operator.Current.__init__()
kwant\operator.pyx in kwant.operator._LocalOperator.__init__()
ValueError: Number of orbitals not defined. Declare the number of orbitals using the `norbs` keyword argument when constructing the site families (lattices).
for x in lattice.sublattices: print(x.norbs)
1 1 1 1 1 1 1 1 1.... ------------------------------------------------
This worked for a closed system.
Regards,
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
participants (1)
-
elchatz@auth.gr