WELSIM is the #1 engineering simulation software for the open-source community.
Sunday, December 28, 2025
Compile the open-source electromagnetic simulation solver Palace
Palace is a parallel finite element solver developed by AWS Labs for full-wave 3D electromagnetic simulation, released under the Apache 2.0 open-source license. This solver supports full-wave frequency/time-domain simulation, eigenmode analysis, and parameter extraction for electrostatics/magnetostatics. It is compatible with platforms ranging from laptops to supercomputers and supports GPU acceleration, enabling the modeling of quantum computing hardware, RF/microwave devices, antennas, and other systems.
The author previously published a brief article introducing how to compile Palace on Windows, titled Compile the electromagnetic simulation solver Palace in Windows. . Expanding upon that earlier work, this article details the compilation process more in-depth, with a particular focus on the compilation of dependent libraries. The dependent libraries discussed in this article are as follows:
Hypre: A large-scale linear algebra matrix computation library, using version 2.30.
MUMPS: An open-source software library for solving large-scale sparse linear systems of equations.
ARPACK-NG: A library that supports complex linear matrix computations and is used for eigenvalue computation. Primarily written in Fortran, it can be compiled independently without relying on PETSc.
GSLib: Used for interpolation computations in high-order spectral elements.
libCEED: A linear algebra computation management framework that supports parallel computing across various CPUs, GPUs, and clusters.
MFEM: A flexible, efficient, and scalable finite element discretization framework used as the core solving dependency library for Palace.
System Environment and Compilers
Operating System: Windows 11, 64-bit
Compilers: Visual Studio 2022 Community (C++17), Intel Fortran Compiler 2022, and Intel MKL 2024.
Palace Version: 0.15
Compiling Hypre
Hypre is an open-source high-performance parallel linear solver library developed by Lawrence Livermore National Laboratory (LLNL) designed specifically for large-scale scientific computing and engineering simulation. Its core objective is to solve large-scale sparse linear systems of equations (in the form of Ax=b) efficiently, particularly strong at handling ultra-large-scale problems in distributed memory parallel environments. Hypre natively supports MPI parallelism, enabling it to utilize the full computing power of distributed memory architectures, such as supercomputers and clusters, and easily handle linear systems with millions or even billions of degrees of freedom. This stark advantage distinguishes Hypre from smaller solvers (e.g., Eigen).
Compiling Hypre on Windows is simple. You can directly use the built-in CMake configuration file to generate Visual Studio project files, which will in turn produce the static library file.
When configuring CMake, set the parameters as follows:
HYPRE_WITH_MPI = ON
HYPRE_USING_OPENMP = ON
HYPRE_WITH_CUDA = OFF
HYPRE_ENABLE_SYCL = OFF
HYPRE_INSTALL_PREFIX=D:/WelSimLLC/CodeDV/3rdParty/hypre/myInstall
CMAKE_INSTALL_PREFIX=D:/WelSimLLC/CodeDV/3rdParty/hypre/myInstall
If the compilation proceeds smoothly, then the hypre.lib static library file will be generated.
Compiling MUMPS
To solve Wave Port problems, the Palace solver requires one of three direct linear algebra solvers: SuperLU, STRUMPACK, or MUMPS. MUMPS is selected as the dependent library given that the author is relatively familiar with it.
MUMPS is an open-source parallel sparse direct solver library co-developed by French institutions including INRIA and CNRS. Its core objective is to solve large-scale sparse linear systems of equations (Ax=b) using the direct method. Unlike Hypre, which primarily relies on iterative methods, MUMPS computes without iteration by leveraging matrix decomposition (LU/Cholesky) via direct methods. This approach delivers higher precision and more robustness, making it particularly well-suited for solving sparse matrix problems involving asymmetric, symmetric positive definite, or indefinite matrices.
MUMPS depends on BLAS/LAPACK (basic linear algebra libraries) and SCALAPACK (parallel linear algebra library). In this case, the dependency is the Intel MKL Library.
The original version of MUMPS does not provide a compilation method for Windows. Instead, you can opt for the scivision/mumps version available on GitHub, which offers a CMake-based compilation approach for seamless implementation. The latest version 5.8.1 was downloaded for this example.
First ensure that the environment variable contains the following configuration: MKLTOOL= C:\Program Files (x86)\Intel\oneAPI\mkl\latest
Under CMake configuration, set the following parameters:
MUMPS_openmp = ON
MUMPS_parallel = OFF
Once the Visual Studio project files are generated, compile the project to produce all static libraries of MUMPS. The generated static libraries are illustrated in the figure below.
Press enter or click to view image in full size
Compiling ARPACK
For eigenvalue-related computations (e.g., eigenmode calculations), Palace requires a complex-number eigenvalue solver such as SLEPc or ARPACK. Since SLEPc depends on PETSc, which has a rather complex compilation on Windows, ARPACK is selected as the complex-number solver for Palace.
ARPACK is an open-source library for large-scale eigenvalue and eigenvector computations, co-developed by institutions including Rice University and Sandia National Laboratories. Its core objective is to efficiently compute a subset of eigenvalues and their corresponding eigenvectors for large sparse matrices. Unlike libraries such as Hypre and MUMPS, which are designed to solve linear systems of equations (Ax=b), ARPACK focuses specifically on tackling eigenvalue problems (Ax=λx or Ax=λBx).
Press enter or click to view image in full size
Download ARPACK-NG from GitHub and use its built-in CMake build configuration. Set the following parameters in CMake:
ICE = ON
Eigen = ON
Build_SHARED_LIBS = OFF
Meanwhile, ensure that the environment variable contains the entry MKLTOOL= C:\Program Files (x86)\Intel\oneAPI\mkl\latest; this allows CMake to automatically locate the BLAS and LAPACK libraries within MKL.
After generating the Visual Studio project files, you can directly compile the project to obtain the ARPACK static library.
Compiling GSLib
GSLIB is an open-source parallel sparse communication library designed to efficiently support sparse data gather/scatter communication and operators in parallel numerical simulation scenarios, such as the finite element method, spectral element method, and finite difference method. It greatly simplifies the development of parallel sparse communication and lowers the barrier to distributed memory programming. Its adaptive algorithms ensure efficient communication in large-scale parallel computing, satisfying ultra-large-scale simulation requirements.
Press enter or click to view image in full size
Since GSLIB does not come with CMake configuration files, it is unable to automatically generate Visual Studio project files on Windows, requiring you to create the Visual Studio project files manually. Create a new static library project named gslib-palace, and add all the source files and header files to this project.
In the preprocessor definitions of the Visual Studio project, add GSLIB_USE_CBLAS and GSLIB_USE_MKL.
During compilation, when the following error messages appear:
unary minus operator applied to unsigned type, result still unsigned
You will need to modify the code, for example, changing
p[map->n].el = -(uint)1;
to
p[map->n].el = 0-(uint)1;
This allows the compilation to succeed.
Become a member
When the following error message appears:
potentially uninitialized local pointer variable 'h' used
You will need to modify the code and initialize the pointer with a NULL value.
If you receive a prompt indicating that the fgs_free function has already been defined redundantly, simply comment out the fgs_setup, fgs_free, and fgs_unique functions.
Compiling libCEEM
libCEED is an efficient and scalable discretization library that focuses on high-performance computational discretization based on finite element and spectral element methods. It provides a lightweight algebraic interface for linear and nonlinear operators as well as preconditioners; it supports runtime selection and optimized implementations across a variety of computing devices such as CPUs and GPUs.
Compiling libCEED is the most challenging part of the entire task because libCEED does not provide CMake configuration files and contains numerous options. Coupled with the fact that Visual Studio does not support C99 syntax, extensive manual modifications to the source files are required, especially modifications related to dynamic arrays. For example, change the following dynamic array:
CeedInt num_points[num_elem];
to:
CeedInt *num_points = (CeedInt *)malloc(num_elem * sizeof(CeedInt));
After usage, you also need to free the array from memory at the end using the free function: free(num_points);.
Certain strings containing file paths also require modification. For instance, change:
*(relative_file_path) = strstr(absolute_file_path, "ceed/jit-source");
to:
#ifdef
_WIN32
*(relative_file_path) = strstr(absolute_file_path, "ceed\\jit-source");
#else
*(relative_file_path) = strstr(absolute_file_path, "ceed/jit-source");
#endif
Since Visual Studio’s support for weak functions differs from that of Linux, the weak functions in the source code need to be modified as follows:
Original code:
#define
CEED_BACKEND(name, num_prefixes, ...) \
CEED_INTERN int name(void) __attribute__((weak)); \
int name(void) { return CeedRegister_Weak(__func__, num_prefixes, __VA_ARGS__); }
#include
"ceed-backend-list.h"
Modified code:
#ifdef _WIN32
#define CEED_BACKEND(name, num_prefixes, ...) \
CEED_INTERN int name(void) __declspec(selectany); \
int name(void) { return CeedRegister_Weak(__func__, num_prefixes, __VA_ARGS__); }
#else
#define CEED_BACKEND(name, num_prefixes, ...) \
CEED_INTERN int name(void) __attribute__((weak)); \
int name(void) { return CeedRegister_Weak(__func__, num_prefixes, __VA_ARGS__); }
#include "ceed-backend-list.h"
#endif
Visual Studio does not support the __restrict__ keyword and requires it to be changed to __restrict.
Other minor modifications need to be made, such as replacing popen with _popen and pclose with _pclose. Additionally, there is an environment variable setting: setenv("RUST_TOOLCHAIN", "nightly", 0), which needs to be modified as follows:
char env_str[1024];
snprintf(env_str, sizeof(env_str), "%s=%s", "nightly", 0);
_putenv(env_str);
To reduce complexity, this compilation supports only CPU parallel computing and does not require GPU parallel support. Therefore, in the ceed-backend-list.h file, only the following functionalities need to be enabled:
CEED_BACKEND(CeedRegister_Opt_Blocked, 1, "/cpu/self/opt/blocked")
CEED_BACKEND(CeedRegister_Opt_Serial, 1, "/cpu/self/opt/serial")
CEED_BACKEND(CeedRegister_Ref, 1, "/cpu/self/ref/serial")
CEED_BACKEND(CeedRegister_Ref_Blocked, 1, "/cpu/self/ref/blocked")
CEED_BACKEND(CeedRegister_Xsmm_Blocked, 1, "/cpu/self/xsmm/blocked")
CEED_BACKEND(CeedRegister_Xsmm_Serial, 1, "/cpu/self/xsmm/serial")
All other computing functionalities can be commented out. Upon successful compilation, the static library for libCEED will be generated.
Compiling MFEM
MFEM is the core solver of Palace, an open-source high-order finite element library led by the Lawrence Livermore National Laboratory (LLNL). Designed specifically for large-scale scientific computing and engineering simulation, its core objective is to provide a flexible, efficient, and scalable finite element discretization framework. MFEM also serves as a mainstream open-source finite element tool for computational fluid dynamics, electromagnetic simulation, structural mechanics, nuclear physics, and other fields.
Press enter or click to view image in full size
Compiling MFEM is relatively straightforward. You can generate Visual Studio project files via CMake for compilation. Set the following options to ON in CMake:
MFEM_USE_MPI = ON
MFEM_USE_ZLIB = ON
MFEM_USE_METIS = ON
MFEM_USE_LAPACK = ON
MFEM_USE_LEGACY_OPENMP = ON
MFEM_THREAD_SAFE = ON
MFEM_USE_MUMPS = ON
Generate the Visual Studio project files and compile them directly to obtain the MFEM static library.
Compiling Palace
At this point, all complex dependent libraries have been successfully compiled. Proceed to the final step of this project: use the built-in CMake configuration file to generate Visual Studio project files and compile Palace. Note that you should select the CMakeLists.txt file located in the palace subdirectory instead of the one in the root directory, as the latter is used for generating the SuperBuild.
Set the following parameters in CMake:
PALACE_WITH_ARPACK = ON
PALACE_WITH_OPENMP = ON
PALACE_WITH_SLEPC = OFF
MPI_Fortran_WORKS = C:/Program Files (x86)/Microsoft SDKs/MPI/Include/x64
Configure the following paths:
nlohmann_json_DIR = D:/WelSimLLC/CodeDV/3rdParty/nlohmann_json/json-3.12.0/myInstall/share/cmake/nlohmann_json
fmt_DIR = D:\WelSimLLC\CodeDV\3rdParty\fmt\fmt-11.0.2\myInstall\lib\cmake\fmt
scn_DIR = D:\WelSimLLC\CodeDV\libPack\lib\scn\cmake\scn
MFEM_DIR = D:/WelSimLLC/CodeDV/libPack/lib/palace/mfem-cmake
arpackng_DIR = D:\WelSimLLC\CodeDV\libPack\lib\palace\arpack-cmake\arpackng
Open the generated Visual Studio project, and you will see a static library project named libpalace and an executable project named palace. If the compiler reports missing header files or the linker indicates unresolved functions during compilation, you can directly add the relevant paths and static libraries to the projects.
After completing the compilation, you can run a test on palace.exe. Note that you need to place all dynamic dependent libraries (such as the MKL dynamic libraries) in the same directory as palace.exe before running it.
Run a simple test case. The output shown below indicates that the compilation has been successful basically.
Press enter or click to view image in full size
Conclusion
As open-source electromagnetic field simulation solvers are presently scarce, Palace stands out as the most feature-rich one available. As a result, Palace relies on a large number of dependent libraries, and its version is still under continuous iterations. Some of these dependencies only support Linux builds, which adds to the complexity of compiling Palace on Windows. This article documents the complete compilation process of Palace and provides a resource for the open-source community on how to build Palace for Windows.
There are also other dependent libraries that are relatively easy to compile, such as Eigen, fmt, Metis, and nlohmann/json. Experienced developers can often independently build these libraries on Windows, so it is not discussed in this article.
The author has included the compiled palace.exe executable file in the WELSIM installation package, so you are able to directly obtain the Windows version of palace.exe from the WELSIM installer without having to compile it yourself.
This article describes the configuration of Palace for CPU multi-core parallel computing. The compilation methods for GPU-accelerated versions, such as CUDA, HIP, or SYCL, will be discussed in future articles.
WelSim and the author are not affiliated with Palace, Hypre, MUMPS, ARPACK, GSLIB, libCEED, or MFEM, nor do they have any direct connections with the development teams or institutions behind these projects. The references to the names and images of these open-source software in this article are solely for the purpose of technical blog documentation and software usage guidance.
Saturday, December 27, 2025
编译开源电磁仿真求解器Palace
Palace 是AWS Labs推出的一款用于全波 3D 电磁仿真的并行有限元求解器,开源许可证为Apache 2.0,求解器支持频域/时域全波、特征模、静电/静磁集总参数提取,适配笔记本到超算的多平台与 GPU 加速,可以用于量子计算硬件、射频 / 微波器件、天线等建模。
Image
笔者曾经简要介绍了如何在Windows下编译Palace的文章,参见《Windows环境下编译电磁仿真求解器Palace》一文。本文是在前文的基础上,更为详细的介绍编译过程,尤其着重介绍依赖库的编译。本文讨论的依赖库有:
Hypre:大型线性代数矩阵计算包。本例使用2.33.0版本。
MUMPS:来自法国的求解大规模稀疏线性方程组的开源软件库。本例使用5.8.1版本。
ARPACK-NG:支持复数线性矩阵计算,用于特征值计算。以Fortran程序为主,无需依赖PETSc,可以独立编译。需要通过Palace提供的diff文件手动修改部分源代码。
GSLIB:用于高阶谱单元的插值计算。
libCEED:是一款线性代数计算管理终端,支持对各种CPU,GPU和集群的并行计算。本例使用0.12版本。需要手动修改源代码以通过Windows Visual Studio的编译。
MFEM:提供灵活、高效、可扩展的有限元离散化框架。本例使用4.8.1版本。是Palace的核心求解依赖库。需要通过Palace提供的diff文件手动修改部分源代码。
系统环境与依赖库
操作系统:Windows 11, 64-bit
编译器:Visual Studio 2022 Community, C++17。Inter Fortran Compiler 2022,Intel MKL 2024。
Palace版本:0.15
编译Hypre
Hypre是劳伦斯利弗莫尔国家实验室 LLNL 开发的开源高性能并行线性求解器库,专为大规模科学计算和工程模拟设计。核心目标是高效求解大规模稀疏线性方程组(形如 Ax=b),尤其擅长处理超大规模、分布式内存并行环境下的问题。hypre 原生支持 MPI并行,能充分利用超级计算机、集群等分布式内存架构的算力,轻松处理数百万甚至数十亿自由度的线性系统,这是它区别于小型求解器(如 Eigen)的核心优势。
Image
Windows下编译hypre并不复杂,可以直接使用自带的CMakeFile文件,生成Visual Studio的项目文件,生成静态库文件。在配置CMake时,参数如下设置:
HYPRE_WITH_MPI = ON
HYPRE_USING_OPENMP = ON
HYPRE_WITH_CUDA = OFF
HYPRE_ENABLE_SYCL = OFF
HYPRE_INSTALL_PREFIX=D:/WelSimLLC/CodeDV/3rdParty/hypre/myInstall
CMAKE_INSTALL_PREFIX=D:/WelSimLLC/CodeDV/3rdParty/hypre/myInstall
如果编译顺利,会生成hyper.lib静态库文件。
编译 MUMPS
Palace求解器需要SuperLU, StrumPack,或者MUMPS三个直接线代求解器中的一个,才能求解Wave Port问题。由于笔者比较熟悉MUMPS,因此就选择的MUMPS求解器作为依赖库。
MUMPS是由法国 INRIA、CNRS 等机构联合开发的开源并行稀疏直接求解器库。它的核心目标是用 “直接法” 求解大规模稀疏线性方程组(Ax=b),区别于 hypre 以 “迭代法” 为主,MUMPS 用直接法通过矩阵分解(LU/Cholesky)计算出解,无需迭代,精度更高、鲁棒性更强,尤其适合求解非对称、对称正定 / 不定的稀疏矩阵问题。
MUMPS 依赖 BLAS/LAPACK(基础线性代数库)、SCALAPACK(并行线性代数库)。这里我们使用Intel的MKL库作为依赖库。
原始版本的MUMPS不提供Windows的编译方式,可以选择GitHub上的scivision/mumps版本,提供了基于CMake的编译方式,可以轻易实现编译。本例下载的是最新的5.8.1版本。
确保环境变量中含有MKLTOOL= C:\Program Files (x86)\Intel\oneAPI\mkl\latest
在CMake编译下,设置
MUMPS_openmp = ON
MUMP_parallel = OFF
生成Visual Studio的项目文件后,直接编译即可生成MUMPS的所有静态库。生成的静态库如下图所示。
Image
编译ARPACK
Palace在计算特征值相关的功能时,如计算Eigenmode,需要有SLEPc或者ARPACK复数求解器。由于SLEPc依赖PETSc,而PETSc在Windows下的编译较为复杂,因此就不选用SLEPc,这里选择ARPACK作为Palace的复数求解器。
ARPACK是由莱斯大学、桑迪亚国家实验室等机构,联合开发的开源大规模特征值/特征向量求解库。它的核心目标是高效计算大型稀疏矩阵的少数特征值与对应特征向量,和 hypre、MUMPS 这类求解线性方程组(Ax=b)的库不同,ARPACK 专注于处理特征值问题(Ax=λx 或 Ax=λBx)。
Image
从GitHub上下载ARPACK-ng,使用自带的CMake编译方式。确保环境变量中含有MKLTOOL= C:\Program Files (x86)\Intel\oneAPI\mkl\latest,这样CMake会自动找到MKL里的BLAS和Lapack。在CMake中设置如下
ICE = ON
Eigen = ON
Build_SHARED_LIBS = OFF
同时,确保环境变量中含有MKLTOOL= C:\Program Files (x86)\Intel\oneAPI\mkl\latest,这样CMake会自动找到MKL里的BLAS和Lapack。
同时,需要根据palace目录中extern/patch/arpack-ng文件夹下的diff文件,对源文件做相应修改。生成Visual Studio项目文件后,既可以直接编译得到Arpack的静态库。
编译GSLib
GSLIB是一个开源的并行稀疏通信库,它专为有限元、谱元、有限差分等并行数值模拟场景,提供高效的稀疏数据聚合 – 分发(Gather/Scatter)通信与算子支持。大幅简化并行稀疏通信开发,降低分布式内存编程门槛;自适应算法保证大规模并行下的通信效率,适配超大规模仿真需求。
Image
由于GSLib并没有CMake文件,无法在Windows下自动生成Visual Studio的项目文件,需要用户自己建立Visual Studio的项目文件。新建一个静态库项目,取名为gslib-palace,并将所有的源文件和头文件添加到此项目中。
在Visual Studio的项目预处理定义中,添加GSLIB_USE_CBLAS, GSLIB_USE_MKL。
编译时,当遇到以下错误提示时:
unary minus operator applied to unsigned type, result still unsigned
需要修改代码,如将
p[map->n].el = -(uint)1;
改为
p[map->n].el = 0-(uint)1;
以通过编译。
当遇到以下错误提示时:
potentially uninitialized local pointer variable 'h' used
需要修改代码,给指针添加NULL初始值。
如果提示fgs_free函数已经有重复的定义。将fgs_setup, fgs_free与fgs_unique函数注释掉即可。
编译libCEEM
libCEED 是一个高效可扩展的离散化库,专注于基于有限元和谱元方法的高效计算离散化。它提供轻量级代数接口,用于线性和非线性算子及预条件子,支持基于 CPU、GPU 等多种计算设备的运行时选择优化实现。
Image
编译libCEEM是整个工作的难点,由于libCEED不提供CMakeFile文件,同时含有较多的选项,同时Visual Studio不支持C99的语法,需要大量手动修改源文件,尤其是对于动态数组的修改。如将以下动态数组
CeedInt num_points[num_elem];
修改成为
CeedInt *num_points = (CeedInt *)malloc(num_elem * sizeof(CeedInt));
使用完成后,还需在结尾处,使用free函数,从内存中删除此数组,free(num_points)。
一些含有路径的字符串,也需要做修改。如
*(relative_file_path) = strstr(absolute_file_path, "ceed/jit-source");
改为
#ifdef
_WIN32
*(relative_file_path) = strstr(absolute_file_path, "ceed\\jit-source");
#else
*(relative_file_path) = strstr(absolute_file_path, "ceed/jit-source");
#endif
由于Visual Studio对weak的函数支持方式与Linux不一样,需要对源码中的weak函数做如下修改:
#define
CEED_BACKEND(name, num_prefixes, ...) \
CEED_INTERN int name(void) __attribute__((weak)); \
int name(void) { return CeedRegister_Weak(__func__, num_prefixes, __VA_ARGS__); }
#include
"ceed-backend-list.h"
改为
#ifdef
_WIN32
#define
CEED_BACKEND(name, num_prefixes, ...) \
CEED_INTERN int name(void) __declspec(selectany); \
int name(void) { return CeedRegister_Weak(__func__, num_prefixes, __VA_ARGS__); }
#else
#define
CEED_BACKEND(name, num_prefixes, ...) \
CEED_INTERN int name(void) __attribute__((weak)); \
int name(void) { return CeedRegister_Weak(__func__, num_prefixes, __VA_ARGS__); }
#include
"ceed-backend-list.h"
#endif
Visual Studio不支持__restrict__关键字,需要改成__restrict。
还有一些小范围的修改,如将popen改成_popen,将pclose改成 _pclose。有一处环境变量设定setenv("RUST_TOOLCHAIN", "nightly", 0),需要做如下修改:
char env_str[1024];
snprintf(env_str, sizeof(env_str), "%s=%s", "nightly", 0);
_putenv(env_str);
为了减少不必要的复杂度,本次编译只支持CPU并行计算的内容,GPU并行无需支持,因此在ceed-backend-list.h文件中,只需要支持以下功能:
CEED_BACKEND(CeedRegister_Opt_Blocked, 1, "/cpu/self/opt/blocked")
CEED_BACKEND(CeedRegister_Opt_Serial, 1, "/cpu/self/opt/serial")
CEED_BACKEND(CeedRegister_Ref, 1, "/cpu/self/ref/serial")
CEED_BACKEND(CeedRegister_Ref_Blocked, 1, "/cpu/self/ref/blocked")
CEED_BACKEND(CeedRegister_Xsmm_Blocked, 1, "/cpu/self/xsmm/blocked")
CEED_BACKEND(CeedRegister_Xsmm_Serial, 1, "/cpu/self/xsmm/serial")
其余的计算功能可以注释掉。编译成功后会生成libCEEM的静态库。
编译MFEM
MFEM是Palace的核心求解器,由劳伦斯利弗莫尔国家实验室(LLNL)主导开发的开源高阶有限元库,专为大规模科学计算和工程仿真设计,核心目标是提供灵活、高效、可扩展的有限元离散化框架。MFEM 也是计算流体力学、电磁仿真、结构力学、核物理模拟等领域的主流开源有限元工具。
Image
编译MFEM相对简单,可以通过CMake的方式生成Visual Studio项目文件来编译。在CMake的选项中,选择激活的选项如下:
MFEM_USE_MPI = ON
MFEM_USE_ZLIB = ON
MFEM_USE_METIS = ON
MFEM_USE_LAPACK = ON
MFEM_USE_LEGACY_OPENMP = ON
MFEM_THREAD_SAFE = ON
MFEM_USE_MUMPS = ON
同时,需要根据palace目录中extern/patch/mfem文件夹下的diff文件,对源文件做相应修改。由于需要修改的源文件较多,需要耐心仔细,或者在Linux下先编译一遍,将自动修改好的mfem拷贝覆盖至Windows下需要编译的mfem文件夹。整个生成Visual Studio的项目文件后,直接编译,即可得到mfem的静态库。
编译Palace
至此,复杂的依赖库都已经编译完成。开始整个项目的最后一步,使用自带的CMakeFile文件,生成Visual Studio的项目文件,编译Palace。这里要注意的是,应该选择在palace子目录中的CMakeFile.txt文件,而不是根目录下的CMakeFile.txt,因为后者是用于生成Superbuild的。
CMake下设置:
PALACE_WITH_ARPACK = ON
PALACE_WITH_OPENMP = ON
PALACE_WITH_SLEPC = OFF
MPI_Fortran_WORKS = C:/Program Files (x86)/Microsoft SDKs/MPI/Include/x64
设置路径
nlohmann_json_DIR = D:/WelSimLLC/CodeDV/3rdParty/nlohmann_json/json-3.12.0/myInstall/share/cmake/nlohmann_json
fmt_DIR = D:\WelSimLLC\CodeDV\3rdParty\fmt\fmt-11.0.2\myInstall\lib\cmake\fmt
scn_DIR = D:\WelSimLLC\CodeDV\libPack\lib\scn\cmake\scn
MFEM_DIR = D:/WelSimLLC/CodeDV/libPack/lib/palace/mfem-cmake
arpackng_DIR = D:\WelSimLLC\CodeDV\libPack\lib\palace\arpack-cmake\arpackng
打开生成的Visual Studio项目,可以看到名为libpalace的静态库项目,和名为palace的可执行文件项目。如果在编译时提示找不到头文件,或者连接时缺少相关函数,可以直接在项目中添加相关路径和静态库。
Image
完成编译后,可以试运行一下palace.exe。注意使用时,需要将动态依赖库放置与palace.exe同一个文件夹下,如MKL系列的相关动态库文件。
计算一个简单算例,得到如下显示。表明编译基本成功。
Image
总结
目前可用的开源电磁场仿真求解器不多,Palace是目前功能最多的开源电磁求解器。Palace的依赖库较多,版本还在不断更新迭代,一些依赖库只支持Linux版本,增加了Windows下编译的难度。本文记录编译整个Palace的过程,同时给开源社区提供一些Windows下编译Palace的参考。
还有一些其他依赖库编译相对容易,如Eigen, fmt, Metis,nlhmann/json等。有经验的开发者可以自行在Windows下成功编译,就不在本文中赘述了。
笔者已将编译好的palace.exe可执行文件收录在WELSIM安装包中,用户也可以直接从WELSIM安装包中获得Windows版本的palace.exe,无需自己编译。
本文介绍的是CPU多核并行计算下的Palace,GPU版本的编译方法,如CUDA, HIP,或SYCL版本,会在以后的文章中讨论。
WelSim与作者不隶属于Palace, Hypre, MUMPS, Arpack, GSLib, libCEEM, 和MFEM。和Palace, Hypre, MUMPS, Arpack, GSLib, libCEEM, 和MFEM开发团队与机构没有直接关系。这里引用这些开源软件的名称和图片仅用作技术博客文章与软件使用的参考。
Tuesday, September 30, 2025
Generating Particles for Complex Geometries Using WELSIM
With the development of modern engineering simulation, particle-based simulation has been increasingly adopted by the industrial community. Particle-related computations and software have emerged in various fields of engineering and science. In addition to pure particle simulations, such as molecular dynamics, there are also coupled methods with continuum approaches like the finite element method, enabling more sophisticated simulations. An example is the SPH (Smoothed Particle Hydrodynamics) method, which simulates the motion of fluids and granular materials.
As a result, the demands on particle simulations are also rising. Particle generation is the first and most critical step in all such simulations. Therefore, algorithms and processes for generating particles are particularly important. The author has previously discussed numerical methods for generating particles in the article titled “Automatic Generation of Simulation Particles.”
Press enter or click to view image in full size
Generating particles for simple geometric models, such as cubes, is not difficult. However, when the geometry becomes more complex, particle generation becomes challenging. Currently, there are not many software solutions on the market that can generate particles for arbitrary shapes. WELSIM is already capable of handling this well and can export particles as external files for use in other software. This article provides a brief introduction on how to generate particles in WELSIM.
1. Open WELSIM and Import a STEP Geometry Model
In this example, a cylindrical model with a circular hole is imported. Set the geometry’s Create Particles property to True.
Press enter or click to view image in full size
2. Click the Meshing Button to Automatically Generate Particles
In this setup, 441 particles are generated.
Press enter or click to view image in full size
3. To Increase Particle Density
Modify the Maximum Size value in the mesh settings. When set to 0.01, the particle density increases.
4. Adjust Particle Display Size for Clarity
When the number of particles increases, it helps to reduce their display size for better visibility. In the 3D View of the mesh object, set the Particle Size value. Here, it is set to 0.001.
Now, a larger number of particles can be seen — 16,060 in total. WELSIM thus allows for easy and efficient generation of particles at any desired density.
Press enter or click to view image in full size
5. Export the Particles
Once particle generation is complete, export the particle file. Right-click the Mesh objectand select Export Particles from the context menu.
Press enter or click to view image in full size
6. In the Export Dialog
Enter the filename and choose the export format. The current version supports the VTK PolyData format. More formats will be supported in future versions.
Press enter or click to view image in full size
The exported file can be loaded and used by other software. For example, ParaView can be used to visualize the exported particles, as shown in the image.
Press enter or click to view image in full size
Conclusion
This article outlines the steps for generating particles using WELSIM. Users only need to import a geometry in STEP format and, through an automatic mesh-like method, can quickly generate particles at various densities. Although a simple geometry was used here, the same process can be applied to complex models. The software also supports exporting particle data for use in other applications. The particle generation feature is already available in version 2025R3 and will continue to be improved in future releases.
WELSIM has no direct affiliation with the author or the developers of ParaView. ParaView is referenced here purely as a technical example for demonstration purposes.
Monday, September 29, 2025
使用WELSIM生成复杂几何模型的粒子
随着现代工程仿真的发展,粒子仿真也越来越多的被工业届接受。粒子相关的计算和软件在各个工程和科学领域都有出现。除了单纯的粒子计算,如分子动力学计算,还有与有限元等连续介质计算方法耦合,实现更为精巧的计算。如SPH方法计算流体和沙石颗粒的运动。随之,人们对粒子计算的要求也不断提高。而生成粒子是所有计算的第一步,也是整个计算的关键一环。因此,生成粒子的算法和实现过程,就显得尤为重要了。作者曾讨论过生成粒子的数值方法,参见《自动化生成仿真粒子的方法》一文。
Image
生成简单几何模型,如立方体,的粒子并不难,但是当粒子区域轮廓变得复杂时,生成粒子就变得困难了。目前市场可以生成任意轮廓粒子的软件并不多,WELSIM已经可以很好的实现这点,并输出为外部文件,用于其他软件的计算。本文就如何在WELSIM下生成粒子,做一个简要介绍。
1. 打开WELSIM软件,并导入一个STEP几何模型。这里导入一个带有圆孔的圆柱体。并将几何体的创建粒子(Create Particles)属性设为真。
Image
2. 点击网格划分按钮,便可自动生成粒子。此设置下,生成了441个粒子。
Image
3. 如果想得到密度更高的粒子,可以修改网格设置属性中的最大单元尺寸(Maximum Size)值。当把值改为0.01时,粒子的密度会增加。
Image
4. 粒子数量增加后,为了显示更为清楚,可以调整粒子显示大小。点击网格节点的三维视图(3D View),设置粒子尺寸(Particle Size)值即可,这里设为0.001。
Image
此时,可以看到生成了更多的粒子,数量达到16,060。因此,使用WELSIM可以方便快捷地生成任意密度的粒子。
Image
5. 粒子生成工作已经完成。下一步来导出粒子文件。右键点击Mesh节点,从弹出菜单中选择导出粒子(Export Particles)。
Image
6. 在导出对话框中,输入文件名称和类型。目前已经支持了VTK PolyData格式,以后版本中,会增加更多的导出格式。
Image
导出文件可以被其他软件读取并使用。如图所示,使用ParaView读取此文件的显示结果。
Image
总结
本文介绍了如何使用WELSIM生成粒子的方法步骤。用户只需导入STEP格式的几何体,通过类似自动化网格划分的方式,快速得到各种不同密度的粒子。本文中使用的几何模型较为简单,复杂的几何体也可以同样的方式得到粒子。同时,提供了粒子数据导出功能,用户可以将生成的粒子用于其他软件的计算。粒子生成功能已经存在2025R3版中,会在后续的版本中不断增强和改进。
WelSim与作者和ParaView开发者没有直接关系。这里引用ParaView仅用作技术博客文章与软件使用的参考。
Sunday, August 24, 2025
Methods for Automatic Particle Generators
Modern engineering simulation software is not only capable of analyzing continuous domains, for instance, using the finite element method (FEM) to compute structures, fluids, or electromagnetic fields, but it also has enough computational process for discontinuous particle systems. Examples include pure particle molecular dynamics, discrete element methods (DEM), smoothed particle hydrodynamics (SPH), and coupled simulations with FEM. The primary prerequisite to compute particle systems is having the ability to generate particles within a model, including data of the particle positions, shapes, and volumes. This is similar to how in finite element analysis, a mesh containing nodes and element information must first be created.
When simulating particle systems, the first step is to generate the position, size, and shape of the particles. Thus, the particle generator becomes a critical component of the entire analysis system. A good particle generator should be able to quickly produce initial-state particles and generate particles according to various shapes and boundary conditions. Common automated particle generation methods are lattice structures, finite element mesh conversion, and network growth. This article discusses these well-known particle generation methods for SPH systems and their implementation mechanisms.
Lattice Structures
Lattice-based generation is particularly suitable for microscale materials. Typical structures include FCC (face-centered cubic) and BCC (body-centered cubic) lattices, which are often found in crystalline materials. Once the initial lattice structure is defined, the particle generator replicates this structure to fill the entire region.
Press enter or click to view image in full size
For this method of particle generation, the user needs to provide the boundary of the simulation domain (usually a bounding box), the particle type within each lattice, and the spacing between particles. Algorithmically, this is a straightforward approach, so it is widely applied in molecular dynamics and similar particle-based simulations.
Finite Element Mesh Conversion
A finite element mesh consists of nodes and elements; the element types vary depending on the model. Instances include tetrahedral and hexahedral solid meshes, as well as triangular and quadrilateral surface meshes. Since meshes can represent irregular geometries, the irregular shape stays captured once converting them into particles. In particle systems coupled with FEM, this particle generation approach allows for convenient coupling with finite element computations, as commonly seen in particle-FEM and SPH analyses.
Press enter or click to view image in full size
The general procedure for converting a mesh into particles involves calculating the centroid of each element and its characteristic size. These values determine the position and size of each particle. In principle, each finite element corresponds to one particle. However, because FEM meshes may be non-uniform, it may cause the resulting particle distribution to be uneven. Additional integration may be required to refine the generated particles, and boundary particles may also require special marking to enable the addition of boundary conditions in later simulations. In computational fluid dynamics (CFD), particles can also enter the simulation domain continuously through specified inflow boundaries. Currently, WELSIM supports particle generation from finite element meshes.
Network-Based Generation
Another common particle generation method is based on network growth, often implemented with tree and branching algorithms. Starting from an initial trunk structure, branches are allowed to grow within a fixed region according to specific rules, generating new branches (particles). By providing parameters such as a starting point, second point, segment length, gradient, and initial shape, particles can be generated iteratively. This is how new branches are created. Typically, if a new branch is too close to an existing one or belongs to the same parent particle, it is discarded. This approach incorporates randomness through stochastic processes, resulting in particle distributions with a degree of variability.
Conclusion
This article introduced conventionally used automated particle generation methods in simulation software. For FEM-related software, mesh-to-particle conversion is particularly practical, as the generated particles can be directly applied to FEM-coupled simulations. The general-purpose FEM software WELSIM already supports mesh-to-particle conversion, and users are able to export the generated particles to utilize in other analyses.
Wednesday, August 20, 2025
自动化生成仿真粒子的方法
现代工程仿真软件不仅具有分析连续介质的功能,如有限元方法计算结构、流体、或电磁场。也有增强了对非连续粒子系统的计算能力,如纯粒子的分子动力学计算,离散元,光滑粒子流体动力学(SPH),以及与有限元耦合的计算。计算粒子系统的首要条件就是能够在模型中产生粒子,包含了粒子的位置,形状,和体积大小等数据。这与有限元分析需要生成含有节点和单元信息的网格类似。
Image
在计算粒子体系时,第一步是生成粒子的位置,大小,和形状。因此,粒子生成器也就成为整个分析系统的关键部分。好的粒子生成器可以快速生成初始状态粒子,还可以根据不同的形状和边界来生成粒子。常见的自动化粒子生成方式有,晶体点阵,网络生长,和有限元网格转换。本文就讨论常见的可用于SPH系统的粒子生成方法,及其实现机理。
晶体点阵(Lattice)
使用点阵方式生成粒子是一种常见的方式,尤其适用于材料的微小尺度的计算。如材料晶体结构中常见的FCC、BCC等结构。当初始的点阵结构给定以后,粒子生成器会复制这个结构并铺满整个区域。
Image
对于此类型的粒子生成,需要用户提供整个模拟区域的边界,通常是一个矩形盒子,每个点阵中粒子类型,和粒子之间的位置。算法上,这也是一种简单直接的粒子生成方式,大量应用于分子动力学等粒子生成之中。
有限元网格转换
有限元网格是一种包含了节点与单元的数据,根据模型的不同,单元的类型也会不同。这种网格是有限元分析计算中的基础数据之一。代表性的有四面体和六面体实体单元网格,和三角形与四边形平面网格。网格可以表达不规则的形状,因此,转换成为粒子后,也可以表征不规则的形状。在与有限元结合的粒子系统中,这种粒子生成方式,能够方便与有限元计算进行耦合,如常见的粒子有限元和SPH分析。
Image
转换网格到粒子的常用方法是,获取网格每个单元的重心,和单元的直径大小。以此确定每个粒子的位置和大小。原则上每个单元会对应生成一个粒子。由于有限元网格的密度可能不均匀,以此方法生成的粒子分布也不均匀。有时需要再将生成的粒子进行均匀化处理。对于位于边界的粒子,可能还需要标记额外的内容,以方便在后续的分析中施加边界条件。如流体动力学计算(CFD)中,会在某个流入边界中不断生成粒子进入仿真区域。WELSIM已经能够根据有限元网格生成粒子的功能。
基于网络增长生成
另一种常见的粒子生成方式是通过网络增长,具体的算法上常使用树与分支的方式。初始一个树状结构的主干,允许分支在固定区域内按照一定方式生长,生成新的节点,即粒子。在输入起始点和第二个点,片段长度,梯度,初始形状等参数后。这种生成方式的核心是如何创立新的分支,通常的做法是,如果新节点与当前某个节点位置很近,或者都属于同一个父节点,则不会生成这个新节点(分支)。基于网格生成粒子的方法使用了随机数,因此生成的粒子会有一定的随机性。
Image
总结
本文介绍了仿真软件中,自动化生成粒子的常用方法。对于有限元相关的软件,网格转化为粒子的方式更为实用,可以直接将生成的粒子应用于有限元耦合计算中。通用有限元软件WELSIM已经支持了从网格到粒子的转化,用户还可以将生成的粒子导出,用于其他类型的分析。
Wednesday, July 23, 2025
Orthotropic Hill Plasticity Model
In the field of structural mechanics, the plastic deformation processes of many materials are anisotropic in nature. Examples include composite materials, titanium alloys, additively manufactured structures, and multiscale materials. In these cases, traditional isotropic yield criteria are no longer sufficient to accurately describe the behavior, and appropriate models are required to characterize anisotropic plastic yielding. Commonly used anisotropic yield functions include the Hill, Barlat, Banabic, and Cazacu models. Among them, the Hill model was proposed relatively early and has a wide range of applications. It performs particularly well in describing orthotropic materials and is extensively used in structural finite element analysis.
hill_augmented_manufacturing
The Hill model is named after Professor R. Hill, who was appointed Professor of Applied Mathematics at the University of Nottingham in 1953. His 1950 work “The Mathematical Theory of Plasticity” laid the foundation for modern plasticity theory. He is widely regarded as one of the most significant contributors to solid mechanics in the second half of the 20th century.
It’s important to note that the Hill model is not the only yield criterion for orthotropic anisotropic materials. Alternatives include Barlat models with 3 or 6 parameters, or modified versions of the Hill yield criterion. This article focuses only on the classical Hill model, but similar approaches can be used to determine parameters for other yield models. The Hill model is applicable for analyzing plastic deformation in anisotropic materials and can be viewed as a generalized form of the von Mises yield criterion tailored for anisotropic behavior. It is particularly useful for orthotropic plastic materials in structural engineering applications.
The Hill yield criterion is given by:
hill_yield_equation
For shell elements, the yield function is given by:
hill_yield_equation2
Where σ represents the stress components. For 3D models, F to H are six anisotropy calibration coefficients, also known as Hill parameters, which can be determined through material experiments. For shell elements, only four parameters F to N are required.
In computational mechanics, solid elements typically use yield stress ratios (or yield stresses) R11, R22, R33, R12, R13, R23 to calculate Hill parameters. To determine the yield stress ratios, the material’s yield stresses under different loading conditions must be measured:
σ11, σ22, σ33 are obtained from tensile tests.
σ12, σ13, σ23 are obtained from shear tests.
For shell elements, Lankford parameters are used to determine the Hill parameters. A Lankford parameter rₐ is defined as the ratio of plastic strain in the plane to that in the thickness direction. For orthotropic anisotropy, rₐ can be obtained from simple tensile tests:
r₀₀: tensile direction aligned with the orthotropic axis 1.
r₉₀: tensile direction perpendicular to the orthotropic axis 1. Once r₀₀, r₄₅, r₉₀ are measured, the Hill parameters can be calculated. Higher Lankford values indicate better formability.
Most finite element analysis software requires the user to input either R values or Lankford parameters for the Hill model. Once these are specified, the Hill yield criterion equation can be fully determined.
Support for the orthotropic Hill model in WelSim
The complexity of the Hill model lies in parameter input and solving the orthotropic nonlinear behavior. The general-purpose simulation software WESLIM supports transient analysis involving the Hill model. The free material editing software MatEditor supports Hill material model input. Currently, MatEditor supports three types of orthotropic Hill plastic material models and can generate OpenRadioss material input scripts: Law32, Law73/74, and Law93.
mateditor_hill_orthotropic
Conclusion
The Hill model effectively describes orthotropic yield behavior, especially in tension-compression directions and in scenarios with minimal shear deformation. It can also be used to model the mechanical behavior of metallic lattice structures in additive manufacturing.
Hill parameters can be determined via R or Lankford parameters. When these parameters are unavailable from experiments, they can be approximated using curve fitting methods.
WelSim already provides support for the Hill model and can be integrated with OpenRadioss for transient simulations involving orthotorpic plastic deformation.
WelSim and authors have no direct affiliation with developers of OpenRadioss. References to OpenRadioss here are solely for technical blogging and software usage discussion.
Subscribe to:
Posts (Atom)