コード例 #1
0
ファイル: VPMRotor.cs プロジェクト: wtliu/pmsm_calculation
        /// <summary>
        /// Assuming a FEMM window is opened, build rotor into that
        /// </summary>
        /// <param name="MaterialParams"></param>
        public override void BuildInFEMM(FEMM femm = null)
        {
            if (femm == null)
            {
                femm = FEMM.DefaultFEMM;
            }

            bool fullbuild = Motor.GeneralParams.FullBuildFEMModel;

            // create material data
            femm.mi_addmaterialAir(AirMaterialName);
            femm.mi_addmaterialMagnet(MagnetMaterialName, mu_M, Hc, 0);
            femm.mi_addmaterialSteel(SteelMaterialName, 1, 1, Lam_d, Lam_fill, FEMM.LaminationType.NotLaminated,
                                     BH.Select(p => p.b).ToArray(), BH.Select(p => p.h).ToArray());

            // create boundary data
            femm.mi_addboundprop_Prescribed_A(BoundaryProperty, 0, 0, 0, 0);

            /////// Build 1 poles
            ////Half one
            // segments (magnet)
            femm.mi_addSegmentEx(xA, yA, xB, yB, Group_Lines_Rotor); //AB
            femm.mi_addSegmentEx(xB, yB, xE, yE, Group_Lines_Rotor); //BE
            femm.mi_addSegmentEx(xD, yD, xE, yE, Group_Lines_Rotor); //DE
            femm.mi_addSegmentEx(xE, yE, xF, yF, Group_Lines_Rotor); //EF
            femm.mi_addSegmentEx(xF, yF, xC, yC, Group_Lines_Rotor); //FC
            femm.mi_addSegmentEx(xD, yD, xG, yG, Group_Lines_Rotor); //DG
            femm.mi_addSegmentEx(xH, yH, xG, yG, Group_Lines_Rotor); //HG
            femm.mi_addSegmentEx(xH, yH, xI, yI, Group_Lines_Rotor); //HI
            femm.mi_addSegmentEx(xI, yI, xF, yF, Group_Lines_Rotor); //IF
            femm.mi_addSegmentEx(xH, yH, xJ, yJ, Group_Lines_Rotor); //HJ
            femm.mi_addSegmentEx(xI, yI, xK, yK, Group_Lines_Rotor); //IK
            if (Poletype == PoleType.MiddleAir)
            {
                femm.mi_addSegmentEx(xJ, yJ, xJ, 0, Group_Lines_Rotor);//JJ1
            }
            else
            {
                femm.mi_addSegmentEx(xJ, yJ, xK, yK, Group_Lines_Rotor); //JK
            }
            // arcsegments AC
            double a = (Math.Atan(yA / xA) - Math.Atan(yC / xC)) * 180 / Math.PI;

            femm.mi_addArcEx(xC, yC, xA, yA, a, 1, Group_Lines_Rotor);
            // arcsegment RS
            femm.mi_addArcEx(xR, yR, xS, yS, alphaDegree, 1, Group_Lines_Rotor);

            // blocks
            // air block label
            double air1X = (xA + xB + xC) / 3;
            double air1Y = (yA + yB + yC) / 3;

            femm.mi_addBlockLabelEx(air1X, air1Y, AirMaterialName, Group_BlockLabel_Magnet_Air);
            //FEMM.mi_addBlockLabelEx(air1X, -air1Y, AirBlockName, Group_Label);

            if (Poletype != PoleType.MiddleAir)
            {
                double air2X = (xJ + xK + xI + xH) / 4;
                double air2Y = (yJ + yK + yI + yH) / 4;
                femm.mi_addBlockLabelEx(air2X, air2Y, AirMaterialName, Group_BlockLabel_Magnet_Air);
                //  femm.mi_addBlockLabelEx(air2X, -air2Y, AirBlockName, Group_Label);
            }

            // magnet block label
            double magBlockLabelX = (xD + xI) / 2;
            double magBlockLabelY = (yD + yI) / 2;

            femm.mi_addBlockLabelEx(magBlockLabelX, magBlockLabelY, MagnetMaterialName, Group_BlockLabel_Magnet_Air, alphaM * 180 / Math.PI - 90 + 180);//+180 but set back later
            //femm.mi_addBlockLabelEx(magBlockLabelX, -magBlockLabelY, MagnetBlockName, Group_Label, 90 - alphaM * 180 / Math.PI + 180);

            ///// mirrored all
            femm.mi_clearselected();
            femm.mi_selectgroup(Group_Lines_Rotor);
            femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
            femm.mi_mirror(0, 0, 1, 0, FEMM.EditMode.group);

            //// the remainings: not symmetrical
            if (Poletype == PoleType.MiddleAir)
            {
                femm.mi_addBlockLabelEx((xJ + xK0) / 2, 0, AirMaterialName, Group_BlockLabel_Magnet_Air);
            }

            ////////// Build 2 poles
            // copy pole if full build
            if (fullbuild)
            {
                femm.mi_clearselected();
                femm.mi_selectgroup(Group_Lines_Rotor);
                femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
                femm.mi_copyrotate(0, 0, 360 / (2 * p), 1, FEMM.EditMode.group);
            }
            // rotate the magnet direction (of the first pole)
            femm.mi_clearselected();
            femm.mi_selectlabel(magBlockLabelX, magBlockLabelY);
            femm.mi_setblockprop(MagnetMaterialName, true, 0, "", alphaM * 180 / Math.PI - 90, Group_BlockLabel_Magnet_Air, 0);
            femm.mi_clearselected();
            femm.mi_selectlabel(magBlockLabelX, -magBlockLabelY);
            femm.mi_setblockprop(MagnetMaterialName, true, 0, "", 90 - alphaM * 180 / Math.PI, Group_BlockLabel_Magnet_Air, 0);

            if (fullbuild)
            {
                //////// Build p-1 pair of poles remaining
                femm.mi_clearselected();
                femm.mi_selectgroup(Group_Lines_Rotor);
                femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
                femm.mi_copyrotate(0, 0, 360 / p, p - 1, FEMM.EditMode.group);
            }

            /////// The remaining: not symmetrical: add label for rotor steel
            femm.mi_addBlockLabelEx((DiaYoke / 2 + O2 / 2), 0, SteelMaterialName, Group_BlockLabel_Steel);


            if (fullbuild)
            {
                // pre-rotate rotor (only in fullbuild)
                femm.mi_clearselected();
                femm.mi_selectgroup(Group_Lines_Rotor);
                femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
                femm.mi_selectgroup(Group_BlockLabel_Steel);
                femm.mi_moverotate(0, 0, PreviewRotateAngle, FEMM.EditMode.group);
            }

            if (!fullbuild)
            {
                //build boundary of motor: 2 lines, anti-periodic
                String boundaryName = "rotor-apb-1";
                femm.mi_addSegmentEx(0, 0, xS, yS, Group_Lines_Rotor);
                femm.mi_addSegmentEx(0, 0, xS, -yS, Group_Lines_Rotor);

                femm.mi_addboundprop_AntiPeriodic(boundaryName);

                femm.mi_clearselected();
                femm.mi_selectsegment(xS, yS);
                femm.mi_selectsegment(xS, -yS);
                femm.mi_setsegmentprop(boundaryName, 0, true, false, Group_Lines_Rotor);
            }
        }
コード例 #2
0
ファイル: SPMRotor.cs プロジェクト: wtliu/pmsm_calculation
        /// <summary>
        /// Assuming a FEMM window is opened, build rotor into that
        /// </summary>
        /// <param name="MaterialParams"></param>
        public override void BuildInFEMM(FEMM femm = null)
        {
            if (femm == null)
            {
                femm = FEMM.DefaultFEMM;
            }

            bool fullbuild = Motor.GeneralParams.FullBuildFEMModel;

            // create material data
            //femm.mi_addmaterialAir(AirMaterialName);
            femm.mi_addmaterialMagnet(MagnetMaterialName, mu_M, Hc, 0);
            femm.mi_addmaterialSteel(SteelMaterialName, 1, 1, Lam_d, Lam_fill, FEMM.LaminationType.NotLaminated,
                                     BH.Select(p => p.b).ToArray(), BH.Select(p => p.h).ToArray());

            // create boundary data
            femm.mi_addboundprop_Prescribed_A(BoundaryProperty, 0, 0, 0, 0);

            /////// Build 1 poles
            ////Half one

            // arcsegments AC
            double a = GammaM / 180 * alphaDegree;

            femm.mi_addArcEx(xR, yR, xA, yA, a, 1, Group_Lines_Rotor);
            // arcsegment RS
            femm.mi_addArcEx(xRR, yRR, xSS, ySS, alphaDegree, 1, Group_Lines_Rotor);
            // segments (magnet)
            femm.mi_addSegmentEx(xA, yA, xB, yB, Group_Lines_Rotor);

            // blocks
            // magnet block label
            double magBlockLabelX = (xR + xRR) / 2;
            double magBlockLabelY = 0;

            femm.mi_addBlockLabelEx(magBlockLabelX, magBlockLabelY, MagnetMaterialName, Group_BlockLabel_Magnet_Air, 180);//+180 but set back later
            //femm.mi_addBlockLabelEx(magBlockLabelX, -magBlockLabelY, MagnetBlockName, Group_Label, 90 - alphaM * 180 / Math.PI + 180);

            ///// mirrored all
            femm.mi_clearselected();
            femm.mi_selectgroup(Group_Lines_Rotor);
            femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
            femm.mi_mirror(0, 0, 1, 0, FEMM.EditMode.group);

            ////////// Build 2 poles
            // copy pole if full build
            if (fullbuild)
            {
                femm.mi_clearselected();
                femm.mi_selectgroup(Group_Lines_Rotor);
                femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
                femm.mi_copyrotate(0, 0, 360 / (2 * p), 1, FEMM.EditMode.group);
            }
            // rotate the magnet direction (of the first pole)
            femm.mi_clearselected();
            femm.mi_selectlabel(magBlockLabelX, magBlockLabelY);
            femm.mi_setblockprop(MagnetMaterialName, true, 0, "", 0, Group_BlockLabel_Magnet_Air, 0);

            if (fullbuild)
            {
                //////// Build p-1 pair of poles remaining
                femm.mi_clearselected();
                femm.mi_selectgroup(Group_Lines_Rotor);
                femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
                femm.mi_copyrotate(0, 0, 360 / p, p - 1, FEMM.EditMode.group);
            }

            /////// The remaining: not symmetrical: add label for rotor steel
            femm.mi_addBlockLabelEx(RYoke / 2, 0, SteelMaterialName, Group_BlockLabel_Steel);


            if (fullbuild)
            {
                // pre-rotate rotor (only in fullbuild)
                femm.mi_clearselected();
                femm.mi_selectgroup(Group_Lines_Rotor);
                femm.mi_selectgroup(Group_BlockLabel_Magnet_Air);
                femm.mi_selectgroup(Group_BlockLabel_Steel);
                femm.mi_moverotate(0, 0, PreRotateAngle, FEMM.EditMode.group);
            }

            if (!fullbuild)
            {
                //build boundary of motor: 2 lines, anti-periodic
                String boundaryName = "rotor-apb-1";
                femm.mi_addSegmentEx(0, 0, xS, yS, Group_Lines_Rotor);
                femm.mi_addSegmentEx(0, 0, xS, -yS, Group_Lines_Rotor);

                femm.mi_addboundprop_AntiPeriodic(boundaryName);

                femm.mi_clearselected();
                femm.mi_selectsegment(xS, yS);
                femm.mi_selectsegment(xS, -yS);
                femm.mi_setsegmentprop(boundaryName, 0, true, false, Group_Lines_Rotor);
            }
        }