public override int Run(string[] remainingArguments) { SingleMainRotorHelicopter model = (SingleMainRotorHelicopter) new SingleMainRotorHelicopter().LoadDefault(); model.MainRotor.useDynamicInflow = false; model.TailRotor.useDynamicInflow = false; model.FCS.trimControl = false; bool ok = true; Console.WriteLine("%Trim sweep u=" + ustart + " => " + uend + " v=" + v + " w=" + w + " h=" + h); Console.WriteLine("%u\tHelicopter.powerreq" + "\tHelicopter.theta_0\tHelicopter.theta_p\tHelicopter.theta_cos\tHelicopter.theta_sin" + "\tMainRotor.beta_0\tMainRotor.beta_cos\tMainRotor.beta_sin" + "\tHelicopter.theta\tHelicopter.phi"); model.Height = h; for (var u = ustart; u <= uend + ustep / 2; u += ustep) { model.AbsoluteVelocity = Vector <double> .Build.DenseOfArray(new double[] { u, v, w }); model.AngularVelocity = Vector <double> .Build.Zero3(); try { model.TrimInit(); model.Trim(); Console.Error.WriteLine(u + " m/s col " + Math.Round(model.Collective * 100) + " lon " + Math.Round(model.LongCyclic * 100) + " lat " + Math.Round(model.LatCyclic * 100) + " ped " + Math.Round(model.Pedal * 100) + " roll " + (model.RollAngle * 180 / Math.PI).ToStr() + " pitch " + (model.PitchAngle * 180 / Math.PI).ToStr()); double theta_0, theta_sin, theta_cos; model.MainRotor.GetControlAngles(out theta_0, out theta_sin, out theta_cos); double theta_p, temp; model.TailRotor.GetControlAngles(out theta_p, out temp, out temp); Console.WriteLine(u + "\t" + model.PowerRequired + "\t" + theta_0 + "\t" + theta_p + "\t" + theta_cos + "\t" + theta_sin + "\t" + model.MainRotor.beta_0 + "\t" + model.MainRotor.beta_cos + "\t" + model.MainRotor.beta_sin + "\t" + model.Attitude.y() + "\t" + model.Attitude.x()); } catch (TrimmerException e) { Console.Error.WriteLine(" Failed: " + e.Message); ok = false; } } return(ok ? 0 : 1); }
public override int Run(string[] remainingArguments) { SingleMainRotorHelicopter model = (SingleMainRotorHelicopter) new SingleMainRotorHelicopter().LoadDefault(); model.MainRotor.useDynamicInflow = false; // TODO optional model.TailRotor.useDynamicInflow = false; model.FCS.trimControl = false; model.FCS.enabled = false; // TODO optional model.AbsoluteVelocity = Vector <double> .Build.DenseOfArray(new double[] { u, v, w }); model.TrimInit(); model.Trim(); RigidBody body = new RigidBody(); body.ForceModel = model; body.Mass = model.Mass; body.Inertia = model.Inertia; body.Rotation = model.Rotation; Console.WriteLine("%Simulation at u=" + u + " v=" + v + " w=" + w + " control=" + control + " deflection=" + deflection * 180.0 / Math.PI + " deftime=" + deflectionTime); Console.WriteLine("%t" + "\tHelicopter.u\tHelicopter.v\tHelicopter.w" + "\tHelicopter.p\tHelicopter.q\tHelicopter.r" + "\tHelicopter.phi\tHelicopter.theta\tHelicopter.psi" + "\tHelicopter.theta_0\tHelicopter.theta_sin\tHelicopter.theta_cos\tHelicopter.theta_p" + "\tMainRotor.beta_0\tMainRotor.beta_sin\tMainRotor.beta_cos\tTailRotor.beta_0" + "\tEngine.Omega\tEngine.Qeng\tEngine.Qload" ); // Store neutral control angles double t0n, tsn, tcn, tpn; model.GetControlAngles(out t0n, out tsn, out tcn, out tpn); for (double t = 0.0; t <= time; t += timeStep) { if (Math.Abs(deflection) > 1e-5 && deflectionTime > 1e-5 && deflectionDuration > 1e-5 && !String.IsNullOrWhiteSpace(control)) { if (t >= deflectionTime && t <= deflectionTime + deflectionDuration) { if (control.StartsWith("col")) { model.SetControlAngles(t0n + deflection, tsn, tcn, tpn); } else if (control.StartsWith("lon")) { model.SetControlAngles(t0n, tsn + deflection, tcn, tpn); } else if (control.StartsWith("lat")) { model.SetControlAngles(t0n, tsn, tcn + deflection, tpn); } else if (control.StartsWith("ped")) { model.SetControlAngles(t0n, tsn, tcn, tpn + deflection); } } else if (t > deflectionTime + deflectionDuration) { model.SetControlAngles(t0n, tsn, tcn, tpn); } } body.Update(timeStep); double t0, ts, tc, tp; model.GetControlAngles(out t0, out ts, out tc, out tp); Console.WriteLine(t + "\t" + model.Velocity.x() + "\t" + model.Velocity.y() + "\t" + model.Velocity.z() + "\t" + model.AngularVelocity.x() + "\t" + model.AngularVelocity.y() + "\t" + model.AngularVelocity.z() + "\t" + model.Attitude.x() + "\t" + model.Attitude.y() + "\t" + model.Attitude.z() + "\t" + t0 + "\t" + ts + "\t" + tc + "\t" + tp + "\t" + model.MainRotor.beta_0 + "\t" + model.MainRotor.beta_sin + "\t" + model.MainRotor.beta_cos + "\t" + model.TailRotor.beta_0 + "\t" + model.Engine.Omega + "\t" + model.Engine.Qeng + "\t" + model.Engine.load ); } return(0); }