Пример #1
0
        private void CreateSimulator()
        {
            if (!float.TryParse(textBoxSoundSpeed.Text, out mC0))
            {
                MessageBox.Show("E: parse Sound Speed failed");
                return;
            }
            float Δt_ms;

            if (!float.TryParse(textBoxTimeStep.Text, out Δt_ms))
            {
                MessageBox.Show("E: parsing Time step failed");
                return;
            }
            if (!float.TryParse(textBoxWallReflectivity.Text, out mWallReflectivity) || mWallReflectivity < 0.0f || 1.0f <= mWallReflectivity)
            {
                MessageBox.Show("E: wall reflectivity should be number between 0.0 and 1.0");
                return;
            }
            if (!float.TryParse(textBoxSc.Text, out mSc) || mSc < 0.0f || 1.0f < mSc)
            {
                MessageBox.Show("E: Courant Number of 1-dimension FDTD should be number between 0.0 and 1.0");
                return;
            }

            /*
             * Sc = C0Δt/Δx
             * Δx = C0Δt/Sc
             *
             */


            mΔt = Δt_ms * 0.001f;

            mΔx = mC0 * mΔt / mSc;

            textBlockHalf.Text = string.Format("{0:0.00}", mΔx * 512);
            textBlockFull.Text = string.Format("{0:0.00}", mΔx * 1024);

            if (null != mDT)
            {
                mDT.Stop();
            }

            lock (mLock) {
                if (mSim != null)
                {
                    mSim.Term();
                    mSim = null;
                }

                mSim = new WaveSimFdtd1D(mW, mC0, mΔt, mΔx, mWallReflectivity);
            }

            if (null != mDT)
            {
                mDT.Start();
            }
        }
Пример #2
0
 private void Window_Closed(object sender, EventArgs e)
 {
     mSim.Term();
     mSim = null;
 }