admin 管理员组文章数量: 1087139
2024年6月11日发(作者:excel随机数固定范围生成两位小数)
NP-TEAM@
[键入文字]
在Ubuntu10.04.1下安装Geant4
作者 陶仕达 高永凤 王云海 吴福源
指导老师:胡华四教授
珍藏版
2011年
0
陕西省西安市咸宁西路28号
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
目录
目录 ............................................................................................................................................. 1
一、准备工作 ............................................................................................................................. 3
1.1安装基本编译环境 ........................................................................................................... 3
1.2安裝OpenGL Library ......................................................................................................... 3
1.3安裝OpenGL Utilities ....................................................................................................... 3
1.4安装sudo apt-get install libxt-dev .................................................................................... 3
1.5安装libxmu。打开新立得软件包管理器,查找libxmu。把找到的七项全装上。 ... 3
1.6安装sudo apt-get install libxi-dev .................................................................................... 3
1.7确认已安装g++。命令如下: ........................................................................................ 3
二、下载安装CLHEP .................................................................................................................. 4
2.1到以下网站下载CLHEP数据包。 ................................................................................... 4
2.2把下载的数据包放到某个文件夹。 ............................................................................... 4
2.3解压。 ................................................................................................... 4
2.4进入你解压出来的文件夹配置环境。 ........................................................................... 4
2.5编译CLHEP。 ................................................................................................................... 5
2.6安装CLHEP ....................................................................................................................... 5
三、下载安装GEANT4 ............................................................................................................... 6
3.1到以下网站下载你所需的数据包 。 ............................................................................. 6
3.2解压。 ........................................................................................... 6
3.3解压。 ............................................................................................ 7
3.4配置环境。 ....................................................................................................................... 7
3.5回答问题. .......................................................................................................................... 7
3.6安装GEANT4。 ................................................................................................................ 8
3.7安装成功。 ..................................................................................................................... 10
四、运行应用程序 ................................................................................................................... 10
4.1创建运行脚本。 ............................................................................................................. 10
4.2创建Geant4工作目录。 ............................................................................................... 10
4.3把应用程序复制到你的工作文件夹。 ......................................................................... 11
4.4配置应用程序运行环境。 ............................................................................................. 11
1
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
4.5编译程序。 ..................................................................................................................... 12
4.6运行生成的可执行文件。 ............................................................................................. 12
4.7打开视窗,查看你定义的几何模型。 ............................................................................ 13
4.9查看粒子径迹和粒子碰撞过程。 ................................................................................. 13
4.10 运行完毕,退出。 ......................................................................................................... 14
五、结束语 ............................................................................................................................... 14
2
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
一、准备工作
1.1安装基本编译环境
sudo apt-get install build-essential
1.2安裝OpenGL Library
sudo apt-get install libgl1-mesa-dev
1.3安裝OpenGL Utilities
sudo apt-get install libglu1-mesa-dev
1.4安装sudo apt-get install libxt-dev
不装这个包在编译geant4时会报error: X11/Intrinsic.h: No such file or directory的错误。
1.5安装libxmu。
打开新立得软件包管理器,查找libxmu。把找到的七项
全装上。
否则编译geant4时会遇到如下错误:include/:46:29: error:
X11/Xmu/StdCmap.h: No such file or directory。 原因可能是默认安装的libxmu相关包都不是dev版
(develop),所以在系统中没有头文件。
1.6安装sudo apt-get install libxi-dev
(在Ubuntu上)
否则将可能出现如下错误:
/usr/bin/ld: cannot find -lXi
collect2: ld returned 1 exit status
make[1]: *** [../../bin/linux/release/particles] Error 1
1.7确认已安装g++。
命令如下:
g++ -v
3
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
二、下载安装CLHEP
2.1到以下网站下载CLHEP数据包。
/proj-clhep/DISTRIBUTION/
2.2把下载的数据包放到某个文件夹。
例如:
~/CLHEP
2.3解压。
(当然也可以直接用右键解压)
cd ~/CLHEP
tar -zxvf
你将在终端将看到如下内容
starting with:
2.0.4.5/
2.0.4.5/CLHEP/
2.0.4.5/CLHEP/CVS/
2.0.4.5/CLHEP/CVS/Root
2.0.4.5/CLHEP/CVS/Repository
And ending with:
2.0.4.5/CLHEP/Vector/configure
2.0.4.5/CLHEP/
2.0.4.5/CLHEP/
2.0.4.5/CLHEP/
2.0.4.5/CLHEP/configure
2.4进入你解压出来的文件夹配置环境。
命令如下:
cd 2.0.4.5/CLHEP
sudo ./configure --prefix /u/ey/perl/CLHEP
输入密码后,你将看到如下内容:
starts with:
checking build i686-pc-linux-gnu
checking host i686-pc-linux-gnu
checking target i686-pc-linux-gnu
checking for a /usr/bin/install -c
checking whether build environment yes
And ends with:
: creating test/
: creating test/
: creating test/
: creating Exceptions/defs.h
: executing depfiles commands
4
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
2.5编译CLHEP。
命令如下:
make
你将看到如下内容:
starts with:
Making all in Units
make[1]: Entering directory
`/afs//u/ey/perl/CLHEP/2.0.4.5/CLHEP/Units'
Making all in Units
make[2]: Entering directory
`/afs//u/ey/perl/CLHEP/2.0.4.5/CLHEP/Units/U
nits'
make all-am
And ends with:
rm -f
liblist=`./getObjectList -shared Units Vector Evaluator
GenericFunctions Geometry Random Matrix RandomObjects RefCount
Cast Exceptions`;
g++ -O -ansi -pedantic -Wall -D_GNU_SOURCE -g -O2 -o
-shared -Wl,-soname,
$liblist -o
./build-header
make[1]: Leaving directory
`/afs//u/ey/perl/CLHEP/2.0.4.5/CLHEP'
2.6安装CLHEP
。命令如下:
make install
你将看到如下内容:
starts with:
Making install in Units
make[1]: Entering directory
`/afs//u/ey/perl/CLHEP/2.0.4.5/CLHEP/Units'
Making install in Units
make[2]: Entering directory
`/afs//u/ey/perl/CLHEP/2.0.4.5/CLHEP/Units/Uni
ts'
And ends with:
test -z "/u/ey/perl/CLHEP/include/CLHEP" || mkdir -p --
"/u/ey/perl/CLHEP/include/CLHEP"
if test -f ClhepVersion.h; then
echo " /usr/bin/install -c -m 644 'ClhepVersion.h'
'/u/ey/perl/CLHEP/include/CLHEP/ClhepVersion.h'";
/usr/bin/install -c -m 644 "ClhepVersion.h"
"/u/ey/perl/CLHEP/include/CLHEP/ClhepVersion.h";
5
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
else :; fi
/usr/bin/install -c -m 644 'ClhepVersion.h'
'/u/ey/perl/CLHEP/include/CLHEP/ClhepVersion.h'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory
`/afs//u/ey/perl/CLHEP/2.0.4.5/CLHEP'
make[1]: Leaving directory
`/afs//u/ey/perl/CLHEP/2.0.4.5/CLHEP'
这样以后,你将在
/u/ey/perl/CLHEP/2.0.4.5/CLHEP
目录中里看到include和
lib两个目录。如果你看到以上两个目录得话,恭喜你,你的CLHEP安装成功了!
三、下载安装GEANT4
3.1到以下网站下载你所需的数据包 。
/geant4/
3.2解压。
把下载的压缩包解压到某一个文件夹。命
令如下:
cd ~/geant4
tar -zxvf
你将看到如下内容:
starting with:
geant4.9.3.p02/
geant4.9.3.p02/Configure
geant4.9.3.p02/LICENSE
geant4.9.3.p02/ReleaseNotes/
geant4.9.3.p02/ReleaseNotes/
And ending with:
geant4.9.3.p02/source/visualization/modeling/src/G4Trajector
geant4.9.3.p02/source/visualization/modeling/src/G4Trajector
geant4.9.3.p02/source/visualization/modeling/src/
geant4.9.3.p02/source/visualization/modeling/src/G4VTrajecto
geant4.9.3.p02/source/visualization/modeling/src/G4VisTrajCo
6
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
3.3解压。
在你geant4.9.3.p02文件夹里新建一个名为
data的文件夹,把下载的数据包放进去,解压(其他数
据包同理)。解压命令如下:
cd ~/geant4/geant4.9.3.p02/data
tar -zxvf
你将在终端将看到如下内容
starting with:
G4EMLOW6.9/
G4EMLOW6.9/auger/
G4EMLOW6.9/auger/
G4EMLOW6.9/auger/
G4EMLOW6.9/auger/
And ending with:
G4EMLOW6.9/tripdata/
G4EMLOW6.9/tripdata/
G4EMLOW6.9/tripdata/
G4EMLOW6.9/tripdata/
G4EMLOW6.9/tripdata/
3.4配置环境。
进入geant4.9.3.p02文件夹配置环境。命令如下:
cd ~/geant4/geant4.9.3.p02
./Configure -build
3.5回答问题。
输入以上两条命令按回车后,你将在终端被问一系列问题,除
以下两个问题外,全部采用默认设置。
问题一:
When it asks:
Enable building of the X11 OpenGL visualization driver? [n]
Enter:
y
This tells Geant4 that you want to include the optional OpenGL Visualization
driver.
问题二:
When it asks:
Enable building of the X11 RayTracer visualization driver? [n]
Enter:
y
This tells Geant4 that you want to include the optional RayTracerX Visualization
driver.
问题回答完后,终端将显示如下内容:
WARNING: the generated configuration file
can be edited if necessary!
You can introduce any change to the configuration file
/u/ey/perl/geant4/geant4.9.3.p02/.config/bin/Linux-g++/confi
before the final installation.
7
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
To do so, use a shell escape now (e.g. !vi
/u/ey/perl/geant4/geant4.9.3.p02/.config/bin/Linux-g++/confi
).
Press [Enter] to start installation or use a shell escape to edit
:
如果你确实看到了以上内容,恭喜你,你马上就可以享受到一个愉快的安装之旅
了。
3.6安装GEANT4。
按下回车,开始安装。这时你将终端看到如下内容:
Now starting Geant4
On this machine the G4SYSTEM=Linux-g++
On this machine the G4INSTALL=/u/ey/perl/geant4/geant4.9.3.p02
On this machine the G4TMP=/u/ey/perl/geant4/geant4.9.3.p02/tmp
On this machine the G4LIB=/u/ey/perl/geant4/geant4.9.3.p02/lib
On this machine the
G4LEVELGAMMADATA=/u/ey/perl/geant4/geant4.9.3.p02/data/Photo
nEvaporation2.0
On this machine the
G4RADIOACTIVEDATA=/u/ey/perl/geant4/geant4.9.3.p02/data/Radi
oactiveDecay3.2
On this machine the
G4LEDATA=/u/ey/perl/geant4/geant4.9.3.p02/data/G4EMLOW6.9
On this machine the
G4NEUTRONHPDATA=/u/ey/perl/geant4/geant4.9.3.p02/data/G4NDL3
.13
On this machine the
G4ABLADATA=/u/ey/perl/geant4/geant4.9.3.p02/data/G4ABLA3.0
On this machine the CLHEP_BASE_DIR=/u/ey/perl/geant4/CLHEP
On this machine the
CLHEP_INCLUDE_DIR=/u/ey/perl/geant4/CLHEP/include
On this machine the CLHEP_LIB_DIR=/u/ey/perl/geant4/CLHEP/lib
On this machine the CLHEP_LIB=CLHEP
On this machine G4UI_NONE is not set - following UIs will be built:
On this machine G4VIS_NONE is not set - following drivers will
be built:
On this machine the G4VIS_BUILD_OPENGLX_DRIVER=1
On this machine the G4VIS_BUILD_RAYTRACERX_DRIVER=1
On this machine the G4VIS_USE_OPENGLX=1
On this machine the G4VIS_USE_RAYTRACERX=1
On this machine the XMFLAGS=
On this machine the XMLIBS=
On this machine the XMFLAGS=
8
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
On this machine the XAWFLAGS=
On this machine the XAWLIBS=
On this machine the G4LIB_BUILD_SHARED=1
************************************************************
Installation Geant4 version : geant4-09-03-patch-01
Copyright (C) 1994-2010 Geant4 Collaboration
************************************************************
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file
src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Removing library libG4globman.a ...
Removing library ...
Compiling ...
Compiling ...
Compiling ...
Compiling ...
当你看到以下内容的时候,我又要恭喜你,你的编译已经成功开始了。内容如下:
Compiling ...
9
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
3.7安装成功。
继续等上个40分钟左右,如果你看到以下内容的话,恭喜你,
你的Geant4至此已经安装成功了。当然你不必坐在电脑前干等,插上电源线,
乘机去洗个衣服或吃个饭什么的都行。^_^~
Building library management utility liblist ...
Libraries installation completed !
####################################################
# Your Geant4 installation seems to be successful!
# To be sure please have a look into the log file:
#
/u/ey/perl/geant4/geant4.9.3.p02/.config/bin/Linux-g++/g4mak
####################################################
四、运行应用程序
4.1创建G4脚本。
命令如下:
./Configure
你将在终端看到如下内容:
--- Geant4 Toolkit Installation ---
(setting environments for USER )
---------------------------------------------------
The Geant4 toolkit installation was found.
The files env.[c]sh will be copied to your current directory.
For setting Geant4 environments you should make:
source
or
.
It will also check G4WORKDIR setting and set it to
your HOME if needed.
You can use these files also for further modifications
(adding your own environments).
这样,你将在~/geant4/geant4.9.3.p02目录下看到和两个文件。
4.2创建G4工作目录。
命令如下:
export G4WORKDIR=~/g4work
10
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
4.3把应用程序复制到你的工作文件夹。
这里选择A01。命令如下:
cp -r ~/geant4/geant4.9.3.p02/examples/extended/analysis/A01
$G4WORKDIR/A01
4.4配置应用程序运行环境。
注意,每次在一个新终端运行应用程序时你都
应该做这一步。命令如下:
export G4WORKDIR=~/g4work
export LD_LIBRARY_PATH=~/CLHEP/lib/:$LD_LIBRARY_PATH
source ~/geant4/geant4.9.3.p02/
你将在终端看到如下内容:
On this machine the G4SYSTEM=Linux-g++
On this machine the G4INSTALL=/u/ey/perl/geant4/geant4.9.3.p02
On this machine the G4LIB=/u/ey/perl/geant4/geant4.9.3.p02/lib
On this machine the
G4LEVELGAMMADATA=/u/ey/perl/geant4/geant4.9.3.p02/data/Photo
nEvaporation2.0
On this machine the
G4RADIOACTIVEDATA=/u/ey/perl/geant4/geant4.9.3.p02/data/Radi
oactiveDecay3.2
On this machine the
G4LEDATA=/u/ey/perl/geant4/geant4.9.3.p02/data/G4EMLOW6.9
On this machine the
G4NEUTRONHPDATA=/u/ey/perl/geant4/geant4.9.3.p02/data/G4NDL3
.13
On this machine the
G4ABLADATA=/u/ey/perl/geant4/geant4.9.3.p02/data/G4ABLA3.0
On this machine the
G4REALSURFACEDATA=/u/ey/perl/geant4/geant4.9.3.p02/data/Real
Surface1.0
On this machine the CLHEP_BASE_DIR=/u/ey/perl/geant4/CLHEP
On this machine the
CLHEP_INCLUDE_DIR=/u/ey/perl/geant4/CLHEP/include
On this machine the CLHEP_LIB_DIR=/u/ey/perl/geant4/CLHEP/lib
On this machine the CLHEP_LIB=CLHEP
On this machine the G4UI_USE_TCSH=1
On this machine the G4VIS_BUILD_OPENGLX_DRIVER=1
On this machine the G4VIS_BUILD_RAYTRACERX_DRIVER=1
On this machine the G4VIS_USE_OPENGLX=1
On this machine the G4VIS_USE_RAYTRACERX=1
On this machine the XMFLAGS=
On this machine the XMLIBS=
On this machine the XMFLAGS=
On this machine the XMLIBS=
11
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
On this machine the XAWFLAGS=
On this machine the XAWLIBS=
On this machine the G4LIB_BUILD_SHARED=1
4.5编译程序。
进入你的应用程序文件夹编译程序。命令如下:
cd $G4WORKDIR/A01
make
你将在终端看到如下内容:
beginning with:
Making dependency for file ...
Making dependency for file
src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
Making dependency for file src/ ...
And ending with:
Creating/replacing object files in
/u/ey/perl/g4work/tmp/Linux-g++/A01app/libA01app.a ...
Compiling ...
Using granular libraries ...
Linking A01app ...
... Done!
4.6运行生成的可执行文件。
命令如下:
$G4WORKDIR/bin/Linux-g++/A01app
你将在终端看到如下内容:
starts with:
************************************************************
Geant4 version Name: geant4-09-03-patch-01 (9-April-2010)
Copyright : Geant4 Collaboration
Reference : NIM A 506 (2003), 250-303
WWW : /geant4
************************************************************
Visualization
Visualization
Registering
You have successfully registered the following graphics systems.
Current available graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRep (HepRepXML)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML1FILE (VRML1FILE)
12
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
OpenGLImmediateX (OGLIX)
OpenGLStoredX (OGLSX)
RayTracerX (RayTracerX)
And ends with:
EMcalorimeterPhysical[0] EMcalorimeterLogical 1 CsI
cellPhysical[-1] cellLogical 0 CsI /EMcalorimeter
HadCalorimeterPhysical[0] HadCalorimeterLogical 1 Lead
HadCalColumnPhysical[-1] HadCalColumnLogical 1 Lead
HadCalCellPhysical[-1] HadCalCellLogical 1 Lead
HadCalLayerPhysical[-1] HadCalLayerLogical 1 Lead
HadCalScintiPhysical[0] HadCalScintiLogical 0
Scintillator /HadCalorimeter
Idle>
4.7打开视窗,查看你定义的几何模型。
即在“Idle>”后输入以下命令:
/vis/open OGLIX
/vis/drawVolume
你将在一个新窗口看到如下图形
4.9查看粒子径迹和粒子碰撞过程。
即在终端继续输入如下命令:
/vis/scene/add/trajectories
/vis/scene/add/hits
/run/beamOn 1
你将在图像窗口看到以下图像(可能会稍微有点不同)
13
继往开来,勇攀高峰,在21世纪努力把西安交通大学建设成世界一流大学。
4.10 运行完毕,退出。
命令如下:
exit
五、结束语
文章是别人的,机子却是自己的。还是有问题,那就百度一下吧,百度不知的话
谷歌知。当然,网上的好些论坛上也潜伏着不少热心的高人,在注意网络礼节的
前提下,尽管问吧。Enjoy yourself ! ^_^…
推荐论坛:/forum
Copyleft@
2011年1月18日
14
版权声明:本文标题:Ubuntu下安装Geant4 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1718114664a717163.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论