Giter VIP home page Giter VIP logo

pyeels's Introduction

PyEELS - Python EELS simulation package

PyEELS is a python package intended for simulating Electron Energy Loss Spectroscopy from model band structures.

The use of the package can be seen as threefold:

  1. Constructing a real space model system
  2. Create/generate model band structures in reciprocal space
  3. Simulate EELS on the model band structure

The creation of model band structures is mainly based on PythTB, an additional model with parabolic bands is also provided.

The simulation of EELS is based on (https://www.duo.uio.no/handle/10852/63504) and implemented in an C extension thus can be multiprocessed for faster calculation.

HyperSpy has been chosen as a framework for an interactive visualization of EELS-spectra, in this process Jupyter Notebook is a natural platform for scripting purpose.

An example is presented below:

# Generate real space crystal model
from pyeels import Crystal

myCrystal = Crystal(lattice=np.eye(3))
myAtom = Atom(number=0,position=[0,0,0])
myAtom.add_orbital(Orbital(label="s", onsite=0))
myCrystal.add_atom(atom=myAtom)

# Create parabolic bands in reciprocal space
from pyeels import ParabolicBand
reci = ParabolicBand(myCrystal)

reci.set_grid(mesh=31) # Number of k-points in each dimension

# Parabolic valence band
reci.set_parabolic(effective_mass=[-0.5, -0.5, -0.5], 
                   energy_offset=0, 
                   k_center=[0,0,0], 
                   wave=np.array([0,0.02])
                  )
		 
# Parabolic conduction band
reci.set_parabolic(effective_mass=[ 0.5,  0.5,  0.5], 
                   energy_offset=1, 
                   k_center=[0,0,0],
                   wave=np.array([0,1])
                  )

# Calculate EELS on the parabolic bands
from pyeels import EELS

mySystem = EELS(myCrystal)
mySystem.temperature = 0    # Absolute zero
mySystem.fermienergy = 0.5  # Placing the fermi level at center of the band gap

mySystem.set_meta(
	name="My test sample", 
	author=["Author1", "Author2"], 
	title="myCrystal", 
	notes="This model is just an example." 
	)

# The q-resolution of the scattering cross section
# no argument correspond to the density of the k-grid in Brillouin Zone
mySystem.set_diffraction_zone()

mySignal = mySystem.calculate_eels_multiproc(energyBins=np.linspace(0,4,200),
                                     	     smearing=0.05
                                     	     max_cpu=4
					    )
					    
#HyperSpy visuailzation
mySignal.plot()

pyeels's People

Contributors

sindrerb avatar sindrebilden avatar thomasaarholt avatar

Stargazers

 avatar Shahram_Yalameha avatar Wang, En  avatar M avatar HojeChun avatar Håkon Kvernmoen avatar Yenting Li avatar  avatar Xu He avatar  avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

pyeels's Issues

wrong reference to position in function set_position

AttributeError                            Traceback (most recent call last)
<ipython-input-5-e24596a2747e> in <module>()
      1 indir.add_atom(atom=atom)
----> 2 indir.add_atom(atom=atom.set_position([0.5,0,0]))

/home/sindrerb/anaconda3/lib/python3.6/site-packages/pyeels/crystal.py in add_atom(self, atom)
     51         existing = False
     52         for existing_atom in self.atoms:
---> 53             if np.all(atom.position == existing_atom.position):
     54                 existing = True
     55         if not existing:

AttributeError: 'NoneType' object has no attribute 'position'

Wrong reference to bands in EELS class

AttributeError                            Traceback (most recent call last)
<ipython-input-24-d7cc3b72be02> in <module>()
----> 1 s = eels.calculate_eels(np.linspace(0,3,50), fermienergy=0.5)

/home/sindrerb/anaconda3/lib/python3.6/site-packages/pyeels/eels.py in calculate_eels(self, energyBins, fermienergy, temperature)
    165         energyBands = []
    166         waveStates = []
--> 167         for band in self.bands:
    168             energyBands.append(band.energies)
    169             waveStates.append(band.waves)

AttributeError: 'EELS' object has no attribute 'bands'

logger not defined in all documents

NameError                                 Traceback (most recent call last)
<ipython-input-10-909d609d27b4> in <module>()
      3 
      4 atom2 = Atom(number=0,position=[0.5,0,0])
----> 5 atom.add_orbital(Orbital(label="s", onsite=0))

/home/sindrerb/anaconda3/lib/python3.6/site-packages/pyeels/atom.py in add_orbital(self, orbital)
     31             return "Placed {} orbital with onsite {}, on {}".format(orbital.label,orbital.onsite, self)
     32         else:
---> 33             _logger.warning("An orbital with label {} allready exist, try different label.".format(orbital.label))
     34 
     35     def set_position(self, position):

NameError: name '_logger' is not defined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.