/// <summary> /// Set up the simulation. /// </summary> /// <param name="entities">The circuit that will be used.</param> /// <exception cref="ArgumentNullException">circuit</exception> /// <exception cref="SpiceSharp.CircuitException"> /// No frequency configuration found /// or /// No frequency sweep found /// </exception> protected override void Setup(EntityCollection entities) { entities.ThrowIfNull(nameof(entities)); base.Setup(entities); // Get behaviors, configurations and states var config = Configurations.Get <FrequencyConfiguration>(); _frequencyBehaviors = EntityBehaviors.GetBehaviorList <IFrequencyBehavior>(); FrequencySweep = config.FrequencySweep.ThrowIfNull("frequency sweep"); // Create the state for complex numbers ComplexState = new ComplexSimulationState(); _loadStateEventArgs = new LoadStateEventArgs(ComplexState); var strategy = ComplexState.Solver.Strategy; strategy.RelativePivotThreshold = config.RelativePivotThreshold; strategy.AbsolutePivotThreshold = config.AbsolutePivotThreshold; // Setup behaviors var solver = ComplexState.Solver; for (var i = 0; i < _frequencyBehaviors.Count; i++) { _frequencyBehaviors[i].GetEquationPointers(solver); } ComplexState.Setup(Variables); }
/// <summary> /// Set up the simulation. /// </summary> /// <param name="entities">The circuit that will be used.</param> protected override void Setup(EntityCollection entities) { entities.ThrowIfNull(nameof(entities)); // Get behaviors, configurations and states var config = Configurations.Get <FrequencyConfiguration>(); FrequencySweep = config.FrequencySweep.ThrowIfNull("frequency sweep"); // Create the state for complex numbers ComplexState = new ComplexSimulationState(); var strategy = ComplexState.Solver.Strategy; strategy.RelativePivotThreshold = config.RelativePivotThreshold; strategy.AbsolutePivotThreshold = config.AbsolutePivotThreshold; // Setup the rest of the behaviors base.Setup(entities); // Cache local variables _frequencyBehaviors = EntityBehaviors.GetBehaviorList <IFrequencyBehavior>(); _loadStateEventArgs = new LoadStateEventArgs(ComplexState); ComplexState.Setup(Variables); }
/// <summary> /// Set up the simulation. /// </summary> /// <param name="circuit">The circuit that will be used.</param> /// <exception cref="ArgumentNullException">circuit</exception> /// <exception cref="SpiceSharp.CircuitException"> /// No frequency configuration found /// or /// No frequency sweep found /// </exception> protected override void Setup(Circuit circuit) { if (circuit == null) { throw new ArgumentNullException(nameof(circuit)); } base.Setup(circuit); // Get behaviors, configurations and states var config = Configurations.Get <FrequencyConfiguration>(); FrequencySweep = config.FrequencySweep ?? throw new CircuitException("No frequency sweep found"); // Create the state for complex numbers ComplexState = new ComplexSimulationState(); _loadStateEventArgs = new LoadStateEventArgs(ComplexState); var strategy = ComplexState.Solver.Strategy; strategy.RelativePivotThreshold = config.RelativePivotThreshold; strategy.AbsolutePivotThreshold = config.AbsolutePivotThreshold; // Setup behaviors _frequencyBehaviors = SetupBehaviors <BaseFrequencyBehavior>(circuit.Entities); var solver = ComplexState.Solver; for (var i = 0; i < _frequencyBehaviors.Count; i++) { _frequencyBehaviors[i].GetEquationPointers(solver); } ComplexState.Setup(Variables); }
/// <inheritdoc /> protected override void CreateStates() { base.CreateStates(); _state = new ComplexSimulationState(FrequencyParameters.CreateSolver(), BiasingParameters.NodeComparer); _loadStateEventArgs = new LoadStateEventArgs(_state); }