Example #1
0
 public LaunchModel()
 {
     Constants           = new Constants();
     SimulationSteps     = new List <SimulationStep>();
     Output              = new OutputParams();
     OutputByStage       = new List <OutputParams>();
     OutputOrbit         = new OrbitOutput();
     ControlOptimization = new ControlOptimization();
 }
Example #2
0
        private void RunSimulation(int maxSteps = 10000)
        {
            SimulationSteps.Clear();
            OutputByStage.Clear();
            Output      = new OutputParams();
            OutputOrbit = new OrbitOutput();

            SimulationStep prev    = null;
            SimulationStep current = CreateFirstStep();

            SimulationSteps.Add(current);

            for (int i = 0; i < maxSteps; i++)
            {
                WriteToLog(current.GetLogMessage());
                prev    = current;
                current = RunStep(prev);
                var output = CheckOutput(prev, current);
                if (current.Stage > Launcher.Stages.Count)
                {
                    Output = output;
                    break;
                }

                SimulationSteps.Add(current);
            }

            CalculateOutputOrbit();
            if (PitchProgram.Tmax != Output.T)
            {
                PitchProgram.Tmax = Output.T;
                RunSimulation(maxSteps);
                return;
            }

            OutputByStage.ForEach(os => WriteToLog(os.GetLogMessage()));
            WriteToLog(Output.GetLogMessage());
            WriteToLog(OutputOrbit.GetLogMessage());
        }