public Pendulum() { InitializeComponent(); Create3DViewPort(); var sol = ExplicitRungeKutta.Solve(0.01); //StreamWriter file = new StreamWriter("t_z_theta_0_01.txt"); //int count = 0; //var s = sol.t.ToString(); //for (int i = 0; i < 4001; i++) //{ // file.WriteLine(sol.t[i]); // file.WriteLine(sol.z[i]); // file.WriteLine(sol.theta[i]); // count++; //} //int a = count; File.WriteAllLines( "t.txt" // <<== Put the file name here , sol.t.Select(d => d.ToString()) ); File.WriteAllLines( "z.txt" // <<== Put the file name here , sol.z.Select(d => d.ToString()) ); File.WriteAllLines( "theta.txt" // <<== Put the file name here , sol.theta.Select(d => d.ToString()) ); string path_t = "t.txt"; string[] t_lines = File.ReadAllLines(path_t); string path_z = "z.txt"; string[] z_lines = File.ReadAllLines(path_z); string path_theta = "theta.txt"; string[] theta_lines = File.ReadAllLines(path_theta); for (int i = 0; i < 4001; i++) { sol.t[i] = Convert.ToDouble(t_lines[i]); sol.z[i] = Convert.ToDouble(z_lines[i]); sol.theta[i] = Convert.ToDouble(theta_lines[i]); } }
public z_plot() { InitializeComponent(); var solution = ExplicitRungeKutta.Solve(0.1); SeriesCollection = new SeriesCollection { new LineSeries { Title = "z/m", Values = new ChartValues <double>(solution.z), PointGeometry = null } }; YFormatter = value => (value / 10).ToString(); DataContext = this; }