#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Python Skript, das Naturkonstanten einliest und Groessenordnungen
abschaetzt
>>> execfile('orders-of-magnitude.py')
nb of electrons in volume 1000 nm^3: 2.789e+05
nb of electrons in volume    1 nm^3: 796.6
field with I =  100 mW/cm^2: amplitude  434 V/m
"""

from scipy.constants import physical_constants as const
from scipy.constants import pi, find
# example: find('Planck')
from scipy import real, imag, sqrt

eps0 = const['electric constant'][0]
mu0 = const['mag. constant'][0]
c = const['speed of light in vacuum'][0]
hbar = const['Planck constant over 2 pi'][0]
kB = const['Boltzmann constant'][0]
e0 = const['elementary charge'][0]
amu = const['unified atomic mass unit'][0]
me = const['electron mass'][0]
a0 = const['Bohr radius'][0]
G = const['Newtonian constant of gravitation'][0]
micron_SI = 1e-6
nm = 1e-9

if True:
   # density, atom number per volume
   rho = 0.968*1e3 # kg/m^3 mass density of Na
   V = (10*nm)**3 # volume
   mA = 22.99*amu # atomic (or molecular) mass for Na atom
   Z = 11 # electrons per atom (molecule), total (10 are bound)
   Nb = Z*V*rho/mA

   print('nb of electrons in volume %4.4g nm^3: %4.4g' %(V/(1*nm)**3, Nb))
   # density, atom number per volume
   rho = 2.65*1e3 # kg/m^3 mass density of glass
   V = (1*nm)**3 # volume
   mA = 60.1*amu # atomic (or molecular) mass for Si + 2 x O
   Z = 30 # electrons per atom (molecule), total (all are bound)
   Nb = Z*V*rho/mA
   print('nb of electrons in volume %4.4g nm^3: %4.4g' %(V/(1*nm)**3, Nb))

   # light intensity (time-averaged) and electric field
   Int = 100.*1e-3/(1e-4) # intensity in mW/cm^2 and W/m^2
   field = sqrt(Int/(2*eps0*c)) # field amplitude in V/m
   print('field with I = %4.4g mW/cm^2: amplitude %4.4g V/m' %(Int/(1e-3/(1e-4)), field))