Exemple #1
0
        public static double[,] ComputeConvectionMatrix(PolyMatrix N, double u, double v, double w, Point Size)
        {
            var ConvectionMatrix = N.Transpose() * (u * N.Differentiate(0) + v * N.Differentiate(1) + w * N.Differentiate(2));
            var Zero             = new Point(); // point that starts at the origin

            return(ConvectionMatrix.Integrate(Zero, Size));
        }
Exemple #2
0
 static private void PrintNaturalCoordinates(PolyMatrix N)
 {
     for (int iNode = 0; iNode < N.Data.Length; iNode++)
     {
         var    Id           = new Index(N.Data [iNode, 0].Order);
         string ScreenOutput = "N" + iNode.ToString() + " = ";
         for (int jCoeff = 0; jCoeff < N.Data[iNode, 0].Coefficients.Length; jCoeff++)
         {
             double a = N.Data [iNode, 0].Coefficients [jCoeff];
             if (a != 0.0)
             {
                 var Sub = Id.Ind2Sub(jCoeff);
                 ScreenOutput = ScreenOutput + a.ToString("F2");
                 for (int iSub = 0; iSub < Sub.Length; iSub++)
                 {
                     if (Sub [iSub] > 1)
                     {
                         ScreenOutput = ScreenOutput + "L" + iSub.ToString() + "^" + Sub [iSub] + "*";
                     }
                     else if (Sub[iSub] == 1)
                     {
                         ScreenOutput = ScreenOutput + "L" + iSub.ToString() + "*";
                     }
                 }
                 ScreenOutput = ScreenOutput.Remove(ScreenOutput.Length - 1);
                 ScreenOutput = ScreenOutput + " + ";
             }
         }
         Console.WriteLine(ScreenOutput.Remove(ScreenOutput.Length - 3));
     }
 }
Exemple #3
0
        public static double[] ComputeHeatGenerationMatrix(double G, PolyMatrix N, Point a, Point b)
        {
            var P  = N.Transpose().Integrate(a, b);
            var P1 = new double[P.Length];

            for (int i = 0; i < P1.Length; i++)
            {
                P1 [i] = G * P [i, 0];
            }
            return(P1);
        }
Exemple #4
0
        public static double[,] ComputeConductionMatrix(PolyMatrix B, Point a, Point b, double kx, double ky, double kz)
        {
            double[,] D = new double[3, 3];
            D [0, 0]    = kx;
            D [1, 1]    = ky;
            D [2, 2]    = kz;
            var Kn = B.Transpose() * D * B;
            var Ke = Kn.Integrate(a, b);

            return(Ke);
        }
Exemple #5
0
        // For Volume Elements
        #region Volume Terms
        public static double[,] ComputeMassMatrix(PolyMatrix N, Point a, Point b)
        {
            if (N.Rows > 1)
            {
                throw new Exception("N must be 1 row x n cols");
            }
            N = N.Transpose() * N;
            var Me = N.Integrate(a, b);

            return(Me);
        }
Exemple #6
0
        public static double[,] ComputeCapacitanceMatrix(PolyMatrix N, Point a, Point b, double rho, double cp)
        {
            var CapMatrix = ComputeMassMatrix(N, a, b);
            var Cp        = rho * cp;

            for (int i = 0; i < N.Rows; i++)
            {
                for (int j = 0; j < N.Cols; j++)
                {
                    CapMatrix[i, j] = CapMatrix[i, j] * Cp;
                }
            }
            return(CapMatrix);
        }
Exemple #7
0
        public static PolyMatrix ComputeGradientMatrix(PolyMatrix N)
        {
            if (N.Rows > 1)
            {
                throw new Exception("N must be 1 row x n cols");
            }
            var Ndx = N.Differentiate(0);
            var Ndy = N.Differentiate(1);
            var Ndz = N.Differentiate(2);
            var B   = new PolyMatrix(3, N.Cols);

            for (int j = 0; j < N.Cols; j++)
            {
                B.Data[0, j] = Ndx.Data[0, j];
                B.Data[1, j] = Ndy.Data[0, j];
                B.Data[2, j] = Ndz.Data[0, j];
            }
            return(B);
        }
Exemple #8
0
 public static double[,] ComputeConductionMatrix(PolyMatrix B, Point a, Point b, double k)
 {
     return(ComputeConductionMatrix(B, a, b, k, k, k));
 }