Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Noise"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
 public Noise(IComponentBindingContext context)
     : base(context)
 {
     _state   = context.GetState <INoiseSimulationState>();
     _rs      = new NoiseThermal("rs", ComplexVariables.Positive, ComplexVariables.PosPrime);
     _id      = new NoiseShot("id", ComplexVariables.PosPrime, ComplexVariables.Negative);
     _flicker = new NoiseGain("flicker", ComplexVariables.PosPrime, ComplexVariables.Negative);
 }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Noise"/> class.
        /// </summary>
        /// <param name="context">The binding context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Noise(IComponentBindingContext context)
            : base(context)
        {
            _state      = context.GetState <INoiseSimulationState>();
            _properties = context.ModelBehaviors.GetValue <ModelTemperature>().Properties;
            var d  = Variables.Drain;
            var s  = Variables.Source;
            var dp = Variables.DrainPrime;
            var sp = Variables.SourcePrime;

            _rd      = new NoiseThermal("rd", d, dp);
            _rs      = new NoiseThermal("rs", s, sp);
            _id      = new NoiseThermal("id", dp, sp);
            _flicker = new NoiseGain("flicker", dp, sp);
        }
Exemple #3
0
        /// <summary>
        /// Integrates the noise density into the total integrated noise figures.
        /// It computes the integration assuming that noise = a * frequency^exponent. It
        /// automatically tracks the noise density from one point to the next.
        /// </summary>
        /// <param name="state">The noise simulation state.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="state"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown if the simulation state does not store enough points in history.</exception>
        public virtual void Integrate(INoiseSimulationState state)
        {
            state.ThrowIfNull(nameof(state));

            var    lnOutputNoiseDensity = Math.Log(Math.Max(OutputNoiseDensity, 1e-38));
            var    lnFrequency          = state.Point.Value.LogFrequency;
            var    lnLastFrequency      = state.Point.GetPreviousValue(1).LogFrequency;
            var    exponent             = (lnOutputNoiseDensity - _lnLastOutputNoiseDensity) / (lnFrequency - lnLastFrequency);
            double delta;

            // Use simple box integration if the noise contribution doesn't change significantly over the frequency
            if (Math.Abs(exponent) < 1e-10)
            {
                delta             = state.Point.Value.Frequency - state.Point.GetPreviousValue(1).Frequency;
                TotalOutputNoise += OutputNoiseDensity * delta;
                TotalInputNoise  += OutputNoiseDensity * state.Point.Value.InverseGainSquared * delta;
                return;
            }

            exponent += 1.0;

            // Is the noise ~ 1/f?
            if (Math.Abs(exponent) < 1e-10)
            {
                delta = lnFrequency - lnLastFrequency;
            }
            else
            {
                delta = (Math.Exp(exponent * lnFrequency) - Math.Exp(exponent * lnLastFrequency)) / exponent;
            }

            // Compute total output noise
            var a = Math.Exp(lnOutputNoiseDensity - exponent * lnFrequency);

            TotalOutputNoise += a * delta;

            // Compute total input noise
            a = Math.Exp(lnOutputNoiseDensity + state.Point.Value.LogInverseGainSquared - exponent * lnFrequency);
            TotalInputNoise += a * (lnFrequency - lnLastFrequency);

            _lnLastOutputNoiseDensity = lnOutputNoiseDensity;
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Noise"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Noise(IComponentBindingContext context)
            : base(context)
        {
            var complex = context.GetState <IComplexSimulationState>();

            _noise = context.GetState <INoiseSimulationState>();

            var c  = complex.GetSharedVariable(context.Nodes[0]);
            var b  = complex.GetSharedVariable(context.Nodes[1]);
            var e  = complex.GetSharedVariable(context.Nodes[2]);
            var bp = BasePrime;
            var cp = CollectorPrime;
            var ep = EmitterPrime;

            _rc      = new NoiseThermal("rc", c, cp);
            _rb      = new NoiseThermal("rb", b, bp);
            _re      = new NoiseThermal("re", e, ep);
            _ic      = new NoiseShot("ic", cp, ep);
            _ib      = new NoiseShot("ib", bp, ep);
            _flicker = new NoiseGain("1/f", bp, ep);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NoiseSimulationState"/> class.
 /// </summary>
 /// <param name="parent">The parent.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="parent"/> is <c>null</c>.</exception>
 public NoiseSimulationState(INoiseSimulationState parent)
 {
     _parent = parent.ThrowIfNull(nameof(parent));
 }