Exemple #1
0
        private void ResetParameterSets()
        {
            _currentParameterSetIndex = 0;

            // Use the same parameter set if there are no winning parameters
            if (!WinningParameterSets.Any())
            {
                return;
            }

            ParameterSets.Clear();

            var capacity = ParameterSets.Capacity;

            for (var i = 0; i < capacity; i++)
            {
                var randomValue = _random.NextDouble();
                if (randomValue < 0.75)
                {
                    var winningParameterSet = WinningParameterSets.GetRandomElement();
                    ParameterSets.Add(winningParameterSet);

                    WinningParameterSets.Remove(winningParameterSet);
                }
                else
                {
                    var randomParameterSet = GetRandomParameterSet();
                    ParameterSets.Add(randomParameterSet);
                }
            }

            WinningParameterSets.Clear();
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="frequencySweep">Sweep for the frequency points</param>
        protected FrequencySimulation(Identifier name, Sweep <double> frequencySweep) : base(name)
        {
            ParameterSets.Add(new FrequencyConfiguration(frequencySweep));

            // Create a complex state with shared matrix
            States.Add(new ComplexState());
        }
 /// <summary>
 /// Creates a new instance of the <see cref="CurrentControlledCurrentSource"/> class.
 /// </summary>
 /// <param name="name">The name of the current controlled current source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="voltageSource">The name of the voltage source</param>
 /// <param name="gain">The current gain</param>
 public CurrentControlledCurrentSource(string name, string pos, string neg, string voltageSource, double gain)
     : this(name)
 {
     ParameterSets.Get <BaseParameters>().Coefficient.Value = gain;
     Connect(pos, neg);
     ControllingName = voltageSource;
 }
Exemple #4
0
        /// <summary>
        /// Setup the simulation
        /// </summary>
        /// <param name="circuit">Circuit</param>
        protected override void Setup(Circuit circuit)
        {
            if (circuit == null)
            {
                throw new ArgumentNullException(nameof(circuit));
            }

            // Get base behaviors
            base.Setup(circuit);

            // Get behaviors and configurations
            var config = ParameterSets.Get <TimeConfiguration>() ?? throw new CircuitException("{0}: No time configuration".FormatString(Name));

            TimeConfiguration  = config;
            Method             = config.Method ?? throw new CircuitException("{0}: No integration method specified".FormatString(Name));
            TransientBehaviors = SetupBehaviors <BaseTransientBehavior>(circuit.Objects);

            // Setup the state pool and register states
            StatePool = new StatePool(Method);
            for (int i = 0; i < TransientBehaviors.Count; i++)
            {
                TransientBehaviors[i].GetEquationPointers(RealState.Solver);
                TransientBehaviors[i].CreateStates(StatePool);
            }
            StatePool.BuildStates();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the current-controlled switch</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="controllingSource">The controlling voltage source</param>
 public CurrentSwitch(string name, string pos, string neg, string controllingSource)
     : base(name, CurrentSwitchPinCount)
 {
     ParameterSets.Add(new BaseParameters());
     Connect(pos, neg);
     ControllingName = controllingSource;
 }
Exemple #6
0
 /// <summary>
 /// Creates a new instance of the <see cref="CurrentSource"/> class.
 /// </summary>
 /// <param name="name">The name of the current source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="waveform">The Waveform-object</param>
 public CurrentSource(string name, string pos, string neg, Waveform waveform)
     : this(name)
 {
     ParameterSets.Add(new CommonBehaviors.IndependentSourceParameters(waveform));
     ParameterSets.Add(new CommonBehaviors.IndependentSourceFrequencyParameters());
     Connect(pos, neg);
 }
Exemple #7
0
        /// <summary>
        /// Setup the simulation
        /// </summary>
        /// <param name="circuit">Circuit</param>
        protected override void Setup(Circuit circuit)
        {
            if (circuit == null)
            {
                throw new ArgumentNullException(nameof(circuit));
            }
            base.Setup(circuit);

            // Setup behaviors, configurations and states
            BaseConfiguration         = ParameterSets.Get <BaseConfiguration>();
            TemperatureBehaviors      = SetupBehaviors <BaseTemperatureBehavior>(circuit.Objects);
            LoadBehaviors             = SetupBehaviors <BaseLoadBehavior>(circuit.Objects);
            InitialConditionBehaviors = SetupBehaviors <BaseInitialConditionBehavior>(circuit.Objects);

            // Setup the load behaviors
            RealState          = States.Get <RealState>();
            _realStateLoadArgs = new LoadStateEventArgs(RealState);
            for (int i = 0; i < LoadBehaviors.Count; i++)
            {
                LoadBehaviors[i].GetEquationPointers(Nodes, RealState.Solver);
            }
            RealState.Initialize(Nodes);

            // Allow nodesets to help convergence
            OnLoad += LoadNodeSets;
        }
 public ModelsController()
 {
     ParameterSets.Push(2);
     ParameterSets.Push(2);
     ParameterSets.Push(2);
     ParameterSets.Push(2);
 }
Exemple #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the current source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="dc">The DC value</param>
 public CurrentSource(string name, string pos, string neg, double dc)
     : this(name)
 {
     ParameterSets.Add(new CommonBehaviors.IndependentBaseParameters(dc));
     ParameterSets.Add(new CommonBehaviors.IndependentFrequencyParameters());
     Connect(pos, neg);
 }
Exemple #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the voltage source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="waveform">The waveform</param>
 public VoltageSource(string name, string pos, string neg, Waveform waveform)
     : base(name, VoltageSourcePinCount)
 {
     ParameterSets.Add(new CommonBehaviors.IndependentBaseParameters(waveform));
     ParameterSets.Add(new CommonBehaviors.IndependentFrequencyParameters());
     Connect(pos, neg);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="inductorName1">Inductor 1</param>
 /// <param name="inductorName2">Inductor 2</param>
 /// <param name="coupling">Mutual inductance</param>
 public MutualInductance(string name, string inductorName1, string inductorName2, double coupling)
     : base(name, 0)
 {
     ParameterSets.Add(new BaseParameters(coupling));
     InductorName1 = inductorName1;
     InductorName2 = inductorName2;
 }
Exemple #12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the voltage source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="dc">The DC value</param>
 public VoltageSource(string name, string pos, string neg, double dc)
     : base(name, VoltageSourcePinCount)
 {
     ParameterSets.Add(new CommonBehaviors.IndependentSourceParameters(dc));
     ParameterSets.Add(new CommonBehaviors.IndependentSourceFrequencyParameters());
     Connect(pos, neg);
 }
Exemple #13
0
 public ViewParameter(ParameterSets parameterSets, FormMain mainForm)
 {
     InitializeComponent();
     this.parameterSets = parameterSets;
     this.mainForm      = mainForm;
     fillParameter();
 }
Exemple #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the current-controlled current source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="controllingSource">The controlling voltage source name</param>
 /// <param name="gain">The transresistance (gain)</param>
 public CurrentControlledVoltageSource(string name, string pos, string neg, string controllingSource, double gain)
     : base(name, CurrentControlledVoltageSourcePinCount)
 {
     ParameterSets.Add(new BaseParameters(gain));
     Connect(pos, neg);
     ControllingName = controllingSource;
 }
Exemple #15
0
        /// <summary>
        /// werte an Pic schreiben
        /// </summary>
        /// <param name="mainForm"></param>
        /// <param name="parameter"></param>
        public void writeParameters(FormMain mainForm, ParameterSets parameter)
        {
            bool err = true;

            mainForm.writeUpdate = true;
            // Verbindung öffnen wenn noch nicht verbunden
            if (!sp.IsOpen)
            {
                err = connect(mainForm, false);
            }
            // wenn fehler
            if (err == false)
            {
                return;
            }

            // Progressbar einblenden und Cursor auf wait setzen
            mainForm.toolStripProgressBar.Visible = true;
            mainForm.Cursor  = Cursors.WaitCursor;
            mainForm.Enabled = false;

            // wenn Prameter Set 1
            if (mainForm.tabControlParameter.SelectedIndex == 0)
            {
                // alle Parameter schreiben
                foreach (ParameterSets.ParameterSetsStruc value in parameter.parameterForm1)
                {
                    // wenn fehler beim schreiben dann aussteigen
                    if (err = parameterWrite(mainForm, value) == false)
                    {
                        break;
                    }
                }
            }
            else
            {
                // wenn SET 2
                // alle Parameter schreiben
                foreach (ParameterSets.ParameterSetsStruc value in parameter.parameterForm2)
                {
                    // wenn fehler beim schreiben dann aussteigen
                    if (err = parameterWrite(mainForm, value) == false)
                    {
                        break;
                    }
                }
            }
            // Progressbar ausblenden und Cursor auf default setzen
            mainForm.toolStripProgressBar.Value   = 0;
            mainForm.toolStripProgressBar.Visible = false;
            mainForm.Cursor  = Cursors.Default;
            mainForm.Enabled = true;



            //nochmals alle parameter lesen und prüfen ob mit werten gleich
            readParameters(mainForm, parameter, true);
            mainForm.writeUpdate = false;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the model</param>
        public CurrentSwitchModel(string name) : base(name)
        {
            // Add parameters
            ParameterSets.Add(new ModelBaseParameters());

            // Add factories
            Behaviors.Add(typeof(ModelLoadBehavior), () => new ModelLoadBehavior(Name));
        }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LosslessTransmissionLine"/> class.
 /// </summary>
 /// <param name="name">The name of the entity.</param>
 /// <param name="pos1">The positive terminal on one side.</param>
 /// <param name="neg1">The negative terminal on one side.</param>
 /// <param name="pos2">The positive terminal on the other side.</param>
 /// <param name="neg2">The negative terminal on the other side.</param>
 /// <param name="impedance">The characteristic impedance.</param>
 /// <param name="delay">The delay.</param>
 public LosslessTransmissionLine(string name, string pos1, string neg1, string pos2, string neg2, double impedance, double delay)
     : this(name)
 {
     Connect(pos1, neg1, pos2, neg2);
     var bp = ParameterSets.Get <BaseParameters>();
     bp.Impedance   = impedance;
     bp.Delay.Value = delay;
 }
Exemple #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BehavioralCurrentSource"/> class. Current flows from the positive
 /// to the negative node.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="pos">The positive node.</param>
 /// <param name="neg">The negative node.</param>
 /// <param name="expression">The expression.</param>
 public BehavioralCurrentSource(string name, string pos, string neg, string expression)
     : base(name, BehavioralCurrentSourcePinCount)
 {
     ParameterSets.Add(new BaseParameters {
         Expression = expression
     });
     Connect(pos, neg);
 }
        public void GetDefaultValue()
        {
            var paramSets = new ParameterSets();

            Assert.AreEqual(1.0, paramSets.Get <ParamSet1>().DoubleValue);
            Assert.AreEqual("HelloWorld!", paramSets.Get <ParamSet1>().StringValue);
            Assert.AreEqual(new Pnt(1.0, 2.0, 3.0), paramSets.Get <ParamSet1>().PointValue);
        }
Exemple #20
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the simulation</param>
        /// <param name="source">The name of the swept source</param>
        /// <param name="start">The starting value</param>
        /// <param name="stop">The stopping value</param>
        /// <param name="step">The step value</param>
        public DC(Identifier name, Identifier source, double start, double stop, double step) : base(name)
        {
            var config           = new DcConfiguration();
            SweepConfiguration s = new SweepConfiguration(source, start, stop, step);

            config.Sweeps.Add(s);
            ParameterSets.Add(config);
        }
Exemple #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NonlinearResistor"/> class.
        /// </summary>
        /// <param name="name">The string of the entity.</param>
        /// <param name="nodeA">Node A</param>
        /// <param name="nodeB">Node B</param>
        public NonlinearResistor(string name, string nodeA, string nodeB) : base(name, 2)
        {
            // Add a NonlinearResistorBehaviors.BaseParameters
            ParameterSets.Add(new BaseParameters());

            // Connect the entity
            Connect(nodeA, nodeB);
        }
Exemple #22
0
 public ViewParameter(ParameterSets parameterSets, FormMain mainForm)
 {
     InitializeComponent();
     this.parameterSets = parameterSets;
     this.mainForm      = mainForm;
     fillParameter();
     errorLabels = new ResourceManager("UAVP.UAVPSet.Resources.error", this.GetType().Assembly);
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="nmos">True for NMOS transistors, false for PMOS transistors</param>
        public Mosfet3Model(string name, bool nmos) : base(name)
        {
            // Add parameters
            ParameterSets.Add(new ModelBaseParameters(nmos));
            ParameterSets.Add(new ModelNoiseParameters());

            // Add factories
            Behaviors.Add(typeof(ModelTemperatureBehavior), () => new ModelTemperatureBehavior(Name));
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the model</param>
        public VoltageSwitchModel(Identifier name)
            : base(name)
        {
            // Add parameters
            ParameterSets.Add(new ModelBaseParameters());

            // Add factories
            Behaviors.Add(typeof(ModelLoadBehavior), () => new ModelLoadBehavior(Name));
        }
Exemple #25
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the device</param>
        public Mosfet1Model(Identifier name) : base(name)
        {
            // Add parameters
            ParameterSets.Add(new ModelBaseParameters());
            ParameterSets.Add(new ModelNoiseParameters());

            // Add factories
            Behaviors.Add(typeof(ModelTemperatureBehavior), () => new ModelTemperatureBehavior(Name));
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the device</param>
        public BipolarJunctionTransistorModel(Identifier name) : base(name)
        {
            // Add parameters
            ParameterSets.Add(new ModelBaseParameters());
            ParameterSets.Add(new ModelNoiseParameters());

            // Add factories
            Behaviors.Add(typeof(ModelTemperatureBehavior), () => new ModelTemperatureBehavior(Name));
        }
Exemple #27
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the voltage-controlled current source</param>
        public VoltageControlledCurrentSource(Identifier name)
            : base(name, VoltageControlledCurrentSourcePinCount)
        {
            // Add parameters
            ParameterSets.Add(new BaseParameters());

            // Add factories
            Behaviors.Add(typeof(LoadBehavior), () => new LoadBehavior(Name));
            Behaviors.Add(typeof(FrequencyBehavior), () => new FrequencyBehavior(Name));
        }
Exemple #28
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">The name of the current-controlled current source</param>
        public CurrentControlledVoltageSource(string name)
            : base(name, CurrentControlledVoltageSourcePinCount)
        {
            // Add parameters
            ParameterSets.Add(new BaseParameters());

            // Add factories
            Behaviors.Add(typeof(LoadBehavior), () => new LoadBehavior(Name));
            Behaviors.Add(typeof(FrequencyBehavior), () => new FrequencyBehavior(Name));
        }
Exemple #29
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="drain">Drain</param>
        /// <param name="gate">Gate</param>
        /// <param name="source">Source</param>
        /// <param name="bulk">Bulk</param>
        /// <param name="width">Transistor width</param>
        /// <param name="length">Transistor length</param>
        public BSIM3(string name, string drain, string gate, string source, string bulk, double width, double length)
            : base(name, BSIM3PinCount)
        {
            var bp = new BaseParameters();

            ParameterSets.Add(bp);
            bp.Width.Value  = width;
            bp.Length.Value = length;
            Connect(drain, gate, source, bulk);
        }
Exemple #30
0
        /// <summary>
        /// Setup simulation
        /// </summary>
        /// <param name="circuit">Circuit</param>
        protected override void Setup(Circuit circuit)
        {
            base.Setup(circuit);

            // Get DC configuration
            DcConfiguration = ParameterSets.Get <DcConfiguration>();

            // Get sweeps
            Sweeps = new NestedSweeps(DcConfiguration.Sweeps);
        }