13 KiB
em3d-MT
Introduction
{ em3d-MT is an open-source MATLAB-based package for 3D forward modeling of magnetotelluric (MT) and radiomagnetotelluric (RMT) data. It is built on an edge-based finite element (FE) framework and solves the full-wave Maxwell’s equations, accounting for both conduction and displacement currents. This enables accurate modeling in the RMT frequency range. The software supports arbitrary anisotropy in both electrical conductivity and dielectric permittivity, allowing flexible simulation of complex geological scenarios. It utilizes unstructured tetrahedral meshes and a customizable geological modeling workflow to accommodate irregular terrain and heterogeneous media. To address the high computational cost of 3D modeling, em3d-MT integrates a direct linear solver with a double-layer parallelization strategy. This design supports efficient simulation over multiple frequencies using OpenMP-based multithreading and frequency-level parallelization. }
软件架构
This section provides detailed instructions for installing and configuring the em3d-MT package. The software is developed in MATLAB and requires proper setup of external solvers for efficient computation. 2.1 System Requirements Operating System: Windows or Linux MATLAB Version: R2023a (or later) Memory: The actual memory usage depends on model size and number of frequencies. 2.2 Required Software MATLAB (R2023a or later): The core environment in which em3d-MT operates. em3d-MT relies on several external tools and libraries to facilitate 3D geological modeling and mesh generation. The following software is required for proper functionality: GeoMesh For 3D geological modeling and mesh generation, GeoMesh is used. This is an open-source tool specifically designed for electromagnetic (EM) modeling, based on the COMSOL Multiphysics and MATLAB interface (Liu et al., 2024). GeoMesh generates unstructured tetrahedral meshes, which are ideal for representing complex subsurface structures in the forward modeling process. You can find the tool at https://gitee.com/sduem/geomesh Additionally, em3d-MT supports two types of direct solvers for solving the finite element system: Panua-Pardiso: An optimized direct solver used for solving large sparse linear systems. It offers high performance and memory efficiency. More information can be found at https://panua.ch/pardiso/ UMFPACK: An alternative direct solver supported by em3d-MT for solving sparse linear systems, suitable for small models or testing. More information can be found at http://faculty.cse.tamu.edu/davis/suitesparse.html
2.3 Installation
Step 1: Install MATLAB Install MATLAB (R2023a or later). Parallel Computing Toolbox is available for multi-core support. Step 2: Set Up Panua-Pardiso Solver Windows: Refer to Barbara (2025). Add PARDISO lib to Matlab in Windows and LINUX, MATLAB Central File Exchange. https://www.mathworks.com/matlabcentral/fileexchange/119053-add-pardiso-lib-to-matlab-in-windows-and-linux, January 13, 2025. The following steps outline how to configure the Panua-Pardiso solver in the Windows environment: [1] Register for a Panua account. Then download the panua-pardiso-20240228-win package from the official website: https://panua.ch/pardiso/, and extract the contents. [2] Open the bin folder in the extracted directory. Press Win + R, type cmd, and drag get_fingerprint.exe into the Command Prompt window. Press Enter to generate your machine fingerprint. [3] Copy the machine fingerprint into the input box on the Panua Pardiso website. An activation key will be sent to your registered email. [4] Create a file named panua.lic, paste the activation key into the file, and move it to the user directory (e.g., C:\Users\Username). [5] Add MinGW Compiler to MATLAB by visiting: https://www.mathworks.com/matlabcentral/fileexchange/52848-matlab-support-for-mingw-w64-c-c-compiler [6] Download and install Intel OneAPI Base Toolkit including MKL (Math Kernel Library) from: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html [7] Compile MEX Files. After updating the specific paths in the runMEM.m script to match your system, run the script in MATLAB to compile the required .mex files. The following script is used to compile the Panua-Pardiso interface with MATLAB via MEX. It links the necessary Panua, MATLAB, and Intel MKL libraries using MinGW:
%% This one works (pardisoinit): mex -largeArrayDims -L'PATH\TO\YOUR \Pardiso\panua-pardiso-20230718-win\lib' -llibpardiso... -L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwlapack... -L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwblas... -L'PATH\TO\YOUR\Intel oneAPI\compiler\2023.0.0\windows\compiler\lib\intel64' -lm... -output pardisoinit common.cpp matlabmatrix.cpp sparsematrix.cpp pardisoinfo.cpp pardisoinit.cpp
%% This one works (pardisoreorder):
mex -largeArrayDims -L'PATH\TO\YOUR \Pardiso\panua-pardiso-20230718-win\lib' -llibpardiso...
-L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwlapack...
-L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwblas...
-L'PATH\TO\YOUR\Intel oneAPI\compiler\2023.0.0\windows\compiler\lib\intel64' -lm...
-output pardisoreorder common.cpp matlabmatrix.cpp sparsematrix.cpp pardisoinfo.cpp pardisoreorder.cpp
%% This one works (pardisofactor):
mex -largeArrayDims -L'PATH\TO\YOUR \Pardiso\panua-pardiso-20230718-win\lib' -llibpardiso...
-L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwlapack...
-L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwblas...
-L'PATH\TO\YOUR\Intel oneAPI\compiler\2023.0.0\windows\compiler\lib\intel64' -lm...
-output pardisofactor common.cpp matlabmatrix.cpp sparsematrix.cpp pardisoinfo.cpp pardisofactor.cpp
%% This one works (pardisofactor): mex -largeArrayDims -L'PATH\TO\YOUR \Pardiso\panua-pardiso-20230718-win\lib' -llibpardiso... -L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwlapack... -L'PATH\TO\YOUR\Matalb\Matlab2023a\extern\lib\win64\mingw64' -lmwblas... -L'PATH\TO\YOUR\Intel oneAPI\compiler\2023.0.0\windows\compiler\lib\intel64' -lm... -output pardisofree common.cpp matlabmatrix.cpp sparsematrix.cpp pardisoinfo.cpp pardisofree.cpp
Ubuntu:Refer to the official README provided in the Panua-Pardiso package.
/***********************************************************************************************************************
Copyright (C) 2022 until present, by Panua Technologies Sagl, Switzerland. All Rights Reserved.
Interface between the Panua-Pardiso 8.0 solver and Matlab.
This program can be downloaded from the following site: http://www.panua.ch
The above copyright and permission notice must appear in all partial and complete copies of this file.
***********************************************************************************************************************/
INSTALLATION
This interface for Panua-Pardiso was created using the Matlab external ('mex') interface. For more information on mex, consult the MathWorks website at https://www.mathworks.com/help/matlab/call-mex-file-functions.html. In order to use this interface in Matlab, you will first have to configure mex on your system. This can be done by typing in the Matlab command line
mex -setup
The easiest way to install the interface is to use the provided Makefile and type in the command line $ make all To remove all mex executables type in the command line $ make clean The provided interface is currently compatible with Linux users. The Makefile specifies four variables that you might need to adapt according to your system setup. These are
- MEXSUFFIX: the suffix appended to the MEX files on your system. For more information type in the Matlab command line
ext = mexext or visit https://mathworks.com/help/matlab/ref/mexext.html
- MEX: the mex executable located somewhere within your MATLAB installation directory.
- CXX: your C++ compiler (executable). IMPORTANT: The linked C++ compiler must be compatible with your MATLAB installation. MathWorks keeps a detailed list of MATLAB software package versions and the compilers that are compatible with them here: https://mathworks.com/support/requirements/supported-compilers-linux.html.
- PARDISOHOME: the directory where the Pardiso shared library is located. SUGGESTED: your home directory "${HOME}". If you are not using the provided Makefile, you can compile file individually from the command line. The example below creates the mex executable pardisoinit.mexa64 $ mex -cxx CXX=g++ CC=g++ LD=g++ -L~\ -lpardiso -lmwlapack -lmwblas -lgfortran -lpthread -lm -output pardisoinit common.cpp matlabmatrix.cpp sparsematrix.cpp pardisoinfo.cpp pardisoinit.cpp Depending on your system setup you may need to include other flags, such as -largeArrayDims.
CONTENTS
├── common.h, .cpp # Commonly used mex check functions.
├── matlabmatrix.h, .cpp # Functions to ensure the compatibility of Pardiso with Matlab matrices.
├── pardisoinfo.h, .cpp # Available functionalities of the Pardiso solver.
├── pardisoinit.cpp # Initialize the Pardiso data structures. Specify type of matrix, and solver. Produces executable.
├── pardisoinit.mexa64
├── pardisofree.cpp # Release memory associated with all internal Pardiso structures. Produces executable.
├── pardisofree.mexa64
├── pardisoreorder.cpp # Pardiso reordering (symbolic factorization) of sparse input matrix. Produces executable.
├── pardisoreorder.mexa64
├── pardisofactor.cpp # Numeric factorization of a sparse matrix. Produces executable.
├── pardisofactor.mexa64
├── pardisosolve.cpp # Pardiso solution for a system of equations. Produces executable.
├── pardisosolve.mexa64
├── example_complex.m # Using Pardiso on a sparse, symmetric, and complex matrix.
├── example_hermitian.m # Using Pardiso on a sparse complex Hermitian positive definite matrix.
├── example_symmetric.m # Using Pardiso on a sparse real and symmetric matrix.
├── example_unsymmetrix.m # Using Pardiso on a sparse real and unsymmetric matrix.
NOTES
- Discrepancy in OMP version used. A common error with mex files is the version of OMP that is statically linked to the program. This error would appear after executing the mex file and would read:
OMP: Error #15: Initializing libiomp5.a, but found libiomp5.so already initialized. OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. To work around this issue set the environment variable KMP_DUPLICATE_LIB_OK to TRUE, in order to allow the program to continue its execution. In the Matlab command line this is achieved by typing setenv("KMP_DUPLICATE_LIB_OK","TRUE")
- Controlling the number of available cores. The safest way to control the number of cores is by setting the environment variable in the command line, e.g., $ export OMP_NUM_THREADS=16 and then executing Matlab from the same terminal session/window. To check that the number of cores is set correctly, either use
verbose = true; in your code, or print out the value of (after Pardiso has been initialized) fprintf('Number of cores %d',info.iparm(3)); It always recommended to control the parallel execution of the solver by explicitly setting OMP_NUM_THREADS. If fewer processors are available than specified, the execution may slow down instead of speeding up. Note that the number of threads that can be utilized by Pardiso is bounded by the maximum number of threads allowed by your Panua licence. For more information visit http://www.panua.ch/pardiso.
MISC
- The mex interface was first developed by Peter Carbonetto, UBC Vancouver, October 2009. Adapted and modified by Dimosthenis Pasadakis, Panua-Technologies, January 2024.
使用说明
- xxxx
- xxxx
- xxxx
参与贡献
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request
特技
- 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
- Gitee 官方博客 blog.gitee.com
- 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
- GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
- Gitee 官方提供的使用手册 https://gitee.com/help
- Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/