File Exchange

image thumbnail


version (876 KB) by Todd Karin
Energies and matrix elements of hydrogen atom in magnetic field of arbitrary strength

1 Download

Updated 27 Apr 2016

View License

H2DBLAB is a Matlab companion to the H2db code [1], a package that
solves for the wavefunctions and eigenergies of the hydrogen atom in
a magnetic field. H2DBLAB contains matlab scripts for importing the
wavefunctions and calculating matrix elements. There are also
functions for correlating the high field and low field quantum
numbers. The software is developed on Mac OS, but should work also on
Linux. Small changes may need to be made for compatibility with
Windows OS.

The included fortran h2db code is almost identical to that provided
by Schimeczek et. al. [1]. However, small modifications from the
provided code were made in order to create the 'savewavefunction.f90'
and 'zerofieldquantumnumbers.f90' scripts.

These functions have been tested extensively, but no gaurantee is
made to their accuracy. The accuracy of calculated matrix elements
depends on the size of the rho-z mesh used.

To run, also install DGradient, available at:

Executables were created using 64-bit Mac OS X, and can either be
generated yourself or downloaded from my personal website
(, and add to the h2dblab directory.

[1] C. Schimeczek and G. Wunner. "Accurate 2d finite element
calculations for hydrogen in magnetic fields of arbitrary strength."
Computer Physics Communications. 185, 614-621 (2014).


h2db, h2dblab, hydrogen, atom, magnetic field


h2db_filenameList - list of filenames in a folder at specified beta
h2db_generateCompatibleMesh - put two wavefunctions on the same grid
h2db_generateRzMesh - generate 2D mesh grid for coordinates r and z
h2db_import2dbb - import an h2db solution into matlab
h2db_matrixElement - compute matrix elements
h2db_matrixElementDresselhaus - compute Dresselhaus matrix elements
h2db_matrixElementEikr - compute matrix element of Eikr
h2db_plotWavefunction - contour plot of wavefunction
h2db_smoothWavefunction - smooths out discontinuities
h2db_stateSpecification - convert high field QN to low field QN
h2db_wavefunctionPrefixes - find types of stored wavefunctions
h2db_wavefuntionNorm - norm of a wavefunction
splitByChar - split a string at a specified character
findElement - Find the element of a vector closest to a value.


DGradient, h2db

Created By

Todd Karin

Cite As

Todd Karin (2020). h2dblab (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: DGradient

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!