Пример #1
0
        /// <summary>
        /// Run the simulation
        /// </summary>
        /// <returns>SimulationOutput</returns>
        public SimulationOutput Run()
        {
            _isCancelled      = false;
            _isRunning        = true;
            _resultsAvailable = false;

            DisplayIntro();

            ExecuteMCLoop();

            _isRunning = false;
            if (_isCancelled)
            {
                _resultsAvailable = false;
                return(null);
            }

            var detectors = _virtualBoundaryController.VirtualBoundaries
                            .Select(vb => vb.DetectorController)
                            .Where(dc => dc != null)
                            .SelectMany(dc => dc.Detectors).ToList();

            Results = new SimulationOutput(_input, detectors);

            _resultsAvailable = true;

            return(Results);
        }
Пример #2
0
        public static UnmanagedOutput ToUnmanagedOutput(this SimulationOutput output)
        {
            UnmanagedOutput unmanagedOutput = new UnmanagedOutput();

            UnmanagedIO.Assign2DPointer(output.A_rz, ref unmanagedOutput.A_rz);
            //UnmanagedIO.Assign1DPointer(output.A_z, ref unmanagedOutput.A_z);
            //UnmanagedIO.Assign1DPointer(output.A_layer, ref unmanagedOutput.A_layer);
            unmanagedOutput.Atot = output.Atot;
            //UnmanagedIO.Assign2DPointer(output.Flu_rz, ref unmanagedOutput.Flu_rz);
            //UnmanagedIO.Assign1DPointer(output.Flu_z, ref unmanagedOutput.Flu_z);
            UnmanagedIO.Assign2DPointer(output.R_ra, ref unmanagedOutput.R_ra);
            UnmanagedIO.Assign1DPointer(output.R_r, ref unmanagedOutput.R_r);
            UnmanagedIO.Assign1DPointer(output.R_a, ref unmanagedOutput.R_a);
            UnmanagedIO.Assign1DPointer(output.R_r2, ref unmanagedOutput.R_r2);
            UnmanagedIO.Assign2DPointer(output.R_xy, ref unmanagedOutput.R_xy);
            UnmanagedIO.Assign2DPointer(output.T_ra, ref unmanagedOutput.T_ra);
            UnmanagedIO.Assign1DPointer(output.T_r, ref unmanagedOutput.T_r);
            UnmanagedIO.Assign1DPointer(output.T_a, ref unmanagedOutput.T_a);
            unmanagedOutput.Rd = output.Rd;
            //unmanagedOutput.Rtot = output.Rtot;
            unmanagedOutput.Td = output.Td;
            UnmanagedIO.Assign2DPointer(output.R_rt, ref unmanagedOutput.R_rt);

            //UnmanagedIO.Assign2DPointer(output.D_rt, ref unmanagedOutput.D_rt);

            return(unmanagedOutput);
        }
Пример #3
0
 public static void ToManagedOutput(ref UnmanagedOutput unmanagedOutput, ref SimulationOutput output)
 {
     //output.Atot = unmanagedOutput.Atot;
     //output.Rd = unmanagedOutput.Rd;
     //output.Rtot = unmanagedOutput.Rtot;
     //output.Td = unmanagedOutput.Td;
     //output.wt_pathlen_out_top = unmanagedOutput.wt_pathlen_out_top;
     //output.wt_pathlen_out_bot = unmanagedOutput.wt_pathlen_out_bot;
     //output.wt_pathlen_out_sides = unmanagedOutput.wt_pathlen_out_sides;
     //output.nomega = unmanagedOutput.nomega;
     //output.cramer_wt = unmanagedOutput.cramer_wt;
     //output.Rconv = unmanagedOutput.Rconv;
     //output.Rconv2 = unmanagedOutput.Rconv2;
     //output.num_visit_conv = unmanagedOutput.num_visit_conv;
     //output.num_visit = unmanagedOutput.num_visit;
 }
Пример #4
0
        /// <summary>
        /// Method to run parallel MC simulations
        /// </summary>
        /// <param name="simulations">array of MonteCarloSimulation</param>
        /// <returns>array of SimulationOutput</returns>
        public static SimulationOutput[] RunAll(MonteCarloSimulation[] simulations)
        {
            SimulationOutput[] outputs = new SimulationOutput[simulations.Length];
            var options = new ParallelOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            };

            Parallel.ForEach(simulations, options, (sim, state, index) =>
            {
                try
                {
                    outputs[index] = simulations[index].Run();
                }
                catch
                {
                    Console.WriteLine("Problem occurred running simulation #{0}. Make sure all simulations have distinct 'OutputName' properties?", index);
                }
            });

            return(outputs);
        }