SENS Script | SENS Script With Comments

SENS, sensitivity analysis Simulation Template:

#tolerance
#nosave
#noprint
#vector
set rewind
set noecho
#simulation
set printmode = save
#mprint
nameplot ref
SET COLWIDTH=22
SET SPICEDIGITS=5
printstatus -t ########_sensitivity_for_each_parameter_########
nextparam null
while param <> null
    alterparam tolerance(param)/3
    #simulation
    paramvec = param
    printstatus -p paramvec
    #mprint
    nv = nextvector(null)
    while nv <> null
        if length(nv) = 1
           nv = nv - ref.nv
        end
        nv = nextvector(nv)
    end
    unalterparam
    nextparam
end
set printmode = print
unset noecho
pl = nextplot(null)
while pl <> null
    if sameplot(ref.default) = 0
       nv = nextvector(null)
       while nv <> null
          if length(nv) = 1
             if ref.nv <> 0
                 nv = (300*NV)/REF.NV
              else
                 nv = 3*NV
              end
            end
            nv = nextvector(nv)
        end
    end
    pl = nextplot(pl)
end

printstatus -t ########sorting_sensitivity_for_each_parameter_########
printstatus -t
setplot ref
sort -vd
pl = nextplot(null)
while pl <> null
   if sameplot(ref.default) = 0
      SETPARAM PARAMVEC
      printstatus -p paramvec
      ECHO
      ECHO -u "**********SENSITIVITY DATA**********"
      ECHO
      ECHO -un "PARAMETER NAME: "
      PRINTNAME PARAMVEC
      ECHO
      ECHO -un " NOMINAL VALUE: "
      PRINTVAL  PARAMVEC
      ECHO
      ECHO
      PRINTTEXT -u VECTOR SENSITIVITY%
      ECHO
      ECHO
      sort -vd
      nv = nextvector(null)
      while nv <> null
         if length(nv) = 1
             if ref.nv <> 0
                 PRINTNAME NV
                 PRINTVAL NV
             else
                 PRINTNAME NV
                 PRINTVAL NV
                 ECHO -n *
             end
             ECHO
          end
           nv = nextvector(nv)
      end
    end
    pl = nextplot(pl)
end
ECHO
ECHO
setplot ref
echo ########## SENSITIVITY analysis Results #############
#mprint

SENS, sensitivity analysis Simulation Template With Comments:

*Instruct the netlist builder to show tolerances
#tolerance

*Suppress automatic vector saves
#nosave

*Suppress IsSpice4 printout
#noprint

*Save vectors needed for measurements
#vector

*Set the output file pointer to the beginning to remove
* the input net list
set rewind

*Set the  noecho environment for print formatting
set noecho

*Run the specified simulation and save the results
#simulation
set printmode = save
#mprint

*Rename the simulation plot
nameplot ref

*Set the print format
SET COLWIDTH=22
SET SPICEDIGITS=5

*Tell the user where we are
printstatus -t ########_sensitivity_for_each_parameter_########

*Loop through all of the parameters
nextparam null
while param <> null
    *Alter each parameter
    alterparam tolerance(param)/3
    *Simulate
    #simulation
    Save the parameter reference in the new plot
    paramvec = param
    *Tell the user where we are
    printstatus -p paramvec
    *Save the data
    #mprint
    *Loop through the vectors
    nv = nextvector(null)
    while nv <> null
        *Save the sensitivities of scalar data
        if length(nv) = 1
           nv = nv - ref.nv
        end;  end if
                 *Get the next vector
        nv = nextvector(nv)
    end ; end vector loop
         *Restore the parameter
    unalterparam
    *Get the next parameter
    nextparam
end; end parameter loop
*Set print mode for printing output data
set printmode = print
unset noecho
*Loop through the plots
pl = nextplot(null)
while pl <> null
    if sameplot(ref.default) = 0
       *Loop through the vectors
       nv = nextvector(null)
       while nv <> null
          if length(nv) = 1
             *Save the sensitivities
             if ref.nv <> 0
                 nv = (300*NV)/REF.NV
              else
                 nv = 3*NV
              end ; end if
            end ; end if
            nv = nextvector(nv)
        end ; end vector loop
    end; end if
        *Get next plot
    pl = nextplot(pl)
end ; end plot loop
*Tell the user what's going on
printstatus -t ########sorting_sensitivity_for_each_parameter_########
printstatus -t
*Make ref the current plot
setplot ref
*Sort by descending value
sort -vd
*Loop through the plots
pl = nextplot(null)
while pl <> null
   if sameplot(ref.default) = 0
            *Print Headers
      SETPARAM PARAMVEC
      printstatus -p paramvec
      ECHO
      ECHO -u "**********SENSITIVITY DATA**********"
      ECHO
      ECHO -un "PARAMETER NAME: "
      PRINTNAME PARAMVEC
      ECHO
      ECHO -un " NOMINAL VALUE: "
      PRINTVAL  PARAMVEC
      ECHO
      ECHO
      PRINTTEXT -u VECTOR SENSITIVITY%
      ECHO
      ECHO
            *Sort by descending data value
      sort -vd
     *Loop through the vectors and print data
      nv = nextvector(null)
      while nv <> null
         if length(nv) = 1
             if ref.nv <> 0
                 PRINTNAME NV
                 PRINTVAL NV
             else
                 PRINTNAME NV
                 PRINTVAL NV
                 ECHO -n *
             end ; end if
             ECHO
          end ; end if
                      *Get next vector
          nv = nextvector(nv)
      end; end vector loop
    end ; end if
        *Get next plot
    pl = nextplot(pl)
end; end plot loop
ECHO
ECHO
*Print data in output file for SpiceNet to read
setplot ref
echo ########## SENSITIVITY analysis Results #############
#mprint