Exemple #1
0
        private IVector CalculateRhsImplicit(ILinearSystem linearSystem, bool addRhs)
        {
            //TODO: what is the meaning of addRhs? Do we need this when solving dynamic thermal equations?
            //TODO: stabilizingRhs has not been implemented

            // result = (capacity/dt^2-diffusionConductivity/dt-massTransportConductivity/dt+stabilizingConductivity)*temperature - (StabilizingRhs - rhs/dt))
            // result = -dt(conductuvity*temperature - rhs -dt(stabilizingConductivity*temperature + StabilizingRhs))
            double a0 = 1 / Math.Pow(timeStep, 2);
            double a1 = 1 / (2 * timeStep);
            double a2 = 1 / timeStep;
            int    id = linearSystem.Subdomain.ID;

            capacityTimesTemperature[id] = provider.CapacityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            capacityTimesTemperature[id].ScaleIntoThis(a0);
            diffusionConductivityTimesTemperature[id] = provider.DiffusionConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            diffusionConductivityTimesTemperature[id].ScaleIntoThis(a2);
            massTransportConductivityTimesTemperature[id] = provider.MassTransportConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            massTransportConductivityTimesTemperature[id].ScaleIntoThis(a2);
            stabilizingConductivityTimesTemperature[id] = provider.StabilizingConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            rhs[id].ScaleIntoThis(a2);
            var rhsResult = capacityTimesTemperature[id].Subtract(diffusionConductivityTimesTemperature[id]);

            rhsResult.SubtractIntoThis(massTransportConductivityTimesTemperature[id].Subtract(stabilizingConductivityTimesTemperature[id]));
            rhsResult.SubtractIntoThis(stabilizingRhs[id].Subtract(rhs[id]));
            return(rhsResult);
        }
Exemple #2
0
        private IVector CalculateRhsImplicit(ILinearSystem linearSystem, bool addRhs)
        {
            //TODO: what is the meaning of addRhs? Do we need this when solving dynamic thermal equations?
            //TODO: stabilizingRhs has not been implemented

            // result = (capacity/dt^2-diffusionConductivity/dt-massTransportConductivity/dt+stabilizingConductivity)*temperature - (StabilizingRhs - rhs/dt))
            // result = -dt(conductuvity*temperature - rhs -dt(stabilizingConductivity*temperature + StabilizingRhs))
            int id = linearSystem.Subdomain.ID;

            double[,] kappa = new double[model.Nodes.Count, model.Nodes.Count];
            kappa[0, 0]     = 1;
            kappa[model.Nodes.Count - 1, model.Nodes.Count - 1] = 1;
            IMatrix penalty = Matrix.CreateFromArray(kappa);
            double  a0      = 1 / Math.Pow(timeStep, 2);
            double  a1      = 1 / (2 * timeStep);
            double  a2      = 1 / timeStep;

            dummyWeakImpositionTimesTemperature[id] = penalty.Multiply(temperature[id]);
            dummyWeakImpositionTimesTemperature[id].ScaleIntoThis(a2);
            capacityTimesTemperature[id] = provider.CapacityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            capacityTimesTemperature[id].ScaleIntoThis(a0);
            diffusionConductivityTimesTemperature[id] = provider.DiffusionConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            diffusionConductivityTimesTemperature[id].ScaleIntoThis(a2);
            diffusionConductivityTimesTemperature[id].AddIntoThis(dummyWeakImpositionTimesTemperature[id]);
            massTransportConductivityTimesTemperature[id] = provider.MassTransportConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            massTransportConductivityTimesTemperature[id].ScaleIntoThis(a2);
            stabilizingConductivityTimesTemperature[id] = provider.StabilizingConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
            rhs[id].ScaleIntoThis(a2);
            var rhsResult = capacityTimesTemperature[id].Subtract(diffusionConductivityTimesTemperature[id]);

            rhsResult.SubtractIntoThis(massTransportConductivityTimesTemperature[id].Subtract(stabilizingConductivityTimesTemperature[id]));
            rhsResult.SubtractIntoThis(stabilizingRhs[id].Subtract(rhs[id]));
            return(rhsResult);
        }
Exemple #3
0
        private IVector CalculateRhsImplicit(ILinearSystem linearSystem, int ti)
        {
            //TODO: what is the meaning of addRhs? Do we need this when solving dynamic thermal equations?
            //TODO: stabilizingRhs has not been implemented

            // result = (capacity/dt^2-diffusionConductivity/dt-massTransportConductivity/dt+stabilizingConductivity)*temperature - (StabilizingRhs - rhs/dt))
            // result = -dt(conductuvity*temperature - rhs -dt(stabilizingConductivity*temperature + StabilizingRhs))
            int    id = linearSystem.Subdomain.ID;
            double a0 = 1 / Math.Pow(timeStep, 2);
            double a1 = 1 / (2 * timeStep);
            double a2 = 1 / timeStep;

            if (timeIncrement < BDForder - 1)
            {
                capacityTimesTemperature[id] = provider.CapacityMatrixVectorProduct(linearSystem.Subdomain, temperature[BDForder][id]);
                capacityTimesTemperature[id].ScaleIntoThis(a0);
                //stabilizingConductivityTimesTemperature[id] = provider.StabilizingConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
                rhs[id].ScaleIntoThis(a2);
                var rhsResult = capacityTimesTemperature[id].Subtract(stabilizingRhs[id]);
                rhsResult.AddIntoThis(rhs[id]);
                return(rhsResult);
            }
            else
            {
                effectiveTemperature[id].Clear();
                for (int i = 0; i < BDForder; i++)
                {
                    var a = temperature[i][id].Scale(BDFcoeff[BDForder - 1, i]);
                    effectiveTemperature[id].AddIntoThis(a);
                }
                capacityTimesTemperature[id] = provider.CapacityMatrixVectorProduct(linearSystem.Subdomain, effectiveTemperature[id]);
                capacityTimesTemperature[id].ScaleIntoThis(-a0);
                //stabilizingConductivityTimesTemperature[id] = provider.StabilizingConductivityMatrixVectorProduct(linearSystem.Subdomain, temperature[id]);
                var rhsLoads = rhs[id].LinearCombination(a2, stabilizingRhs[id], 1);
                rhsLoads.ScaleIntoThis(BDFcoeff[BDForder - 1, BDForder + 1]);
                var rhsResult = capacityTimesTemperature[id].Add(rhsLoads);
                return(rhsResult);
            }
        }