/// <summary>
        /// This method creates a new instance of class <see cref="Beam{TProfile}"/>.
        /// This is a step to create the input fot finite element analysis.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="degreesOfFreedom"></param>
        /// <returns>A new instance of class <see cref="Beam{TProfile}"/>.</returns>
        public override async Task <Beam <TProfile> > BuildBeam(BeamRequest <TProfile> request, uint degreesOfFreedom)
        {
            GeometricProperty geometricProperty = new GeometricProperty();

            if (request.Profile.Area != null && request.Profile.MomentOfInertia != null)
            {
                geometricProperty.Area = await ArrayFactory.CreateVectorAsync(request.Profile.Area.Value, request.NumberOfElements).ConfigureAwait(false);

                geometricProperty.MomentOfInertia = await ArrayFactory.CreateVectorAsync(request.Profile.MomentOfInertia.Value, request.NumberOfElements).ConfigureAwait(false);
            }
            else
            {
                geometricProperty.Area = await this._geometricProperty.CalculateArea(request.Profile, request.NumberOfElements).ConfigureAwait(false);

                geometricProperty.MomentOfInertia = await this._geometricProperty.CalculateMomentOfInertia(request.Profile, request.NumberOfElements).ConfigureAwait(false);
            }

            var beam = new Beam <TProfile>()
            {
                Fastenings        = await this._mappingResolver.BuildFastenings(request.Fastenings).ConfigureAwait(false),
                Forces            = await this._mappingResolver.BuildForceVector(request.Forces, degreesOfFreedom).ConfigureAwait(false),
                GeometricProperty = geometricProperty,
                Length            = request.Length,
                Material          = MaterialFactory.Create(request.Material),
                NumberOfElements  = request.NumberOfElements,
                Profile           = request.Profile
            };

            return(beam);
        }
Esempio n. 2
0
        /// <summary>
        /// This method creates a new instance of class <see cref="BeamWithDva{TProfile}"/>.
        /// This is a step to create the input fot finite element analysis.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="degreesOfFreedom"></param>
        /// <returns>A new instance of class <see cref="Beam{TProfile}"/>.</returns>
        public override async Task <BeamWithDva <TProfile> > BuildBeam(BeamWithDvaRequest <TProfile> request, uint degreesOfFreedom)
        {
            double[] dvaMasses        = new double[request.Dvas.Count];
            double[] dvaStiffnesses   = new double[request.Dvas.Count];
            uint[]   dvaNodePositions = new uint[request.Dvas.Count];

            int i = 0;

            foreach (DynamicVibrationAbsorber dva in request.Dvas)
            {
                dvaMasses[i]        = dva.Mass;
                dvaStiffnesses[i]   = dva.Stiffness;
                dvaNodePositions[i] = dva.NodePosition;
                i += 1;
            }

            GeometricProperty geometricProperty = new GeometricProperty();

            if (request.Profile.Area != 0 && request.Profile.MomentOfInertia != 0)
            {
                geometricProperty.Area = await ArrayFactory.CreateVectorAsync(request.Profile.Area.Value, request.NumberOfElements).ConfigureAwait(false);

                geometricProperty.MomentOfInertia = await ArrayFactory.CreateVectorAsync(request.Profile.MomentOfInertia.Value, request.NumberOfElements).ConfigureAwait(false);
            }
            else
            {
                geometricProperty.Area = await this._geometricProperty.CalculateArea(request.Profile, request.NumberOfElements).ConfigureAwait(false);

                geometricProperty.MomentOfInertia = await this._geometricProperty.CalculateMomentOfInertia(request.Profile, request.NumberOfElements).ConfigureAwait(false);
            }

            var beam = new BeamWithDva <TProfile>()
            {
                DvaMasses         = dvaMasses,
                DvaNodePositions  = dvaNodePositions,
                DvaStiffnesses    = dvaStiffnesses,
                Fastenings        = await this._mappingResolver.BuildFastenings(request.Fastenings).ConfigureAwait(false),
                Forces            = await this._mappingResolver.BuildForceVector(request.Forces, degreesOfFreedom + (uint)request.Dvas.Count).ConfigureAwait(false),
                GeometricProperty = geometricProperty,
                Length            = request.Length,
                Material          = MaterialFactory.Create(request.Material),
                NumberOfElements  = request.NumberOfElements,
                Profile           = request.Profile
            };

            return(beam);
        }
        public CalculateGeometricPropertyTest()
        {
            this._operation = new GeometricProperty();

            this._precision = 1e-18;

            this._diameter             = 0.03175;
            this._width                = 25e-3;
            this._height               = 3e-3;
            this._piezoelectricHeight  = 0.267e-3;
            this._diameterThickness    = 2.1e-3;
            this._rectangularThickness = 0.5e-3;

            // The calculations were made manually with the values inside that test.
            this._circleWithThicknessArea                  = 1.95611266575769E-04;
            this._circleWithoutThicknessArea               = 7.91730436089840E-04;
            this._circleWithThicknessMomentOfInertia       = 2.1603613923E-08;
            this._circleWithoutThicknessMomentOfInertia    = 4.9882110171E-08;
            this._rectangleWithThicknessArea               = 2.7000000000000E-05;
            this._rectangleWithoutThicknessArea            = 7.5000000000000E-05;
            this._rectangleWithThicknessMomentOfInertia    = 4.0250000E-11;
            this._rectangleWithoutThicknessMomentOfInertia = 5.6250000E-11;
            this._rectanglePiezoelectricMomentOfInertia    = 3.5701411E-11;
        }
        /// <summary>
        /// This method creates a new instance of class <see cref="BeamWithPiezoelectric{TProfile}"/>.
        /// This is a step to create the input fot finite element analysis.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="degreesOfFreedom"></param>
        /// <returns>A new instance of class <see cref="BeamWithPiezoelectric{TProfile}"/>.</returns>
        public override async Task <BeamWithPiezoelectric <TProfile> > BuildBeam(BeamWithPiezoelectricRequest <TProfile> request, uint degreesOfFreedom)
        {
            GeometricProperty geometricProperty = new GeometricProperty();
            GeometricProperty piezoelectricGeometricProperty = new GeometricProperty();

            uint numberOfPiezoelectricPerElements = PiezoelectricPositionFactory.Create(request.PiezoelectricPosition);

            uint[] elementsWithPiezoelectric = request.ElementsWithPiezoelectric ?? this.CreateVectorWithAllElements(request.NumberOfElements);

            // Calculating beam geometric properties.
            if (request.Profile.Area != null && request.Profile.MomentOfInertia != null)
            {
                geometricProperty.Area = await ArrayFactory.CreateVectorAsync(request.Profile.Area.Value, request.NumberOfElements).ConfigureAwait(false);

                geometricProperty.MomentOfInertia = await ArrayFactory.CreateVectorAsync(request.Profile.MomentOfInertia.Value, request.NumberOfElements).ConfigureAwait(false);
            }
            else
            {
                geometricProperty.Area = await this._geometricProperty.CalculateArea(request.Profile, request.NumberOfElements).ConfigureAwait(false);

                geometricProperty.MomentOfInertia = await this._geometricProperty.CalculateMomentOfInertia(request.Profile, request.NumberOfElements).ConfigureAwait(false);
            }

            // Calculating piezoelectric geometric properties.
            if (request.PiezoelectricProfile.Area != null && request.PiezoelectricProfile.MomentOfInertia != null)
            {
                double area            = request.PiezoelectricProfile.Area.Value * numberOfPiezoelectricPerElements;
                double momentOfInertia = request.PiezoelectricProfile.MomentOfInertia.Value * numberOfPiezoelectricPerElements;

                piezoelectricGeometricProperty.Area = await ArrayFactory.CreateVectorAsync(area, request.NumberOfElements, elementsWithPiezoelectric).ConfigureAwait(false);

                piezoelectricGeometricProperty.MomentOfInertia = await ArrayFactory.CreateVectorAsync(momentOfInertia, request.NumberOfElements, elementsWithPiezoelectric).ConfigureAwait(false);
            }
            else
            {
                piezoelectricGeometricProperty.Area = await this._geometricProperty.CalculatePiezoelectricArea(request.PiezoelectricProfile, request.NumberOfElements, elementsWithPiezoelectric, numberOfPiezoelectricPerElements).ConfigureAwait(false);

                piezoelectricGeometricProperty.MomentOfInertia = await this._geometricProperty.CalculatePiezoelectricMomentOfInertia(request.PiezoelectricProfile, request.Profile, request.NumberOfElements, elementsWithPiezoelectric, numberOfPiezoelectricPerElements).ConfigureAwait(false);
            }

            var beam = new BeamWithPiezoelectric <TProfile>()
            {
                DielectricConstant        = request.DielectricConstant,
                DielectricPermissiveness  = request.DielectricPermissiveness,
                ElasticityConstant        = request.ElasticityConstant,
                ElectricalCharge          = new double[request.NumberOfElements + 1],
                ElementsWithPiezoelectric = elementsWithPiezoelectric,
                Fastenings        = await this._mappingResolver.BuildFastenings(request.Fastenings).ConfigureAwait(false),
                Forces            = await this._mappingResolver.BuildForceVector(request.Forces, degreesOfFreedom).ConfigureAwait(false),
                GeometricProperty = geometricProperty,
                Length            = request.Length,
                Material          = MaterialFactory.Create(request.Material),
                NumberOfElements  = request.NumberOfElements,
                NumberOfPiezoelectricPerElements = numberOfPiezoelectricPerElements,
                PiezoelectricConstant            = request.PiezoelectricConstant,
                PiezoelectricDegreesOfFreedom    = request.NumberOfElements + 1,
                PiezoelectricGeometricProperty   = piezoelectricGeometricProperty,
                PiezoelectricProfile             = request.PiezoelectricProfile,
                PiezoelectricSpecificMass        = request.PiezoelectricSpecificMass,
                PiezoelectricYoungModulus        = request.PiezoelectricYoungModulus,
                Profile = request.Profile
            };

            return(beam);
        }