public override void BuildInFEMM(FEMM femm = null) { if (femm == null) { femm = FEMM.DefaultFEMM; } var Rotor = Motor.Rotor; var Stator = Motor.Stator; // create material femm.mi_addmaterialAir(AirMaterialName); femm.mi_addBlockLabelEx(Rotor.RGap + delta * 0.8, 0, AirMaterialName, Group_Fixed_BlockLabel_Airgap); if (!Motor.GeneralParams.FullBuildFEMModel) { //build boundary of motor: 2 lines, anti-periodic String boundaryName = "airgap-apb-0"; int Group_Lines = Group_Lines_Airgap; double x1 = Rotor.RGap * Math.Cos(Rotor.alpha); double y1 = Rotor.RGap * Math.Sin(Rotor.alpha); double x2 = Stator.RGap * Math.Cos(Rotor.alpha); double y2 = Stator.RGap * Math.Sin(Rotor.alpha); femm.mi_addSegmentEx(x1, y1, x2, y2, Group_Lines); femm.mi_addSegmentEx(x1, -y1, x2, -y2, Group_Lines); femm.mi_addboundprop_AntiPeriodic(boundaryName); femm.mi_clearselected(); femm.mi_selectgroup(Group_Lines); femm.mi_setsegmentprop(boundaryName, 0, true, false, Group_Lines); } base.BuildInFEMM(femm); }
/// <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); } }
/// <summary> /// Make a femm model using parameters from rotor creation process /// </summary> /// <param name="outfile">Output femm model</param> /// <param name="original">The original femm model to insert into</param> public void MakeAFEMMModelFile(String outfile, String original = "") { if (!isPointsCoordCalculated) { CalcPointsCoordinates(); } // create new or open an exist if (original == "") { FEMM.newdocument(FEMM.DocumentType.Magnetic); } else { FEMM.open(original); } // double Rrotor = RotorParams.Rrotor; double alpha = 2 * Math.PI / (4 * RotorParams.p); double alphaM = RotorParams.alphaM; int p = RotorParams.p; ///// Build 1 poles // point far right of rotors double xI = Rrotor; double yI = 0; // segments (magnet) FEMM.mi_addSegmentEx(xA, yA, xB, yB, Group_Lines); //AB FEMM.mi_addSegmentEx(xA, yA, xF, yF, Group_Lines); //AF FEMM.mi_addSegmentEx(xA, yA, xD, yD, Group_Lines); //AD FEMM.mi_addSegmentEx(xB, yB, xC, yC, Group_Lines); //BC FEMM.mi_addSegmentEx(xC, yC, xD, yD, Group_Lines); //CD // mirrored segments (magnet) FEMM.mi_addSegmentEx(xA, -yA, xB, -yB, Group_Lines); //AB FEMM.mi_addSegmentEx(xA, -yA, xF, -yF, Group_Lines); //AF FEMM.mi_addSegmentEx(xA, -yA, xD, -yD, Group_Lines); //AD FEMM.mi_addSegmentEx(xB, -yB, xC, -yC, Group_Lines); //BC FEMM.mi_addSegmentEx(xC, -yC, xD, -yD, Group_Lines); //CD // barrier segments FEMM.mi_addSegmentEx(xC, yC, xC, -yC, Group_Lines); //AB FEMM.mi_addSegmentEx(xD, yD, xD, -yD, Group_Lines); //AF // arcsegments double a = (Math.Atan(yF / xF) - Math.Atan(yB / xB)) * 180 / Math.PI; FEMM.mi_addArcEx(xB, yB, xF, yF, a, 1, Group_Lines); FEMM.mi_addArcEx(xF, -yF, xB, -yB, a, 1, Group_Lines); // arcsegments rotor FEMM.mi_addArcEx(xI, yI, xG, yG, alpha * 180 / Math.PI, 1, Group_Lines); FEMM.mi_addArcEx(xG, -yG, xI, yI, alpha * 180 / Math.PI, 1, Group_Lines); // blocks // air block label double air1X = (xA + xB + xF) / 3; double air1Y = (yA + yB + yF) / 3; FEMM.mi_addBlockLabelEx(air1X, air1Y, AirBlockName, Group_Label); FEMM.mi_addBlockLabelEx(air1X, -air1Y, AirBlockName, Group_Label); FEMM.mi_addBlockLabelEx((xC + xD) / 2, 0, AirBlockName, Group_Label); // magnet block label double magBlockLabelX = (xA + xC) / 2; double magBlockLabelY = (yA + yC) / 2; FEMM.mi_addBlockLabelEx(magBlockLabelX, magBlockLabelY, MagnetBlockName, Group_Label, 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); ///// Build 2 poles FEMM.mi_clearselected(); FEMM.mi_selectgroup(Group_Lines); FEMM.mi_selectgroup(Group_Label); FEMM.mi_copyrotate(0, 0, 360 / (2 * p), 1, FEMM.EditMode.group); // rotate the magnet direction FEMM.mi_clearselected(); FEMM.mi_selectlabel(magBlockLabelX, magBlockLabelY); FEMM.mi_setblockprop(MagnetBlockName, true, 0, "", alphaM * 180 / Math.PI - 90, Group_Label, 0); FEMM.mi_clearselected(); FEMM.mi_selectlabel(magBlockLabelX, -magBlockLabelY); FEMM.mi_setblockprop(MagnetBlockName, true, 0, "", 90 - alphaM * 180 / Math.PI, Group_Label, 0); ///// Build p-1 pair of poles remaining FEMM.mi_clearselected(); FEMM.mi_selectgroup(Group_Lines); FEMM.mi_selectgroup(Group_Label); FEMM.mi_copyrotate(0, 0, 360 / p, p - 1, FEMM.EditMode.group); FEMM.mi_addBlockLabelEx(0, 0, SteelBlockName, Group_Rotor_Steel); // clear selected, refresh, and go to natural zoom FEMM.mi_clearselected(); FEMM.mi_zoomnatural(); // save as if (Path.GetDirectoryName(outfile) == "") { outfile = Path.GetDirectoryName(original) + "\\" + outfile; } FEMM.mi_saveas(outfile); FEMM.mi_close(); }
/// <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); } }
/// <summary> /// Build Stator in FEMM /// </summary> /// <param name="MaterialParams"></param> public override void BuildInFEMM(FEMM femm = null) { if (femm == null) { femm = FEMM.DefaultFEMM; } AbstractRotor Rotor = Motor.Rotor; bool fullbuild = Motor.GeneralParams.FullBuildFEMModel; // create material 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()); femm.mi_addmaterialCopper(WireMaterialName, WireConduct, WireType, 1, WireDiameter); // create boundary femm.mi_addboundprop_Prescribed_A(BoundaryProperty, 0, 0, 0, 0); /////// Build half slot ////segments - lines femm.mi_addSegmentEx(xB, yB, xC, yC, Group_Lines_Stator); //BC femm.mi_addSegmentEx(xD, yD, xE, yE, Group_Lines_Stator); //DE femm.mi_addSegmentEx(xF, yF, xF, 0, Group_Lines_Stator); //FF1 if (yC != yCC) { femm.mi_addSegmentEx(xC, yC, xCC, yCC, Group_Lines_Stator);//CC' } //// arcsegments //BA double a = (Math.Atan(yA / xA) - Math.Atan(yB / xB)) * 180 / Math.PI; femm.mi_addArcEx(xB, yB, xA, yA, a, 1, Group_Lines_Stator); //DC' femm.mi_addArcEx(xD, yD, xCC, yCC, 90, 30, Group_Lines_Stator); //EF femm.mi_addArcEx(xF, yF, xE, yE, 90, 30, Group_Lines_Stator); //// the coil femm.mi_addSegmentEx(xD2, yD2, xE2, yE2, Group_Lines_Stator); femm.mi_addSegmentEx(xF2, yF2, xF2, 0, Group_Lines_Stator); femm.mi_addSegmentEx(xCC2, yCC2, xCC2, 0, Group_Lines_Stator); //CC2-D2 femm.mi_addArcEx(xD2, yD2, xCC2, yCC2, 90, 30, Group_Lines_Stator); //EF femm.mi_addArcEx(xF2, yF2, xE2, yE2, 90, 30, Group_Lines_Stator); ////// mirrored half to one femm.mi_clearselected(); femm.mi_selectgroup(Group_Lines_Stator); femm.mi_mirror(0, 0, 1, 0, FEMM.EditMode.group); //////// Build Q slots (copy) femm.mi_clearselected(); femm.mi_selectgroup(Group_Lines_Stator); femm.mi_selectgroup(Group_BlockLabel_Wire); if (fullbuild) { femm.mi_copyrotate(0, 0, 360.0 / Q, Q - 1, FEMM.EditMode.group); } else { femm.mi_copyrotate(0, 0, 360.0 / Q, Q / (2 * Rotor.p) - 1, FEMM.EditMode.group); // rotate so they match with rotor femm.mi_clearselected(); femm.mi_selectgroup(Group_Lines_Stator); femm.mi_selectgroup(Group_BlockLabel_Wire); // rotate angle to double shiftangle = -Rotor.alphaDegree + 180.0 / Q; femm.mi_moverotate(0, 0, shiftangle, FEMM.EditMode.group); } ////// Block labels (steel) femm.mi_addBlockLabelEx((xF + Rstator) / 2, 0, SteelMaterialName, Group_BlockLabel_Steel); /////// Stator outer lines (2 arcs) if (fullbuild) { femm.mi_addArcEx(Rstator, 0, -Rstator, 0, 180, 10, Group_Lines_Stator); femm.mi_addArcEx(-Rstator, 0, Rstator, 0, 180, 10, Group_Lines_Stator); } else { femm.mi_addArcEx(Rstator * Math.Cos(Rotor.alpha), -Rstator * Math.Sin(Rotor.alpha), Rstator * Math.Cos(Rotor.alpha), Rstator * Math.Sin(Rotor.alpha), 2 * Rotor.alphaDegree, 10, Group_Lines_Stator); } // Set boundary condition for outline stator femm.mi_clearselected(); if (fullbuild) { femm.mi_selectarcsegment(0, Rstator); femm.mi_selectarcsegment(0, -Rstator); } else { femm.mi_selectarcsegment(Rstator, 0); } femm.mi_setarcsegmentprop(10, BoundaryProperty, false, Group_Lines_Stator); /////// Wire, circuits in slot foreach (Circuit c in circuits) { femm.mi_addcircprop(c.name, c.current, c.circuitType); } double r = (xD + xE) / 2; foreach (Coil sci in coils) { int i = coils.IndexOf(sci); if (fullbuild) { //angle go clockwise from 3 o'clock (=0 degree in decarter), double aa = -2 * Math.PI * i / Q; double x = r * Math.Cos(aa); double y = r * Math.Sin(aa); femm.mi_addBlockLabelEx(x, y, WireMaterialName, Group_BlockLabel_Wire, sci.inCircuit, sci.Nturns); } else { //angle go clockwise from 3 o'clock (=0 degree in decarter), shift +pi/Q (to match rotor) int nn = Q / (2 * Rotor.p); double aa = -2 * Math.PI * i / Q + (nn % 2 == 0 ? Math.PI / Q : 0); double x = r * Math.Cos(aa); double y = r * Math.Sin(aa); if (aa > -Rotor.alpha || aa < -2 * Math.PI + Rotor.alpha) { femm.mi_addBlockLabelEx(x, y, WireMaterialName, Group_BlockLabel_Wire, sci.inCircuit, sci.Nturns); } } } if (fullbuild) { //pre-rotate stator (fullbuild only) femm.mi_clearselected(); femm.mi_selectgroup(Group_Lines_Stator); femm.mi_selectgroup(Group_BlockLabel_Wire); 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 = "stator-apb-1"; double x1 = Rinstator * Math.Cos(Rotor.alpha); double y1 = Rinstator * Math.Sin(Rotor.alpha); double x2 = Rstator * Math.Cos(Rotor.alpha); double y2 = Rstator * Math.Sin(Rotor.alpha); femm.mi_addSegmentEx(x1, y1, x2, y2, Group_Lines_Stator); femm.mi_addSegmentEx(x1, -y1, x2, -y2, Group_Lines_Stator); femm.mi_addboundprop_AntiPeriodic(boundaryName); femm.mi_clearselected(); femm.mi_selectsegment(x2, y2); femm.mi_selectsegment(x2, -y2); femm.mi_setsegmentprop(boundaryName, 0, true, false, Group_Lines_Stator); } }
/// <summary> /// Call this AFTER rotating rotor to make sure boundary conditional in airgap is solid /// Assuming the file FEMM was created using the same motor /// </summary> public override void AddBoundaryAtAngle(double rotateAngleDeg, FEMM femm = null) { if (Motor.GeneralParams.FullBuildFEMModel) { return; } if (femm == null) { femm = FEMM.DefaultFEMM; } var Rotor = Motor.Rotor; var Stator = Motor.Stator; //build boundary of motor: 2 lines, anti-periodic String[] boundaryNames = new String[] { "airgap-apb-1", "airgap-apb-2", "airgap-apb-3" }; int[] Group_Lines = { Group_Lines_Airgap + 1, Group_Lines_Airgap + 2, Group_Lines_Airgap + 3 }; // re-add boundary (airgap) double rotateAngleRad = rotateAngleDeg * Math.PI / 180; double x1 = Rotor.RGap * Math.Cos(Rotor.alpha + rotateAngleRad); double y1 = Rotor.RGap * Math.Sin(Rotor.alpha + rotateAngleRad); double x2 = (Rotor.RGap + delta / 2) * Math.Cos(Rotor.alpha + rotateAngleRad); double y2 = (Rotor.RGap + delta / 2) * Math.Sin(Rotor.alpha + rotateAngleRad); double x3 = (Rotor.RGap + delta / 2) * Math.Cos(Rotor.alpha); double y3 = (Rotor.RGap + delta / 2) * Math.Sin(Rotor.alpha); double x4 = Stator.RGap * Math.Cos(Rotor.alpha); double y4 = Stator.RGap * Math.Sin(Rotor.alpha); // add segment femm.mi_addSegmentEx(x1, y1, x2, y2, Group_Lines[0]); femm.mi_addSegmentEx(x3, y3, x4, y4, Group_Lines[2]); femm.mi_addArcEx(x3, y3, x2, y2, rotateAngleDeg, 1, Group_Lines[1]); // add boundary foreach (String bn in boundaryNames) { femm.mi_addboundprop_AntiPeriodic(bn); } // set boundary for (int i = 0; i < Group_Lines.Count(); i++) { femm.mi_clearselected(); femm.mi_selectgroup(Group_Lines[i]); femm.mi_setsegmentprop(boundaryNames[i], 0, true, false, Group_Lines[i]); femm.mi_setarcsegmentprop(1, boundaryNames[i], false, Group_Lines[i]); } // copy boundary femm.mi_clearselected(); femm.mi_selectgroup(Group_Lines[0]); femm.mi_selectgroup(Group_Lines[1]); femm.mi_selectgroup(Group_Lines[2]); femm.mi_copyrotate(0, 0, -2 * Rotor.alphaDegree, 1, FEMM.EditMode.group); // special case: airgap becomes 2 sections if (Math.Abs(Math.Abs(rotateAngleDeg) - 2 * Rotor.alphaDegree) < 1e-8) { double x = (Rotor.RGap + delta * 0.2) * Math.Cos(rotateAngleRad); double y = (Rotor.RGap + delta * 0.2) * Math.Sin(rotateAngleRad); femm.mi_addBlockLabelEx(x, y, AirMaterialName, Group_Fixed_BlockLabel_Airgap); } base.AddBoundaryAtAngle(rotateAngleDeg, femm); }