public LumpedPort(uint priority, uint portNum, double r, Vector3D p1, Vector3D p2,
            ENormDir dir, bool excite = false)
            : base("port-" + portNum)
        {
            m_portNum = portNum;
            m_rInternal = Double.NaN;

            m_time = null;
            m_uTdValue = null;
            m_iTdValue = null;
            Freqs = null;
            m_uFdValue = null;
            m_iFdValue = null;

            if (p1.Coordinates[(uint)dir] == p2.Coordinates[(uint)dir])
            {
                Console.WriteLine("Error: Excitation vector normal direction component must not be zero");
                return;
            }

            double dirSign = p1.Coordinates[(uint)dir] < p2.Coordinates[(uint)dir] ? +1.0 : -1.0;

            // Lumped element
            Material le;
            if (r > 0 && r != Double.NaN)
            {
                m_rInternal = r;
                le = new LumpedElement("port_resist_" + portNum, dir, r: r, c: 1);
            }
            else
            {
                m_rInternal = Double.NaN;
                le = new Metal("port_resist_" + portNum);
            }
            m_primitives.Add(new Box(this, le, priority, p1, p2));
            ZReference = m_rInternal;

            // Excitation
            Vector3D ev = new Vector3D();
            ev[(int)dir] = 1.0;
            ExcitationField ef = new ExcitationField("port_excite_" + portNum,
                ExcitationField.EType.E_FIELD_SOFT, -dirSign * ev);
            m_primitives.Add(new Box(this, ef, priority, p1, p2));

            // Probes
            Vector3D u1 = 0.5 * (p1 + p2);
            Vector3D u2 = 0.5 * (p1 + p2);
            u1[(int)dir] = p1[(int)dir];
            u2[(int)dir] = p2[(int)dir];
            Probe probe_u = new Probe("port_ut" + portNum, Probe.EType.VOLTAGE_PROBE, -dirSign);
            m_primitives.Add(new Box(this, probe_u, priority, u1, u2));

            Vector3D i1 = new Vector3D(p1.x, p1.y, p1.z);
            Vector3D i2 = new Vector3D(p2.x, p2.y, p2.z);
            i1[(int)dir] = 0.5 * (p1[(int)dir] + p2[(int)dir]);
            i2[(int)dir] = 0.5 * (p1[(int)dir] + p2[(int)dir]);
            Probe probe_i = new Probe("port_it" + portNum, Probe.EType.CURRENT_PROBE, dirSign, dir);
            m_primitives.Add(new Box(this, probe_i, priority, i1, i2));
        }
Exemplo n.º 2
0
        public LumpedPort(uint priority, uint portNum, double r, Vector3D p1, Vector3D p2,
                          ENormDir dir, bool excite = false)
            : base("port-" + portNum)
        {
            m_portNum   = portNum;
            m_rInternal = Double.NaN;

            m_time     = null;
            m_uTdValue = null;
            m_iTdValue = null;
            Freqs      = null;
            m_uFdValue = null;
            m_iFdValue = null;

            if (p1.Coordinates[(uint)dir] == p2.Coordinates[(uint)dir])
            {
                Console.WriteLine("Error: Excitation vector normal direction component must not be zero");
                return;
            }

            double dirSign = p1.Coordinates[(uint)dir] < p2.Coordinates[(uint)dir] ? +1.0 : -1.0;

            // Lumped element
            Material le;

            if (r > 0 && r != Double.NaN)
            {
                m_rInternal = r;
                le          = new LumpedElement("port_resist_" + portNum, dir, r: r, c: 1);
            }
            else
            {
                m_rInternal = Double.NaN;
                le          = new Metal("port_resist_" + portNum);
            }
            m_primitives.Add(new Box(this, le, priority, p1, p2));
            ZReference = m_rInternal;

            // Excitation
            Vector3D ev = new Vector3D();

            ev[(int)dir] = 1.0;
            ExcitationField ef = new ExcitationField("port_excite_" + portNum,
                                                     ExcitationField.EType.E_FIELD_SOFT, -dirSign * ev);

            m_primitives.Add(new Box(this, ef, priority, p1, p2));

            // Probes
            Vector3D u1 = 0.5 * (p1 + p2);
            Vector3D u2 = 0.5 * (p1 + p2);

            u1[(int)dir] = p1[(int)dir];
            u2[(int)dir] = p2[(int)dir];
            Probe probe_u = new Probe("port_ut" + portNum, Probe.EType.VOLTAGE_PROBE, -dirSign);

            m_primitives.Add(new Box(this, probe_u, priority, u1, u2));

            Vector3D i1 = new Vector3D(p1.x, p1.y, p1.z);
            Vector3D i2 = new Vector3D(p2.x, p2.y, p2.z);

            i1[(int)dir] = 0.5 * (p1[(int)dir] + p2[(int)dir]);
            i2[(int)dir] = 0.5 * (p1[(int)dir] + p2[(int)dir]);
            Probe probe_i = new Probe("port_it" + portNum, Probe.EType.CURRENT_PROBE, dirSign, dir);

            m_primitives.Add(new Box(this, probe_i, priority, i1, i2));
        }