基於 MOOSE 的應用程序開發所需的依賴項的大量庫首選方法是通過 Conda獲取。按照以下説明使用 Conda 在計算機上創建環境。
1. 安裝Miniforge。
根據您的平台,請按照以下步驟安裝 Miniforge。如果您在這些步驟中遇到問題,請訪問Conda 故障排除指南。
- Linux Users:
Linux用户:
點擊查看代碼
curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh -b -p ~/miniforge
- Macintosh Users with Intel processors:
使用 Intel 處理器的 Macintosh 用户:
點擊查看代碼
curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-x86_64.sh
bash Miniforge3-MacOSX-x86_64.sh -b -p ~/miniforge
- Macintosh Users with Apple Silicon processors:
使用 Apple Silicon 處理器的 Macintosh 用户:
點擊查看代碼
curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
bash Miniforge3-MacOSX-arm64.sh -b -p ~/miniforge
將 Miniforge 安裝在主目錄中後,導出 PATH 以便可以使用:
點擊查看代碼
export PATH=$HOME/miniforge/bin:$PATH
現在我們可以執行 conda ,初始化它,然後退出終端:
點擊查看代碼
conda init --all
exitCopy
重新啓動終端後,您應該會看到以 (base) 為前綴的提示。這表示您處於基礎環境中,並且 Conda 已準備好運行:
點擊查看代碼
$ (base) ~>
全新安裝後,您應該做的下一件事是對基本 Conda 環境執行更新:
點擊查看代碼
conda update --all --yes
添加 INL 的公共通道以訪問 INL 的 Conda 包庫:
點擊查看代碼
conda config --add channels https://conda.software.inl.gov/public
警告:不要使用 sudo
如果您發現自己在使用 Conda 命令時使用了 sudo 命令...有些不對勁。需要 sudo 的最常見原因是由於 Conda 安裝不當。Conda 應該安裝到您的主目錄中,而不使用 sudo 。
注:Miniforge vs Miniconda vs Anaconda
他們的核心都是包含conda這一工具,來實現 python 環境(environment) 和 包(package) 管理的,(其實不僅僅可以用來管理python,很多語言R, Java, C都支持)。
Anaconda 和 Miniconda 是一個公司的產品,商用是付費的,個人暫時免費;而Miniforge是由社區主導,用GitHub託管,完全免費。Miniconda 和 Miniforge 是差不多的產物,代表着輕量化,而Anaconda是完整版,就略顯臃腫。
Miniforge 使用conda-forge 作為默認 channel,而 Miniconda 使用anaconda.org 作為默認channel。
注:conda channels (源)
conda channels (源)是 packages 存儲的位置,也即是你是從哪個來源下載這個包,對應到conda內部處理則是下載文件的鏈接。因為不同源會有相同名字的包,因此必須指定來源,同時安裝conda的時候也會有一個默認的channel。目前主流的就是 conda-forge,齊全且更新快。如果有多個channel,他們會按順序確定優先級,優先的源上找不到,就會到下一個優先級的源上去找。還可以設置channel的優先級是否strict,如果是strict的話,則只會在這一個源上查找。
2.創建 MOOSE 環境
Create a unique conda environment for MOOSE, named moose, and install the MOOSE dependency packages:
為 MOOSE 創建名為 moose 的唯一 conda 環境,並安裝 MOOSE 依賴項包:
點擊查看代碼
conda create -n moose moose-dev=2023.12.20
After the installation completes, activate the new environment:
安裝完成後,激活新環境:
點擊查看代碼
conda activate moose
If you are running into errors, please see our troubleshooting guide for Conda.
如果您遇到錯誤,請參閲Conda 故障排除指南
對於打開的每個終端窗口,以及每次要執行 MOOSE 相關工作時,都需要 conda activate moose 。如果您希望將其自動執行,可以將該命令添加到 shell 配置文件的末尾。
3. 克隆 MOOSE
MOOSE is hosted on GitHub and should be cloned directly from there using git. We recommend creating a directory ~/projects to contain all of your MOOSE related work.
MOOSE 託管在 GitHub 上,應使用 git 直接從那裏克隆。我們建議創建一個目錄 ~/projects 來包含所有與 MOOSE 相關的工作。
To clone MOOSE, run the following commands in a terminal:
要克隆 MOOSE,請在終端中運行以下命令:
點擊查看代碼
mkdir -p ~/projects
cd ~/projects
git clone https://github.com/idaholab/moose.git
cd moose
git checkout master
gitee鏡像 https://gitee.com/mirrors/moose.git
4.構建和測試 MOOSE
To build MOOSE run the following commands:
要構建 MOOSE,請運行以下命令:
點擊查看代碼
cd ~/projects/moose/test
make -j 6
To test MOOSE, run the following commands:
若要測試 MOOSE,請運行以下命令:
點擊查看代碼
cd ~/projects/moose/test
./run_tests -j 6
Some tests are SKIPPED. This is normal as some tests are specific to available resources, or some other constraint your machine does not satisfy. If you see failures, or you see MAX FAILURES, thats a problem! And it needs to be addressed before continuing:
某些測試被跳過。這是正常的,因為某些測試特定於可用資源,或者計算機不滿足的其他一些約束。如果您看到失敗,或者您看到 MAX FAILURES ,那就是一個問題!在繼續之前,需要解決它:
- Supply a report of the actual failure (scroll up a ways). For example the following snippet does not give the full picture (created with ./run_tests -i always_bad):
提供實際故障的報告(向上滾動)。例如,以下代碼片段沒有給出全貌(使用 ./run_tests -i always_bad 創建):
點擊查看代碼
Final Test Results:
--------------------------------------------------------------------------------
tests/test_harness.always_ok .................... FAILED (Application not found)
tests/test_harness.always_bad .................................. FAILED (CODE 1)
--------------------------------------------------------------------------------
Ran 2 tests in 0.2 seconds. Average test time 0.0 seconds, maximum test time 0.0 seconds.
0 passed, 0 skipped, 0 pending, 2 FAILED
相反,您需要向上滾動並報告實際錯誤:
點擊查看代碼
materials/derivative_material_interface.required_property/allow_override .................................. OK
materials/derivative_material_interface.required_property/derivative_parsed_material ...................... OK
partitioners/petsc_partitioner.ptscotch_weight_elment ........................................ [min_cpus=4] OK
partitioners/petsc_partitioner.ptscotch_weight_side .......................................... [min_cpus=4] OK
partitioners/petsc_partitioner.ptscotch_weight_both .......................................... [min_cpus=4] OK
partitioners/petsc_partitioner.parmetis ...................................................... [min_cpus=4] OK
partitioners/petsc_partitioner.parmetis_weight_element ....................................... [min_cpus=4] OK
partitioners/petsc_partitioner.parmetis_weight_side .......................................... [min_cpus=4] OK
partitioners/petsc_partitioner.parmetis_weight_both .......................................... [min_cpus=4] OK
partitioners/petsc_partitioner.parmetis_presplit_mesh ........................................ [min_cpus=2] OK
meshgenerators/distributed_rectilinear/partition.1D_4 ........................................ [min_cpus=4] OK
meshgenerators/distributed_rectilinear/partition.3D_3 ........................................ [min_cpus=3] OK
meshgenerators/distributed_rectilinear/partition.3D_4 ........................................ [min_cpus=4] OK
meshgenerators/distributed_rectilinear/partition.3D_8 ................... [min_cpus=8,insufficient slots] SKIP
------------------------------------------------------------------------------------------
Ran 4100 tests in 393.7 seconds. Average test time 0.3 seconds, maximum test time 22.9 seconds.
4100 passed, 106 skipped, 0 pending, 0 failed
5.卸載
If you wish to remove the moose environment at any time, you may do so using the following commands:
如果您希望隨時刪除駝鹿環境,可以使用以下命令進行操作:
點擊查看代碼
conda activate base
conda env remove -n moose
Now that you have a working MOOSE, proceed to 'New Users' to begin your tour of MOOSE!
現在您已經有了一個可以工作的 MOOSE,請前往“新用户”開始您的 MOOSE 之旅!