Resistor example 1D - Ionized dopant profile explanation
This page explains the following code snipped from the 1D Resistor Example:
Ionized dopant profile
set Nd 1.0e19 set Na 1.0e15 set Doping [expr {$Nd-$Na}]
"Doping" is Really "Ionized Dopants"
"Nd" is the concentration of n-type dopants in your resistor. If we assume all dopants are ionized (as opposed to using the more advanced but not always necessary incomplete ionization model), then each n-type dopant is going to give up an electron, leaving behind a FIXED AND POSITIVELY CHARGED dopant ion behind. This is why "$Nd" in the "Doping" expression is positive. Using a similar argument, "Na" is the concentration of p-type dopants in your resistor. If we assume all dopants are ionized, then each p-type dopant gives up a hole, leaving behind a FIXED AND NEGATIVELY CHARGED dopant ion behind. This is why "$Na" in the "Doping" expression is negative.
This is a Constant Doping Profile
In this simple resistor example, "set" is used to define Na, Nd, and Doping because each evaluates to just 1 number; they do not depend on x, y, or z, nor on any solution variables. Be sure to use the "$" when using these tcl variables. (Note: In more complicated examples, "sel z=" or "solution const val=" is always used instead, which do not require the "$", so be careful.)