Callback Procedures
C Callbacks and Interactions
Three procedures are called during diffusion processing which can help build equations. Through the pdb entries, they can be figured to link to tcl procedures to help set up the equations, solutions, and solution data.
There is a setup procedure called first during simulation. This is called when the all the solutions are being queried to determine if the need to be solved. Not every solution variable is enabled at all times. Routines in FLOOPS check to see if a solution is needed, and if the the setup procedure string is set in pdb it is executed. During this procedure, additional solutions can be enabled or disabled as appropriate for the model level selected by a user.
The equation procedure is called when equations are being build for each material. These procedures can be used to construct the equation string. Model options can be checked and equations configured based on runtime options selected by the user.
Finally, a cleanup procedure is called when the diffusion is finished and memory is released. This allows objects to be released or reset as appropriate.
Setup Procedure
The setup procedure uses the keyword InitProc in the property data base. The procedure takes two arguments - a material and a solution name. These procedures can be used to initialize different solution variables as required by the model options selected by the user. For example, the command
pdbSetString Silicon Boron InitProc InitDopant
tells the code to invoke the InitDopant procedure every time solutions are being checked - typically at the beginning of the diffusion step. The actual procedure is as follows:
proc InitDopant {Mat Sol} { set pdbMat [pdbName $Mat] set model [pdbGetSwitch $pdbMat $Sol DiffModel] #if we have the react model, we need to set up solutions if {$model == 3} { #get a list of defects we react with set ld [pdbGetString $pdbMat $Sol Defects] foreach d $ld { solution add name = ${Sol}${d} solve !damp !negative } puts "Reaction Model for $Sol" } }
The pdbName function converts a command line specification of material to a pdb entry name for a material. The function then gets the currently selected diffusion model for the passed dopant and material. If it is the reaction model, then we will need to create additional solution variables for the dopant-defect pairs. The react model solves explicitly for each of these pairs. The property data base is queried and returns a list of defects that this dopant interacts with. Each defect is then added as a dopant defect pair species that needs to be solved.
Equation Procedure
The equation procedure's primary responsibility is to construct the equation string. It uses the keyword EquationProc in the property data base. The procedure takes two arguments - a material and a solution name. These procedures can be used to initialize the equation string based on user selected parameters at runtime. For example:
pdbSetString Silicon Boron EquationProc DopantBulk
tells the code to call the tcl procedure DopantBulk before reading the equation from the pdb and parsing it. This is done at the beginning of each diffusion step. The actual procedure used is:
proc DopantBulk { Mat Sol } { set pdbMat [pdbName $Mat] #work with the active model - create DopantActive... set ActModel [pdbGetSwitch $pdbMat $Sol ActiveModel] set ActName ${Sol}Active if {$ActModel == 0} { term name = $ActName add eqn = $Sol $Mat } elseif {$ActModel == 1} { set ss [pdbDelayDouble $pdbMat $Sol Solubility] set eqn "$ss * $Sol / ($ss $Sol)" term name = $ActName add eqn = $eqn $Mat } else { #need to add dynamic precipitation here! set ss [pdbDelayDouble $pdbMat $Sol Solubility] set eqn "$ss * $Sol / ($ss $Sol)" term name = $ActName add eqn = $eqn $Mat } set model [pdbGetSwitch $pdbMat $Sol DiffModel] set ChgName 0 if {$model == 0} { set ChgName [DopantConstant $Mat $Sol] } elseif {$model == 1} { set ChgName [DopantFermi $Mat $Sol] } elseif {$model == 2} { set ChgName [DopantPair $Mat $Sol] } elseif {$model == 3} { set ChgName [DopantReact $Mat $Sol] } #set up charged species in potential equation set chgtype [pdbGetSwitch $pdbMat $Sol Charge] set chg [term name=Charge print $Mat] if {[lsearch $chg $ChgName] == -1} { #acceptor if {$chgtype == 1} { term name = Charge add eqn = "$chg - $ChgName" $Mat #donor } elseif {$chgtype == 2} { term name = Charge add eqn = "$chg $ChgName" $Mat } #neutrals } elseif {$chgtype == 0} {} } }
This procedure first (as is standard) gets the pdb name of the material. The next step is to parse the active model and create a term for the active concentration as a function of the chemical concentration. This is done either with a equality or a simple rollover of the concentration at the solubility.
Depending on the DiffModel selected, [examples.htm different routines] are selected to implement the actual diffusion equation. Each one is responsible for returning the name of the charged species. Finally, a check is made to see if the name of the charged species is already in the change term, and added if it is not with the appropriate sign based on the type of dopant.
CleanUp Procedure
This procedure allows for terms and expression to be cleared at the end of a diffusion process. The keyword for this procedure is EqnCleanUp. This procedure is also invoked with the name of the material and solution, and it is called at the end of the diffusion step. Generally, not too much needs to be cleaned up, since we do want to have [term.htm term]s available for use in the [../Post/select.html select command].
ComputeNode Equation
This option allows for selective solution of equations in the bulk. For example, wasted CPU time is the only result for solving for dislocation loops where there are none currently and the energetics are very unfavorable for nucleation. This equation is checked every time step, and the nodal list for that solution variable is modified accordingly. In this way, the nodes solved can be updated dynamically as conditions change.
The ComputeNode keyword is used as the entry for the pdb. The string passed should be a valid boolean expression, and it will be evaluated node by node. Comparison operators are useful for these evaluations. For example:
pdbSetString Silicon C311 ComputeNode "(I2 > 1.0e8) || (C311 > 1.0e8)"
This will compute 311 concentration only at nodes in which the di-interstitial or 311 concentration is greater than 108/cm3. Care must be used in making sure that the conditional is appropriate and does not change the final answer of the simulation. Convergence problems can also result if these are too aggressive. This is probably something that should not be set by casual users, only experts. However, since it is in the property data base it is possible for any user to make changes. Perhaps we should implement security for pdb?
See Also
[language.htm language][tutorials.htm , ][examples.htm complex examples], [tutorials.htm tutorials], [eqn.htm equation], [term.htm term], [solutions.htm solution], [../Post/select.html select]