예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpiceInstance"/> class.
 /// </summary>
 /// <param name="parameters">The method description.</param>
 /// <param name="state">The biasing simulation state.</param>
 /// <param name="maxOrder">The maximum order.</param>
 protected SpiceInstance(SpiceMethod parameters, IBiasingSimulationState state, int maxOrder)
 {
     Parameters = parameters.ThrowIfNull(nameof(parameters));
     State      = state.ThrowIfNull(nameof(state));
     MaxOrder   = maxOrder;
     States     = new NodeHistory <SpiceIntegrationState>(maxOrder + 2);
 }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConvergenceAid"/> class.
        /// </summary>
        /// <param name="variable">The variable.</param>
        /// <param name="state">The biasing simulation state.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="variable"/> or <paramref name="state"/> is <c>null</c>.</exception>
        /// <exception cref="SpiceSharpException">Thrown if the variable for the convergence aid was not found.</exception>
        public ConvergenceAid(IVariable variable, IBiasingSimulationState state, double value)
        {
            Variable = variable.ThrowIfNull(nameof(variable));
            Value    = value;

            _state = state.ThrowIfNull(nameof(state));
            if (!state.Map.Contains(variable))
            {
                throw new SpiceSharpException(Properties.Resources.Simulations_ConvergenceAidVariableNotFound.FormatString(variable.Name));
            }
            _index    = state.Map[variable];
            _diagonal = _state.Solver.GetElement(new MatrixLocation(_index, _index));
            _rhs      = !Value.Equals(0.0) ? _state.Solver.GetElement(_index) : _state.Solver.FindElement(_index);
            _state.Solution[_index] = Value;
        }