準備
ucsampcgをegs5/calcディレクトリにコピー
egs5/samplecodes/ucsampcg を egs5/calc/へ
フォルダ構成
egs5/calc/
egs5run* simple/ ucsampcg/
egs5/calc/ucsampcg/
ucsampcg.data ucsampcg.f ucsampcg.inp ucsampcg.out
戻る
注意!
スライド中ソースのコピペに際して
! ~~~~~~~ Pegs COPTIONs INPUT ~~~~~~~
IRAYL = 1 ! Rayleigh scattering
100 format(a3, i5, 3f9.5, 2x, 3f9.5, 2x, f9.5)
write(*,*)'----------------- something comments -----------------
$----------------'
戻る
注意2!
戻る
ucsampcg.fの内容確認その1
nmed=2 ! number of medium: 物質数 medarr(1)='FE-RAYLEIGH '! 物質名を任意で入力(24文字) medarr(2)='AIR AT NTP '! .inpで定義 : med(1)=1 ! 領域1 = 1番medium = medarr(1) med(2)=0 ! 領域2 = 0番medium = vacuum : do i=1,nreg ecut(i)=100.0 ! エネルギー下限値(電子・陽電子) pcut(i)=100.0 ! エネルギー下限値(光子) iphter(i) = 0 ! EGSオプション :
戻る
ucsampcg.fの内容確認その2
call rluxinit ! Initialize the Ranlux random-number generator
! source
iqi = -1 ! 線種:電子
xin = 0.0 ! 線源座標 (x,y,z)
yin = 0.0
zin = 0.0
uin = 0.0 ! 方向ベクトル (u,v,w)
vin = 0.0
win = 1.0
iri = 0 ! initial region (0: Automatic search in CG)
wti = 1.0 ! Weight = 1 since no variance reduction used
ncases = 1000 ! 計算回数
ei = 1000.D0 ! 線源エネルギー (MeV)
if(irin.le.0.or.irin.gt.nreg) then
戻る
ucsampcg.fの内容確認その3
nlines=0 nwrite=15 maxpict=20 ! CGVIEW用に出力する線源数 : do i=1,ncases ! 主計算ループ : call shower(iqi,...) ! EGSの実効的メインルーチンである shower の call if (i.le.maxpict) call plotxyz(99,... ! PICTファイル出力 : end do etot=etot/totke write(6,240) etot ! 結果の出力 240 FORMAT(//,' Total energy fraction in run=',G15.7,/, *' Which should be close to unity')
戻る
ucsampcg.inp の内容
.inpファイル = 物質情報と、物質ごとの計算パラメータの設定
ELEM
&INP IRAYL=0,IBOUND=0,INCOH=0,ICPROF=0,IMPACT=0 &END
FE-RAYLEIGH FE
FE
ENER
&INP AE=1.5,AP=0.100,UE=2000.0,UP=2000.0 &END
TEST
&INP &END
PWLF
&INP &END
DECK
&INP &END
:
戻る
計算体系
ucsampcg.dataの内容
cgviewで確認してみましょう
ucsampcg.data
RPP 1 -1.5 1.5 -1.5 1.5 0.0 3.0 直方体 領域No xの下限上限 yの下限上限 zの下限上限 (cm) RPP 2 -2.5 2.5 -2.5 2.5 -1 4.0 直方体 領域No xの下限上限 yの下限上限 zの下限上限 (cm) END Z1 +1 Z2 +2 -1 ← 一番最後の領域 =「計算打ち切り領域」に自動設定される END 1 0 ↑ z1,z2 それぞれの物質番号 0は真空
戻る
計算を実行してみましょう
egs5の実行
(Win)$ egs5run ucsampcg¥ucsampcg 1 file(s) copied. 1 file(s) copied. include <<===>> ...
以下の出力が出た場合はエラーです
apparent state: unit 4 named egs5job.inp : abnormal program terminationこの場合、ucsampcg/ucsampcg.dataの最終行を削除し、再度計算を実行して下さい
(Mac/Linux)
$ ./egs5run ucsampcg ============================ egs5run script has starte ============================ working directory is /Users/iwase/egs5/calc
以下の出力はエラーではありません
22459 | call PWLF1(NGL,NALG,AP,UP,RMT2,EPG,ZTHRG,ZEPG,NIPG,DLOG,DEXP,AXG,B
Warning: Interface mismatch in dummy procedure 'xfun' at (1): 'dlog' is not a subroutine
:
戻る
CGVIEWで飛跡の確認
「ファイル」「体系・飛跡データ読込」から egs5/calc/egs5job.picを開く
飛跡の確認
戻る
スコアリング量の確認
ucsampcg.f中のサブルーチンausgabの確認
ucsampcg.f: 378行目あたり
! ----------------------
! Add deposition energy
! ----------------------
esum(ir(np))=esum(ir(np)) + edep ← 各領域へのエネルギー付与の集計
詳しくは別演習で説明します
! ----------------------------------------------------------------
! Print out stack information (for limited number cases and lines)
! ----------------------------------------------------------------
if (nlines.lt.nwrite) then
write(6,1240) e(np),z(np),w(np),iq(np),ir(np),iarg ← 粒子情報の書出
1240 FORMAT(3G15.7,3I5)
nlines=nlines+1
end if
! ------------------------------------
! Output particle information for plot
! ------------------------------------
if (i.le.maxpict) then
call plotxyz(iarg,np,iq(np),x(np),y(np),z(np),e(np),ir(np),
* wt(np),time(np)) ← pictファイルへの粒子情報の書出
end if
戻る
スコアリング量の確認(2)
ucsampcg.f中のメインルーチンの確認
ucsampcg.f: 77行目あたり
common/totals/esum(MXREG),maxpict,i ← メインルーチンとサブルーチンausgabで変数を共有
共有箱/totals/、共有する変数 esum,maxpict,i
同じ定義がサブルーチンausgab側にも必要
real*8 esum
integer maxpict
ucsampcg.f: 291行目あたり
!-----------------------------------------------------------------------
! Step 7: Initialization-for-ausgab
!-----------------------------------------------------------------------
do i=1,nreg
esum(i)=0.D0 ← 変数の初期化
end do
戻る
スコアリング量の確認(3)
ucsampcg.f中のメインルーチンの確認
ucsampcg.f: 77行目あたり
call shower(iqi,ei,xi,yi,zi,ui,vi,wi,irinn,wti)
:
end do
:
!-----------------------------------------------------------------------
! Step 9: Output-of-results
!-----------------------------------------------------------------------
totke=ncases*ekin ← 総線源エネルギー(入力値)
write(6,220) ei,ncases
:
etot=0.D0
do i=1,nreg
etot=etot+esum(i) ← 全領域に付与されたエネルギー(出力値)
esum(i)=esum(i)/totke ← 各領域に付与されたエネルギー / 総線源エネルギー
write(6,230) i, esum(i) ← 書き出し
end do
etot=etot/totke ← 全領域に付与されたエネルギー / 総線源エネルギー
write(6,240) etot ← 書き出し
戻る
結果ファイル
egs5job.out
通常、計算段階出力や書き出したい変数値、結果までを含む
egs5job.out: 冒頭部
PEGS5-call comes next
:
HATCH-call comes next
:
EGS SUCCESSFULLY 'HATCHED' FOR 2 MEDIA.
:
Shower Results:
e z w
1000.000 0.000000 1.000000
1000.000 0.000000 1.000000
999.9994 0.5137929E-04 1.000000
999.9985 0.1367128E-03 1.000000
:
egs5job.out: 後半部
Elapsed Time (sec)= 2.32700E-02
Incident total energy of electron= 1000.0 MeV
Number of cases in run= 1000
Energy deposition summary:
Fraction in region 1= 0.4015938
Fraction in region 2= 0.5984062
Total energy fraction in run= 1.000000
Which should be close to unity
→ 出力情報を一通り理解してみましょう
戻る
surface crossing 設定例
z = 3(cm)で領域1から領域2へ移動する粒子
ucsampcg.f:405行目あたり
include 'include/egs5_useful.f'
real*8 rnnow,etot
integer i,idin,ifti,ifto, nlist,j,k,n
character*24 medarr(MXMED)
real*8 ekine
ucsampcg.f: 418行目あたり
esum(ir(np))=esum(ir(np)) + edep
! Add surface crossing
if(iarg.eq.0)then
if (irold.eq.1 .and. ir(np).eq.2 .and. z(np).eq.3.0d0 )then
ekine = e(np) - iabs(iq(np))*RM
if(iq(np).eq.-1) write(91,100)ekine
if(iq(np).eq. 1) write(92,100)ekine
if(iq(np).eq. 0) write(93,100)ekine
100 format(f10.5)
endif
endif
戻る