Spice# is a cross-platform electronic circuit simulator based on Berkeley Spice - the mother of commercial industry-standard circuit simulators.
Spice# is a Spice circuit simulator written in C#. The framework is made to be compatible with the original Berkeley Spice simulator, but bugs have been squashed and features can and will probably will be added.
You can find documentation at https://spicesharp.github.io/SpiceSharp/. There you can find a guide for getting started, as well as more information about:
Simulating a circuit is relatively straightforward. For example:
using System;
using SpiceSharp;
using SpiceSharp.Components;
using SpiceSharp.Simulations;
namespace SpiceSimulation
{
class Program
{
static void Main(string[] args)
{
// Build the circuit
var ckt = new Circuit(
new VoltageSource("V1", "in", "0", 0.0),
new Resistor("R1", "in", "out", 1.0e3),
new Resistor("R2", "out", "0", 2.0e3)
);
// Create a DC sweep and register to the event for exporting simulation data
var dc = new DC("dc", "V1", 0.0, 5.0, 0.001);
dc.ExportSimulationData += (sender, exportDataEventArgs) =>
{
Console.WriteLine(exportDataEventArgs.GetVoltage("out"));
};
// Run the simulation
dc.Run(ckt);
}
}
}
Most standard Spice-components are available, and building your own custom components is also possible!
Spice# is available as a NuGet Package.
Status | |
---|---|
Windows | |
MacOS | |
Linux/Ubuntu |
Spice# aims to be:
Having been implemented in the .NET framework does have some limitations: