General Equation Builder

From Flooxs
Revision as of 20:41, 28 January 2010 by Nrowsey (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

You can add and use this procedure to create continuity equations for your species. You must tell it:

  1. the name (Name) of your species (e.g. Hole)
  2. the material (Mat) you wish to add the continuity equation in (e.g. Silicon)
  3. what type of species you are adding, and therefore what type of constant (Const) the equation should have
    1. choose 0 for fixed species (e.g. a non-mobile oxide trap)
    2. choose D for mobile species that will diffuse but are not charged (e.g. hydrogen or H2)
    3. choose MOB for species that are mobile AND charged (e.g. Elec or Hole)
  4. the value (Val) of the constant specified in 3. (e.g. 150.0) (note, Val does not have to be a number)
  5. the charge (Charge) on the species (choose 0, -, or +)

This procedure will also add all charged species to Poisson's equation in the material specified, as long as you have already added Poisson's equation (for example, using AddPoisson) in that material (otherwise it prints an error message).

proc AddSpecies {Name Mat Const Val Charge} {
   set eqn "ddt($Name)"
   if {$Const == "D"} {append eqn "-$Val*grad($Name)"}
   if {$Const == "MOB"} {
       if {$Charge == "-"} {append eqn "-$Val*Vt*sgrad(($Name), +DevPsi/Vt-log(Gamma_n))"}
       if {$Charge == "+"} {append eqn "-$Val*Vt*sgrad(($Name), -DevPsi/Vt+log(Gamma_p))"}
   }
   #Add dharged terms to Poisson Equation
   if {$Charge != "0"} {
       if {[pdbIsAvailable $Mat DevPsi Equation]} {
           set eqnP [pdbGetString $Mat DevPsi Equation]
           set eqnP [append eqnP " $Charge $Name"]
           pdbSetString $Mat DevPsi Equation $eqnP
           puts "Amending Poisson Eqn in $Mat to: $eqnP"
       }
   }
   #Store the transport equation in the pdb
   puts "Adding $Name Equation in $Mat: $eqn"
   pdbSetString $Mat $Name Equation $eqn
}
#Example:
#Procedure	Name	Mat		Const	Val	Charge
#--------------------------------------------------------------
AddSpecies	H2	Oxide		D	1.7e-15	        0
AddSpecies     Elec    Silicon         MOB     300.0           -
AddSpecies     Hole    Silicon         MOB     "(300.0/2.0)"   +