public void TitanIILaunch() { Vector3d r0 = new Vector3d(rearth, 0, 0); Vector3d v0 = new Vector3d(0, 0, 0); Pontryagin p = new Pontryagin(type: ProbType.MULTIBURN, mu: mu); double inc = 90; double heading = Math.Asin(Math.Cos(inc * UtilMath.Deg2Rad) / Math.Cos(0)); // clockwise from north Console.WriteLine("heading = " + heading); p.AddArc(type: ArcType.BURN, r0: r0, v0: v0, pv0: new Vector3d(0, Math.Cos(heading), Math.Sin(heading)), pr0: Vector3d.zero, m0: 149600 + 3580, dt0: 1, isp: 297, thrust: 2 * 1096.8 * 1000, max_bt: 156); p.AddArc(type: ArcType.BURN, r0: r0, v0: v0, pv0: new Vector3d(0, Math.Cos(heading), Math.Sin(heading)), pr0: Vector3d.zero, m0: 28400 + 3580, dt0: 0, isp: 316, thrust: 445 * 1000); Console.WriteLine(p.arcs[0].pv0); //p.terminal5constraint(new Vector3d(r185, 0, 0), new Vector3d(0, 0, v185)); p.flightangle4constraint(r185, v185, 0, inc * UtilMath.Deg2Rad); p.Optimize(0); for (int i = 0; i < 27; i++) { Console.WriteLine(p.y0[i]); } double[] z = new double[27]; p.optimizationFunction(p.y0, z, null); Console.WriteLine("---zeros start---"); for (int i = 0; i < 27; i++) { Console.WriteLine(z[i]); } Console.WriteLine("---zeros done---"); double[] yf = new double[26]; p.multipleIntegrate(p.y0, yf); Console.WriteLine("--- yf start---"); for (int i = 0; i < 26; i++) { Console.WriteLine(yf[i]); } Console.WriteLine("--- yf end---"); Console.WriteLine(new Vector3d(yf[13], yf[14], yf[15]) * p.r_scale); Console.WriteLine(new Vector3d(yf[16], yf[17], yf[18]) * p.v_scale); double tf = p.y0[26] * p.t_scale; for (int i = 0; i <= 20; i++) { Console.WriteLine(p.solution.m(tf / 20 * i)); } Console.WriteLine(p.solution.r(tf)); Console.WriteLine(p.solution.v(tf)); Assert.Equal(1, 0); }
public void optimizationFunctionComplex() { Pontryagin p = new Pontryagin(type: ProbType.COASTBURN, mu: mu); p.AddArc(ArcType.COAST, r0: new Vector3d(r185, 0, 0), v0: new Vector3d(0, v185, 0), m0: 32740, pv0: Vector3d.zero, pr0: Vector3d.zero, dt0: 0); p.AddArc(type: ArcType.BURN, r0: new Vector3d(r185, 0, 0), v0: new Vector3d(0, v185, 0), m0: 32740, pv0: Vector3d.zero, pr0: Vector3d.zero, dt0: 0, isp: 316, thrust: 232.7 * 1000); p.terminal5constraint(rT, vT); p.Normalize(); double[] y0 = { 1, 0, 0, 0, 1, 0, -0.0079393319393622, -0.921121328331003, 0.38831077875087, -0.0249794942101294, -0.00793933193936288, 0.000443266671129501, 32740, 0.916851279873006, -0.399228920038651, -6.63961013907058e-25, 0.399228920038652, 0.916851279873009, -2.95663849598675e-24, 0.0105704943277902, -0.853632995077797, 0.356200199360623, 0.182433205882693, 0.302834215667251, -0.154618483225328, 32740, -0.410675683157609, 0.514092715632044 }; double[] z = new double[28]; p.optimizationFunction(y0, z, null); for (int i = 0; i < 28; i++) { Console.WriteLine(z[i]); } for (int i = 0; i < 28; i++) { Assert.Equal(0, z[i], 4); } }