/// <summary> /// Executes the simulation. /// </summary> protected override void Execute() { base.Execute(); // Setup the state var state = RealState; state.UseIc = false; // UseIC is only used in transient simulations state.UseDc = true; Op(DcMaxIterations); var exportargs = new ExportDataEventArgs(this); OnExport(exportargs); }
/// <summary> /// Execute the DC simulation /// </summary> protected override void Execute() { base.Execute(); // Setup the state var state = RealState; var baseconfig = BaseConfiguration; state.UseIc = false; // UseIC is only used in transient simulations state.UseDc = true; state.Domain = RealState.DomainType.None; state.Gmin = baseconfig.Gmin; Op(baseconfig.DcMaxIterations); var exportargs = new ExportDataEventArgs(this); Export(exportargs); }
/// <summary> /// The method that is called whenever the simulation is ready to export data. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The arguments.</param> private void OnExportSimulationData(object sender, ExportDataEventArgs args) { // Nothing left... if (!_continue) { return; } // If time has caught up with the currently targeted point, let's export it ourselves! if (_method.Time > _points.Current - _parameters.MinDelta) { // Pass it through _parameters.Export(sender, args); // Find the next point that is eligible for targetting while (_continue && _points.Current < _method.Time + _parameters.MinDelta) { _continue = _points.MoveNext(); } } }
private void CreatePointForSeries(Simulation simulation, ICircuitContext context, ExportDataEventArgs eventArgs, List <Export> exports, List <Series> series) { double x = 0; if (simulation is Transient) { x = eventArgs.Time; } if (simulation is AC) { x = eventArgs.Frequency; } if (simulation is DC dc) { if (eventArgs.GetSweepValues().Length > 1) { // TODO: Add support for DC Sweeps > 1 context.Result.Validation.Add( new ValidationEntry( ValidationEntrySource.Reader, ValidationEntryLevel.Warning, ".PLOT doesn't support sweep count > 1")); return; } x = eventArgs.GetSweepValues().FirstOrDefault(); } for (var i = 0; i < exports.Count; i++) { try { double val = exports[i].Extract(); if (!double.IsNaN(val)) { series[i].Points.Add(new Point { X = x, Y = val }); } } catch (Exception) { // ignore exception } } }
private static void CreateRowInPrint(ref int rowIndex, Simulation simulation, ICircuitContext context, ExportDataEventArgs eventArgs, List <Export> exports, Print print) { Row row = new Row(rowIndex++); double x = 0; if (simulation is Transient) { x = eventArgs.Time; } if (simulation is AC) { x = eventArgs.Frequency; } if (simulation is DC dc) { if (dc.Sweeps.Count > 1) { // TODO: Add support for DC Sweeps > 1 context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, ".PRINT doesn't support sweep count > 1")); return; } x = eventArgs.SweepValue; } if (!(simulation is OP)) { row.Columns.Add(x); } for (var i = 0; i < exports.Count; i++) { try { double val = exports[i].Extract(); row.Columns.Add(val); } catch (Exception) { row.Columns.Add(double.NaN); } } print.Rows.Add(row); }
/// <summary> /// Calls the <see cref="ExportSimulationData"/> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The argument.</param> public void Export(object sender, ExportDataEventArgs args) { ExportSimulationData?.Invoke(sender, args); }