Beispiel #1
0
        private void GetBetasEzVecs(
            double omega, System.Numerics.Complex[] eVals, System.Numerics.Complex[][] eVecs)
        {
            int modeCnt = eVals.Length;

            for (int iMode = 0; iMode < modeCnt; iMode++)
            {
                var eVal = eVals[iMode];
                var beta = System.Numerics.Complex.Sqrt(eVal);
                if (beta.Imaginary > 0)
                {
                    beta = System.Numerics.Complex.Conjugate(beta);
                }
                eVals[iMode] = beta;

                var eVec  = eVecs[iMode];
                var e     = new IvyFEM.Lapack.ComplexMatrix(eVec, eVec.Length, 1);
                var RyyZ  = (IvyFEM.Lapack.ComplexMatrix)Ryy;
                var work  = RyyZ * e;
                var work2 = IvyFEM.Lapack.Functions.zdotc(eVec, work.Buffer);
                var d     = System.Numerics.Complex.Sqrt(
                    (System.Numerics.Complex)(omega * Constants.Mu0) /
                    (((System.Numerics.Complex)beta.Magnitude) * work2));
                eVec         = IvyFEM.Lapack.Functions.zscal(eVec, d);
                eVecs[iMode] = eVec;
            }
        }
Beispiel #2
0
        private void SetBoundaryCondition(double omega,
                                          IvyFEM.Linear.ComplexSparseMatrix A, System.Numerics.Complex[] B,
                                          uint portCnt, out EMWaveguide1DEigenFEM[] eigenFEMs)
        {
            eigenFEMs = new EMWaveguide1DEigenFEM[portCnt];
            for (uint portId = 0; portId < portCnt; portId++)
            {
                uint portNodeCnt = World.GetPortNodeCount(QuantityId, portId);

                var eigenFEM = new EMWaveguide1DEigenFEM(World, QuantityId, portId);
                eigenFEMs[portId] = eigenFEM;

                eigenFEM.Frequency = Frequency;
                eigenFEM.Solve();
                System.Numerics.Complex[]   betas   = eigenFEM.Betas;
                System.Numerics.Complex[][] ezEVecs = eigenFEM.EzEVecs;
                IvyFEM.Lapack.ComplexMatrix b       = eigenFEM.CalcBoundaryMatrix(omega, betas, ezEVecs);
                for (int col = 0; col < portNodeCnt; col++)
                {
                    int colCoId   = World.PortNode2Coord(QuantityId, portId, col);
                    int colNodeId = World.Coord2Node(QuantityId, colCoId);
                    for (int row = 0; row < portNodeCnt; row++)
                    {
                        int rowCoId   = World.PortNode2Coord(QuantityId, portId, row);
                        int rowNodeId = World.Coord2Node(QuantityId, rowCoId);

                        A[rowNodeId, colNodeId] += b[row, col];
                    }
                }

                bool isIncidentPort = (portId == World.GetIncidentPortId(QuantityId));
                if (isIncidentPort)
                {
                    int incidentModeId = World.GetIncidentModeId(QuantityId);
                    System.Diagnostics.Debug.Assert(incidentModeId != -1);
                    System.Numerics.Complex   beta0   = betas[incidentModeId];
                    System.Numerics.Complex[] ezEVec0 = ezEVecs[incidentModeId];
                    System.Numerics.Complex[] I       = eigenFEM.CalcIncidentVec(beta0, ezEVec0);
                    for (int row = 0; row < portNodeCnt; row++)
                    {
                        int rowCoId   = World.PortNode2Coord(QuantityId, portId, row);
                        int rowNodeId = World.Coord2Node(QuantityId, rowCoId);

                        B[rowNodeId] += I[row];
                    }
                }
            }
        }
Beispiel #3
0
        private bool ComplexDenseSolve(
            out System.Numerics.Complex[] X, ComplexSparseMatrix A, System.Numerics.Complex[] B)
        {
            bool success = false;

            IvyFEM.Lapack.ComplexMatrix denseA = (IvyFEM.Lapack.ComplexMatrix)A;
            int xRow;
            int xCol;
            int ret = IvyFEM.Lapack.Functions.zgesv(out X, out xRow, out xCol,
                                                    denseA.Buffer, denseA.RowLength, denseA.ColumnLength,
                                                    B, B.Length, 1);

            System.Diagnostics.Debug.Assert(ret == 0);
            success = (ret == 0);

            return(success);
        }