This page contains useful formulas used in our research and engineering, as well as code for the open-source Numbat scientific calculator that implements the formulas.

Important information

Some of the code implementations of these formulas only work if the functions are placed in a separate file that is interpreted by Numbat; they are not guaranteed to work in REPL/interactive session mode! Thus it is highly recommended to save the functions to a custom module that you can then import into an interactive section. Specifically, create a file <module-path>/custom/functions.nbt, where <module-path> can be found according to the below table:

PlatformPath
Linux$HOME/.config/numbat or $XDG_CONFIG_HOME/numbat
macOS$HOME/Library/Application Support/numbat
WindowsC:\Users\<username>\AppData\Roaming\numbat

Then, simply put all the below functions into <module-path>/custom/functions.nbt. You can easily import them in any Numbat interactive session (REPL) by simply running (in Numbat):

use custom::functions

Tip: It is useful to add a variable NUMBAT_LIB by putting export NUMBAT_LIB = <module-path> (Unix/Bash-like shells) or $env:NUMBAT_LIB = <module-path> (Windows Powershell) in your shell config (~/.bashrc, ~/.zshrc etc. for Unix, $profile for Windows Powershell) so that you can simply type <youreditor> $NUMBAT_LIB to quickly edit the file (e.g. notepad $NUMBAT_LIB on Windows and nano $NUMBAT_LIB on Mac/Linux).

For more information, please consult the Numbat documentation for more details.

Electricity & magnetism

Electrical power transferred of current across potential :

Numbat code:

# Formula definition
fn electrical_power(I: Current, deltaV: Voltage) -> Power = I*deltaV

# Usage
electrical_power(somecurrent, somevoltage)
electrical_power(somecurrent, somevoltage) -> W # Optionally convert to watts

Stefan-Boltzmann law:

Where is the intensity (power density, in units of power over area), is the emissivity and is a dimensionless number between 0 and 1 ( for a perfect blackbody), is the absolute temperature (in Kelvin) and is the Stefan-Boltzmann constant.

Relativity

Electron normalized velocity () as function of electrostatic potential , electron mass , electron charge , and speed of light :

Calculation code (for Numbat):

# Formula definition
fn relativity_beta(deltaV: Voltage) -> Scalar = 
		sqrt(1 - (1 + ratio)^(-2))
	where electron_mass_energy = electron_mass * c^2
	  and electron_kinetic_energy = elementary_charge * deltaV
	  and ratio = electron_kinetic_energy/electron_mass_energy

# Usage
relativity_beta(somevoltage)
print("{relativity_beta(somevoltage)}c") # pretty-print e.g. "0.5c"

Warning This code only works if you put the function in a separate file (e.g. as a custom module). Please see the top of the page for more details.

Vacuum systems

Density of dry air as function of temperature and pressure where is the specific gas constant of air1:

Note that for room temperature air, it is common to set (equivalent to or ).

# Formula definition (one-liner)
fn dry_air_density(P: Pressure, T: Temperature) -> MassDensity = P/(T*287.052874 J / (kg*K))

# Equivalent multiline form (more readable)
fn dry_air_density(P: Pressure, T: Temperature) -> MassDensity = P/(R_air * T) 
	where R_air = 287.052874 J / (kg*K)

# Usage
dry_air_density(somepressure, 300K) # for room temperature, arbitrary pressure

Warning The multiline version of the code only works if you put the function in a separate file (e.g. as a custom module). Please see the top of the page for more details. Note that the one-liner version does not suffer from the same issue.

Footnotes

  1. See https://en.wikipedia.org/wiki/Gas_constant#Specific_gas_constant