ltspice

package module
v0.0.0-...-59b3d47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 12 Imported by: 0

README

ltspice-go

A Go-based parser for LTSpice raw binary data.

TODOs

  • Core Features

    • Parse LTSpice raw file metadata
    • Parse LTSpice raw file binary data
    • Write LTSpice raw file metadata
    • Write LTSpice raw file binary data
  • Additional Features

    • Handle complex values in binary data
    • Handle fast access data structure in binary data
    • Handle stepped simulations (extract stepping information from .log files)
  • Data Analysis and Utilities

    • Provide functions to manipulate parsed simulation data
      • Filter by variable
      • Filter by time range
    • Provide functions to export data to other formats (CSV, JSON, etc.)
    • Provide functions to generate plots
  • Simulations supported

    • Operation Point
    • DC transfer characteristic
    • AC Analysis
    • Transient Analysis
    • Transfer Function
    • Noise Spectral Density - (V/Hz½ or A/Hz½)
  • Documentation and Examples

    • Write comprehensive documentation
    • Provide usage examples
  • Testing and Validation

    • Unit tests
    • Test against a variety of LTSpice raw files
    • Validate correct parsing of binary data
    • Validate correct writing of binary data

Documentation

Index

Constants

View Source
const (
	HeaderBinary          = "binary:"
	HeaderValues          = "values:"
	HeaderTitle           = "Title"
	HeaderDate            = "Date"
	HeaderPlotName        = "Plotname"
	HeaderFlags           = "Flags"
	HeaderVariablesNumber = "No. Variables"
	HeaderPoints          = "No. Points"
	HeaderOffset          = "Offset"
	HeaderCommand         = "Command"
	HeaderVariables       = "Variables"
	HeaderBackannotation  = "Backannotation"
)

Variables

View Source
var (
	ErrInvalidSimulationType   = errors.New("invalid simulation type")
	ErrInvalidSimulationHeader = errors.New("invalid simulation header")
	ErrLineTooLong             = errors.New("line too long")
	ErrInvalidUTF16            = errors.New("invalid UTF-16 sequence")
	ErrUnexpectedNull          = errors.New("unexpected null character")
	ErrUnexpectedError         = errors.New("unexpected error")
	ErrUnexpectedEndOfFile     = errors.New("unexpected end of file")
)

Functions

This section is empty.

Types

type Flags

type Flags int
const (
	None Flags = 1 << iota
	Complex
	Forward
	Log
	Stepped
	FastAccess
)

func ParseFlags

func ParseFlags(flagStrings ...string) Flags

func (*Flags) ClearFlag

func (f *Flags) ClearFlag(flag Flags)

func (Flags) HasFlag

func (f Flags) HasFlag(flag Flags) bool

func (*Flags) SetFlag

func (f *Flags) SetFlag(flag Flags)

func (Flags) String

func (f Flags) String() string

type Simulation

type Simulation struct {
	Data        map[string][]float64
	ComplexData map[string][]complex128
	// contains filtered or unexported fields
}

func Parse

func Parse(fileName string) (*Simulation, error)

func (*Simulation) GetFlags

func (sim *Simulation) GetFlags() Flags

func (*Simulation) GetNumberOfDataPoints

func (sim *Simulation) GetNumberOfDataPoints() int

func (*Simulation) GetNumberOfVariables

func (sim *Simulation) GetNumberOfVariables() int

func (*Simulation) GetType

func (sim *Simulation) GetType() SimulationType

func (*Simulation) GetVariableNames

func (sim *Simulation) GetVariableNames() []string

func (*Simulation) GetVariables

func (sim *Simulation) GetVariables() []Trace

type SimulationMetadata

type SimulationMetadata struct {
	Title        string
	Date         time.Time
	SimType      SimulationType
	Flags        Flags
	NoVariables  int
	NoPoints     int
	Offset       float64
	Command      string
	Traces       []Trace
	BinaryOffset int
}

type SimulationType

type SimulationType int
const (
	OperatingPoint SimulationType = iota
	DCtransfer
	ACAnalysis
	TransientAnalysis
	NoiseSpectralDensity
	TransferFunction
)

func SimulationTypeFromString

func SimulationTypeFromString(str string) (SimulationType, error)

func (SimulationType) String

func (s SimulationType) String() string

type Trace

type Trace struct {
	Order int // the order of the variable as it appears in the binary dataframe
	Name  string
	Typ   string // the type of the variable (time, frequency, device_voltage etc..)
	Size  int    // the size of a signle data point in bytes
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL