##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Lance Simms, Stanford University 2009
#FDGrid_1d.py
#
#A class that creates the 1d grid to be used for the finite differencing scheme
#
#INPUTS
#  TP: int
#    The total number of points on the grid
#  RMin: float
#    The minimum radius to consider (0 is avoided because of divergence)
#  RMax: float
#    The maximum radius to consider
#  Simple: int
#    0 - Use grid that defines things in terms of pixels 
#    1 - Use grid that uses actual physical dimensions of pixels
#  Mobility: int
#    0 - Use constant mobilities throughout diode
#    1 - Use doping concentration dependent mobilities
#  N_a_max: float
#    Doping concentration in p region
#  N_d_max: float
#    Doping concentration in n region
#  N_bulk: float
#    Doping concentration in bulk region
#
#############################################

from numpy import *
from pylab import *
import matplotlib.pylab as mplot
import string 
import pdb

class RadGrid_1d:

  #INSTANTIATION######################
  def __init__(self, TP, RMin=0.00, RMax=20., \
               N_a_max=2, N_bulk=2, N_d_max=2, \
               TvFlag = 0, Simple = 0):

    #Define some constants to be used by objects
    self.e_0   = 8.85419e-12          # F * m^-1 - 8.85419 e-14 F*cm^-1
    self.e_si  = 11.8                 # Relative Permittivity for Si   
    self.q     = double(1.6022e-19)   # Coulombs per electron
    self.k     = double(1.38066e-23)  # Joules per Kelvin
    self.T     = double(300)          # Kelvin
    self.Theta = double(self.q/(self.k*self.T)) # Factor relating energies
    self.n_i   = 1e16                 # intrinsic concentration cm^-3


    #SIMPLE = 1 ======================Grid with realistic distance/time scale
    if Simple == 1:
      #Define the grid
      self.dr_min = double(RMax-RMin)/TP
      self.r      = frange(RMin, RMax, self.dr_min)
      self.dr     = self.r[1:TP]-self.r[0:TP-1]
      self.I      = TP-1
    #SIMPLE = 0 ======================Very simple grid in units of pixel
    elif Simple == 0:
      #Define the grid
      self.dr_min = double(RMax-RMin)/TP
      self.r      = frange(RMin, RMax, self.dr_min)
      self.dr     = self.r[1:TP]-self.r[0:TP-1]
      self.I      = TP-1
