Esempio n. 1
0
        // ....Compute element Matrix.....................................
        public override double[,] ComputeMatrix()
        {
            double[] gaussCoord = { -1 / Math.Sqrt(3), 1 / Math.Sqrt(3) };
            if (Modell.Material.TryGetValue(ElementMaterialId, out var abstractMaterial))
            {
            }
            material        = (Material)abstractMaterial;
            ElementMaterial = material ?? throw new ArgumentNullException(nameof(material));
            var conductivity = material.Leitfähigkeit[0];

            MatrizenAlgebra.Clear(elementMatrix);
            foreach (var coor1 in gaussCoord)
            {
                foreach (var coor2 in gaussCoord)
                {
                    var z0 = coor1;
                    var z1 = coor2;
                    ComputeGeometry(z0, z1);
                    Sx = ComputeSx(z0, z1);
                    // Ke = C*Sx*SxT*determinant
                    MatrizenAlgebra.MultAddMatrixTransposed(elementMatrix, Determinant * conductivity, Sx, Sx);
                }
            }
            return(elementMatrix);
        }
Esempio n. 2
0
        // ... compute element matrix ..................................
        public override double[,] ComputeMatrix()
        {
            ComputeGeometry();
            var factor = ElementMaterial.MaterialWerte[0] * ElementCrossSection.QuerschnittsWerte[0] / length;
            var sx     = ComputeSx();

            _stiffnessMatrix = MatrizenAlgebra.MultTransposedRect(factor, sx);
            return(_stiffnessMatrix);
        }
Esempio n. 3
0
        // ....Compute element matrix.....................................
        public override double[,] ComputeMatrix()
        {
            ComputeGeometry();
            ComputeStrainDisplacementTransformation();
            ComputeMaterial();
            // Ke = 0.5*thickness*determinant*BT*E*B
            var temp = MatrizenAlgebra.MultTransposedMatrix(0.5 * ElementCrossSection.QuerschnittsWerte[0] * Determinant, b, e);

            matrix = MatrizenAlgebra.Mult(temp, b);
            return(matrix);
        }
Esempio n. 4
0
        public override double[] ComputeElementState(double z0, double z1, double z2)
        {
            for (var i = 0; i < 8; i++)
            {
                elementTemperatures[i] = Nodes[i].NodalDof[0];
            }
            // midPointHeatState = E * Sx(transponiert) * Temperatures
            var midpointHeatState = MatrizenAlgebra.MultTransposed(Sx, elementTemperatures);

            midpointHeatState = MatrizenAlgebra.Mult(e, midpointHeatState);
            return(midpointHeatState);
        }
Esempio n. 5
0
        // --- Elementverhalten ----------------------------------

        // ....Berechne Elementspannungen: sigma = E * B * Ue (Element Verformungen) ......
        public override double[] ComputeZustandsvektor()
        {
            for (var i = 0; i < NodesPerElement; i++)
            {
                var nodalDof = i * 2;
                elementVerformungen[nodalDof]     = Nodes[i].NodalDof[0];
                elementVerformungen[nodalDof + 1] = Nodes[i].NodalDof[1];
            }
            var temp = MatrizenAlgebra.Mult(e, b);
            var elementSpannungen = MatrizenAlgebra.Mult(temp, elementVerformungen);

            return(elementSpannungen);
        }
Esempio n. 6
0
        public override double[] ComputeElementState(double z0, double z1)
        {
            _ = new double[2];                 // in element
            ComputeGeometry(z0, z1);
            Sx = ComputeSx(z0, z1);
            for (var i = 0; i < NodesPerElement; i++)
            {
                elementTemperatures[i] = Nodes[i].NodalDof[0];
            }
            var conductivity      = material.Leitfähigkeit[0];
            var midpointHeatState = MatrizenAlgebra.MultTransposed(-conductivity, Sx, elementTemperatures);

            return(midpointHeatState);
        }
Esempio n. 7
0
        // --- Elementverhalten ----------------------------------

        // ....Berechne Elementspannungen: sigma = E * B * Ue (Elementverformungen) ......
        public override double[] ComputeZustandsvektor()
        {
            for (var i = 0; i < 8; i++)
            {
                var nodalDof = i * ElementDof;
                elementDeformations[nodalDof]     = Nodes[i].NodalDof[0];
                elementDeformations[nodalDof + 1] = Nodes[i].NodalDof[1];
                elementDeformations[nodalDof + 2] = Nodes[i].NodalDof[2];
            }
            var temp            = MatrizenAlgebra.Mult(e, b);
            var elementStresses = MatrizenAlgebra.Mult(temp, elementDeformations);

            return(elementStresses);
        }
Esempio n. 8
0
        // ... compute end forces of frame element........................
        public override double[] ComputeElementState()
        {
            var localMatrix = ComputeLocalMatrix();
            var vector      = ComputeZustandsvektor();

            // contribution of the node deformations
            ElementState    = MatrizenAlgebra.Mult(localMatrix, vector);
            ElementState[2] = -ElementState[2];

            // contribution of the beam loads
            foreach (var item in modell.PunktLasten)
            {
                if (!(item.Value is PunktLast punktLast))
                {
                    continue;
                }
                if (punktLast.ElementId != ElementId)
                {
                    continue;
                }
                vector    = punktLast.ComputeLocalLoadVector();
                vector[2] = -vector[2];
                for (var i = 0; i < vector.Length; i++)
                {
                    ElementState[i] -= vector[i];
                }
            }
            foreach (var item in modell.ElementLasten)
            {
                if (!(item.Value is LinienLast linienLast))
                {
                    continue;
                }
                if (linienLast.ElementId != ElementId)
                {
                    continue;
                }
                vector    = linienLast.ComputeLocalLoadVector();
                vector[2] = -vector[2];
                for (var i = 0; i < vector.Length; i++)
                {
                    ElementState[i] -= vector[i];
                }
            }
            return(ElementState);
        }
Esempio n. 9
0
        protected double[,] ComputeSx(double z0, double z1, double z2)
        {
            var zx = new double[3, 3];

            zx[0, 0] = (xz[1, 1] * xz[2, 2] - xz[1, 2] * xz[2, 1]) / Determinant;
            zx[1, 0] = -(xz[1, 0] * xz[2, 2] - xz[1, 2] * xz[2, 0]) / Determinant;
            zx[2, 0] = (xz[1, 0] * xz[2, 1] - xz[1, 1] * xz[2, 0]) / Determinant;

            zx[0, 1] = -(xz[0, 1] * xz[2, 2] - xz[0, 2] * xz[2, 1]) / Determinant;
            zx[1, 1] = (xz[0, 0] * xz[2, 2] - xz[0, 2] * xz[2, 0]) / Determinant;
            zx[2, 1] = -(xz[0, 0] * xz[2, 1] - xz[0, 1] * xz[2, 0]) / Determinant;

            zx[0, 2] = (xz[0, 1] * xz[1, 2] - xz[0, 2] * xz[1, 1]) / Determinant;
            zx[1, 2] = -(xz[0, 0] * xz[1, 2] - xz[0, 2] * xz[1, 0]) / Determinant;
            zx[2, 2] = (xz[0, 0] * xz[1, 1] - xz[0, 1] * xz[1, 0]) / Determinant;
            Sx       = MatrizenAlgebra.Mult(sz, zx);
            return(Sx);
        }
Esempio n. 10
0
        // ....Compute element Matrix.....................................
        public override double[,] ComputeMatrix()
        {
            ComputeGeometry();
            if (Modell.Material.TryGetValue(ElementMaterialId, out var abstractMaterial))
            {
            }
            material        = (Material)abstractMaterial;
            ElementMaterial = material;
            if (material == null)
            {
                return(elementMatrix);
            }
            var conductivity = material.Leitfähigkeit[0];

            // Ke = area*c*Sx*SxT
            elementMatrix = MatrizenAlgebra.RectMultMatrixTransposed(0.5 * Determinant * conductivity, Sx, Sx);

            return(elementMatrix);
        }
Esempio n. 11
0
        // ....Compute element matrix.....................................
        public override double[,] ComputeMatrix()
        {
            if (Modell.Material.TryGetValue(ElementMaterialId, out var abstractMaterial))
            {
            }
            Material = (Material)abstractMaterial;
            double[] gCoord  = { -1 / Math.Sqrt(5.0 / 3), 0, 1 / (Math.Sqrt(5.0 / 3)) };
            double[] gWeight = { (5.0 / 9), (8.0 / 9), (5.0 / 9) };                               // gaussian coordinates, weights
            _ = new double[8, 3];
            MatrizenAlgebra.Clear(elementMatrix);

            // material matrix für ebene Verzerrung (plane strain)
            var conduct = ((Material)Material)?.Leitfähigkeit;

            if (conduct != null)
            {
                e[0, 0] = conduct[0];
                e[1, 1] = conduct[1];
                e[2, 2] = conduct[2];
            }

            for (var i = 0; i < gCoord.Length; i++)
            {
                var z0 = gCoord[i]; var g0 = gWeight[i];
                for (var j = 0; j < gCoord.Length; j++)
                {
                    var z1 = gCoord[j]; var g1 = gWeight[j];
                    for (var k = 0; k < gCoord.Length; k++)
                    {
                        var z2 = gCoord[k]; var g2 = gWeight[k];
                        ComputeGeometry(z0, z1, z2);
                        Sx = ComputeSx(z0, z1, z2);
                        // Ke = determinant*g0*g1*g2*Sx*E*SxT
                        var temp = MatrizenAlgebra.Mult(Sx, e);
                        MatrizenAlgebra.MultAddMatrixTransposed(elementMatrix, Determinant * g0 * g1 * g2, temp, Sx);
                    }
                }
            }
            return(elementMatrix);
        }
Esempio n. 12
0
        public override double[] ComputeElementState(double z0, double z1)
        {
            var elementWärmeStatus = new double[2];             // in element

            ComputeGeometry();
            if (Modell.Material.TryGetValue(ElementMaterialId, out var abstractMaterial))
            {
            }
            material        = (Material)abstractMaterial;
            ElementMaterial = material;
            if (Modell.Elemente.TryGetValue(ElementId, out element))
            {
                for (var i = 0; i < element.Nodes.Length; i++)
                {
                    if (Modell.Knoten.TryGetValue(element.NodeIds[i], out knoten))
                    {
                    }

                    //Debug.Assert(node != null, nameof(node) + " != null");
                    if (knoten != null)
                    {
                        elementTemperatures[i] = knoten.NodalDof[0];
                    }
                }

                if (material == null)
                {
                    return(elementWärmeStatus);
                }
                var conductivity = material.Leitfähigkeit[0];
                elementWärmeStatus = MatrizenAlgebra.MultTransposed(-conductivity, Sx, elementTemperatures);
            }
            else
            {
                throw new ModellAusnahme("Element2D3: " + ElementId + " nicht im Modell gefunden");
            }
            return(elementWärmeStatus);
        }
Esempio n. 13
0
 // ....Compute element matrix.....................................
 public override double[,] ComputeMatrix()
 {
     MatrizenAlgebra.Clear(elementMatrix);
     ComputeMaterial();
     for (var i = 0; i < GCoord.Length; i++)
     {
         z0 = GCoord[i]; g0 = GWeight[i];
         for (var j = 0; j < GCoord.Length; j++)
         {
             z1 = GCoord[j]; g1 = GWeight[j];
             for (var k = 0; k < GCoord.Length; k++)
             {
                 z2 = GCoord[k]; g2 = GWeight[k];
                 ComputeGeometry(z0, z1, z2);
                 Sx = ComputeSx(z0, z1, z2);
                 ComputeStrainDisplacementTransformation();
                 // Ke = determinant*g0*g1*g2*BT*E*B
                 var temp = MatrizenAlgebra.MultTransposedMatrix(Determinant * g0 * g1 * g2, b, e);
                 MatrizenAlgebra.MultAddMatrix(elementMatrix, temp, b);
             }
         }
     }
     return(elementMatrix);
 }
Esempio n. 14
0
        //... solveEigenstates() ....................................................
        public void SolveEigenstates()
        {
            // allocate the solution vectors
            x = new double[numberOfStates][];
            p = new double[numberOfStates][];
            for (var i = 0; i < numberOfStates; i++)
            {
                x[i] = new double[dimension];
                p[i] = new double[dimension];
            }
            eigenValue = new double[numberOfStates];

            // reduce the number of eigenvalues to the maximum possible number
            var counter = 0;

            for (row = 0; row < dimension; row++)
            {
                if (status[row])
                {
                    counter++;
                }
            }
            if (numberOfStates > dimension - counter)
            {
                numberOfStates = dimension - counter;
            }

            var profileSolverStatus =
                new ProfillöserStatus(a, w, y, status, profile);

            // loop over the specified number of eigenstates
            for (state = 0; state < numberOfStates; state++)
            {
                raleigh = 0;
                s       = 0;
                // set start vector w0
                for (row = 0; row < dimension; row++)
                {
                    if (status[row])
                    {
                        w[row] = 0;
                    }
                    else
                    {
                        w[row] = 1;
                    }
                }

                // start iteration for next eigenstate
                double m;
                do
                {
                    // increment iteration counter
                    s++;
                    // check if number of iterations is greater Smax
                    if (s > SMax)
                    {
                        throw new BerechnungAusnahme("Eigensolver: too many iterations " + s);
                    }

                    // B-orthogonalization of w(s-1) with respect to all smaller
                    // eigenvectors x[0] to x[state-1]
                    for (var i = 0; i < state; i++)
                    {
                        var c = 0.0;
                        // compute c(i) and subtract c(i)*p(i) from w
                        for (row = 0; row < dimension; row++)
                        {
                            if (!status[row])
                            {
                                c += w[row] * x[i][row];
                            }
                        }
                        for (row = 0; row < dimension; row++)
                        {
                            if (!status[row])
                            {
                                w[row] -= c * p[i][row];
                            }
                        }
                    }

                    // solve A * y(s) = w(s-1) for y(s)
                    profileSolverStatus.SetRhs(w);
                    profileSolverStatus.SolvePrimal();

                    // compute z(s) = B * y(s)
                    z = MatrizenAlgebra.Mult(b, y, status, profile);

                    // compute m2 = 1 / (y[s] * z[s])
                    double sum = 0;
                    for (row = 0; row < dimension; row++)
                    {
                        if (!status[row])
                        {
                            sum += y[row] * z[row];
                        }
                    }
                    m2 = 1 / sum;


                    //	compute Rayleigh quotient r = m2 * y(s)(T) * w(s-1)
                    // and the difference ( r(s) - r(s-1) )
                    sum = 0;
                    for (row = 0; row < dimension; row++)
                    {
                        if (!status[row])
                        {
                            sum += y[row] * w[row];
                        }
                    }
                    sum         *= m2;
                    deltaRaleigh = sum - raleigh;
                    raleigh      = sum;

                    //	compute w(s) = m(s) * z(s)
                    m = Math.Sqrt(Math.Abs(m2));
                    for (row = 0; row < dimension; row++)
                    {
                        if (!status[row])
                        {
                            w[row] = m * z[row];
                        }
                    }

                    // continue iteration as long as change in Rayleigh factor (r(s)-r(s-1)
                    // is greater than error bound
                } while (Math.Abs(deltaRaleigh) > Math.Abs(RaleighFactor * raleigh));

                // store computed eigenstate and vector p=w=Bx for B-orthogonalization
                eigenValue[state] = raleigh;
                for (row = 0; row < dimension; row++)
                {
                    x[state][row] = m * y[row];
                    p[state][row] = w[row];
                }
            }
        }
Esempio n. 15
0
        public void Perform()
        {
            double alfa, beta, gamma, theta;

            if (method == 1)
            {
                alfa = 0; theta = 1; beta = parameter1; gamma = parameter2;
            }
            else if (method == 2)
            {
                beta = 1.0 / 6; gamma = 0.5; alfa = 0; theta = parameter1;
            }
            else if (method == 3)
            {
                theta = 1; alfa = parameter1; gamma = 0.5 - alfa; beta = 0.25 * (1 - alfa) * (1 - alfa);
            }
            else
            {
                throw new BerechnungAusnahme("TimeIntegration2NdOrderStatus: invalid method identifier entered");
            }

            var gammaDt             = gamma * dt;
            var betaDt2             = beta * dt * dt;
            var gammaDtTheta        = gamma * dt * theta;
            var dt1MGamma           = dt * (1 - gamma);
            var dt2MBetaDt2         = dt * dt / 2 - beta * dt * dt;
            var thetaDt             = theta * dt;
            var thetaDt1MGamma      = theta * dt * (1 - gamma);
            var theta2Dt2MBetaDt2   = theta * theta * dt2MBetaDt2;
            var betaDt2Theta2AlfaP1 = beta * dt * dt * theta * theta * (1 + alfa);

            var primal    = new double[dimension];
            var dual      = new double[dimension];
            var timeSteps = displacement.Length;

            acceleration = new double[timeSteps][];
            for (var i = 0; i < timeSteps; i++)
            {
                acceleration[i] = new double[dimension];
            }

            // calculate initial accelerations at unrestrained dof, for M[i]>0
            var rhs = MatrizenAlgebra.Mult(k, displacement[0], status, profile);

            for (var i = 0; i < dimension; i++)
            {
                // if (status[i]) continue; ODER wenn M[i]=0 continue --> RHS[i]=0
                if (status[i] | m[i] == 0)
                {
                    continue;
                }
                rhs[i]             = (forcingFunction[0][i] - c[i] * velocity[0][i] - rhs[i]) / m[i];
                acceleration[0][i] = rhs[i];
            }

            // constant coefficient matrix
            var cm = new double[dimension][];

            for (var row = 0; row < dimension; row++)
            {
                cm[row] = new double[row + 1 - profile[row]];
                for (var col = 0; col <= (row - profile[row]); col++)
                {
                    cm[row][col] = betaDt2Theta2AlfaP1 * k[row][col];
                }
                cm[row][row - profile[row]] += m[row] + gammaDtTheta * c[row];
            }

            var profileSolverStatus = new ProfillöserStatus(
                cm, rhs, primal, dual, status, profile);

            profileSolverStatus.Decompose();

            for (var counter = 1; counter < timeSteps; counter++)
            {
                // calculate displacement(hat) and velocity(hat) at n+1
                for (var i = 0; i < dimension; i++)
                {
                    displacement[counter][i] = displacement[counter - 1][i]
                                               + thetaDt * velocity[0][i]
                                               + theta2Dt2MBetaDt2 * acceleration[counter - 1][i];
                    velocity[1][i] = velocity[0][i] + thetaDt1MGamma * acceleration[counter - 1][i];
                }

                // calculate new RHS
                for (var i = 0; i < dimension; i++)
                {
                    rhs[i] = (1 + alfa) * displacement[counter][i] - alfa * displacement[counter - 1][i];
                }
                rhs = MatrizenAlgebra.Mult(k, rhs, status, profile);
                for (var i = 0; i < dimension; i++)
                {
                    if (!status[i])
                    {
                        rhs[i] = (1 - theta) * forcingFunction[counter - 1][i]
                                 + theta * forcingFunction[counter][i]
                                 - c[i] * velocity[1][i] - rhs[i];
                    }
                }

                // backsubstitution
                profileSolverStatus.SetRhs(rhs);
                profileSolverStatus.SolvePrimal();

                // displacements, velocities and accelerations at next time step
                for (var i = 0; i < dimension; i++)
                {
                    if (status[i])
                    {
                        continue;
                    }
                    acceleration[counter][i] = acceleration[counter - 1][i]
                                               + (primal[i]
                                                  - acceleration[counter - 1][i]) / theta;
                    displacement[counter][i] = displacement[counter - 1][i]
                                               + dt * velocity[0][i]
                                               + dt2MBetaDt2 * acceleration[counter - 1][i]
                                               + betaDt2 * acceleration[counter][i];
                    velocity[0][i] = velocity[0][i]
                                     + dt1MGamma * acceleration[counter - 1][i]
                                     + gammaDt * acceleration[counter][i];
                }
            }
        }
Esempio n. 16
0
        public void Perform()
        {
            var alfaDt = alfa * dt;
            var dtAlfa = dt * (1 - alfa);
            var primal = new double[dimension];

            var timeSteps = Temperature.Length;

            That = new double[dimension];
            Tdot = new double[timeSteps][];
            for (var i = 0; i < timeSteps; i++)
            {
                Tdot[i] = new double[dimension];
            }

            // calculate initial temperature gradients
            var rhs = MatrizenAlgebra.Mult(k, Temperature[0], profile);

            for (var i = 0; i < dimension; i++)
            {
                Tdot[0][i] = (ForcingFunction[0][i] - rhs[i]) / c[i];
            }

            // evaluate constant coefficient matrix
            var cm = new double[dimension][];

            for (var row = 0; row < dimension; row++)
            {
                cm[row] = new double[row + 1 - profile[row]];
                for (var col = 0; col <= (row - profile[row]); col++)
                {
                    cm[row][col] = alfaDt * k[row][col];
                }
                cm[row][row - profile[row]] += c[row];
            }

            var profileSolverStatus =
                new ProfillöserStatus(cm, rhs, primal, status, profile);

            profileSolverStatus.Decompose();

            for (var counter = 1; counter < timeSteps; counter++)
            {
                // calculate temperature gradients at restrained nodes
                for (var i = 0; i < dimension; i++)
                {
                    if (status[i])
                    {
                        Tdot[counter][i] = (Temperature[counter][i] - Temperature[counter - 1][i]) / dt;
                    }
                }

                // calculate T(hat) for next step
                for (var i = 0; i < dimension; i++)
                {
                    if (status[i])
                    {
                        That[i] = Temperature[counter][i];
                    }
                    else
                    {
                        That[i] = Temperature[counter - 1][i] + dtAlfa * Tdot[counter - 1][i];
                    }
                }

                // modification of RHS
                rhs = MatrizenAlgebra.Mult(k, That, status, profile);
                var rhSfr = MatrizenAlgebra.MultUl(cm, Tdot[counter], status, profile);
                for (var i = 0; i < dimension; i++)
                {
                    rhs[i] = ForcingFunction[counter][i] - rhSfr[i] - rhs[i];
                }

                // backsubstitution
                profileSolverStatus.SetRhs(rhs);
                profileSolverStatus.SolvePrimal();

                // temperatures and gradients at next time step for unrestrained nodes
                for (var i = 0; i < dimension; i++)
                {
                    if (status[i])
                    {
                        continue;
                    }
                    Tdot[counter][i]        = primal[i];
                    Temperature[counter][i] = That[i] + alfaDt * primal[i];
                }
            }
        }