Skip to content

Instantly share code, notes, and snippets.

@jarvist
Created June 18, 2015 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarvist/9be95a73537430f242d3 to your computer and use it in GitHub Desktop.
Save jarvist/9be95a73537430f242d3 to your computer and use it in GitHub Desktop.
Stat Mech Recombination from various (Boltzmann, FD) kernels
{
"metadata": {
"language": "Julia",
"name": "",
"signature": "sha256:1a9071938dba4bd8f1ff573acb818698bab505d669c6377b952b615085b22cb0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"kb=8.6173324E-5 # in units of eV\n",
"\u03b2=1/(kb*300) # Thermodynamic Beta; units\n",
"\n",
"N=1000\n",
"#pot=0.13*randn(N) # Normal distribution\n",
"pot=0.13*sin(range(0,N)) # Sinusoidal variations\n",
"\n",
"function partition(f)\n",
" Zh=sum(f(-pot))\n",
" Ze=sum(f(pot))\n",
" \u03c1h=(1/Zh) * f(-pot)\n",
" \u03c1e=(1/Ze) * f(pot)\n",
"\n",
" @printf \"Zh: %e Ze: %e e: %e h: %e\\n\" Zh Ze sum(\u03c1e) sum(\u03c1h)\n",
" # Factors of N make these values independent of number of elements in the\n",
" # potential, self-consistent, and equal to R=1 for a flat potential.\n",
" @printf \"R=N*N/(Zh*Ze): %e\\t\" N*N/(Zh*Ze)\n",
" @printf \"R=N*sum(\u03c1e.*\u03c1h): %e\" N*sum(\u03c1h.*\u03c1e)\n",
" println()\n",
" println()\n",
"end\n",
"\n",
"println(\"Boltzmann statistics...\")\n",
"partition( x -> exp(-\u03b2*x) )\n",
"println(\"Fermi-Dirac statistics...\")\n",
"partition( x -> 1./(exp(\u03b2*x) + 1.0) )\n",
"println(\"Fermi-Dirac, chem pot = 1.0 eV...\")\n",
"partition( x -> 1./(exp(\u03b2*(x+1.0)) + 1.0) )"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Boltzmann statistics...\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Zh: 2.791863e+04 Ze: 2.791881e+04 e: 1.000000e+00 h: 1.000000e+00\n",
"R=N*N/(Zh*Ze): 1.282948e-03\tR=N*sum(\u03c1e.*\u03c1h): 1.282948e-03\n",
"\n",
"Fermi-Dirac statistics...\n",
"Zh: 4.999837e+02 Ze: 5.000163e+02 e: 1.000000e+00 h: 1.000000e+00\n",
"R=N*N/(Zh*Ze): 4.000000e+00\tR=N*sum(\u03c1e.*\u03c1h): 2.759667e-01\n",
"\n",
"Fermi-Dirac, chem pot = 1.0 eV...\n",
"Zh: 4.432327e-13 Ze: 4.432356e-13 e: 1.000000e+00 h: 1.000000e+00\n",
"R=N*N/(Zh*Ze): 5.090185e+30\tR=N*sum(\u03c1e.*\u03c1h): 1.282948e-03\n",
"\n"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment