本帖最后由 cathyzhyq 于 2017-5-7 21:25 编辑
下面是ZPL macro的全部程序段,麻烦大家帮我挑一挑错。多谢啦~~NSC editor中只有一个光源和一个探测器
分别是 object 4 ——source point;
和 object 5 ——detector rectangle;
ZPL旨在产生几万~几十万个随机位置作为光源坐标,带入NSC系统,进行ray trace, 最终在探测器 detector rectangle上得到能量值并且一条一条输出
坐标-能量 对应数据:x, y, z, energy。
!This is the main program
For i=0,10,1
GOSUB source_position
NEXT
END # This is the end of the main program
! This is the sub-routine
SUB source_position
!create 3 randoms
r=RAND(9.9)
angle=RAND(360)
z0=RAND(9.9)
pi=3.1415926
!create the coordination parameter
y=r*SINE(angle*pi/180)
x=y/TANG(angle*pi/180)
z=z0+0.1
!set the source_position
SETNSCPOSITION 1,4,1,x
SETNSCPOSITION 1,4,2,y
SETNSCPOSITION 1,4,3,z
!ray tracing
surf=1
source=4
split=1
scatt=1
pol=1
ignore_err=1
random_seed=1
save=0
object=0
obj=5
pix=0
data=0
temp=NSDD(surf, object, pix, data) #clear the detector
NSTR surf, source, split, scatt, pol, ignore_err, random_seed, save
!print
PRINT
PRINT i
PRINT "Reading on detector is", x, y, z, NSDD(surf, obj, pix, data)
!recover source_position
SETNSCPOSITION 1,4,1,0
SETNSCPOSITION 1,4,2,0
SETNSCPOSITION 1,4,3,0
RETURN # This is the end of the sub-routine