コード例 #1
0
        private static IStructure CreateAndSaveStructure(UnitCellDetails unitCellDetails, DiscretisationInfo discretisationInfo)
        {
            var    structure         = new Structure(unitCellDetails, discretisationInfo);
            string structureFilename = @"D:\data\structureCss.csv";

            WriteLine("Saving the structure in " + structureFilename);
            Save(structure.Permittivity, structure.XCells, structure.YCells, structureFilename);
            return(structure);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var dx = 0.58652 * u / 40.0;
            var dy = 0.58652 * u / 40.0;
            //calculating the time step using Corant Limit formula
            var dt = 0.9 * CalculateTimeStepUsingCourantLimit(dx, dy);
            var discretisationInfo = new DiscretisationInfo(dx, dy, dt);

            var unitCellDetails = new UnitCellDetails(
                xPeriod: 0.58652 * u,
                yPeriod: 0.58652 * u,
                dielectricBackground: Eps0,
                rodholeDielectric: 3.4 * 3.4 * Eps0,
                rodHoleRadius: 0.2 * 0.58652 * u,
                discretisationInfo: discretisationInfo);


            //creating the structure to be simulated
            var structure = CreateAndSaveStructure(unitCellDetails, discretisationInfo);

            //creating the source to be used to excite the structure
            int    timeSteps = 200000;
            Source source    = CreateSource(discretisationInfo, timeSteps);

            var EField         = new ComplexField(structure.XCells, structure.YCells);
            var HField         = new ComplexField(structure.XCells, structure.YCells);
            var fdtdPropagator = new FDTDPropagator(discretisationInfo, EField, HField, structure);

            fdtdPropagator.OnMultipleReached += (t) => Messenger.SimulationTimeInfos(timeSteps, t);
            var detector1 = new Detector(20, 20);
            var detector2 = new Detector(unitCellDetails.XPeriod / 3.0, unitCellDetails.YPeriod * 0.8, discretisationInfo.Dx, discretisationInfo.Dy);
            var detectors = new List <Detector> {
                detector1, detector2
            };

            WriteLine();
            Messenger.PrintSimulationRunDetails(timeSteps, timeSteps * discretisationInfo.Dt);
            var watch = Stopwatch.StartNew();

            fdtdPropagator.Propagate(timeSteps, source, detectors);
            Messenger.ElapsedTime(watch);
            WriteLine();

            SaveDetectors(detectors);

            WriteLine("Press Enter to terminate");
            ReadLine();
        }