コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: OP.cs プロジェクト: slicol/SpiceSharp
        /// <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);
        }
コード例 #3
0
ファイル: Truncating.cs プロジェクト: SpiceSharp/SpiceSharp
        /// <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();
                }
            }
        }
コード例 #4
0
        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
                }
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 /// <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);
 }