-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from SpiceSharp/development
Development
- Loading branch information
Showing
80 changed files
with
2,190 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
src/SpiceSharpParser.IntegrationTests/AnalogBehavioralModeling/PolyTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using Xunit; | ||
|
||
namespace SpiceSharpParser.IntegrationTests | ||
{ | ||
public class PolyTests : BaseTests | ||
{ | ||
[Fact] | ||
public void VoltageControlledVoltageSourceFirstFormat() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) E test circuit - first format", | ||
"R1 1 0 100", | ||
"V1 1 0 2", | ||
"ESource 2 0 POLY(1) 1 0 2 1", // V(1) + 2 | ||
".OP", | ||
".SAVE V(2,0)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "V(2,0)"); | ||
Assert.Equal(4, export); | ||
} | ||
|
||
[Fact] | ||
public void VoltageControlledVoltageSourceSecondFormat() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) E test circuit - second format", | ||
"R1 1 0 100", | ||
"V1 1 0 2", | ||
"ESource 2 0 POLY(1) (1,0) 2 1", // V(1) + 2 | ||
".OP", | ||
".SAVE V(2,0)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "V(2,0)"); | ||
Assert.Equal(4, export); | ||
} | ||
|
||
[Fact] | ||
public void VoltageControlledVoltageSourceFirstFormatSecondDimension() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) E test circuit - first format", | ||
"R1 1 0 100", | ||
"V1 1 0 2", | ||
"V3 3 0 3", | ||
"ESource 2 0 POLY(2) 1 0 3 0 2 1 1", // V(1) + V(3) + 2 | ||
".OP", | ||
".SAVE V(2,0)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "V(2,0)"); | ||
Assert.Equal(7, export); | ||
} | ||
|
||
[Fact] | ||
public void VoltageControlledVoltageSourceSecondFormatSecondDimension() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) E test circuit - second format", | ||
"R1 1 0 100", | ||
"V1 1 0 2", | ||
"V3 3 0 3", | ||
"ESource 2 0 POLY(2) (1,0) (3,0) 2 1 1 ", // V(1) + V(3) + 2 | ||
".OP", | ||
".SAVE V(2,0)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "V(2,0)"); | ||
Assert.Equal(7, export); | ||
} | ||
|
||
[Fact] | ||
public void VoltageControlledCurrentSourceFirstFormat() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) G test circuit", | ||
"R1 1 0 100", | ||
"V1 2 0 2", | ||
"GSource 1 0 POLY(1) 2 0 2 1", // V(2) + 2 | ||
".OP", | ||
".SAVE I(GSource)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "I(GSource)"); | ||
Assert.Equal(4, export); | ||
} | ||
|
||
[Fact] | ||
public void VoltageControlledCurrentSourceSecondFormat() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) G test circuit", | ||
"R1 1 0 100", | ||
"V1 2 0 2", | ||
"GSource 1 0 POLY(1) (2,0) 2 1", // V(2) + 2 | ||
".OP", | ||
".SAVE I(GSource)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "I(GSource)"); | ||
Assert.Equal(4, export); | ||
} | ||
|
||
[Fact] | ||
public void CurrentControlledCurrentSource() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) F test circuit", | ||
"R1 1 0 100", | ||
"R2 1 0 200", | ||
"I1 1 0 2", | ||
"FSource 2 0 POLY(1) I1 2 1", // I(I1) + 2 | ||
".OP", | ||
".SAVE I(FSource)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "I(FSource)"); | ||
Assert.Equal(4, export); | ||
} | ||
|
||
[Fact] | ||
public void CurrentControlledVoltageSource() | ||
{ | ||
var netlist = ParseNetlist( | ||
"Poly(1) H test circuit", | ||
"R1 1 0 100", | ||
"I1 1 0 2", | ||
"HSource 2 0 POLY(1) I1 2 1", // I(I1) + 2 | ||
".OP", | ||
".SAVE V(2,0)", | ||
".END"); | ||
|
||
Assert.NotNull(netlist); | ||
double export = RunOpSimulation(netlist, "V(2,0)"); | ||
Assert.Equal(4, export); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
src/SpiceSharpParser.IntegrationTests/AnalogBehavioralModeling/TableTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Xunit; | ||
|
||
namespace SpiceSharpParser.IntegrationTests | ||
{ | ||
public class TableTests : BaseTests | ||
{ | ||
[Fact] | ||
public void ParsingFirstFormat() | ||
{ | ||
var netlist = ParseNetlist( | ||
"TABLE circuit", | ||
"V1 1 0 1.5m", | ||
"R1 1 0 10", | ||
"E12 2 1 TABLE {V(1,0)} = (0,1) (1m,2) (2m,3)", | ||
"R2 2 0 10", | ||
".SAVE V(2,1)", | ||
".OP", | ||
".END"); | ||
|
||
var export = RunOpSimulation(netlist, "V(2,1)"); | ||
Assert.NotNull(netlist); | ||
Assert.Equal(2.5, export); | ||
} | ||
|
||
[Fact] | ||
public void ParsingSecondFormat() | ||
{ | ||
var netlist = ParseNetlist( | ||
"TABLE circuit", | ||
"V1 1 0 1.5m", | ||
"R1 1 0 10", | ||
"E12 2 1 TABLE {V(1,0)} (0,1) (1m,2) (2m,3)", | ||
"R2 2 0 10", | ||
".SAVE V(2,1)", | ||
".OP", | ||
".END"); | ||
var export = RunOpSimulation(netlist, "V(2,1)"); | ||
Assert.NotNull(netlist); | ||
Assert.Equal(2.5, export); | ||
} | ||
|
||
[Fact] | ||
public void ParsingThirdFormat() | ||
{ | ||
var netlist = ParseNetlist( | ||
"TABLE circuit", | ||
"V1 1 0 1.5m", | ||
"R1 1 0 10", | ||
"E12 2 1 TABLE {V(1,0)} ((0,1) (1m,2) (2m,3))", | ||
"R2 2 0 10", | ||
".SAVE V(2,1)", | ||
".OP", | ||
".END"); | ||
var export = RunOpSimulation(netlist, "V(2,1)"); | ||
Assert.NotNull(netlist); | ||
Assert.Equal(2.5, export); | ||
} | ||
|
||
[Fact] | ||
public void ParsingAdvancedExpression() | ||
{ | ||
var netlist = ParseNetlist( | ||
"TABLE circuit", | ||
"V1 1 0 1.5", | ||
"V2 2 1 2.5", | ||
"R1 3 2 10", | ||
"R2 3 0 10", | ||
"E12 3 2 TABLE {9 + (V(1,0) + V(2,0))} ((-10,-10) (10, 10))", | ||
".SAVE V(3,2)", | ||
".OP", | ||
".END"); | ||
Assert.NotNull(netlist); | ||
var export = RunOpSimulation(netlist, "V(3,2)"); | ||
Assert.NotNull(netlist); | ||
Assert.Equal(10, export); | ||
} | ||
} | ||
} |
Oops, something went wrong.