/// <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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
        /// <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)
            });
        }
Ejemplo n.º 6
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;
            Branch     = _complex.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);

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

            _elements = new ElementSet <Complex>(_complex.Solver,
                                                 new MatrixLocation(pos, br),
                                                 new MatrixLocation(neg, br),
                                                 new MatrixLocation(br, pos),
                                                 new MatrixLocation(br, neg),
                                                 new MatrixLocation(br, cbr));
        }
        /// <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));
        }