public static void RunSimulation(SimulationInput input, string outputFolderPath) { var mc = new MonteCarloSimulation(input); // locate root folder for output, creating it if necessary var path = string.IsNullOrEmpty(outputFolderPath) ? Path.GetFullPath(Directory.GetCurrentDirectory()) : Path.GetFullPath(outputFolderPath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // locate destination folder for output, creating it if necessary var resultsFolder = Path.Combine(path, input.OutputName); if (!Directory.Exists(resultsFolder)) { Directory.CreateDirectory(resultsFolder); } mc.SetOutputPathForDatabases(path); SimulationOutput detectorResults = mc.Run(); input.ToFile(Path.Combine(resultsFolder, input.OutputName + ".txt")); foreach (var result in detectorResults.ResultsDictionary.Values) { // save all detector data to the specified folder DetectorIO.WriteDetectorToFile(result, resultsFolder); } }
static void Main(string[] args) { try { var input = new SimulationInput( 1000000, // FIX 1e6 takes about 110 minutes my laptop "", // if non-empty string here, need to create sub-folder new SimulationOptions( 0, RandomNumberGeneratorType.MersenneTwister, AbsorptionWeightingType.Continuous, PhaseFunctionType.HenyeyGreenstein, new List <DatabaseType>() { }, // databases to be written false, // track statistics 0.0, // RR threshold -> 0 = no RR performed 1), new DirectionalPointSourceInput( new Position(0.0, 0.0, 0.0), new Direction(0.0, 0.0, 1.0), 0), new MultiLayerTissueInput( new LayerTissueRegion[] { new LayerTissueRegion( new DoubleRange(double.NegativeInfinity, 0.0), new OpticalProperties(0.0, 1e-10, 0.0, 1.0) ), //new LayerTissueRegion( // new DoubleRange(0.0, 0.1), // new OpticalProperties(0.033, 1.0, 0.8, 1.38) // ), new LayerTissueRegion( new DoubleRange(0.0, 100.0), new OpticalProperties(0.0, 1.0, 0.8, 1.38) ), new LayerTissueRegion( new DoubleRange(100.0, double.PositiveInfinity), new OpticalProperties(0, 1e-10, 0.0, 1.0) ) } ), new List <IDetectorInput>() { new ROfRhoAndTimeDetectorInput { Rho = new DoubleRange(0.0, 40, 201), // numbers for scaled MC Time = new DoubleRange(0.0, 4, 801) } // numbers for scaled MC } ); SimulationOutput output = new MonteCarloSimulation(input).Run(); input.ToFile("infile.txt"); // the following gets are R(rho,time) for scaled. //var rOfRhoAndTime = output.ResultsDictionary[TallyType.ROfRhoAndTime.ToString()]; //string folderPath = "results"; //if (!Directory.Exists(folderPath)) // Directory.CreateDirectory(folderPath); //DetectorIO.WriteDetectorToFile(rOfRhoAndTime, folderPath); } catch (Exception e) { Console.WriteLine("Failed to run: Reason: " + e.Message); throw; //return false; } }