ứng dụng tin học trong vật lý hạt nhân

15 0 0
Tài liệu đã được kiểm tra trùng lặp
ứng dụng tin học trong vật lý hạt nhân

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Trình bày kết quảb Vẽ histogram.c Fit tìm các hệ số.. So sánh và đánh giá với giá trị thực.Hệ số sau khi được Fit:... Câu 2: Hãy viết phương trình C++, sử dụng phương pháp Monte-Carlo th

Trang 1

TRƯỜNG ĐẠI HỌC KHOA HỌC TỰ NHIÊN, ĐHQG-HCMĐỀ THI CUỐI KÌ

Học kỳ II – Năm học 2022-2023

Tên học phần: Ứng dụng tin học trong Vật lý hạt nhânNgày thi: 06/2023Họ và tên sinh viên: HOÀNG PHẠM THÀNH ĐẠTMSSV: 20130068

CÂU 1: 2CÂU 2: 3CÂU 3: 4PHỤ Ụ 5 LC

PHỤ LỤC 1: 5

PHỤ LỤC 2: 7

PHỤ LỤC 3: 9

1

Trang 2

Câu 1: Xây dựng phương trình y(x) = x – 1 trong khoảng x=[-3;3] bằng phương pháp

Monte-Carlo Thực hiện mô phỏng cho 50000 sự kiến Trình bày kết quả

b) Vẽ histogram.

c) Fit tìm các hệ số So sánh và đánh giá với giá trị thực.Hệ số sau khi được Fit:

Trang 3

Câu 2: Hãy viết phương trình C++, sử dụng phương pháp Monte-Carlo thực hiện mô

phỏng cho phân bố Gauss với Thự hiện mô phỏng cho 50000 sự kiện Trình bày kết quả

b) Vẽ histogram.

c) Fit tìm và So sánh và đánh giá với giá trị thực.

Sau khi làm khớp ta thu được giá trị các hệ số: Các giá trị này khớp với giá trị thực,tuy nhiên sai số xảy ra vì bài toàn chỉ khảo sát trên khoảng [-5; 10] Do đó, muốn giảm thiểu sai số có thể mở rộng khoảng khảo sát để thu được giá trị các hệ số tốt nhất vì hàm Gauss là hàm phân bố trên toàn miền không gian

3

Trang 4

Câu 3: Xây dựng code Gate/Geant4 (1) mô hình detector nhấp nháy NaI hình trụ 7,6cm

7,6cm với thông số hình học và thông số vật liệu cho trước; và (2) xây dựng bố trị thực nghiệm (hình 2) (Phụ lục 3)

Sử dụng actor về Energy Spectrum để ghi nhận phổ năng lượng để lại trong vật liệu NaI.

a) Mô hình detector nhấp nháy NaI

b) Phổ năng lượng để lại trong vật liệu NaI

Trang 5

PHỤ LỤC

#include <iostream>#include <cmath>#include <cstdlib>#include <ctime>#include <fstream>#include <TH1F.h>#include <TCanvas.h>#include <TFile.h>#include <TApplication.h>//#include <TF1.h>using namespace std;#define N_event 50000int main(int argc, char** argv){

TApplication app("app", &argc, argv); float ran1, ran2;

float x; float Y, y; int i;

ofstream luufile;

luufile.open("C:/Users/Thanh/OneDrive/Desktop/HCMUS/Ky6/CK_ThayHai/NaI_1/data.txt"); //Khởi tạo dữ liệu ngẫu nhiên

srand(time(NULL)); i = 0;

while (i < N_event) {

ran1 = (float)rand() / RAND_MAX; ran2 = (float)rand() / RAND_MAX; x = ran1 * 6 - 3;

Y = ran2 * 9 - 1; y = pow(x, 2) - 1; if (Y < y)

5

Trang 6

{

cout << x << "/t" << Y << "\t" << y << endl; luufile << x << endl;

i = i + 1; } }

luufile.close(); ifstream

file("C:/Users/Thanh/OneDrive/Desktop/HCMUS/Ky6/CK_ThayHai/NaI_1/data.txt"); double data;

TH1* h1 = new TH1F("h1", "Histogram: y(x) = x^2 -1", 1000, -3, 3); //Khai bao histogram /// Doc du lieu tu file va fill vao histogram

while (file >> data) {

h1->Fill(data); }

/// Ve histogram

TCanvas* c1 = new TCanvas(); h1->Draw();

app.Run(); luufile.close(); return 0;}

Trang 7

 Phụ lục 2:#include <iostream>#include <cmath>#include <cstdlib>#include <ctime>#include <fstream>#include <TH1F.h>#include <TCanvas.h>#include <TFile.h>#include <TApplication.h>using namespace std;#define N_event 50000float r1, r2, x1, x2, gauss;float Pi = 3.141592;int main(int argc, char** argv) {

TApplication app("app", &argc, argv);ofstream luufile;

luufile.open("C:/Users/Thanh/OneDrive/Desktop/HCMUS/Ky6/CK_ThayHai/NaI_2/data.txt");/* initialize random seed: */

x2 = sin(2 * Pi * r2);

gauss = x1*x2*2 + 3; //x1*x2*sigma+mean// Xuat so lieu ra man hinh

cout << gauss << endl;// luu so lieu vao file data.txt

7

Trang 8

luufile << gauss << "\n";

r1 = 0.; r2 = 0.; x1 = 0.; x2 = 0.; gauss = 0.;}

luufile.close();ifstream

file("C:/Users/Thanh/OneDrive/Desktop/HCMUS/Ky6/CK_ThayHai/NaI_2/data.txt");double data;

TH1* h1 = new TH1F("h1", "Histogram: Gauss function", 1000, -5, 10); //Khai bao histogram

/// Doc du lieu tu file va fill vao histogramwhile (file >> data)

/// Ve histogram

TCanvas* c1 = new TCanvas();h1->Draw();

app.Run();luufile.close();return 0;}

Trang 9

 Phụ lục 3:Code khai bao vat lieu

/gate/geometry/setMaterialDatabase data/GateMaterials.db# W O R L D

# Al_top

/gate/world/daughters/name Al_top/gate/world/daughters/insert cylinder/gate/Al_top/setMaterial Aluminium/gate/Al_top/geometry/setRmin 0 cm/gate/Al_top/geometry/setRmax 4 cm/gate/Al_top/geometry/setHeight 0.05 cm/gate/Al_top/placement/setTranslation 0.0 0.0 -0.085 cm

9

Trang 10

/gate/Al_top/vis/setColor yellow#/gate/Al_top/vis/forceSolid

# Al_bot

/gate/world/daughters/name Al_bot/gate/world/daughters/insert cylinder/gate/Al_bot/setMaterial Aluminium/gate/Al_bot/geometry/setRmin 0 cm/gate/Al_bot/geometry/setRmax 4.13 cm/gate/Al_bot/geometry/setHeight 3.5 cm

/gate/Al_bot/placement/setTranslation 0.0 0.0 -9.715 cm/gate/Al_bot/vis/setColor yellow

/gate/world/daughters/insert cylinder/gate/SiO2/setMaterial SiO2/gate/SiO2/geometry/setRmin 0 cm/gate/SiO2/geometry/setRmax 4 cm

Trang 11

/gate/Al2O3/geometry/setRmax 4 cm/gate/Al2O3/geometry/setHeight 7.62 cm/gate/Al2O3/placement/setTranslation 0.0 0.0 -4.13 cm/gate/Al2O3/vis/setColor red

/gate/world/daughters/name Al2O3_top/gate/world/daughters/insert cylinder/gate/Al2O3_top/setMaterial Al2O3/gate/Al2O3_top/geometry/setRmin 0 cm/gate/Al2O3_top/geometry/setRmax 4 cm/gate/Al2O3_top/geometry/setHeight 0.16 cm/gate/Al2O3_top/placement/setTranslation 0.0 0.0 -0.24 cm/gate/Al2O3_top/vis/setColor red

/gate/world/daughters/insert cylinder/gate/Silicon/setMaterial Silicon/gate/Silicon/geometry/setRmin 0 cm/gate/Silicon/geometry/setRmax 4 cm/gate/Silicon/geometry/setHeight 0.11 cm/gate/Silicon/placement/setTranslation 0.0 0.0 -0.105 cm/gate/Silicon/vis/setColor cyan

#/gate/Silicon/vis/forceSolid# NaI Detector

# /gate/world/daughters/name NaI_Crystal

-11

Trang 12

/gate/world/daughters/insert cylinder/gate/NaI_Crystal/setMaterial NaI/gate/NaI_Crystal/geometry/setRmin 0 cm/gate/NaI_Crystal/geometry/setRmax 3.81 cm/gate/NaI_Crystal/geometry/setHeight 7.62 cm/gate/NaI_Crystal/placement/setTranslation 0.0 0.0 -4.1 cm/gate/NaI_Crystal/vis/setColor blue

#/gate/NaI_Crystal/vis/forceSolid/gate/NaI_Crystal/attachCrystalSD# - PMT

Code file main :

#/control/execute mac/visu.mac/control/execute mac/verbose.mac

#=====================================================# GEOMETRY

#=====================================================/control/execute mac/geometry.mac

#/control/execute mac/sourcecontainer.mac

#=====================================================

Trang 13

/gate/physics/Positron/SetCutInRegion NaI_Crystal 1.0 m# -

# the following actor regularly store the current # -

/gate/actor/addActor SimulationStatisticActor stat/gate/actor/stat/save output/data123.txt

/gate/actor/stat/saveEveryNSeconds 20# -# the following actor stores Energy Spectrum: histogram# -

/gate/actor/MyActor/enableFluenceTrackSpectrum true/gate/actor/MyActor/enableFluenceCosSpectrum true/gate/actor/MyActor/energySpectrum/setEmin 10 keV/gate/actor/MyActor/energySpectrum/setEmax 2 MeV/gate/actor/MyActor/energySpectrum/setNumberOfBins 1000

#=====================================================# INITIALISATION

/control/execute mac/digitizer.mac

13

Trang 14

#=====================================================# S O U R C E

#=====================================================/control/execute mac/source.mac

#=====================================================# D A T A O U T P U T

/gate/output/root/setFileName output/data/gate/output/root/setRootHitFlag 1/gate/output/root/setRootSinglesFlag 1

#====================================================# R A N D O M E N G I N E A N D S E E D

#==================================================== #JamesRandom Ranlux64 MersenneTwister

#/gate/random/setEngineName JamesRandom#/gate/random/setEngineSeed auto#/gate/random/verbose 1

#=====================================================# M E A S U R E M E N T S E T T I N G S

Trang 15

/gate/source/Cs137/gps/energy 900 keV

/gate/source/Cs137/gps/angtype iso/gate/source/Cs137/visualize 200 blue 3

15

Ngày đăng: 14/05/2024, 16:09