public void runStaticAnalysis() { // load from disk first staticAnalyser.LoadResultsFromDisk(); if (staticAnalyser.Results == null) { FEMM.CloseFemm(); // make sure ans file is created if (!Motor.isFEMModelReady(CurrentFEMMFile)) { Motor.BuildFEMModel(CurrentFEMMFile); } staticAnalyser.OnFinishedAnalysis -= staticAnalyser_OnFinishedAnalysis; staticAnalyser.OnFinishedAnalysis += staticAnalyser_OnFinishedAnalysis; // do measure staticAnalyser.RunAnalysis(); FEMM.CloseFemm(); } else { staticAnalyser_OnFinishedAnalysis(this, staticAnalyser.Results); } }
private void runAllTransientAnalysis_Sync() { // make sure femm file is created if (!Motor.isFEMModelReady(CurrentFEMMFile)) { Motor.BuildFEMModel(CurrentFEMMFile); } // run static first runStaticAnalysis(); sw = new Stopwatch(); sw.Start(); // now run the transient analysis foreach (String name in TransAnalysisGroup.Keys) { // un-subcribe event TransAnalysisGroup[name].OnFinishedAnalysis -= OnFinishAnalysis_internal; // run in sync TransAnalysisGroup[name].RunAnalysis(); // close all opened FEMM.CloseFemm(); } sw.Stop(); log.Info("Analysis time :" + sw.Elapsed.TotalSeconds + "s"); refreshAnalysisResults(); OnMotorAnalysisResultsUpdate(this, null); }
private void mmAnalysis_OnFinishedAnalysis(object sender, AbstractResults e) { sw.Stop(); FEMM.CloseFemm(); refreshAnalysisResults(); OnMotorAnalysisResultsUpdate(this, null); }
private void dqcurrentAnalyser_OnFinishedAnalysis(object sender, AbstractResults e) { sw.Stop(); log.Info("Analysis time :" + sw.Elapsed.TotalSeconds + "s"); FEMM.CloseFemm(); refreshAnalysisResults(); OnMotorAnalysisResultsUpdate(this, null); }
private void bt_sweep_Click(object sender, EventArgs e) { sweeper.OnFinishSweep -= new EventHandler <ParamSweeperResults>(sweeper_OnFinishSweep); sweeper.OnFinishSweep += new EventHandler <ParamSweeperResults>(sweeper_OnFinishSweep); FEMM.CloseFemm(); new Thread(new ThreadStart(sweeper.doSweep)).Start(); }
void sweeper_OnFinishSweep(object sender, ParamSweeperResults e) { if (InvokeRequired) { BeginInvoke((Action) delegate() { sweeper_OnFinishSweep(sender, e); }); return; } FEMM.CloseFemm(); showResultsInDGV(e.ResultsTable); }
protected override void analyze() { DQCurrentMap map = Results as DQCurrentMap; generateListCurrents(map); int n = map.results.Count; int k = 0; foreach (var p in map.results) { k++; log.DebugFormat("Transient Analyzing {0}/{1}: id={2},iq={3}", k, n, p.idq.d, p.idq.q); analyzeOne(p); FEMM.CloseFemm(); } }
/// <summary> /// Actual run, all hard works here /// </summary> private void actualRunOptimization() { sw = new Stopwatch(); sw.Start(); individualCount = 0; // new FEMM windows if (lua["useFEM"] != null) { FEMMToUse = new List <FEMM>(); // 1 windows for now for (int i = 0; i < 1; i++) { FEMMToUse.Add(new FEMM()); } } try { ga.Go(); //results: Ga_AllFinish(ga); } catch (Exception ex) { MessageBox.Show("Genetic algorithm simulation failed: " + ex.Message); ga.Cancelled = true; } sw.Stop(); // close FEMM if (FEMMToUse != null) { FEMMToUse.Clear(); FEMMToUse = null; FEMM.CloseFemm(); } optimizationIsRunning = false; }
void ta_OnFinishedAnalysis(object sender, AbstractResults e) { if (InvokeRequired) { BeginInvoke((Action) delegate() { ta_OnFinishedAnalysis(sender, e); }); } FEMM.CloseFemm(); var tr = e as Transient3PhaseMotorResults; GraphWindow gw = new GraphWindow(); IDictionary <string, object> dict = tr.BuildResultsForDisplay(); foreach (String name in dict.Keys) { var graphdata = dict[name] as ListPointD; if (graphdata != null) { gw.addData(name, graphdata.ToZedGraphPointPairList()); } } gw.Show(); }
// forcefully build fem file public void buildFEMM() { FEMM.CloseFemm(); Motor.BuildFEMModel(CurrentFEMMFile); FEMM.CloseFemm(); }
private void analyzeAnIndividual(Individual ind, out string infotext, out string log, out AbstractMotor motor) { double[] gens = ind.Genes; StringBuilder sb = new StringBuilder(); sb.AppendLine("Took " + (sw.ElapsedMilliseconds / 1000) + " secs. Dict size = " + dict_fitness.Count); infotext = ""; AbstractMMAnalyser mma = null; try { lua_constructMotorfromGens(gens, currentConfig.luascript_constructMotor, out motor, out mma); } catch (Exception ex) { sb.AppendLine("Motor constructing script failed: " + ex.Message); motor = null; } // finish script if (motor != null && currentConfig.luascript_finish != null && currentConfig.luascript_finish != "") { try { //lua["fitness"] = fitness; var a = motor.GetAnalyticalAnalyser(); a.RunAnalysis(); // finite elements analysis if available object fem_results = null; if (lua["useFEM"] != null && a.isDataValid() && mma != null) { // static analysis String outdir = OutputFolderFEM + "\\" + motor.GetMD5String(); Directory.CreateDirectory(outdir); String femFile = outdir + "\\static.FEM"; if (!motor.isFEMModelReady(femFile)) { motor.BuildFEMModel(femFile); } AbstractStaticAnalyser staticAnalyser = motor.GetStaticAnalyser(); staticAnalyser.Path_OriginalFEMFile = femFile; staticAnalyser.OutputPath = outdir; staticAnalyser.DoAnalysisOnOriginalFEMFile = true; staticAnalyser.RunAnalysis(); // mma analysis mma.Path_OriginalFEMFile = femFile; mma.CustomOutputDir = outdir; mma.RunAnalysis(); fem_results = mma.Results; FEMM.CloseFemm(); } object[] o = null; lock (lock_dostring) { lua["motor"] = motor; lua["gens"] = gens; lua["results"] = a.Results; lua["femresults"] = fem_results; o = lua.DoString(currentConfig.luascript_finish, "FinishScript"); } if (o != null && o.Length > 0 && o[0] is string) { infotext = o[0].ToString(); sb.AppendLine("FinishScript:\r\n" + (o[0] as string)); } } catch (Exception ex) { sb.AppendLine("Finish script failed: " + ex.Message); } // sb.AppendLine("Motor details:"); sb.AppendLine(JSON.Beautify(JSON.ToJSON(motor))); } log = sb.ToString(); }