ibei - Calculator for incomplete Bose-Einstein integral
The Bose-Einstein integral appears when calculating quantities pertaining to photons. It is used to derive the Stefan-Boltzmann law, and it also appears when calculating the detailed balance limit of a solar cell as described by Shockley and Queisser [SQ61] , and when calculating the photo-enhanced thermoelectron emission from a material as described by Schwede et.al. [SBR+10] .
The ibei module provides functionality to calculate various
forms of the Bose-Einstein integral, along with well-known models of
photovoltaic devices. The ibei module provides a
ibei.BEI class which includes methods to compute the full,
upper-incomplete, and lower-incomplete Bose-Einstein integrals. It
also includes two convenience classes for calculating the power
density and efficiency of a single-junction solar cell according to
Shockley and Queisser [SQ61] and
deVos [deV92]. See the
Mathematical Description and Applications section for the
mathematical details.
Installation
This package is installable via pip.
pip install ibei
Alternatively, download the source, install hatch, and build.
git clone git@github.com:jrsmith3/ibei.git
pip install hatch
hatch build
pip install dist/ibei-1.0.6.tar.gz # Or whatever is the latest version in that directory.
Examples
Calculate the number of above-bandgap photons from Si at 300K:
>>> import ibei
>>> bandgap = 1.1
>>> bei = ibei.BEI(order=2, energy_bound=bandgap, temperature=300., chemical_potential=0.)
>>> bei.upper()
<Quantity 10549124.09538381 1 / (m2 s)>
Verify Shockley and Queisser’s result [SQ61] that the efficiency of a silicon solar cell is 44%:
>>> import ibei
>>> solarcell = ibei.SQSolarcell(solar_temperature=6000., bandgap=1.1)
>>> solarcell.efficiency()
<Quantity 0.43866807>
Plot efficiency vs. bandgap of a single-junction solar cell as in Shockley and Queisser’s Fig. 3 [SQ61]:
>>> import ibei
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> bandgaps = np.linspace(0, 3.25, 100)
>>> efficiencies = []
>>> for bandgap in bandgaps:
... solarcell = ibei.SQSolarcell(solar_temperature=6000, bandgap=bandgap)
... efficiency = solarcell.efficiency()
... efficiencies.append(efficiency)
>>> plt.plot(bandgaps, efficiencies)
>>> plt.xlabel("Bandgap (eV)")
>>> plt.ylabel("Efficiency")
>>> plt.show()
Efficiency vs. bandgap of a photovoltaic using Shockley and Queisser’s model [SQ61].
API Reference
Mathematical Description and Applications
The Bose-Einstein integral, subsequently referred to as the “full Bose-Einstein integral” or “full integral”, is denoted \(G_{m} (T, \mu)\) and is given by Eq. (1).
The quantity \(h\) is Planck’s constant, \(c\) is the speed of light, \(\mu\) is the chemical potential of photons, \(E\) is the energy of photons, \(T\) is the temperature of the radiator, and \(k\) is Boltzmann’s constant.
Now consider the two integrals \(G_{m} (E_{g}, T, \mu)\) and \(g_{m} (E_{g}, T, \mu)\), called the upper-incomplete Bose-Einstein integral and the lower-incomplete Bose-Einstein integral, respectively, and given by Eqs. (2) and (3), respectively.
The two integrals given above can be summed to form a relationship between the full, upper-incomplete, and lower-incomplete Bose-Einstein integrals.
The integration of the full Bose-Einstein integral can be performed to yield the expression given in Eq. (5).
where \(\Gamma(z)\) is the gamma function and \(Li_{s}(z)\) is the polylogarithm of index \(s\). The upper-incomplete Bose-Einstein integral can be expressed as a finite sum of polylogarithm functions as shown by Smith (reference forthcoming) and given in Eq. (6).
An expression for the lower-incomplete Bose-Einstein integral can be obtained by solving Eq. (4) for \(g_{m} (E_{g}, T, \mu)\) and substituting Eqs. (5) and (6) for the full and upper-incomplete integrals, respectively.
License
The code is licensed under the MIT license. You can use this code in your project without telling me, but it would be great to hear about who’s using the code. You can reach me at joshua.r.smith@gmail.com.
Contributing
The repository is hosted on github . Feel free to fork this project and/or submit a pull request. Please notify me of any issues using the issue tracker .
In the unlikely event that a community forms around this project, please adhere to the Python Community code of conduct.
Developer Notes
This section contains information about some common tasks that are needed during the course of development. I restarted work on this repo years after I last worked on it, so I’m mainly writing these notes to my future self if that situation happens again.
This repository uses hatch
(link) for all of its automation,
so install it before hacking on the source.
# Install dependencies for development.
pip install hatch
To run the tests, call hatch test. hatch will install the
necessary dependencies (e.g. pytest) in a virtual environment and
run the tests. At the time of this writing, I do not believe that
hatch builds and installs the package in the test environment
(which is
a good practice
). I think it just runs what is found in the source directory.
# Run the tests in your local environment.
hatch test
This repo uses sphinx to
create this documentation. There is a hatch environment definition
to build the documentation. HTML is the only automation supported at
this time. The documentation can be built locally as follows.
# Build the documentation in your local environment.
hatch run doc:html
This approach provides all the same advantages as using hatch for
testing, namely, the only dependency that must be installed on the
local system is hatch, and hatch itself manages all of the
other dependencies in a virtual environment.
The official documentation is hosted at
readthedocs. The documentation is
built using their automated build as defined in the ibei repo’s
.readthedocs.yaml
file. Like the other build automations, this automation also uses
hatch.
This repo also features GitHub workflows for continuous integration
automations. Some of these automations leverage hatch as well.
See the config in pyproject.toml and the automation definitions
in the .github subdirectory for information on how they work.
Version numbers are PEP 440 compliant. Versions are indicated by a
tagged commit in the repo (i.e. a “version tag”). Version tags are
formatted as a “version string”; version strings include a
literal “v” prefix followed by a string that can be parsed according
to PEP 440. For example: v2.0.0 and not simply 2.0.0. Such
version strings will have three components, MAJOR.MINOR.PATCH, which
follow clauses 1-8 of the
semver 2.0.0 specification. Any documentation
change by itself will result in an increment of the PATCH component of
the version string.
All commits to the main branch will be tagged releases. There is
no dev branch in this repo. This repo will likely not include
prerelease versions. This repo may include post-release versions.
Such post-release versions correspond to changes to the development
infrastructure and not functional changes to the codebase. Such
post-release versions may result in a new build posted to PyPI, but
it would be good if they didn’t.
This repo includes a GitHub workflow to automatically build the package, test the package, create a GitHub release, and upload the package to PyPI when a version tag is pushed. Version tags are manually created by me (Joshua Ryan Smith) in my local clone of the repo. Therefore, releasing is semi-automated but is initiated by a manual tagging process. I.e. when I want to create a new release, I create a version tag in the repo and push that tag – the GitHub workflows take care of the rest. Such version tags should be annotated. The tag message should include the list of issues that are included in the release.
Citing
You can cite this software as follows.
Smith J.R. ibei (version x.y.z). URL: https://ibei.readthedocs.org
The repo contains a CITATION.cff file (content given below)
formatted as cff.
Tools
like cffconvert exist to convert the cff data to other formats, like
BibTeX.
cff-version: 1.2.0
title: "ibei"
abstract: "Calculators for Bose-Einstein integrals."
repository-code: "https://github.com/jrsmith3/ibei"
url: "https://ibei.readthedocs.org"
type: software
license:
- MIT
authors:
- family-names: Smith
given-names: Joshua Ryan
orcid: "https://orcid.org/0000-0002-3137-7180"
contact:
- family-names: Smith
given-names: Joshua Ryan
email: joshua.r.smith@gmail.com
keywords:
- Bose-Einstein integral
- Bose-Einstein statistics
- python
- thermal radiation
message: "Use information in this file when citing this software."
Bibliography
Alexis deVos. Endoreversible thermodynamics of solar energy conversion. Oxford University Press, Oxford New York, 1992. ISBN 9780198513926.
Jared W. Schwede, Igor Bargatin, Daniel C. Riley, Brian E. Hardin, Samuel J. Rosenthal, Yun Sun, Felix Schmitt, Piero Pianetta, Roger T. Howe, Zhi-Xun Shen, and Nicholas A. Melosh. Photon-enhanced thermionic emission for solar concentrator systems. Nat Mater, 9(9):762–767, Sep 2010. doi:10.1038/nmat2814.