Ejemplo n.º 1
0
        /// <summary>
        /// Set up the simulation.
        /// </summary>
        /// <param name="circuit">The circuit that will be used.</param>
        /// <exception cref="ArgumentNullException">circuit</exception>
        protected override void Setup(Circuit circuit)
        {
            if (circuit == null)
            {
                throw new ArgumentNullException(nameof(circuit));
            }
            base.Setup(circuit);

            // Get behaviors and configuration data
            var config = Configurations.Get <BaseConfiguration>();

            DcMaxIterations            = config.DcMaxIterations;
            AbsTol                     = config.AbsoluteTolerance;
            RelTol                     = config.RelativeTolerance;
            _temperatureBehaviors      = EntityBehaviors.GetBehaviorList <ITemperatureBehavior>();
            _loadBehaviors             = EntityBehaviors.GetBehaviorList <IBiasingBehavior>();
            _initialConditionBehaviors = EntityBehaviors.GetBehaviorList <IInitialConditionBehavior>();

            // Create the state for this simulation
            RealState = new BaseSimulationState
            {
                Gmin = config.Gmin
            };
            _isPreordered  = false;
            _shouldReorder = true;
            var strategy = RealState.Solver.Strategy;

            strategy.RelativePivotThreshold = config.RelativePivotThreshold;
            strategy.AbsolutePivotThreshold = config.AbsolutePivotThreshold;

            // Setup the load behaviors
            _realStateLoadArgs = new LoadStateEventArgs(RealState);
            for (var i = 0; i < _loadBehaviors.Count; i++)
            {
                _loadBehaviors[i].GetEquationPointers(Variables, RealState.Solver);
            }
            RealState.Setup(Variables);

            // TODO: Compatibility - nodesets from nodes instead of configuration should be removed eventually
            if (config.Nodesets.Count == 0)
            {
                foreach (var ns in Variables.NodeSets)
                {
                    _nodesets.Add(new ConvergenceAid(ns.Key, ns.Value));
                }
            }

            // Set up nodesets
            foreach (var ns in config.Nodesets)
            {
                _nodesets.Add(new ConvergenceAid(ns.Key, ns.Value));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set up the simulation.
        /// </summary>
        /// <param name="circuit">The circuit that will be used.</param>
        /// <exception cref="ArgumentNullException">circuit</exception>
        protected override void Setup(EntityCollection circuit)
        {
            circuit.ThrowIfNull(nameof(circuit));
            base.Setup(circuit);

            // Get behaviors and configuration data
            var config = Configurations.Get <BaseConfiguration>().ThrowIfNull("base configuration");

            DcMaxIterations            = config.DcMaxIterations;
            AbsTol                     = config.AbsoluteTolerance;
            RelTol                     = config.RelativeTolerance;
            _temperatureBehaviors      = EntityBehaviors.GetBehaviorList <ITemperatureBehavior>();
            _loadBehaviors             = EntityBehaviors.GetBehaviorList <IBiasingBehavior>();
            _initialConditionBehaviors = EntityBehaviors.GetBehaviorList <IInitialConditionBehavior>();

            // Create the state for this simulation
            RealState = new BaseSimulationState
            {
                Gmin = config.Gmin
            };
            _isPreordered  = false;
            _shouldReorder = true;
            var strategy = RealState.Solver.Strategy;

            strategy.RelativePivotThreshold = config.RelativePivotThreshold;
            strategy.AbsolutePivotThreshold = config.AbsolutePivotThreshold;

            // Setup the load behaviors
            _realStateLoadArgs = new LoadStateEventArgs(RealState);
            for (var i = 0; i < _loadBehaviors.Count; i++)
            {
                _loadBehaviors[i].GetEquationPointers(Variables, RealState.Solver);
            }
            RealState.Setup(Variables);

            // Set up nodesets
            foreach (var ns in config.Nodesets)
            {
                _nodesets.Add(new ConvergenceAid(ns.Key, ns.Value));
            }
        }