public static SparseMatrix PorousMatrix(bool Rigid, double d, Complex k, Complex sin_theta, double freq, double porosity, double tortuosity, double YoungsModulus, double PoissonRatio, double Viscous_Characteristic_Length, double flow_resistivity, double FrameDensity, double Thermal_Permeability_0, double AmbientMeanPressure)
            {
                double  w             = Utilities.Numerics.PiX2 * freq;
                double  v             = Biot_Porous_Absorbers.v();
                double  FrameShear    = AbsorptionModels.Biot_Porous_Absorbers.Shear_Modulus(YoungsModulus, PoissonRatio);
                double  kb            = 2 * FrameShear * (PoissonRatio + 1) / (3 * (1 - 2 * PoissonRatio));
                double  BulkMod_Frame = AbsorptionModels.Biot_Porous_Absorbers.BulkMod_Solid(YoungsModulus, PoissonRatio);
                Complex Kf            = Biot_Porous_Absorbers.BulkMod_Fluid(w, AmbientMeanPressure, porosity, Thermal_Permeability_0);//AmbientMeanPressure / (1 - (gamma - 1) / (gamma * alpha));
                Complex LameL         = YoungsModulus * PoissonRatio / ((1 + PoissonRatio) * (1 - 2 * PoissonRatio));
                Complex LameMu        = YoungsModulus / (2 * (1 + PoissonRatio));
                Complex delta21       = w * w * FrameDensity;
                Complex delta22       = w * w * FrameDensity;
                Complex delta23       = delta21 / LameMu;

                delta21 /= (LameL + 2 * LameMu);
                delta22 /= (LameL + 2 * LameMu);

                //Taken from Lauriks, et. al., 1990.
                double  rho12 = Biot_Porous_Absorbers.rho12(porosity, tortuosity);
                double  rhoa  = Biot_Porous_Absorbers.rhoA(rho12);
                double  Viscous_Permeability = Biot_Porous_Absorbers.Viscous_Permeability(flow_resistivity);
                Complex Gw = Biot_Porous_Absorbers.G_w(tortuosity, porosity, Viscous_Permeability, Viscous_Characteristic_Length, freq, v);

                //Complex rho12eff = Biot_Porous_Absorbers.rho12eff(rhoa, porosity, flow_resistivity, Gw, freq);
                Complex rho22eff = Biot_Porous_Absorbers.rho22eff(rhoa, porosity, flow_resistivity, Gw, freq);
                Complex rho11eff = Biot_Porous_Absorbers.rho11eff(FrameDensity, rhoa, porosity, flow_resistivity, Gw, freq);

                Complex P, Q, R;

                if (!Rigid)
                {
                    //Universal (Limp) Frame Case:
                    P = ((1 - porosity) * (1 - kb / BulkMod_Frame) * BulkMod_Frame + porosity * BulkMod_Frame * kb / Kf) / (1 - porosity - kb / BulkMod_Frame + porosity * BulkMod_Frame / Kf);
                    Q = (1 - porosity - kb / BulkMod_Frame) * porosity * BulkMod_Frame / (1 - porosity - kb / BulkMod_Frame + porosity * BulkMod_Frame / Kf);
                    R = porosity * porosity * BulkMod_Frame / (1 - porosity - kb / BulkMod_Frame + porosity * BulkMod_Frame / Kf);
                }
                else
                {
                    //Rigid Frame Case:
                    P = 4 * FrameShear / 3 + kb + (porosity * porosity) * Kf / porosity;
                    R = porosity * Kf;
                    Q = Kf * (1 - porosity);
                }

                Complex kt  = k * sin_theta;
                Complex k13 = Complex.Sqrt(delta21 - kt * kt);
                Complex k23 = Complex.Sqrt(delta22 - kt * kt);
                Complex k33 = Complex.Sqrt(delta23 - kt * kt);
                Complex Mu1 = Q * delta21 - w * w * rho11eff / (w * w * rho22eff - R * delta21);
                Complex Mu2 = Q * delta22 - w * w * rho11eff / (w * w * rho22eff - R * delta22);
                Complex Mu3 = FrameShear * delta23 - w * w * rho11eff / (w * w * rho22eff);

                SparseMatrix GH  = GammaH_P(kt, w, d, FrameShear, P, Q, R, k13, k23, k33, Mu1, Mu2, Mu3);
                SparseMatrix G0T = Gamma0T_P(kt, w, FrameShear, P, Q, R, k13, k23, k33, Mu1, Mu2, Mu3);

                return(GH * G0T);
            }
            public static SparseMatrix Solid_Matrix(Complex kt, double h, double freq, double density, double Youngs_Modulus, double Poisson_Ratio)
            {
                //h *= -1;

                double Shear_Modulus = Biot_Porous_Absorbers.Shear_Modulus(Youngs_Modulus, Poisson_Ratio);

                double w = Utilities.Numerics.PiX2 * freq;

                Complex kcis2  = w * w * density / Shear_Modulus;
                Complex kcomp2 = kcis2 * ((1 - 2 * Poisson_Ratio) / (2 - 2 * Poisson_Ratio));

                Complex kphi3 = Complex.Sqrt(kcomp2 - kt * kt);
                Complex kpsi3 = Complex.Sqrt(kcis2 - kt * kt);

                Complex cosk13h = Complex.Cos(kphi3 * h);
                Complex sink13h = Complex.Sin(kphi3 * h);
                Complex cosk33h = Complex.Cos(kpsi3 * h);
                Complex sink33h = Complex.Sin(kpsi3 * h);
                Complex KK      = kphi3 * kphi3 + (Poisson_Ratio / (1 - 2 * Poisson_Ratio)) * (kt * kt + kphi3 * kphi3);

                SparseMatrix MH = new SparseMatrix(4, 4);

                MH[0, 0] = -Complex.ImaginaryOne * kt * cosk13h;
                MH[0, 1] = -kt * sink13h;
                MH[0, 2] = -kpsi3 * sink33h;
                MH[0, 3] = -Complex.ImaginaryOne * kpsi3 * cosk33h;
                MH[1, 0] = -kphi3 * sink13h;
                MH[1, 1] = -Complex.ImaginaryOne * kphi3 * cosk13h;
                MH[1, 2] = Complex.ImaginaryOne * kt * cosk33h;
                MH[1, 3] = kt * sink33h;
                MH[2, 0] = -2 * Shear_Modulus * cosk13h * KK / (Complex.ImaginaryOne * w);
                MH[2, 1] = 2 * Shear_Modulus * sink13h * KK / (Complex.ImaginaryOne * w);
                MH[2, 2] = -(2 * Shear_Modulus * kt * kpsi3 * sink33h / w);
                MH[2, 3] = -Complex.ImaginaryOne * 2 * Shear_Modulus * kt * kpsi3 * cosk33h / w;
                MH[3, 0] = 2 * Shear_Modulus * kt * kphi3 * sink13h / w;
                MH[3, 1] = Complex.ImaginaryOne * 2 * Shear_Modulus * kt * kphi3 * cosk13h / w;
                MH[3, 2] = -Complex.ImaginaryOne * Shear_Modulus * cosk33h * (kt * kt - kpsi3 * kpsi3) / w;
                MH[3, 3] = -Shear_Modulus * sink33h * (kt * kt - kpsi3 * kpsi3) / w;

                SparseMatrix M0 = new SparseMatrix(4, 4);

                M0[0, 0] = -Complex.ImaginaryOne * kt;
                M0[0, 3] = -Complex.ImaginaryOne * kpsi3;
                M0[1, 1] = -Complex.ImaginaryOne * kphi3;
                M0[1, 2] = Complex.ImaginaryOne * kt;
                M0[2, 0] = -2 * Shear_Modulus * KK / (Complex.ImaginaryOne * w);
                M0[2, 3] = -(Complex.ImaginaryOne * 2 * Shear_Modulus * kt * kpsi3 / w);
                M0[3, 1] = Complex.ImaginaryOne * 2 * Shear_Modulus * kt * kphi3 / w;
                M0[3, 2] = -Complex.ImaginaryOne * Shear_Modulus * (kt * kt - kpsi3 * kpsi3) / w;

                return(M0 * (MH.Inverse() as SparseMatrix));
            }
            public static SparseMatrix PorousMatrix(bool Rigid, double d, Complex kt, double freq, double porosity, double tortuosity, double YoungsModulus, double PoissonRatio, double flow_resistivity, double FrameDensity, double AmbientMeanPressure, double Viscous_Characteristic_Length = 0, double Viscous_Permeability = 0, double Thermal_Characteristic_Length = 0, double Thermal_Permeability = 0)
            {
                //Viscous_Characteristic_Length = 0.56E-4;
                //Thermal_Characteristic_Length = 1.1E-4;
                //Get the Viscous Parameters...
                if (Viscous_Characteristic_Length == 0)
                {
                    Viscous_Characteristic_Length = System.Math.Sqrt(8 * AbsorptionModels.Biot_Porous_Absorbers.Shear_Viscosity * tortuosity / (flow_resistivity * porosity));
                }
                if (Viscous_Permeability == 0)
                {
                    Viscous_Permeability = Biot_Porous_Absorbers.Viscous_Permeability(flow_resistivity);
                }
                ////Get the Thermal Parameters...
                if (Thermal_Characteristic_Length == 0)
                {
                    Thermal_Characteristic_Length = Biot_Porous_Absorbers.Thermal_Characteristic_Length(Viscous_Characteristic_Length);
                }
                if (Thermal_Permeability == 0)
                {
                    Thermal_Permeability = Viscous_Permeability;                           //;porosity * Thermal_Characteristic_Length * Thermal_Characteristic_Length / 8;
                }
                double  w          = Utilities.Numerics.PiX2 * freq;
                Complex FrameShear = AbsorptionModels.Biot_Porous_Absorbers.Shear_Modulus(YoungsModulus, PoissonRatio) * new Complex(1, .1);
                Complex Gw         = Biot_Porous_Absorbers.G_w(tortuosity, porosity, Viscous_Permeability, Viscous_Characteristic_Length, w);
                //Complex Gw = Biot_Porous_Absorbers.Gp_w(1, tortuosity, Viscous_Permeability, porosity, Viscous_Characteristic_Length, w);
                Complex Gpw   = Biot_Porous_Absorbers.G_w_prime(porosity, Thermal_Permeability, Thermal_Characteristic_Length, w);
                Complex kb    = 2 * FrameShear * (PoissonRatio + 1) / (3 * (1 - 2 * PoissonRatio));
                Complex Kf    = Biot_Porous_Absorbers.BulkMod_Fluid(w, AmbientMeanPressure, porosity, Thermal_Permeability, Gpw);//AmbientMeanPressure / (1 - (gamma - 1) / (gamma * alpha));
                double  rho12 = Biot_Porous_Absorbers.rho12(porosity, tortuosity);
                double  rhoa  = Biot_Porous_Absorbers.rhoA(rho12);

                Complex P, Q, R;

                if (!Rigid)
                {
                    //Universal (Limp) Frame Case:
                    double Ks = AbsorptionModels.Biot_Porous_Absorbers.BulkMod_Solid(YoungsModulus, PoissonRatio);
                    P = ((1 - porosity) * (1 - kb / Ks) * Ks + porosity * Ks * kb / Kf) / (1 - porosity - kb / Ks + porosity * Ks / Kf);
                    Q = (1 - porosity - kb / Ks) * porosity * Ks / (1 - porosity - kb / Ks + porosity * Ks / Kf);
                    R = porosity * porosity * Ks / (1 - porosity - kb / Ks + porosity * Ks / Kf);
                }
                else
                {
                    //Rigid Frame Case:
                    P = 4 * FrameShear / 3 + kb + ((1 - porosity) * (1 - porosity)) * Kf / porosity;
                    R = porosity * Kf;
                    Q = Kf * (1 - porosity);
                }

                Complex rho12eff = Biot_Porous_Absorbers.rho12eff(rhoa, porosity, flow_resistivity, Gw, w);
                Complex rho22eff = Biot_Porous_Absorbers.rho22eff(rhoa, porosity, flow_resistivity, Gw, w);
                Complex rho11eff = Biot_Porous_Absorbers.rho11eff(FrameDensity, rhoa, porosity, flow_resistivity, Gw, w);

                Complex test = w * Complex.Sqrt(rho22eff / R);

                Complex D       = (P * rho22eff + R * rho11eff - 2 * Q * rho12eff);
                Complex rtDELTA = Complex.Sqrt(D * D - 4 * (P * R - Q * Q) * (rho11eff * rho22eff - rho12eff * rho12eff));
                Complex delta   = w * w / (2 * (P * R - Q * Q));
                Complex drho    = P * rho22eff + R * rho11eff - Q * rho12eff;
                Complex delta21 = delta * (drho - rtDELTA);
                Complex delta22 = delta * (drho + rtDELTA);
                Complex delta23 = (w * w / FrameShear) * ((rho11eff * rho22eff - rho12eff * rho12eff) / rho22eff);

                //Complex kt = k * sin_theta;
                Complex k13 = Complex.Sqrt(delta21 - kt * kt);
                Complex k23 = Complex.Sqrt(delta22 - kt * kt);
                Complex k33 = Complex.Sqrt(delta23 - kt * kt);
                Complex Mu1 = P * delta21 - w * w * rho11eff / (w * w * rho12eff - Q * delta21);
                Complex Mu2 = P * delta22 - w * w * rho11eff / (w * w * rho12eff - Q * delta22);
                Complex Mu3 = FrameShear * delta23 - w * w * rho11eff / (w * w * rho22eff);

                SparseMatrix GH  = GammaH_P(kt, w, d, FrameShear, P, Q, R, k13, k23, k33, Mu1, Mu2, Mu3);
                SparseMatrix G0T = GammaH_P(kt, w, 0, FrameShear, P, Q, R, k13, k23, k33, Mu1, Mu2, Mu3).Inverse() as SparseMatrix;

                //SparseMatrix G0T = Gamma0T_P(kt, w, FrameShear, P, Q, R, k13, k23, k33, Mu1, Mu2, Mu3);

                return(GH * G0T);
            }