!**************************************************************************** ! 初期化 !**************************************************************************** subroutine init use consts use fdtd implicit none integer :: id real(8) :: lambda0 print *,'**** INIT ****' write(1,*) '**** INIT ****' ! ******** ファイル入力 ******** call input ! ******** タイムステップ、格子間隔 ******** ! Courant の安定条件 ! v dt < 1/sqrt((1/dx)**2+(1/dy)**2+(1/dz)**2) ! v dt < dx/sqrt(3) when dx=dy=dz lambda0=c/freq dx=lambda0/nlambda0 dy=dx dt=(1.0d0/freq)/nperiod if(dt.gt.1.0d0/sqrt((1.0d0/dx)**2+(1.0d0/dy)**2)/c) then print *,'Sub(init): Courant stability condition must be satisfied' print *,'dt = ',dt print *,'dt < ',1.0d0/sqrt((1.0d0/dx)**2+(1.0d0/dy)**2)/c stop end if write(1,*) 'dt=',dt ! ******** 媒質定数設定 ******** nmedia=3 ! 1: 真空 eps(1)=epsilon0 mu(1)=mu0 sig(1)=0.0d0 ! 2: PEC,PMC (これは別のルーチンで処理する) ! 3: 誘電体 eps(3)=9.0d0*epsilon0 mu(3)=mu0 sig(3)=0.0d0 ! ******** フィールド更新係数 ******** ! 1: 真空 cez0=1.0d0 cezry0=(dt/epsilon0)/dy cezrx0=(dt/epsilon0)/dx chxry0=(dt/mu0)/dy chyrx0=(dt/mu0)/dx ! 3以上: 一般の媒質 do id=3,nmedia cez(id)=(1.0d0-((sig(id)*dt)/(2.0d0*eps(id)))) & /(1.0d0+((sig(id)*dt)/(2.0d0*eps(id)))) cezry(id)=(dt/eps(id))/(1.0d0+((sig(id)*dt)/(2.0d0*eps(id))))/dy cezrx(id)=(dt/eps(id))/(1.0d0+((sig(id)*dt)/(2.0d0*eps(id))))/dx chxry(id)=(dt/mu(id))/dy chyrx(id)=(dt/mu(id))/dx end do ! ******** 吸収境界条件の更新定数 ******** mur1_cx=(c*dt-dx)/(c*dt+dx) mur1_cy=(c*dt-dy)/(c*dt+dy) return end subroutine !---------------------------------------------------------------------------- ! ファイル入力 !---------------------------------------------------------------------------- subroutine input use fdtd implicit none integer :: fp ! ファイル識別子 character(128) :: text open(fp,file='input.dat') read(fp,*) text read(fp,*) text,freq read(fp,*) text,nx read(fp,*) text,nlambda0 read(fp,*) text,nperiod read(fp,*) text,ntime_start read(fp,*) text,ntime_end read(fp,*) text,ntime_step close(fp) freq=freq*1.0d9 ! GHz → Hz に変換 ny=nx ! パラメータ確認 write(1,*) 'FREQUENCY [GHz]=',freq write(1,*) 'NUMBER OF CELLS=',nx write(1,*) 'CELL INTERVAL [(FREE WAVELENGTH)/N]=',nlambda0 write(1,*) 'TIME INTERVAL [(PERIOD)/N]=',nperiod write(1,*) 'TIME STEP (START)=',ntime_start write(1,*) 'TIME STEP (END)=',ntime_end write(1,*) 'TIME STEP (STEP)=',ntime_step return end subroutine ! ! End of file !