Giter Site home page Giter Site logo

gharib85 / waveprop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dylanljones/waveprop

0.0 1.0 0.0 466 KB

Python package to calculate the transmission properties of one-dimensional kronig-penney-systems

License: MIT License

Python 100.00%

waveprop's Introduction

waveprop 0.0.1

Waveprop is a python package to calculate the transmission properties of a one-dimensional kronig-penney-system. The model consists of a scattering region between two leads. The leads and scattering region are built up of unitcells. Currently only rectangular potential-barriers are implemented.

______________________________________________
              |                |
e -->  Lead   |     Sample     |   Lead  -->
______________|________________|______________

Installation

Download package and use pip to install:

pip install -e <folder path>

Use the main folder of "waveprop". Only tested with Python 3.6.

Main Contents

The package consists of four main parts:

The main model package: model

Contains all objects to model the System:

  • The unitcell to build the leads and samples: Cell
  • The Kronig-Penney-Modell for describing the leads: KronigPenney
  • An object to calculate the bandstrukture of the Kronig-Penney-Model: BandFinder
  • The models of the sample region: Sample, OrderedSample and DisorderedSample
  • The main model-object: Model

The calculation package: calculation

This package contains an object holding all used constants constants, some helper methodsa for the calculation and an implementation of the Transfermatrix method: TransferMatrix.

Wrapper classes for plotting data: plotting

The plotting-package contains a two-dimensional (Plot) and three-dimensional (Plot3D) wrapperclass for the matplotlib-libary. In Addition, a Error-Plot class is included (ErrorPlot).

The utility package for helper-modules: utils

All other helper-methods and -objects are contained in the utils package. This includes:

  • A module for displaying the calculation-progress in one console-line: console
  • A custom cuvre object for holding plotting data: Curve
  • Some methods for converting output to latex syntax: latex

Usage

To initialize the model, use the Model object. This will create the two leads from the given Cell object or parameters:

from waveprop import Cell, Model
v = 10  # Barrier Potential-strength of leads in hartree
a, d = 1.0, 0.8  #  lattice constant and barrier width in bohr-radius

lead_cell = Cell(v, a, d)
model = Model(lead_cell) 

#or:
model = Model.from_lead_params(v, a, d)

To add an arbitrary scattering region to the model, use the methods of the model and pass the list of unitcells in the sample region:

sample_cells = [Cell(10, a, d), Cell(12, a, d), Cell(14, a, d)]
model.set_sample(sample_cells)

The ordered sample consists of n identical unit cells. To add this sample, use:

sample_cell = Cell(12, a, d)
model.set_ordered_sample(n=10, cell=sample_cell)

For the disordered sample, the strength of the disorder w has to be given additionaly:

model.set_disordered_sample(w=0.4, n=10, cell=lead_cell)

This will generate a disordered sample, consisting of 10 unitcells with a deviation of 40% of the potential strength.

Transmission

To calculate the transmission properties of the model, first the energy of the considered wave or particle has to be set. After that, all values are accessable. For example:

e = 7  # energy of particle in hartree
model.set_energy(e)

t = model.t  # transmission-koefficient of model for current energy
k = model.k  # bloch-vector of model for current energy

The model also has a method for calculating the transmission-curve in a given energy-range:

energy_range = 0, 20  # calculate the transmission curve for this range of values (hartree)
steps = 1000  # number of transmission values to calculate

e_values, t_values = model.transmission_curve(energy_range, steps=steps)

The data can be plotted quickly using the Plot-object:

from waveprop import Plot

plt = Plot()
plt.plot_transmission((e_values, t_values), col="black")
plt.show()

Example

To show the model and the transmission curve, use the package as shown in test_script.py:

from waveprop import Model, Plot, color_gaps
"""
Create model with default leads (v=10, a=1.0, d=0.8).
"""
model = Model()

"""
Creates disordered sample and uses lead-unitcell as prototype.
The disorder stregth is 0.1, so the potential range is v=9-11.
"""
disorder_strength = 0.1  # disorder strength
n_sample_cells = 10  # number of unit-cells in scattering region
model.set_disordered_sample(w=disorder_strength, n=n_sample_cells)

"""
Show the model using included matplotlib-wrapper
"""
plt = model.show()  # plot generated model
plt.show(tight_layout=True)

"""
Plot the transmission curve of the disordered scattering region
"""
energy_range = 0, 30  # energy range to plot the transmission
data = model.transmission_curve(energy_range)  # get transmission data

plt = Plot()

color_gaps(plt, model)  # color band-gaps
plt.plot_transmission(data)  # plot transmission data
plt.show(tight_layout=True)

This will produce the following output:

-Generated model:

-Corresponding transmission curve:

To Do

  • Unit Test coverage
  • More forms of potential barriers

waveprop's People

Contributors

dylanljones avatar

Watchers

 avatar

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.