Saving a figure of the system
Hello, I have just started using kwant, and I am trying to write a code excerpt that saves a figure of my system, but I just get a blank 3-D space. The code is the following, as taken by the TBModels website: ----------------------------------------------------------------- import kwant import tbmodels import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt model = tbmodels.Model.from_wannier_files( hr_file='..._hr.dat', wsvec_file='..._wsvec.dat', xyz_file='..._centres.xyz', win_file='....win' ) lattice = model.to_kwant_lattice() wire = kwant.Builder() def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5 wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire) fig = plt.figure() ax = plt.subplot() ax = kwant.plot(wire) plt.savefig('wire.png') ---------------------------------------------------------------------------------------- If anyone knows whether the problem is with the system or with the plotting it would be greatly appreciated. Regards -- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
Hello, The program will work if you do the following changes: from kwant import wraparound and write correctly the paths and names of your files. The code is as follows: ############################################# import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt model = tbmodels.Model.from_wannier_files(hr_file='data/wannier90_hr.dat') lattice = model.to_kwant_lattice() wire = kwant.Builder() def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5 wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire) fig = plt.figure() ax = plt.subplot() ax = kwant.plot(wire) plt.savefig('wire.png') ###################### I hope this helps. Adel On Tue, Feb 6, 2018 at 3:28 PM, <elchatz@auth.gr> wrote:
Hello,
I have just started using kwant, and I am trying to write a code excerpt that saves a figure of my system, but I just get a blank 3-D space. The code is the following, as taken by the TBModels website: -----------------------------------------------------------------
import kwant import tbmodels import wraparound
import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='..._hr.dat', wsvec_file='..._wsvec.dat', xyz_file='..._centres.xyz', win_file='....win' )
lattice = model.to_kwant_lattice()
wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0
model.add_hoppings_kwant(wire)
fig = plt.figure()
ax = plt.subplot()
ax = kwant.plot(wire)
plt.savefig('wire.png') ------------------------------------------------------------ ----------------------------
If anyone knows whether the problem is with the system or with the plotting it would be greatly appreciated.
Regards
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
Hello Abbout Adel, The names are correct, I am just omitting in the post. I have changed the library call for wraparound, I still get an empty 3D space. I am not sure I am using correctly pyplot's "figure" class with kwant's plot function. The code is now: ------------------------------------------------------- import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt model = tbmodels.Model.from_wannier_files( hr_file='Wanner_hr.dat', wsvec_file='Wannier_wsvec.dat', xyz_file='Wannier_centres.xyz', win_file='Wannier.win' ) lattice = model.to_kwant_lattice() wire = kwant.Builder() def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5 wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire) fig = plt.figure() ax = kwant.plot(wire) ax.savefig('wire.png') --------------------------------------------------------------------- Regards, Eleni Quoting Abbout Adel <abbout.adel@gmail.com>:
Hello,
The program will work if you do the following changes:
from kwant import wraparound
and write correctly the paths and names of your files.
The code is as follows: #############################################
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files(hr_file='data/wannier90_hr.dat') lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = plt.subplot() ax = kwant.plot(wire) plt.savefig('wire.png')
######################
I hope this helps. Adel
On Tue, Feb 6, 2018 at 3:28 PM, <elchatz@auth.gr> wrote:
Hello,
I have just started using kwant, and I am trying to write a code excerpt that saves a figure of my system, but I just get a blank 3-D space. The code is the following, as taken by the TBModels website: -----------------------------------------------------------------
import kwant import tbmodels import wraparound
import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='..._hr.dat', wsvec_file='..._wsvec.dat', xyz_file='..._centres.xyz', win_file='....win' )
lattice = model.to_kwant_lattice()
wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0
model.add_hoppings_kwant(wire)
fig = plt.figure()
ax = plt.subplot()
ax = kwant.plot(wire)
plt.savefig('wire.png') ------------------------------------------------------------ ----------------------------
If anyone knows whether the problem is with the system or with the plotting it would be greatly appreciated.
Regards
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
Dear Eleni, The program I sent to you works fine for me and I get a nice figure of the system. Now, I have only one file: Wannier_hr.dat I don't know the effect of the other files (which are in general optional for the definition of the model). If you want, you can send to me (in a private message) the other files and I will do the test for you. Hope this helps. Adel On Wed, Feb 7, 2018 at 1:29 PM, <elchatz@auth.gr> wrote:
Hello Abbout Adel,
The names are correct, I am just omitting in the post. I have changed the library call for wraparound, I still get an empty 3D space.
I am not sure I am using correctly pyplot's "figure" class with kwant's plot function.
The code is now:
-------------------------------------------------------
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='Wanner_hr.dat', wsvec_file='Wannier_wsvec.dat', xyz_file='Wannier_centres.xyz', win_file='Wannier.win' )
lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = kwant.plot(wire) ax.savefig('wire.png')
---------------------------------------------------------------------
Regards,
Eleni
Quoting Abbout Adel <abbout.adel@gmail.com>:
Hello,
The program will work if you do the following changes:
from kwant import wraparound
and write correctly the paths and names of your files.
The code is as follows: #############################################
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files(hr_file='data/wannier90_hr .dat') lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = plt.subplot() ax = kwant.plot(wire) plt.savefig('wire.png')
######################
I hope this helps. Adel
On Tue, Feb 6, 2018 at 3:28 PM, <elchatz@auth.gr> wrote:
Hello,
I have just started using kwant, and I am trying to write a code excerpt that saves a figure of my system, but I just get a blank 3-D space. The code is the following, as taken by the TBModels website: -----------------------------------------------------------------
import kwant import tbmodels import wraparound
import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='..._hr.dat', wsvec_file='..._wsvec.dat', xyz_file='..._centres.xyz', win_file='....win' )
lattice = model.to_kwant_lattice()
wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0
model.add_hoppings_kwant(wire)
fig = plt.figure()
ax = plt.subplot()
ax = kwant.plot(wire)
plt.savefig('wire.png') ------------------------------------------------------------ ----------------------------
If anyone knows whether the problem is with the system or with the plotting it would be greatly appreciated.
Regards
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
Dear Abbout Adel, Thank you very much for checking that. I will look to see what is going on with the TB model. Regards, Eleni Quoting Abbout Adel <abbout.adel@gmail.com>:
Dear Eleni,
The program I sent to you works fine for me and I get a nice figure of the system. Now, I have only one file: Wannier_hr.dat I don't know the effect of the other files (which are in general optional for the definition of the model).
If you want, you can send to me (in a private message) the other files and I will do the test for you.
Hope this helps. Adel
On Wed, Feb 7, 2018 at 1:29 PM, <elchatz@auth.gr> wrote:
Hello Abbout Adel,
The names are correct, I am just omitting in the post. I have changed the library call for wraparound, I still get an empty 3D space.
I am not sure I am using correctly pyplot's "figure" class with kwant's plot function.
The code is now:
-------------------------------------------------------
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='Wanner_hr.dat', wsvec_file='Wannier_wsvec.dat', xyz_file='Wannier_centres.xyz', win_file='Wannier.win' )
lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = kwant.plot(wire) ax.savefig('wire.png')
---------------------------------------------------------------------
Regards,
Eleni
Quoting Abbout Adel <abbout.adel@gmail.com>:
Hello,
The program will work if you do the following changes:
from kwant import wraparound
and write correctly the paths and names of your files.
The code is as follows: #############################################
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files(hr_file='data/wannier90_hr .dat') lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = plt.subplot() ax = kwant.plot(wire) plt.savefig('wire.png')
######################
I hope this helps. Adel
On Tue, Feb 6, 2018 at 3:28 PM, <elchatz@auth.gr> wrote:
Hello,
I have just started using kwant, and I am trying to write a code excerpt that saves a figure of my system, but I just get a blank 3-D space. The code is the following, as taken by the TBModels website: -----------------------------------------------------------------
import kwant import tbmodels import wraparound
import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='..._hr.dat', wsvec_file='..._wsvec.dat', xyz_file='..._centres.xyz', win_file='....win' )
lattice = model.to_kwant_lattice()
wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0
model.add_hoppings_kwant(wire)
fig = plt.figure()
ax = plt.subplot()
ax = kwant.plot(wire)
plt.savefig('wire.png') ------------------------------------------------------------ ----------------------------
If anyone knows whether the problem is with the system or with the plotting it would be greatly appreciated.
Regards
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
I confirm that it runs just with the hr.dat file :) Eleni Quoting Abbout Adel <abbout.adel@gmail.com>:
Dear Eleni,
The program I sent to you works fine for me and I get a nice figure of the system. Now, I have only one file: Wannier_hr.dat I don't know the effect of the other files (which are in general optional for the definition of the model).
If you want, you can send to me (in a private message) the other files and I will do the test for you.
Hope this helps. Adel
On Wed, Feb 7, 2018 at 1:29 PM, <elchatz@auth.gr> wrote:
Hello Abbout Adel,
The names are correct, I am just omitting in the post. I have changed the library call for wraparound, I still get an empty 3D space.
I am not sure I am using correctly pyplot's "figure" class with kwant's plot function.
The code is now:
-------------------------------------------------------
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='Wanner_hr.dat', wsvec_file='Wannier_wsvec.dat', xyz_file='Wannier_centres.xyz', win_file='Wannier.win' )
lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = kwant.plot(wire) ax.savefig('wire.png')
---------------------------------------------------------------------
Regards,
Eleni
Quoting Abbout Adel <abbout.adel@gmail.com>:
Hello,
The program will work if you do the following changes:
from kwant import wraparound
and write correctly the paths and names of your files.
The code is as follows: #############################################
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files(hr_file='data/wannier90_hr .dat') lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = plt.subplot() ax = kwant.plot(wire) plt.savefig('wire.png')
######################
I hope this helps. Adel
On Tue, Feb 6, 2018 at 3:28 PM, <elchatz@auth.gr> wrote:
Hello,
I have just started using kwant, and I am trying to write a code excerpt that saves a figure of my system, but I just get a blank 3-D space. The code is the following, as taken by the TBModels website: -----------------------------------------------------------------
import kwant import tbmodels import wraparound
import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='..._hr.dat', wsvec_file='..._wsvec.dat', xyz_file='..._centres.xyz', win_file='....win' )
lattice = model.to_kwant_lattice()
wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0
model.add_hoppings_kwant(wire)
fig = plt.figure()
ax = plt.subplot()
ax = kwant.plot(wire)
plt.savefig('wire.png') ------------------------------------------------------------ ----------------------------
If anyone knows whether the problem is with the system or with the plotting it would be greatly appreciated.
Regards
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
Also, if anyone else reads this, I realised it is easier to use the "file" attribute of kwant's plotting routines instead of pyplot's savefig(). Quoting Abbout Adel <abbout.adel@gmail.com>:
Dear Eleni,
The program I sent to you works fine for me and I get a nice figure of the system. Now, I have only one file: Wannier_hr.dat I don't know the effect of the other files (which are in general optional for the definition of the model).
If you want, you can send to me (in a private message) the other files and I will do the test for you.
Hope this helps. Adel
On Wed, Feb 7, 2018 at 1:29 PM, <elchatz@auth.gr> wrote:
Hello Abbout Adel,
The names are correct, I am just omitting in the post. I have changed the library call for wraparound, I still get an empty 3D space.
I am not sure I am using correctly pyplot's "figure" class with kwant's plot function.
The code is now:
-------------------------------------------------------
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='Wanner_hr.dat', wsvec_file='Wannier_wsvec.dat', xyz_file='Wannier_centres.xyz', win_file='Wannier.win' )
lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = kwant.plot(wire) ax.savefig('wire.png')
---------------------------------------------------------------------
Regards,
Eleni
Quoting Abbout Adel <abbout.adel@gmail.com>:
Hello,
The program will work if you do the following changes:
from kwant import wraparound
and write correctly the paths and names of your files.
The code is as follows: #############################################
import kwant import tbmodels from kwant import wraparound import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files(hr_file='data/wannier90_hr .dat') lattice = model.to_kwant_lattice() wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0 model.add_hoppings_kwant(wire)
fig = plt.figure() ax = plt.subplot() ax = kwant.plot(wire) plt.savefig('wire.png')
######################
I hope this helps. Adel
On Tue, Feb 6, 2018 at 3:28 PM, <elchatz@auth.gr> wrote:
Hello,
I have just started using kwant, and I am trying to write a code excerpt that saves a figure of my system, but I just get a blank 3-D space. The code is the following, as taken by the TBModels website: -----------------------------------------------------------------
import kwant import tbmodels import wraparound
import numpy as np import scipy.linalg as la import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt
model = tbmodels.Model.from_wannier_files( hr_file='..._hr.dat', wsvec_file='..._wsvec.dat', xyz_file='..._centres.xyz', win_file='....win' )
lattice = model.to_kwant_lattice()
wire = kwant.Builder()
def shape(p): x, y, z = p return -20 < x < 20 and -5 < y < 5 and -5 < z < 5
wire[lattice.shape(shape, (0, 0, 0))] = 0
model.add_hoppings_kwant(wire)
fig = plt.figure()
ax = plt.subplot()
ax = kwant.plot(wire)
plt.savefig('wire.png') ------------------------------------------------------------ ----------------------------
If anyone knows whether the problem is with the system or with the plotting it would be greatly appreciated.
Regards
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
-- Abbout Adel
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109
participants (2)
-
Abbout Adel
-
elchatz@auth.gr