24小时热门版块排行榜    

查看: 5782  |  回复: 10
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

匿名

用户注销 (小有名气)

本帖仅楼主可见
已阅   同方向广播   申请仿真EPI   回复此楼   编辑   查看我的主页

lvqing323

木虫 (正式写手)

【答案】应助回帖

★ ★
xiegangmai: 金币+2, 谢谢参与! 2013-04-05 21:17:16
感觉上面计算的是均值,既然是求能谱,应该是不同粒子到达的几率,我编的程序,和你们的结果对不上,不知道是哪里的问题,请指正:
引用回帖:
% 能谱嘛,应该是几种粒子输运到达的几率值
clc;clear;
N=5e5;R1=20;d=40;R2=35/2;len=35;
count=zeros(1,3);
for i=1:N
    % 抽取发射位置
    rand_pos=rand(1,2);
    Rr=R1*rand_pos(1);
    a=2*pi*rand_pos(2);
    xr=Rr*cos(a);
    yr=Rr*sin(a);
    % 抽取发射粒子方向
    rand_vel=rand(1,2);
    sita=pi*rand_vel(1);
    b=2*pi*rand_vel(2);
    % 粒子到达探测器近平面区域
    L1=d/abs(cos(sita));
    xd1=xr+L1*abs(sin(sita)*cos(b));
    yd1=xr+L1*abs(sin(sita)*sin(b));
    Rd1=sqrt(xd1^2+yd1^2);
    % 粒子到达探测器远平面
    L2=(d+len)/abs(cos(sita));
    xd2=xr+L2*abs(sin(sita)*cos(b));
    yd2=xr+L2*abs(sin(sita)*sin(b));
    Rd2=sqrt(xd2^2+yd2^2);
    % 抽取粒子
    rand_par=rand;
    if rand_par<=0.15
        % 对应3.0MeV粒子抽样机率
        if Rd1<=R2||Rd2<=R2
            count(3)=count(3)+1;
        end
    elseif rand_par>0.15&&rand_par<=0.4
        % 对应1.0MeV粒子抽样机率
        if Rd1<=R2||Rd2<=R2
            count(2)=count(2)+1;
        end
    else
        % 其余粒子0.7MeV能量
        if Rd1<=R2||Rd2<=R2
            count(1)=count(1)+1;
        end
    end
end
spec=count./N;
EnergyMean=0.7*spec(1)+1.0*spec(2)+3.0*spec(3)

缘来如梦,缘去为空。
8楼2013-04-04 19:03:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 11 个回答

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

王碎碎狼(金币+1): ★有帮助 2012-01-06 09:03:58
写了一个,不知道是不是符合你的要求
CODE:
S=0;
N=5e7;
for i=1:N
     p=rand;
     E=3.0*(p<0.15)+1*(0.15<=p&p<0.4)+0.7*(0.4<=p&p<=1);
     r = -20+40*rand;
     a=-pi/2+pi/2*rand;
if r>=35/2
       a1=atan((35/2-r)/45);
       a2=atan((-35/2-r)/(45+35));
       S=E*(a>=a2&&a<=a1)+S;
elseif r>=-35/2 &r<35/2
      a1=atan((35/2-r)/45);
      a2=atan((-35/2-r)/(45+35));
      S=E*(a>=a2&&a<=a1)+S;
else
      a1=atan((35/2-r)/(45+35));
      a2=atan((-35/2-r)/45);
      S=E*(a>=a2&&a<=a1)+S;  
    end
end
  
Sa=S/N

Sa =

    0.1502
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2011-12-10 10:53:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

引用回帖:
2楼: Originally posted by dbb627 at 2011-12-10 10:53:27:
写了一个,不知道是不是符合你的要求
[code]
S=0;
N=5e7;
for i=1:N
     p=rand;
     E=3.0*(p<0.15)+1*(0.15<=p&p<0.4)+0.7*(0.4<=p&p<=1);
     r = -20+40*rand;
     a= ...

原理图如下


The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
3楼2011-12-10 10:54:16
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

[quote]2楼: Originally posted by dbb627 at 2011-12-10 10:53:27:
写了一个,不知道是不是符合你的要求
CODE:
S=0;
N=5e7;
for i=1:N
     p=rand;
     E=3.0*(p<0.15)+1*(0.15<=p&p<0.4)+0.7*(0.4<=p&p<=1);
     r = -20+40*rand;
     a= ... [/quote]


有点错误
[code]
S=0;
N=5e7;
for i=1:N
     p=rand;
     E=3.0*(p<0.15)+1*(0.15<=p&p<0.4)+0.7*(0.4<=p&p<=1);
     r = -20+40*rand;
     a=-pi/2+pi/2*rand;
if r>=35/2
       a1=atan((35/2-r)/45);
       a2=atan((-35/2-r)/(45+35));
       S=E*(a>=a2&&a<=a1)+S;
elseif r>=-35/2 &r<35/2
     [color=red] a1=atan((35/2-r)/(45+35));[/color]
      a2=atan((-35/2-r)/(45+35));
      S=E*(a>=a2&&a<=a1)+S;
else
      a1=atan((35/2-r)/(45+35));
      a2=atan((-35/2-r)/45);
      S=E*(a>=a2&&a<=a1)+S;  
    end
end
   Sa=S/N

Sa =

    0.1502
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
4楼2011-12-10 10:58:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见