Tcl SpiceGenTcl package (v)

::SpiceGenTcl::Ngspice::SimulatorsTop, Main, Index

ClassesTop, Main, Index

Batch [::SpiceGenTcl::Ngspice::Simulators]Top, Main, Index

Method summary
constructorConstructor for the class.
clearLogClear saved log by unsetting Log variable.
configureConfigure properties.
getLogSee ::SpiceGenTcl::Simulator.getLog
readDataReads raw data file, create RawFile object and return it's reference name.
readLogReads log file of last simulation and save it's content to Log variable.
runSee ::SpiceGenTcl::Simulator.run
runAndReadRuns netlist circuit file.
Properties

Readable: -Command, -Data, -LastRunFileName, -Log, -Name, -Path, -RunLocation

Writable: -Command, -Data, -LastRunFileName, -Log, -Name, -Path, -RunLocation

Superclasses

::SpiceGenTcl::Simulator

Subclasses

BatchLiveLog

constructor [::SpiceGenTcl::Ngspice::Simulators::Batch]Batch, Top, Main, Index

Creates batch ngspice simulator that can be attached to top-level Circuit.

Batch create OBJNAME name path ?runLocation?
Batch new name path ?runLocation?
Parameters
nameName of simulator object.
pathPath of ngspice executable file.
runLocationLocation at which input netlist is stored and all output files will be saved, default is system temporary folder at Linux system. Optional, default /tmp.
method constructor {name path {runLocation /tmp}} {

    # Creates batch ngspice simulator that can be attached to top-level Circuit.
    #  name - name of simulator object
    #  path - path of ngspice executable file
    #  runLocation - location at which input netlist is stored and all output files will be saved,
    #   default is system temporary folder at Linux system
    my configure -Name $name
    my configure -Path $path
    my configure -Command ngspice
    my configure -RunLocation $runLocation
}

clearLog [::SpiceGenTcl::Ngspice::Simulators::Batch]Batch, Top, Main, Index

Clear saved log by unsetting Log variable.

OBJECT clearLog
method clearLog {} {

    # Clear saved log by unsetting Log variable.
    if {[info exists Log]} {
        unset Log
        return
    } else {
        error "Log does not exists for simulator '[my configure -Name]'"
    }
}

readData [::SpiceGenTcl::Ngspice::Simulators::Batch]Batch, Top, Main, Index

Reads raw data file, create RawFile object and return it's reference name.

OBJECT readData
method readData {} {

    # Reads raw data file, create RawFile object and return it's reference name.
    my variable Data
    set Data [::SpiceGenTcl::RawFile new "[my configure -RunLocation]/[my configure -LastRunFileName].raw"]
    return
}

readLog [::SpiceGenTcl::Ngspice::Simulators::Batch]Batch, Top, Main, Index

Reads log file of last simulation and save it's content to Log variable.

OBJECT readLog
method readLog {} {

    # Reads log file of last simulation and save it's content to Log variable.
    set logFile [open "[my configure -RunLocation]/[my configure -LastRunFileName].log" r+]
    set Log [read $logFile]
    close $logFile
    return
}

runAndRead [::SpiceGenTcl::Ngspice::Simulators::Batch]Batch, Top, Main, Index

Runs netlist circuit file.

OBJECT runAndRead circuitStr
Parameters
circuitStrTop-level netlist string.
method runAndRead {circuitStr} {

    # Runs netlist circuit file.
    #  circuitStr - top-level netlist string
    set firstLine [lindex [split $circuitStr \n] 0]
    set runLocation [my configure -RunLocation]
    set cirFile [open "${runLocation}/${firstLine}.cir" w+]
    puts $cirFile $circuitStr
    close $cirFile
    set rawFileName "${runLocation}/${firstLine}.raw"
    set logFileName "${runLocation}/${firstLine}.log"
    set cirFileName "${runLocation}/${firstLine}.cir"
    exec "[my configure -Command]" -b -r $rawFileName -o $logFileName $cirFileName
    my configure -LastRunFileName ${firstLine}
    my readLog
    my readData
}

BatchLiveLog [::SpiceGenTcl::Ngspice::Simulators]Top, Main, Index

Method summary
clearLogSee Batch.clearLog
configureConfigure properties.
getLogSee ::SpiceGenTcl::Simulator.getLog
readDataSee Batch.readData
readLogSee Batch.readLog
runSee ::SpiceGenTcl::Simulator.run
runAndReadRuns netlist circuit file.
Properties

Readable: -Command, -Data, -LastRunFileName, -Log, -Name, -Path, -RunLocation

Writable: -Command, -Data, -LastRunFileName, -Log, -Name, -Path, -RunLocation

Superclasses

Batch

runAndRead [::SpiceGenTcl::Ngspice::Simulators::BatchLiveLog]BatchLiveLog, Top, Main, Index

Runs netlist circuit file.

OBJECT runAndRead circuitStr
Parameters
circuitStrTop-level netlist string.
method runAndRead {circuitStr} {

    # Runs netlist circuit file.
    #  circuitStr - top-level netlist string
    set firstLine [lindex [split $circuitStr \n] 0]
    set runLocation [my configure -RunLocation]
    set cirFile [open "${runLocation}/${firstLine}.cir" w+]
    puts $cirFile $circuitStr
    close $cirFile
    set rawFileName "${runLocation}/${firstLine}.raw"
    set logFileName "${runLocation}/${firstLine}.log"
    set cirFileName "${runLocation}/${firstLine}.cir"
    set command [list [my configure -Command] -b $cirFileName -r $rawFileName]
    set chan [open "|$command 2>@1"]
    set logData ""
    while {[gets $chan line] >= 0} {
        puts $line
        set logData [join [list $logData $line] \n]
        if {[eof $chan]} {
            close $chan
        }
    }
    close $chan
    my configure -LastRunFileName ${firstLine}
    my configure -Log $logData
    my readData
}