示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(IComponentBindingContext context) : base(context)
        {
            var state = context.GetState <IComplexSimulationState>();

            _variables = new OnePort <Complex>(state, context);
            _elements  = new ElementSet <Complex>(state.Solver, _variables.GetMatrixLocations(state.Map));
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Frequency"/> class.
 /// </summary>
 /// <param name="context">The binding context.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
 public Frequency(IComponentBindingContext context)
     : base(context)
 {
     _complex   = context.GetState <IComplexSimulationState>();
     _variables = new OnePort <Complex>(_complex, context);
     _elements  = new ElementSet <Complex>(_complex.Solver, null, _variables.GetRhsIndices(_complex.Map));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="FrequencyBehavior"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public FrequencyBehavior(BehavioralBindingContext context)
            : base(context)
        {
            var bp = context.GetParameterSet<Parameters>();
            var state = context.GetState<IComplexSimulationState>();
            _variables = new OnePort<Complex>(
                state.GetSharedVariable(context.Nodes[0]),
                state.GetSharedVariable(context.Nodes[1]));

            // Build the functions
            var derivatives = new List<Func<Complex>>(Derivatives.Count);
            var builder = new ComplexFunctionBuilder();
            builder.VariableFound += (sender, args) =>
            {
                if (args.Variable == null && DerivativeVariables.TryGetValue(args.Node, out var variable))
                    args.Variable = new FuncVariable<Complex>(variable.Name, () => variable.Value, variable.Unit);
            };
            bp.RegisterBuilder(context, builder);
            var rhsLocs = _variables.GetRhsIndices(state.Map);
            var matLocs = new List<MatrixLocation>(Derivatives.Count * 2);
            foreach (var pair in Derivatives)
            {
                var variable = context.MapNode(state, pair.Key);
                if (state.Map.Contains(variable))
                {
                    derivatives.Add(builder.Build(pair.Value));
                    matLocs.Add(new MatrixLocation(rhsLocs[0], state.Map[variable]));
                    matLocs.Add(new MatrixLocation(rhsLocs[1], state.Map[variable]));
                }
            }

            // Get the matrix elements
            _derivatives = derivatives.ToArray();
            _elements = new ElementSet<Complex>(state.Solver, matLocs.ToArray());
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BiasingBehavior"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public BiasingBehavior(BehavioralBindingContext context)
            : base(context)
        {
            // Make sure that we have access to the voltage over the behavior
            var bp    = context.GetParameterSet <Parameters>();
            var state = context.GetState <IBiasingSimulationState>();

            Variables = new OnePort <double>(
                state.GetSharedVariable(context.Nodes[0]),
                state.GetSharedVariable(context.Nodes[1]));

            // Create the derivatives, while also giving access to the voltage across the capacitor
            var replacer = new NodeReplacer
            {
                Map = new Dictionary <VariableNode, Node>(new VariableNodeComparer(null, null, bp.VariableComparer))
                {
                    { Node.Variable("x"), Node.Voltage(context.Nodes[0]) - Node.Voltage(context.Nodes[1]) }
                }
            };

            Function            = replacer.Build(bp.Function);
            Derivatives         = context.CreateDerivatives(Function);
            DerivativeVariables = new Dictionary <VariableNode, IVariable <double> >(Derivatives.Comparer);
            foreach (var key in Derivatives.Keys)
            {
                DerivativeVariables.Add(key, context.MapNode(state, key));
            }
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Frequency"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
 public Frequency(IComponentBindingContext context)
     : base(context)
 {
     context.Nodes.CheckNodes(2);
     _complex   = context.GetState <IComplexSimulationState>();
     _variables = new OnePort <Complex>(_complex, context);
     _elements  = new ElementSet <Complex>(_complex.Solver, _variables.GetMatrixLocations(_complex.Map));
 }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(IComponentBindingContext context) : base(context)
        {
            context.Nodes.CheckNodes(2);
            var state = context.GetState <IBiasingSimulationState>();

            _variables = new OnePort <double>(state, context);
            _elements  = new ElementSet <double>(state.Solver, _variables.GetMatrixLocations(state.Map));
        }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(ISwitchBindingContext context)
            : base(context)
        {
            var state = context.GetState <IComplexSimulationState>();

            _variables = new OnePort <Complex>(state.GetSharedVariable(context.Nodes[0]), state.GetSharedVariable(context.Nodes[1]));
            _elements  = new ElementSet <Complex>(state.Solver, _variables.GetMatrixLocations(state.Map));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(BehavioralBindingContext context)
            : base(context)
        {
            var bp    = context.GetParameterSet <Parameters>();
            var state = context.GetState <IBiasingSimulationState>();

            _variables = new OnePort <double>(
                state.GetSharedVariable(context.Nodes[0]),
                state.GetSharedVariable(context.Nodes[1]));
            _branch = state.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);

            // Let's build the derivative functions and get their matrix locations/rhs locations
            Function            = bp.Function;
            Derivatives         = context.CreateDerivatives(Function);
            DerivativeVariables = Derivatives.Keys.ToDictionary(d => d, d => context.MapNode(state, d, _branch), Derivatives.Comparer);
            var builder = new RealFunctionBuilder();

            builder.VariableFound += (sender, args) =>
            {
                if (args.Variable == null && DerivativeVariables.TryGetValue(args.Node, out var variable))
                {
                    args.Variable = variable;
                }
            };
            bp.RegisterBuilder(context, builder);
            var derivatives         = new List <Func <double> >(Derivatives.Count);
            var derivativeVariables = new List <IVariable <double> >(Derivatives.Count);
            var matLocs             = new List <MatrixLocation>(Derivatives.Count);
            var rhsLocs             = state.Map[_branch];

            foreach (var pair in Derivatives)
            {
                var variable = DerivativeVariables[pair.Key];
                if (state.Map.Contains(variable))
                {
                    derivatives.Add(builder.Build(pair.Value));
                    derivativeVariables.Add(variable);
                    matLocs.Add(new MatrixLocation(rhsLocs, state.Map[variable]));
                }
            }
            _value = builder.Build(Function);

            // Get the matrix elements
            _derivatives         = derivatives.ToArray();
            _values              = new double[_derivatives.Length];
            _derivativeVariables = derivativeVariables.ToArray();
            _elements            = new ElementSet <double>(state.Solver, matLocs.ToArray());
            int br  = state.Map[_branch];
            int pos = state.Map[_variables.Positive];
            int neg = state.Map[_variables.Negative];

            _coreElements = new ElementSet <double>(state.Solver, new[] {
                new MatrixLocation(br, pos),
                new MatrixLocation(br, neg),
                new MatrixLocation(pos, br),
                new MatrixLocation(neg, br)
            }, new[] { br });
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(BehavioralBindingContext context)
            : base(context)
        {
            var bp    = context.GetParameterSet <Parameters>();
            var state = context.GetState <IComplexSimulationState>();

            _variables = new OnePort <Complex>(
                state.GetSharedVariable(context.Nodes[0]),
                state.GetSharedVariable(context.Nodes[1]));
            _branch = state.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);

            // Build the functions
            var nVariables = new Dictionary <VariableNode, IVariable <Complex> >(Derivatives.Comparer);

            foreach (var variable in Derivatives.Keys)
            {
                var orig = DerivativeVariables[variable];
                nVariables.Add(variable, new FuncVariable <Complex>(orig.Name, () => orig.Value, orig.Unit));
            }
            var builder = new ComplexFunctionBuilder();

            builder.VariableFound += (sender, args) =>
            {
                if (args.Variable == null && DerivativeVariables.TryGetValue(args.Node, out var variable))
                {
                    args.Variable = new FuncVariable <Complex>(variable.Name, () => variable.Value, variable.Unit);
                }
            };
            bp.RegisterBuilder(context, builder);
            var derivatives = new List <Func <Complex> >(Derivatives.Count);
            var rhsLocs     = state.Map[_branch];
            var matLocs     = new List <MatrixLocation>(Derivatives.Count);

            foreach (var pair in Derivatives)
            {
                var variable = context.MapNode(state, pair.Key, _branch);
                if (state.Map.Contains(variable))
                {
                    derivatives.Add(builder.Build(pair.Value));
                    matLocs.Add(new MatrixLocation(rhsLocs, state.Map[variable]));
                }
            }

            // Get the matrix elements
            _derivatives = derivatives.ToArray();
            _values      = new Complex[_derivatives.Length];
            _elements    = new ElementSet <Complex>(state.Solver, matLocs.ToArray());
            int br  = state.Map[_branch];
            int pos = state.Map[_variables.Positive];
            int neg = state.Map[_variables.Negative];

            _coreElements = new ElementSet <Complex>(state.Solver, new[] {
                new MatrixLocation(br, pos),
                new MatrixLocation(br, neg),
                new MatrixLocation(pos, br),
                new MatrixLocation(neg, br)
            });
        }
示例#10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Time"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Time(IComponentBindingContext context) : base(context)
        {
            context.Nodes.CheckNodes(2);
            _biasing   = context.GetState <IBiasingSimulationState>();
            _time      = context.GetState <ITimeSimulationState>();
            _variables = new OnePort <double>(_biasing, context);
            _elements  = new ElementSet <double>(_biasing.Solver,
                                                 _variables.GetMatrixLocations(_biasing.Map),
                                                 _variables.GetRhsIndices(_biasing.Map));
            var method = context.GetState <IIntegrationMethod>();

            _qcap = method.CreateDerivative();
        }
示例#11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(ISwitchBindingContext context)
            : base(context)
        {
            context.ThrowIfNull(nameof(context));

            _iteration       = context.GetState <IIterationSimulationState>();
            _controller      = context.ControlValue;
            ModelTemperature = context.ModelBehaviors.GetValue <ModelTemperature>();
            Parameters       = context.GetParameterSet <Parameters>();

            var state = context.GetState <IBiasingSimulationState>();

            _variables = new OnePort <double>(state.GetSharedVariable(context.Nodes[0]), state.GetSharedVariable(context.Nodes[1]));
            _elements  = new ElementSet <double>(state.Solver, _variables.GetMatrixLocations(state.Map));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(BehavioralBindingContext context)
            : base(context)
        {
            var bp    = context.GetParameterSet <Parameters>();
            var state = context.GetState <IBiasingSimulationState>();

            _variables = new OnePort <double>(
                state.GetSharedVariable(context.Nodes[0]),
                state.GetSharedVariable(context.Nodes[1]));

            // Let's build the derivative functions and get their matrix locations/rhs locations
            Function            = bp.Function;
            Derivatives         = context.CreateDerivatives(Function);
            DerivativeVariables = Derivatives.Keys.ToDictionary(d => d, d => context.MapNode(state, d), Derivatives.Comparer);
            var derivatives         = new List <Func <double> >(Derivatives.Count);
            var derivativeVariables = new List <IVariable <double> >(Derivatives.Count);
            var builder             = new RealFunctionBuilder();

            builder.VariableFound += (sender, args) =>
            {
                if (args.Variable == null && DerivativeVariables.TryGetValue(args.Node, out var variable))
                {
                    args.Variable = variable;
                }
            };
            bp.RegisterBuilder(context, builder);
            var matLocs = new List <MatrixLocation>(Derivatives.Count * 2);
            var rhsLocs = _variables.GetRhsIndices(state.Map);

            foreach (var pair in Derivatives)
            {
                var variable = DerivativeVariables[pair.Key];
                if (state.Map.Contains(variable))
                {
                    derivatives.Add(builder.Build(pair.Value));
                    derivativeVariables.Add(variable);
                    matLocs.Add(new MatrixLocation(rhsLocs[0], state.Map[variable]));
                    matLocs.Add(new MatrixLocation(rhsLocs[1], state.Map[variable]));
                }
            }
            _value               = builder.Build(Function);
            _derivatives         = derivatives.ToArray();
            _derivativeVariables = derivativeVariables.ToArray();
            _values              = new double[_derivatives.Length * 2 + 2];

            // Get the matrix elements
            _elements = new ElementSet <double>(state.Solver, matLocs.ToArray(), rhsLocs);
        }
示例#13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(ICurrentControlledBindingContext context)
            : base(context)
        {
            _complex = context.GetState <IComplexSimulationState>();

            _variables = new OnePort <Complex>(_complex, context);
            _control   = context.ControlBehaviors.GetValue <IBranchedBehavior <Complex> >().Branch;

            var pos = _complex.Map[_variables.Positive];
            var neg = _complex.Map[_variables.Negative];
            var br  = _complex.Map[_control];

            _elements = new ElementSet <Complex>(_complex.Solver,
                                                 new MatrixLocation(pos, br),
                                                 new MatrixLocation(neg, br));
        }
示例#14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing" /> class.
        /// </summary>
        /// <param name="context">The context for the behavior.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown if the simulation does not define an <see cref="IComplexSimulationState"/>.</exception>
        /// <exception cref="TypeNotFoundException">Thrown if the controlling entity does not have a behavior of type <see cref="IBranchedBehavior{T}"/>.</exception>
        public Biasing(ICurrentControlledBindingContext context) : base(context)
        {
            context.ThrowIfNull(nameof(context));
            context.Nodes.CheckNodes(2);
            Parameters = context.GetParameterSet <Parameters>();
            _biasing   = context.GetState <IBiasingSimulationState>();
            _variables = new OnePort <double>(_biasing, context);
            _control   = context.ControlBehaviors.GetValue <IBranchedBehavior <double> >().Branch;

            var pos = _biasing.Map[_variables.Positive];
            var neg = _biasing.Map[_variables.Negative];
            var br  = _biasing.Map[_control];

            _elements = new ElementSet <double>(_biasing.Solver,
                                                new MatrixLocation(pos, br),
                                                new MatrixLocation(neg, br));
        }
示例#15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(IComponentBindingContext context)
            : base(context)
        {
            _complex   = context.GetState <IComplexSimulationState>();
            _variables = new OnePort <Complex>(_complex, context);
            Branch     = _complex.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);

            var pos = _complex.Map[_variables.Positive];
            var neg = _complex.Map[_variables.Negative];
            var br  = _complex.Map[Branch];

            _elements = new ElementSet <Complex>(_complex.Solver,
                                                 new MatrixLocation(pos, br),
                                                 new MatrixLocation(neg, br),
                                                 new MatrixLocation(br, neg),
                                                 new MatrixLocation(br, pos),
                                                 new MatrixLocation(br, br));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The binding context.</param>
        public Biasing(ICurrentControlledBindingContext context)
            : base(context)
        {
            var state = context.GetState <IBiasingSimulationState>();

            _variables = new OnePort <double>(state, context);
            _control   = context.ControlBehaviors.GetValue <IBranchedBehavior <double> >().Branch;

            int r1 = state.Map[_variables.Positive];
            int r2 = state.Map[_variables.Negative];
            int rc = state.Map[_control];

            _elements = new ElementSet <double>(state.Solver,
                                                new[]
            {
                new MatrixLocation(r1, rc),
                new MatrixLocation(r2, rc)
            });
        }
示例#17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(IComponentBindingContext context)
            : base(context)
        {
            context.Nodes.CheckNodes(2);
            var state = context.GetState <IBiasingSimulationState>();

            _variables = new OnePort <double>(state, context);
            Branch     = state.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);

            var pos = state.Map[_variables.Positive];
            var neg = state.Map[_variables.Negative];
            var br  = state.Map[Branch];

            _elements = new ElementSet <double>(state.Solver,
                                                new MatrixLocation(pos, br),
                                                new MatrixLocation(neg, br),
                                                new MatrixLocation(br, neg),
                                                new MatrixLocation(br, pos));
        }
示例#18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BiasingBehavior"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public BiasingBehavior(IComponentBindingContext context)
            : base(context)
        {
            context.ThrowIfNull(nameof(context));

            Parameters = context.GetParameterSet <IndependentSourceParameters>();
            _iteration = context.GetState <IIterationSimulationState>();
            context.TryGetState(out _method);
            Waveform = Parameters.Waveform?.Create(_method);
            if (!Parameters.DcValue.Given)
            {
                // No DC value: either have a transient value or none
                if (Waveform != null)
                {
                    SpiceSharpWarning.Warning(this,
                                              Properties.Resources.IndependentSources_NoDcUseWaveform.FormatString(Name));
                    Parameters.DcValue = new GivenParameter <double>(Waveform.Value, false);
                }
                else
                {
                    SpiceSharpWarning.Warning(this,
                                              Properties.Resources.IndependentSources_NoDc.FormatString(Name));
                }
            }

            // Connections
            _biasing = context.GetState <IBiasingSimulationState>();
            context.TryGetState(out _method);

            _variables = new OnePort <double>(_biasing, context);
            Branch     = _biasing.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);
            var pos = _biasing.Map[_variables.Positive];
            var neg = _biasing.Map[_variables.Negative];
            var br  = _biasing.Map[Branch];

            _elements = new ElementSet <double>(_biasing.Solver, new[] {
                new MatrixLocation(pos, br),
                new MatrixLocation(br, pos),
                new MatrixLocation(neg, br),
                new MatrixLocation(br, neg)
            }, new[] { br });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The binding context.</param>
        public Biasing(ICurrentControlledBindingContext context)
            : base(context)
        {
            var state = context.GetState <IBiasingSimulationState>();

            _variables = new OnePort <double>(state, context);
            _control   = context.ControlBehaviors.GetValue <IBranchedBehavior <double> >().Branch;
            Branch     = state.CreatePrivateVariable("branch", Units.Ampere);
            int pos = state.Map[_variables.Positive];
            int neg = state.Map[_variables.Negative];
            int cbr = state.Map[_control];
            int br  = state.Map[Branch];

            _elements = new ElementSet <double>(state.Solver,
                                                new MatrixLocation(pos, br),
                                                new MatrixLocation(neg, br),
                                                new MatrixLocation(br, pos),
                                                new MatrixLocation(br, neg),
                                                new MatrixLocation(br, cbr));
        }
示例#20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(IComponentBindingContext context) : base(context)
        {
            context.ThrowIfNull(nameof(context));

            Parameters = context.GetParameterSet <Parameters>();
            _biasing   = context.GetState <IBiasingSimulationState>();
            _iteration = context.GetState <IIterationSimulationState>();
            _variables = new OnePort <double>(_biasing, context);
            context.TryGetState <IIntegrationMethod>(out _method);
            Waveform = Parameters.Waveform?.Create(context);

            // Give some warnings if no value is given
            if (!Parameters.DcValue.Given)
            {
                // no DC value - either have a transient value or none
                SpiceSharpWarning.Warning(this,
                                          Waveform != null
                        ? Properties.Resources.IndependentSources_NoDcUseWaveform.FormatString(Name)
                        : Properties.Resources.IndependentSources_NoDc.FormatString(Name));
            }

            _elements = new ElementSet <double>(_biasing.Solver, null, _variables.GetRhsIndices(_biasing.Map));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context"></param>
        public Frequency(ICurrentControlledBindingContext context)
            : base(context)
        {
            // Biasing part
            var bstate = context.GetState <IBiasingSimulationState>();

            _dblVariables = new OnePort <double>(bstate, context);
            _dblControl   = context.ControlBehaviors.GetValue <IBranchedBehavior <double> >().Branch;
            int r1 = bstate.Map[_dblVariables.Positive];
            int r2 = bstate.Map[_dblVariables.Negative];
            int rc = bstate.Map[_dblControl];

            _dblElements = new ElementSet <double>(bstate.Solver, new MatrixLocation(r1, rc), new MatrixLocation(r2, rc));

            // Complex part
            var cstate = context.GetState <IComplexSimulationState>();

            _cplxVariables = new OnePort <Complex>(cstate, context);
            _cplxControl   = context.ControlBehaviors.GetValue <IBranchedBehavior <Complex> >().Branch;
            r1             = cstate.Map[_cplxVariables.Positive];
            r2             = cstate.Map[_cplxVariables.Negative];
            rc             = cstate.Map[_cplxControl];
            _cplxElements  = new ElementSet <Complex>(cstate.Solver, new MatrixLocation(r1, rc), new MatrixLocation(r2, rc));
        }
示例#22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The binding context.</param>
        public Frequency(ICurrentControlledBindingContext context)
            : base(context)
        {
            var bstate = context.GetState <IBiasingSimulationState>();

            _dblVariables = new OnePort <double>(bstate, context);
            _dblControl   = context.ControlBehaviors.GetValue <IBranchedBehavior <double> >().Branch;
            _dblBranch    = bstate.CreatePrivateVariable("branch", Units.Ampere);
            int pos = bstate.Map[_dblVariables.Positive];
            int neg = bstate.Map[_dblVariables.Negative];
            int cbr = bstate.Map[_dblControl];
            int br  = bstate.Map[_dblBranch];

            _dblElements = new ElementSet <double>(bstate.Solver,
                                                   new MatrixLocation(pos, br),
                                                   new MatrixLocation(neg, br),
                                                   new MatrixLocation(br, pos),
                                                   new MatrixLocation(br, neg),
                                                   new MatrixLocation(br, cbr));

            var cstate = context.GetState <IComplexSimulationState>();

            _cplxVariables = new OnePort <Complex>(cstate, context);
            _cplxControl   = context.ControlBehaviors.GetValue <IBranchedBehavior <Complex> >().Branch;
            _cplxBranch    = cstate.CreatePrivateVariable("branch", Units.Ampere);
            pos            = cstate.Map[_cplxVariables.Positive];
            neg            = cstate.Map[_cplxVariables.Negative];
            cbr            = cstate.Map[_cplxControl];
            br             = cstate.Map[_cplxBranch];
            _cplxElements  = new ElementSet <Complex>(cstate.Solver,
                                                      new MatrixLocation(pos, br),
                                                      new MatrixLocation(neg, br),
                                                      new MatrixLocation(br, pos),
                                                      new MatrixLocation(br, neg),
                                                      new MatrixLocation(br, cbr));
        }
示例#23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NoiseGain" /> class.
 /// </summary>
 /// <param name="name">Name of the noise source.</param>
 /// <param name="pos">The positive node.</param>
 /// <param name="neg">The negative node.</param>
 public NoiseGain(string name, IVariable <Complex> pos, IVariable <Complex> neg)
     : base(name)
 {
     _variables = new OnePort <Complex>(pos, neg);
 }