Resistor example 1D - DC solve explanation: Difference between revisions

From Flooxs
Jump to navigation Jump to search
No edit summary
 
Line 29: Line 29:
  AddtoLine $Win I $bias $cur
  AddtoLine $Win I $bias $cur
It sends a point through channel $Win with x and y values $bias and $cur, to the line named "I". See the [[Plotting Examples - new short version | plotting explanation section]] for more information on plotting.
It sends a point through channel $Win with x and y values $bias and $cur, to the line named "I". See the [[Plotting Examples - new short version | plotting explanation section]] for more information on plotting.
==== ramping discussion ====
DC ramping in this case was used to create an IV plot. But it is also usually used to reach a certain DC bias voltage since the solve at V=0.0 can be used as an initial guess as the solve for V=0.1, and that solution can be used as an initial guess for V=0.2, and so on. Indeed, this is what is happening in this "for" loop, where "device" is being called each time as the voltage is increased. Convergence for each step in the loop depends on how different the next solution is compared to the previous solution

Latest revision as of 19:23, 4 November 2010

This page explains the following code snipped from the 1D Resistor example:

DC solve / plot I-V as output

set Win [CreateGraphWindow]
set bias 0.0
for {set bias 0.0} {$bias < 1.01} {set bias [expr $bias+0.1]} {
	contact name=VSS supply = $bias
	device
	set cur [expr abs([contact name=VSS sol=Elec flux] - [contact name=VSS sol=Hole flux])]
	AddtoLine $Win I $bias $cur
}

tcl channels

This line is rather complicated in floods:

set Win [CreateGraphWindow]

The command "CreateGraphWindow" opens a new window for plotting (it'll be a blank set of axes until you write to it). The [] brackets around the [CreateGraphWindow] command mean, "execute this command now." The CreateGraphWindow command actually returns a channel number that you don't see and stores it in the tcl variable "Win". This is so that, in the future, when you want to send data to your plot, you can send it through the channel named "Win".

"Ramping," or consecutive DC solves

Please note from this line:

set bias 0.0

that "bias" is a tcl variable, and not some complex thing that floods already knows about. The "for" loop you see above is how you write a for loop in tcl. The [] brackets mean "evaluate this now and put the result here," and the "$" means "access this string and put what's stored in it here," just like in the rest of our tcl code.

contact name=VSS supply = $bias

is an alagator command, and is being used the same way the it was used in the initial guess section. This line:

set cur [expr abs([contact name=VSS sol=Elec flux] - [contact name=VSS sol=Hole flux])]

retrieves flux of Elec or Hole through the VSS contact from the parameter database,

contact name=VSS sol=Elec flux
contact name=VSS sol=Hole flux

subtracts and takes the absolute value using expr, then stores that number in the tcl variable "cur". "AddtoLine" is a specific command for the "CreateGraphWindow" graphing method:

AddtoLine $Win I $bias $cur

It sends a point through channel $Win with x and y values $bias and $cur, to the line named "I". See the plotting explanation section for more information on plotting.

ramping discussion

DC ramping in this case was used to create an IV plot. But it is also usually used to reach a certain DC bias voltage since the solve at V=0.0 can be used as an initial guess as the solve for V=0.1, and that solution can be used as an initial guess for V=0.2, and so on. Indeed, this is what is happening in this "for" loop, where "device" is being called each time as the voltage is increased. Convergence for each step in the loop depends on how different the next solution is compared to the previous solution