Пример #1
0
 public PM_MMAnalysisResults(int count)
 {
     ListResults = new PMMMAnalysisOneStepResult[count];
 }
Пример #2
0
        private void AnalyzeOne(int step, FEMM femm = null)
        {
            if (femm == null)
            {
                femm = FEMM.DefaultFEMM;
            }

            // open femm file
            femm.open(Path_OriginalFEMFile);

            ///// Rotate rotor to an angle
            // clear the way (line-boundary conditional in airgap)
            Motor.Airgap.RemoveBoundary(femm);

            // normalize, make rotorAngle inside (-2alpha,2alpha) to build FEMM model
            double femmRotorAngle = Motor.GetNormalizedRotorAngle(RotorAngle);

            // rotate rotor
            Motor.Rotor.RotateRotorInFEMM(femmRotorAngle, femm);

            // modify airgap (in case partial build)
            Motor.Airgap.AddBoundaryAtAngle(femmRotorAngle, femm);

            // modify stator currents
            // testing iq=const, id change to see how inductance d,q change
            //double id = 80.0 / StepCount * (step - StepCount);
            //double iq = 40.0;
            //double current = Math.Sqrt(id * id + iq * iq);
            //double Beta = Math.Abs(id) > 1e-8 ? Math.Atan(iq / id) * 180 / Math.PI : 90.0;
            //if (Beta < 0)
            //    Beta += 180;

            // Test change beta, not current
            //double beta = (this.Beta - 100) / StepCount * step + 100;
            //double current = MaxCurrent;

            var stator = Motor.Stator as Stator3Phase;

            // Change current
            double current;

            if (Only2ndQuarter)
            {
                int c = NotIncludeCurrentZero ? 1 : 0;
                current = MaxCurrent * (step + c) / StepCount;
            }
            else
            {
                int c = NotIncludeCurrentZero ? (step < StepCount ? 0 : 1) : 0;
                current = MaxCurrent / StepCount * ((step + c) - StepCount);
            }

            // correction beta with current rotor angle and original angle (0)
            double beta = this.Beta + (RotorAngle - stator.VectorMMFAngle) * Motor.Rotor.p;//in degree

            double IA = current * Math.Cos(beta * Math.PI / 180);
            double IB = current * Math.Cos(beta * Math.PI / 180 - 2 * Math.PI / 3);
            double IC = current * Math.Cos(beta * Math.PI / 180 + 2 * Math.PI / 3);
            Dictionary <String, double> currents = new Dictionary <string, double>()
            {
                { "A", IA }, { "B", IB }, { "C", IC }
            };

            Motor.Stator.SetStatorCurrentsInFEMM(currents, femm);

            // save as new file fem (temp only)
            String stepfileFEM = Path_ToAnalysisVariant + "\\" + String.Format("{0:D4}.FEM", step);

            femm.mi_saveas(stepfileFEM);

            // analyze
            femm.mi_analyze(true);

            // close
            femm.mi_close();

            // delete temp file
            //File.Delete(stepfileFEM);

            // open ans file to measure ?
            String stepfileANS = Path.GetDirectoryName(stepfileFEM) + "\\" + Path.GetFileNameWithoutExtension(stepfileFEM) + ".ans";

            femm.open(stepfileANS);

            Dictionary <String, FEMM.CircuitProperties> cps = Motor.Stator.getCircuitsPropertiesInAns(femm);
            double t = Motor.Rotor.getTorqueInAns(femm);

            PMMMAnalysisOneStepResult result = new PMMMAnalysisOneStepResult();

            result.Iabc = new Fabc {
                a = cps["A"].current, b = cps["B"].current, c = cps["C"].current
            };
            result.FluxLinkage_abc = new Fabc {
                a = cps["A"].fluxlinkage, b = cps["B"].fluxlinkage, c = cps["C"].fluxlinkage
            };
            result.Vabc = new Fabc {
                a = cps["A"].volts, b = cps["B"].volts, c = cps["C"].volts
            };

            // no currents, then save the fluxlinkageM, which is importance to calculate Ld
            var Results = this.Results as PM_MMAnalysisResults;

            result.torque        = t;
            result.FluxLinkage_M = Results.FluxLinkageM;
            result.theta_e       = (RotorAngle - stator.VectorMMFAngle) * Motor.Rotor.p * Math.PI / 180;//in radian

            Results[step] = result;

            femm.mo_close();
        }