大家好,我是一名人菜瘾大的计算机新手。由于专业需要,我要在这个暑假(2022/7-8)学习蒙特卡洛方法在核物理方面的应用(OpenMC)。经过近一个星期的瞎搞(我几乎用了官方文档中的每一个方法,除了Mac平台上的😂),终于在wsl2上差不多完成,现在分享给大家,希望不要像我一样惨🤞。
Hello everyone, I am a computer green hand but addicted to computer. Due to the need of my major, I need to learn the application of Monte Carlo method in nuclear physics(OpenMC) in this summer vacation (2022/7-8). After nearly a week of messing around (I used almost every method in the official documentation except 😂 on Mac), it's almost done on WSL2, and I'm sharing it with you, hopefully not as bad as I did 🤞.
cd ~
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
source /etc/apt/sources.list
sudo apt update
cd ~
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
都选yes就行⬇ Keep yes⬇
bash Miniconda3-py39_4.12.0-Linux-x86_64.sh
要重启再进入环境⬆ Need restart⬆ 到了conda⬇ For conda⬇
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes
conda update conda
到了pip⬇ For pip⬇
conda install pip
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
cd ~
sudo apt install git cmake g++ mpich gfortran libhdf5-dev libpng-dev libeigen3-dev libmpich-dev libnetcdf-dev libtbb-dev libgles2-mesa-dev
#pip install -r requirements-rtd.txt⬇
pip install sphinx==5.0.2 sphinx_rtd_theme==1.0.0 sphinx-numfig jupyter sphinxcontrib-katex sphinxcontrib-svg2pdfconverter numpy scipy h5py pandas uncertainties matplotlib
还有个OpenMOC,以后会用到⬇ There's also OpenMOC, which we'll use in the future⬇
cd ~
pip install swig pillow # Because above,this is enough.
#pip install swig numpy matplotlib h5py pillow
git clone https://github.com/mit-crpg/OpenMOC.git
#git clone https://gitclone.com/github.com/mit-crpg/OpenMOC.git
cd OpenMOC
python setup.py install --user
pip install .
cd ~
git clone https://github.com/openmc-dev/openmc.git
#git clone https://gitclone.com/github.com/openmc-dev/openmc.git
cd openmc
pip install . && cmake .
sudo make install
要花点时间⬆ It takes time⬆
-
If you use OpenMC in your research, please consider giving proper attribution by citing the following publication:
- Paul K. Romano, Nicholas E. Horelik, Bryan R. Herman, Adam G. Nelson, Benoit Forget, and Kord Smith, "OpenMC: A State-of-the-Art Monte Carlo Code for Research and Development," Ann. Nucl. Energy, 82, 90--97 (2015).
This is distributed under the MIT/X license.