static void Main(string[] args) { Console.WriteLine(Revision); if (args.Length < 1) { Console.WriteLine("ERROR: please supply the config file name to process"); WaitForKey(); return; } if (!File.Exists(args[0])) { Console.WriteLine("ERROR: cannot find the input file " + args[0]); WaitForKey(); return; } string log_file_name = Path.GetFileNameWithoutExtension(args[0]) + ".log"; Log log = new Log(log_file_name, Revision); Config config = new Config(args[0], log); if (config.has_errors) { Console.WriteLine("ERRORS: please check the log for details"); WaitForKey(); return; } Puck puck = new Puck(config, log); if (puck.has_errors) { Console.WriteLine("ERRORS: please check the log for details"); WaitForKey(); return; } double k_the_coefficient = config.GetDouble("k_the_coefficient"); if (k_the_coefficient == double.MinValue) { Console.WriteLine("ERROR: cannot find entry k_the_coefficient in the input file"); WaitForKey(); return; } if (puck.modelling_mode == Puck.ModellingMode.Simulate) { puck.Simulate(k_the_coefficient, print_to_log: true); puck.SaveExtra(); puck.SavePlots(Path.GetDirectoryName(args[0])); } else if (puck.modelling_mode == Puck.ModellingMode.Calibrate) { log.Write("Running the root finding algorithm ..."); double fitted_k = puck.Zeroin(0.01, 0.35, 1E-5); double result = puck.Simulate(fitted_k, print_to_log: false); if (Math.Abs(result) < 1E-4) { log.Write(""); log.Write("==> This is the value for k_the_coefficient = " + fitted_k.ToString("0.000000")); log.Write(""); puck.Simulate(fitted_k, print_to_log: true); puck.SaveExtra(); puck.SavePlots(Path.GetDirectoryName(args[0])); } else { log.Write(""); log.Write("ERROR: cannot find k_the_coefficient to match the measured EY. Review the inputs, specially the PSD values"); } } Console.WriteLine(""); Console.WriteLine("Finished"); if (config.GetString("wait_for_keystroke") == "1") { WaitForKey(); } }