public void GenerateDatas() { try { Collection.Clear(); Circuit cir = new Circuit(); cir.ReadCircuit("Circuits/RCcharge.net"); Circuit cir2 = (Circuit)cir.Clone(); cir2.Setup.RemoveAt(0); ACAnalysis ac = new ACAnalysis(); cir2.Setup.Add(ac); ACSweepSolver.Optimize(cir2); cir2.Solve(); ACSweepSolver sol = (ACSweepSolver)ac.Solver; foreach (var res in sol.Voltages) { //Console.Write(res.Key.ToString() + "rad/seg"); foreach (var nodo in res.Value) { if (nodo.Key == "$N_0001") //Console.Write(nodo.Key + " " + nodo.Value.ToString() + "V\r\n"); this.Collection.Add(new Point(res.Key, nodo.Value.Real)); } } } catch (Exception ex) { throw; } }
public override object Clone() { ACAnalysis clon = new ACAnalysis(); clon.EndFrequency = EndFrequency; clon.ScanType = ScanType; clon.StartFrequency = StartFrequency; //clon. = EndFrequency; clon.Points = Points; return clon; }
public override object Clone() { ACAnalysis clon = new ACAnalysis(); clon.EndFrequency = EndFrequency; clon.ScanType = ScanType; clon.StartFrequency = StartFrequency; //clon. = EndFrequency; clon.Points = Points; return(clon); }
public void Simulate(string circuitname) { TxtStatus.Text = circuitname; cir = new Circuit(); //cir.ReadCircuit("Circuits/RCL.net"); cir.ReadCircuit(circuitname); cir2 = (Circuit)cir.Clone(); cir2.Setup.RemoveAt(0); ACAnalysis ac = new ACAnalysis(); cir2.Setup.Add(ac); ACSweepSolver.Optimize(cir2); Refresh(); }
static void Main(string[] args) { int i = 2; switch (i) { case 0: cir.ReadCircuit("circuits/RLcharge.net"); cir2 = (Circuit)cir.Clone(); DCSolver.Optimize(cir2); DCAnalysis ac0 = (DCAnalysis)cir2.Setup[0]; DCSolver solver = (DCSolver)ac0.Solver; //solver.Solve(cir2, ); cir2.Solve(); solver.ExportToCSV("e:/Test.csv"); break; case 1: cir.ReadCircuit("circuits/testidc.net"); cir2 = (Circuit)cir.Clone(); DCSolver.Optimize(cir2); DCAnalysis ac3 = (DCAnalysis)cir2.Setup[0]; DCSolver solver3 = (DCSolver)ac3.Solver; //solver.Solve(cir2, ); cir2.Solve(); solver3.ExportToCSV("e:/Test.csv"); break; case 2: cir.ReadCircuit("circuits/derivador.net"); //cir.ReadCircuit("RCL.net"); cir2 = (Circuit)cir.Clone(); cir2.Setup.RemoveAt(0); ACAnalysis ac = new ACAnalysis(); cir2.Setup.Add(ac); ACSweepSolver.Optimize(cir2); cir2.Solve(); ACSweepSolver sol = (ACSweepSolver)ac.Solver; sol.ExportToCSV("ACSweep.csv"); break; case 3: //cir.ReadCircuit("derivador.net"); cir.ReadCircuit("circuits/RLC.net"); cir2 = (Circuit)cir.Clone(); cir2.Setup.RemoveAt(0); ComplexPlainAnalysis ac1 = new ComplexPlainAnalysis(); cir2.Setup.Add(ac1); ACSweepSolver.Optimize(cir2); cir2.Solve(); sol1 = (ComplexPlainSolver)ac1.Solver; sol1.SelectedNode = sol1.CurrentCircuit.Nodes["out"]; // sol1. sol1.ExportToCSV("e:/plain.csv"); Bitmap bmp = FileUtils.DrawImage(func, ac1.Points, ac1.Points); bmp.Save("e:/plain.bmp"); break; case 4: cir.ReadCircuit("circuits/RCL.net"); //cir.ReadCircuit("RCcharge.net"); cir2 = (Circuit)cir.Clone(); cir2.Setup.RemoveAt(0); TransientAnalysis ac5 = new TransientAnalysis(); ac5.Step = "10n"; cir2.Setup.Add(ac5); TransientSolver sol5 = (TransientSolver)ac5.Solver; TransientSolver.Optimize(cir2); cir2.Solve(); sol5.ExportToCSV("e:/time.csv"); break; case 5: cir.ReadCircuit("circuits/vsingain.net"); //cir.ReadCircuit("RCcharge.net"); cir2 = (Circuit)cir.Clone(); cir2.Setup.RemoveAt(0); TransientAnalysis ac6 = new TransientAnalysis(); ac6.Step = "100n"; cir2.Setup.Add(ac6); TransientSolver sol6 = (TransientSolver)ac6.Solver; TransientSolver.Optimize(cir2); cir2.Solve(); sol6.ExportToCSV("e:/time.csv"); break; default: break; } Console.ReadKey(); }