Пример #1
0
        /// <summary>
        /// Helper for functions that return phasors generated for many sources. Returns a <see cref="PhasorPartialStates"/> that contains
        /// phasors for all sources in <paramref name="sources"/>.
        /// </summary>
        /// <param name="factory"></param>
        /// <param name="sources">Enumeration of sources to construct transfer functions for. All sources listed have to be present in
        /// <returns></returns>
        private PhasorPartialStates GetAllPhasorsHelper(AdmittanceMatrixFactory factory, IEnumerable <ISourceDescription> sources)
        {
            var result = new PhasorPartialStates(factory.NodesCount, factory.ActiveComponentsCount, sources);

            // For each source
            foreach (var source in sources)
            {
                // Get phasor and add it to states
                result.States[source] = GetPhasor(factory, source);
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Merges <paramref name="other"/> into this instance. Adds up all states that are present in both <see cref="PhasorPartialStates"/> and
        /// makes new entries for all states present in <paramref name="other"/> but not in this instance.
        /// </summary>
        /// <param name="other"></param>
        public void MergeWith(PhasorPartialStates other)
        {
            // For all keys in other that are present in this instance
            foreach (var key in States.Keys.Intersect(other.States.Keys))
            {
                // Add corresponding states from other to already existing states in this instance
                States[key].AddState(other.States[key]);
            }

            // For all keys in other that are not present in this instance
            foreach (var key in other.States.Keys.Except(States.Keys))
            {
                // Add them, with values corresponding to them, to this instance
                States.Add(key, other.States[key]);
            }
        }