For fitting simple analytical functions to a given dataset an optimizer with an integrated model library interface is available. The analytical model which combines the dataset and the parameters can be coded in Model Definition Language (MDL) (see Section 2.2.2).
In Figure 4.3 a short example of a MDL file is shown. In
this example some of the SPICE Level 1 parameters were
fitted to the measured data of a MOS Transistor.
The equations [31] for the linear region of the device are
for
VGS > VT and
VDS < VGS - VT
The values A, VT, and l in (4.45) and (4.46) are parameters of the Level 1 model. In the data file the values for vgs, vds and id are provided.
All variables available from the interface of the Model Library, can be used in the evaluation method by the map :ue (e.g., :ue["vgs"] for the value of the gate voltage vgs). These are the variables from the data file and the variables controlled by the optimizer.
Figure 4.3: Example of an MDL file.
Instance fit_function = Level1Fit; NewModel Level1Fit : FunctionModel { Local { Parameter <double> l = 0.1; } evaluate { // overload the variable with the value from the current // evaluation l = :ue["l"]; if (:ue["vgs"] > :ue["vt"]) { if (:ue["vds"] < (:ue["vgs"] - :ue["vt"])) { // linear region :result = :ue["a"] * (:ue["vgs"] - :ue["vt"] - :ue["vds"] / 2.) * :ue["vds"] * (1. + l * :ue["vds"]); } else { // saturation region :result = :ue["a"] / 2. * ( :ue["vgs"] - :ue["vt"] ) * (:ue["vgs"] - :ue["vt"]) * (1. + l * :ue["vds"]); } } else { :result = :ue["id"]; } } }
In the Local section some local parameters are declared and defined. Here only the parameter l is declared. In the first part of the evaluate method this local variable is overwritten with the variables from the data file or the variables controlled by the optimizer. From now on l can be used instead of :ue["l"]. This substitution can be useful for larger models making them more readable.
In the next part (4.45) and (4.46) are coded with the necessary if branches to distinguish between the linear and the saturation region.
For UGS < UT no equation for calculating the current ID is defined in the Level 1 model. But it is not possible to reduce the data set a priori, because the decision which of the equations (4.45) and (4.46) has to be used depends on the optimization value VT varied by the optimizer. To suppress influence of data points for which no equation for ID is defined the measured id value is returned and the residuum for these points is zero.