diff --git a/Circuit/Simulation/Simulation.cs b/Circuit/Simulation/Simulation.cs
index 44b9c5f5..a35fd73d 100644
--- a/Circuit/Simulation/Simulation.cs
+++ b/Circuit/Simulation/Simulation.cs
@@ -69,18 +69,12 @@ public TransientSolution Solution
set { solution = value; InvalidateProcess(); }
}
- private int oversample = 8;
+ private int oversample = 2;
///
/// Oversampling factor for this simulation.
///
public int Oversample { get { return oversample; } set { oversample = value; InvalidateProcess(); } }
- private int iterations = 8;
- ///
- /// Maximum number of iterations allowed for the simulation to converge.
- ///
- public int Iterations { get { return iterations; } set { iterations = value; InvalidateProcess(); } }
-
///
/// The sampling rate of this simulation, the sampling rate of the transient solution divided by the oversampling factor.
///
@@ -313,7 +307,12 @@ private Action DefineProcess()
code.DeclInit(i.Left, i.Right);
// int it = iterations
- LinqExpr it = code.ReDeclInit("it", Iterations);
+ // This used to be a parameter, defaulted to 8. Experiments seem to show that
+ // it basically never makes sense to stop iterating at a limit. This sort of
+ // makes sense, because stopping iteration early suggests that the initial guess
+ // for the next sample will be worse. So, we're just going to use a very large
+ // number of iterations just to avoid getting stuck forever.
+ LinqExpr it = code.ReDeclInit("it", 128);
// do { ... --it } while(it > 0)
code.DoWhile((Break) =>
{
diff --git a/LiveSPICE/LiveSimulation.xaml b/LiveSPICE/LiveSimulation.xaml
index 066334a0..5ce3df49 100644
--- a/LiveSPICE/LiveSimulation.xaml
+++ b/LiveSPICE/LiveSimulation.xaml
@@ -91,9 +91,6 @@
16
-
-
-
diff --git a/LiveSPICE/LiveSimulation.xaml.cs b/LiveSPICE/LiveSimulation.xaml.cs
index c2231fb1..1efa19a9 100644
--- a/LiveSPICE/LiveSimulation.xaml.cs
+++ b/LiveSPICE/LiveSimulation.xaml.cs
@@ -27,7 +27,7 @@ partial class LiveSimulation : Window, INotifyPropertyChanged
public Log Log { get { return (Log)log.Content; } }
public Scope Scope { get { return (Scope)scope.Content; } }
- protected int oversample = 8;
+ protected int oversample = 2;
///
/// Simulation oversampling rate.
///
@@ -37,16 +37,6 @@ public int Oversample
set { oversample = Math.Max(1, value); RebuildSolution(); NotifyChanged(nameof(Oversample)); }
}
- protected int iterations = 8;
- ///
- /// Max iterations for numerical algorithms.
- ///
- public int Iterations
- {
- get { return iterations; }
- set { iterations = Math.Max(1, value); RebuildSolution(); NotifyChanged(nameof(Iterations)); }
- }
-
private double inputGain = 1.0;
///
/// Overall input gain.
@@ -304,7 +294,6 @@ private void RebuildSolution()
Input = inputs.Keys.ToArray(),
Output = probes.Select(i => i.V).Concat(OutputChannels.Select(i => i.Signal)).ToArray(),
Oversample = Oversample,
- Iterations = Iterations,
};
}
catch (Exception Ex)
@@ -337,7 +326,6 @@ private void UpdateSimulation(bool Rebuild)
Input = inputs.Keys.ToArray(),
Output = probes.Select(i => i.V).Concat(OutputChannels.Select(i => i.Signal)).ToArray(),
Oversample = Oversample,
- Iterations = Iterations,
};
}
else
diff --git a/LiveSPICEVst/EditorView.xaml b/LiveSPICEVst/EditorView.xaml
index 7ee0fbf7..d9f9b54f 100644
--- a/LiveSPICEVst/EditorView.xaml
+++ b/LiveSPICEVst/EditorView.xaml
@@ -37,16 +37,6 @@
4
8
- Iterations:
-
- 1
- 2
- 4
- 8
- 16
- 32
- 64
-
diff --git a/LiveSPICEVst/EditorView.xaml.cs b/LiveSPICEVst/EditorView.xaml.cs
index aa13b7fb..692f2f41 100644
--- a/LiveSPICEVst/EditorView.xaml.cs
+++ b/LiveSPICEVst/EditorView.xaml.cs
@@ -45,16 +45,6 @@ public void UpdateSchematic()
break;
}
}
-
- for (int i = 0; i < IterationsComboBox.Items.Count; i++)
- {
- if (int.Parse((IterationsComboBox.Items[i] as ComboBoxItem).Content as string) == Plugin.SimulationProcessor.Iterations)
- {
- IterationsComboBox.SelectedIndex = i;
-
- break;
- }
- }
}
private void OversampleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -64,13 +54,6 @@ private void OversampleComboBox_SelectionChanged(object sender, SelectionChanged
Plugin.SimulationProcessor.Oversample = int.Parse((combo.SelectedItem as ComboBoxItem).Content as string);
}
- private void IterationsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- ComboBox combo = sender as ComboBox;
-
- Plugin.SimulationProcessor.Iterations = int.Parse((combo.SelectedItem as ComboBoxItem).Content as string);
- }
-
private void LoadCircuitButton_Click(object sender, RoutedEventArgs e)
{
string examples =
diff --git a/LiveSPICEVst/LiveSPICEPlugin.cs b/LiveSPICEVst/LiveSPICEPlugin.cs
index b7d4bd22..123981da 100644
--- a/LiveSPICEVst/LiveSPICEPlugin.cs
+++ b/LiveSPICEVst/LiveSPICEPlugin.cs
@@ -83,7 +83,6 @@ public override byte[] SaveState()
{
SchematicPath = SimulationProcessor.SchematicPath,
OverSample = SimulationProcessor.Oversample,
- Iterations = SimulationProcessor.Iterations
};
foreach (var wrapper in SimulationProcessor.InteractiveComponents)
@@ -142,7 +141,6 @@ public override void RestoreState(byte[] stateData)
}
SimulationProcessor.Oversample = programParameters.OverSample;
- SimulationProcessor.Iterations = programParameters.Iterations;
foreach (VSTProgramControlParameter controlParameter in programParameters.ControlParameters)
{
diff --git a/LiveSPICEVst/SimulationProcessor.cs b/LiveSPICEVst/SimulationProcessor.cs
index 03d56442..99e5b138 100644
--- a/LiveSPICEVst/SimulationProcessor.cs
+++ b/LiveSPICEVst/SimulationProcessor.cs
@@ -53,23 +53,9 @@ public int Oversample
}
}
- public int Iterations
- {
- get { return iterations; }
- set
- {
- if (iterations != value)
- {
- iterations = value;
-
- needRebuild = true;
- }
- }
- }
double sampleRate;
int oversample = 2;
- int iterations = 8;
Circuit.Circuit circuit = null;
Simulation simulation = null;
@@ -308,7 +294,6 @@ void UpdateSimulation(bool rebuild)
simulation = new Simulation(ts)
{
Oversample = oversample,
- Iterations = iterations,
Input = new[] { inputExpression },
Output = new[] { outputExpression }
};
diff --git a/LiveSPICEVst/VstProgramParameters.cs b/LiveSPICEVst/VstProgramParameters.cs
index f6633176..d1847d5c 100644
--- a/LiveSPICEVst/VstProgramParameters.cs
+++ b/LiveSPICEVst/VstProgramParameters.cs
@@ -9,13 +9,11 @@ public class VstProgramParameters
{
public string SchematicPath { get; set; }
public int OverSample { get; set; }
- public int Iterations { get; set; }
public List ControlParameters { get; set; }
public VstProgramParameters()
{
OverSample = 2;
- Iterations = 8;
ControlParameters = new List();
}
diff --git a/Tests/Program.cs b/Tests/Program.cs
index 78fe1daf..76c85b76 100644
--- a/Tests/Program.cs
+++ b/Tests/Program.cs
@@ -18,25 +18,24 @@ static async Task Main(string[] args)
.WithArgument("pattern", "Glob pattern for files to test")
.WithOption(new[] { "--plot" }, "Plot results")
.WithOption(new[] { "--samples" }, () => 4800, "Samples")
- .WithHandler(CommandHandler.Create(Test)))
+ .WithHandler(CommandHandler.Create(Test)))
.WithCommand("benchmark", "Run benchmarks", c => c
.WithArgument("pattern", "Glob pattern for files to benchmark")
- .WithHandler(CommandHandler.Create(Benchmark)))
+ .WithHandler(CommandHandler.Create(Benchmark)))
.WithGlobalOption(new Option("--sampleRate", () => 48000, "Sample Rate"))
- .WithGlobalOption(new Option("--oversample", () => 8, "Oversample"))
- .WithGlobalOption(new Option("--iterations", () => 8, "Iterations"));
+ .WithGlobalOption(new Option("--oversample", () => 4, "Oversample"));
return await rootCommand.InvokeAsync(args);
}
- public static void Test(string pattern, bool plot, int sampleRate, int samples, int oversample, int iterations)
+ public static void Test(string pattern, bool plot, int sampleRate, int samples, int oversample)
{
var log = new ConsoleLog() { Verbosity = MessageType.Info };
var tester = new Test();
foreach (var circuit in GetCircuits(pattern, log))
{
- var outputs = tester.Run(circuit, t => Harmonics(t, 0.5, 82, 2), sampleRate, samples, oversample, iterations);
+ var outputs = tester.Run(circuit, t => Harmonics(t, 0.5, 82, 2), sampleRate, samples, oversample);
if (plot)
{
tester.PlotAll(circuit.Name, outputs);
@@ -44,7 +43,7 @@ public static void Test(string pattern, bool plot, int sampleRate, int samples,
}
}
- public static void Benchmark(string pattern, int sampleRate, int oversample, int iterations)
+ public static void Benchmark(string pattern, int sampleRate, int oversample)
{
var log = new ConsoleLog() { Verbosity = MessageType.Error };
var tester = new Test();
@@ -52,7 +51,7 @@ public static void Benchmark(string pattern, int sampleRate, int oversample, int
System.Console.WriteLine(fmt, "Circuit", "Analysis (ms)", "Solve (ms)", "Sim (kHz)", "Realtime x");
foreach (var circuit in GetCircuits(pattern, log))
{
- double[] result = tester.Benchmark(circuit, t => Harmonics(t, 0.5, 82, 2), sampleRate, oversample, iterations, log: log);
+ double[] result = tester.Benchmark(circuit, t => Harmonics(t, 0.5, 820, 2), sampleRate, oversample, log: log);
double analyzeTime = result[0];
double solveTime = result[1];
double simRate = result[2];
diff --git a/Tests/Test.cs b/Tests/Test.cs
index f66ad353..1f55ed12 100644
--- a/Tests/Test.cs
+++ b/Tests/Test.cs
@@ -39,7 +39,6 @@ public Dictionary> Run(
int SampleRate,
int Samples,
int Oversample,
- int Iterations,
Expression? Input = null,
IEnumerable? Outputs = null)
{
@@ -62,7 +61,6 @@ public Dictionary> Run(
Simulation S = new Simulation(TS)
{
Oversample = Oversample,
- Iterations = Iterations,
Input = new[] { Input },
Output = Outputs,
};
@@ -104,7 +102,6 @@ public double[] Benchmark(
Func Vin,
int SampleRate,
int Oversample,
- int Iterations,
Expression? Input = null,
IEnumerable? Outputs = null,
ILog? log = null)
@@ -131,7 +128,6 @@ public double[] Benchmark(
Simulation S = new Simulation(TS)
{
Oversample = Oversample,
- Iterations = Iterations,
Input = new[] { Input },
Output = Outputs,
};