Monday, November 20, 2023

Compile the electromagnetic simulation solver Palace in Windows

 Palace is an open-source, large-scale computational electromagnetic software package supported by the AWS Lab. It is feature-rich and capable of running on various high-performance hardware, supporting OpenMP, MPI, and GPU parallel computing. The use of the Apache open-source license is also highly advantageous. For more details, refer to the article ‘Generating the solver input scripts of the computational electromagnetics software Palace using WELSIM’.

Although Palace is powerful, being a scientific computing program developed based on Linux, the official support for the Windows operating system is not complete. We have conducted research on the feasibility of running Palace on Windows, compiled Palace using Visual Studio, and generated a native Windows application with simulation results.

Palace provides the Superbuild compilation method with CMake, which automatically downloads all required libraries and compiles them completely. It compiles effortlessly on Linux. However, on Windows, many core libraries such as PETSc, SLEPc, libCEED, MUMPS, and others require manual compilation. Therefore, the Superbuild mode provided officially cannot compile as smoothly on Windows. Users need to apply the manual method of establishing Visual Studio projects to complete the building.

System and dependency libraries

Operating System: Windows 10, 64-bit

Compiler: Visual Studio 2022 Community, C++17. Intel Fortran Compiler 2022.

Palace Version: 0.11.2

Dependency Libraries:

Intel MKL: A popular linear algebra solver, using oneAPI 2022.2.0, consistent with the version of Fortran compiler.

METIS: A mesh partitioning tool for parallel computing, version 5.3.

Hypre: A computational library, version 2.52.

nlhmann/json: Modern C++-based JSON read-write package.

{fmt}: Formatting tool for input-output streams in C/C++.

Eigen: A well-known C++ numerical computing package, has no need for compilation; supports direct header file invocation.

libCEED: A linear algebra computation management terminal that supports parallel computing on various CPUs, GPUs, and clusters.

SuperLU_DIST: The parallel version of SuperLU, a sparse direct linear algebra solver library.

STRUMPACK: An open-source software library for large-scale sparse matrix computing.

MUMPS: An open-source software library from France for solving large-scale sparse linear systems.

SLEPc: A complex number linear algebra solver for eigenvalue problems, based on PETSc.

ARPACK-NG: A complex number linear algebra solver for eigenvalue problems, programmed using Fortran 77 langauge.

GSLIB: An interpolation sovler for high-order spectral elements, optional.

Among these, at least one of the three optional linear solvers SuperLU_DIST, STRUMPACK, MUMPS must be present. This article uses MUMPS. Additionally, out of the two complex solvers, SLEPc and ARPACK, at least one is required. Without them, eigenvalue-related computing cannot be performed. This article uses ARPACK.

Visual studio projects

Establish two projects, namely the static library project libpalace, and the executable file project palace. libpalace contains all header and source files. palace is the final generated executable file, containing only a main.cpp file. This is shown in the figure.

Project libpalace

Set the external header file directories.

Add preprocessor macros:

CEED_SKIP_VISIBILITY

PALACE_WITH_ARPACK

_CRT_SECURE_NO_WARNINGS

Project palace

The method to add external header files and preprocessor macros is essentially the same as libpalace, so it will not be repeated here. Compiling the executable program requires linking all dependent libraries. The added linked libraries are as follows,

After building, place all dependent dynamic libraries (*.dll files) together with the palace.exe to run Palace. Test the executable program by running it on the Windows console.

You can also use the mpiexec command for MPI parallel computing. GPU parallel computing should also be feasible and will be discussed in future articles.

To contribute to simulation and the open-source communities, we have open-sourced the building files for Palace, shared at https://github.com/WelSimLLC/palace, and provided the compiled palace.exe executable file for users to use directly.

Conclusion

There are not many available open-source electromagnetic simulation solvers, and Palace provides powerful computing capabilities while also having a very friendly open-source license. WELSIM has become the first developer in the world to successfully compile Palace on Windows and open-source the building methods and files.

Some of Palace’s dependency libraries that also face challenges when building on Windows will be discussed in future articles.

WelSim is not affiliated with Palace and Visual Studio. The development team and organization behind Palace and Visual Studio have no connection to WelSim. This reference is used here solely for the purpose of a technical blog article and software usage.

Sunday, November 19, 2023

Windows环境下编译电磁仿真求解器Palace

Palace是一款开源的大规模计算电磁学软件包,由亚马逊云端业务实验室(AWS Lab)支持。功能丰富,同时能够在不同的高性能硬件上运行,软件上支持OpenMP, MPI和GPU并行计算。Apache的开源协议也是极为友好。详情参见《使用WELSIM生成电磁计算软件Palace的求解器文件》一文。

尽管Palace功能强大,但作为一款基于Linux开发的科学计算程序,官方并没有提供对Windows操作系统的完全支持。笔者对Palace在Windows系统运行的可行性做了研究,使用Visual Studio编译Palace,生成了原生的Windows版本应用程序,并计算得到仿真结果。

Palace提供了CMake的Superbuild编译方式,会自动下载全部的所需依赖库并完全编译。在Linux下可以顺利编译。然而在Windows系统下,大量的依赖库如PETSc,SLEPc,libCEED,MUMPS等核心依赖库需要手动编译,因此官方提供的Superbuild模式,还无法在Windows下顺利编译。我们需要通过手动建立Visual Studio项目的方法,完成编译。

系统环境与依赖库

操作系统:Windows 10, 64-bit

编译器:Visual Studio 2022 Community, C++17。Inter Fortran Compiler 2022。

Palace版本:0.11.2

依赖库

  • Intel MKL:著名的线性矩阵求解器。使用oneAPI 2022.2.0,和Fortran编译器版本一致。
  • METIS:用于并行计算的网格分区工具。使用5.3版本。
  • Hypre:计算包,使用2.52版本。
  • nlhmann/json:一款现代的基于C++的JSON语言读写包。
  • {fmt}:支持C/C++的输入输出流的格式化工具包。
  • Eigen:大名顶顶的C++数值计算包,无需编译,支持头文件直接调用。
  • libCEED:是一款线性代数计算管理终端,支持对各种CPU,GPU和集群的并行计算。
  • SuperLU_DIST:SuperLU的并行版本,是一个并行的稀疏直接线性代数求解器库。
  • STRUMPACK:一款大规模稀疏矩阵直接数值计算的开源软件库。
  • MUMPS:来自法国的求解大规模稀疏线性方程组的开源软件库。
  • SLEPc:支持复数线性矩阵计算,用于特征值计算。需要基于PETSc编译。
  • ARPACK-NG:支持复数线性矩阵计算,用于特征值计算。以F77程序为主,无需依赖PETSc,可以独立编译。
  • GSLIB:用于高阶谱单元的插值计算,可选。

其中,SuperLU_DIST,STRUMPACK,MUMPS三个可选的直接线代求解器至少要有一个。本文选用了MUMPS。SLEPc和ARPACK这两个复数求解器,需要至少一个。如果没有,将无法实现特征值相关的计算。本文选用了ARPACK。

建立项目文件

建立两个项目,分别是静态库项目libpalace,和可执行文件项目palace。libpalace包含所有的头文件和源文件。palace是最后生成的可执行文件,只含有一个main.cpp文件。如图所示,

libpalace项目设置

设置外部头文件链接位置

添加预处理宏命令

CEED_SKIP_VISIBILITY
PALACE_WITH_ARPACK
_CRT_SECURE_NO_WARNINGS

palace项目设置

添加外部头文件和预处理宏命令的方式,与libpalace几乎一样,这里不在赘述。编译可执行程序需要链接所有依赖库。添加的链接库如下

编译后,需要将所有的依赖动态库放置与palace.exe文件在一起,即可运行palace了。测试可执行程序,可以在Windows的命令行下运行。

也可以使用mpiexec命令进行MPI并行计算。GPU并行计算应该也可以实现,会在以后的文章中讨论。

为贡献仿真与开源社区,笔者开源了Palace的编译文件,分享在 github.com/WelSimLLC/pa,并提供了编译好的palace.exe可执行文件,供用户直接使用。

总结

目前可用的开源电磁场仿真求解器不多,Palace提供了强大的计算功能同时,也有着很友好的开源协议。Welsim也成为了世界上第一个在Windows下成功编译Palace,并开源编译方法与文件的开发者。

Palace的一些依赖库在Windows下编译也存在难点,将在以后的文章中讨论。


WelSim与作者不隶属于Palace。和Palace开发团队与机构没有直接关系。这里引用Palace仅用作技术博客文章与软件使用的参考。

Thursday, November 9, 2023

Importing GDS files for CAE simulation analysis

 GDS is a universal 2D CAD electronic layout format widely used in the integrated circuit and chip industry. The simple syntax and broad ecosystem makes it one of the main file formats in the chip and EDA industry. Since engineering simulation CAE software deals with various file formats, supporting GDS files is a necessary feature of modern simulation software. Imported GDS files can be directly applied to thermal and electromagnetic analysis, expanding the application ecosystem of CAE software and enhancing user experience.

The structure of GDS files can include seven elements: Boundary, Path, SREF, AREF, Text, Node, and Box. Details can be found in the article “GDSII, the data format for chip and integrated circuit design.” Among them, Text, Node, and Box do not contain actual geometric information. Therefore, when reading GDS files, the focus is on Boundary, Path, SREF, and AREF content. This information is then converted into geometric models. WELSIM can quickly read GDS files and generate models for simulation analysis.

Import GDS file

In WELSIM, after opening the software and creating a new project, click on “Import Geometry” to open the file dialog.

After importing, the 3D graphics window will display the geometry, and the project window will show the geometry objects.

Since GDS does not contain color information, WELSIM colors the imported geometry randomly; users can modify the colors afterward. All graphics are default on the XY plane, and users can export the model as a STEP file, achieving the conversion from GDSII to STEP format.

Since it is a 2D model, it’s recommended to set the project to 2D and define relevant properties according to the analysis type. Here, we set the model for electromagnetic analysis.

In finite element simulation calculations, the geometry needs to be meshed. Simply click the meshing button to quickly generate the mesh.

Then, proceed with relevant analysis settings, such as adding boundary conditions. After completing the settings, export the solver’s input scripts.

You will see the generated solver scripts in the specified directory.

As GDS is fundamentally a 2D CAD file format, the imported model belongs to the XY plane’s 3D surface model. In future versions, there may be an option to set the thickness of components, generating 3D modeling. The imported GDS model does not consider hierarchy and is uniformly placed under the geometry group object. Users can identify hierarchy through object names. Future versions may reflect hierarchy in the tree structure. Additionally, GDS often uses multiple straight-line segments to define curves, resulting in the imported geometric model having curved boundaries represented by multiple line segments. When applying boundary conditions, users need to select multiple line segments simultaneously.

Conclusion

GDSII is a widely used data format in the chip and integrated circuit industry, and it’s one of the CAD formats modern general-purpose engineering simulation software needs to support. WELSIM supports the import of GDS files, automatically generates geometric models, and provides support for subsequent meshing and analysis.


Wednesday, November 8, 2023

导入GDS文件进行CAE仿真分析

 GDS是一款通用的二维CAD电子排版格式,大量应用于集成电路与芯片行业。其语法简单,生态广泛,已经是芯片与EDA行业的主要文件格式之一。工程仿真CAE软件涉及面广,会遇到各种类型的文件格式,因此支持GDS文件是现代通用仿真软件的必要功能之一。导入的GDS文件,可以直接应用于热与电磁分析,扩大CAE软件的应用生态,同时提升用户体验。

GDS文件的结构能够包含有7种元素,分别是Boundary, Path, SREF, AREF, Text, Node和Box,详情参见《芯片与集成电路设计数据格式之GDSII》一文。其中Text,Node和Box不带有实际的几何信息。所以在读取GDS文件时,主要考虑Boundary,Path,SREF和AREF内容,并将这些信息转换为几何模型。WELSIM可以快速读取GDS文件,并即时生成可用于仿真分析的模型。

WELSIM中导入GDS文件

打开WELSIM软件后,新建一个项目,点击导入图形文件。会有文件打开对话框弹出。

导入后,三维图形窗口会显示几何体,同时项目列表会显示集合体节点。

由于GDS不包含颜色信息,系统会给导入的几何体随机上色,用户也可以自行修改颜色。同时,所有的图形会默认在XY平面上。用户也可以导出模型为STEP格式文件,实现了GDSII到STEP格式的转换。

由于是二维模型,建议将项目设置为2D,并按照分析类型修改相关属性。这里我们将模型设为电磁分析。

在有限元等仿真计算时,需要对几何体进行有限元网格划分,只需点击网格划分按钮,即快速的进行网格划分。

之后进行相关分析设置,如添加各种边界条件等。完成设置后,可以导出求解器的输入文件。

即可在指定的文件目录中,找到所生成的求解器输入文件。

由于GDS本质上是二维CAD文件格式,导入的模型属于XY平面的三维表面模型,以后的版本中,可能会提供对元器件厚度的设置,实现三维模型的特性。导入的GDS模型并没有考虑层级关系,统一放置在几何体组节点下,用户可以通过节点名称识别层级,将来可能会在树结构中体现层级关系。GDS在定义曲线时,常使用的是多个直线段拟合,这使得导入的几何模型的曲线边界是多个线段,在施加边界条件时,用户需要同时选择多个线段。

总结

GDSII是在芯片与集成电路行业行业广泛使用的数据格式,也是现代通用工程仿真软件所需要支持的CAD格式之一。WELSIM支持导入GDS文件,自动生成几何模型,支持后续的网格划分和计算分析提供。


WelSim与作者不隶属于GDSII。和GDSII的开发团队与机构没有直接关系。这里的引用仅用作技术博客文章与软件使用的参考。