GEOS: 开源多物理场耦合模拟框架介绍与使用指南

1. GEOS项目概述

GEOS (Geological and Environmental Simulation Framework) 是一个开源的、多物理场耦合的模拟框架,专门设计用于建模地下环境中的复杂耦合过程。该项目由劳伦斯利弗莫尔国家实验室(LLNL)开发并维护。

主要特点

  • 多物理场耦合:支持流体流动、热传导、力学变形、化学反应等多物理过程的耦合模拟
  • 高性能计算:针对大规模并行计算优化,可处理复杂地质模型
  • 模块化架构:允许用户灵活组合不同物理过程
  • 开源许可:采用BSD-3-Clause许可证

2. GEOS核心功能

支持的物理过程

  1. 流体流动

    • 单相/多相流动
    • 达西流和非达西流
    • 可压缩/不可压缩流体
  2. 固体力学

    • 线性和非线性弹性
    • 塑性变形
    • 断裂力学
  3. 热过程

    • 热传导
    • 热对流
    • 热-水-力耦合
  4. 化学反应

    • 反应输运
    • 地球化学反应

应用领域

  • 碳封存(CCS)
  • 页岩气开发
  • 地热能源开发
  • 核废料处置
  • 油气储层模拟

3. 安装与配置

系统要求

  • Linux或macOS系统(Windows可通过WSL使用)
  • CMake (≥3.14)
  • C++编译器(支持C++14)
  • MPI实现(如OpenMPI或MPICH)
  • BLAS/LAPACK

安装步骤

  1. 获取源代码:

    git clone --recursive https://github.com/GEOSX/GEOS.git
    cd GEOS
    
  2. 配置编译环境:

    mkdir build
    cd build
    cmake -DCMAKE_BUILD_TYPE=Release ..
    
  3. 编译:

    make -j8
    
  4. 运行测试:

    ctest
    

4. 基本使用

输入文件结构

GEOS使用XML格式的输入文件,典型结构如下:

<Problem>
  <Solvers>
    <!-- 定义求解器 -->
  </Solvers>
  
  <Mesh>
    <!-- 定义网格 -->
  </Mesh>
  
  <Geometry>
    <!-- 定义几何体 -->
  </Geometry>
  
  <Events>
    <!-- 定义模拟事件序列 -->
  </Events>
  
  <NumericalMethods>
    <!-- 数值方法设置 -->
  </NumericalMethods>
  
  <ElementRegions>
    <!-- 定义区域及其属性 -->
  </ElementRegions>
  
  <Constitutive>
    <!-- 本构模型 -->
  </Constitutive>
  
  <FieldSpecifications>
    <!-- 初始条件和边界条件 -->
  </FieldSpecifications>
  
  <Outputs>
    <!-- 输出设置 -->
  </Outputs>
</Problem>

运行模拟

mpirun -np 4 geos -i input.xml

5. 示例:单相流动模拟

以下是一个简单的单相流动模拟示例:

<Problem>
  <Solvers>
    <SinglePhaseFVM name="singlePhaseFlow"
                    discretization="fluidFlow"
                    targetRegions="{ region }">
      <LinearSolverParameters directParallel="0"/>
    </SinglePhaseFVM>
  </Solvers>

  <Mesh>
    <InternalMesh name="mesh"
                  elementTypes="{ C3D8 }"
                  xCoords="{ 0, 10 }"
                  yCoords="{ 0, 10 }"
                  zCoords="{ 0, 10 }"
                  nx="{ 10 }"
                  ny="{ 10 }"
                  nz="{ 10 }"
                  cellBlockNames="{ cb1 }"/>
  </Mesh>

  <Geometry>
    <Box name="box"
          xMin="{ -0.01, -0.01, -0.01 }"
          xMax="{ 10.01, 10.01, 10.01 }"/>
  </Geometry>

  <ElementRegions>
    <CellElementRegion name="region"
                       cellBlocks="{ cb1 }"
                       materialList="{ fluid, rock }"/>
  </ElementRegions>

  <Constitutive>
    <CompressibleSinglePhaseFluid name="fluid"
                                  defaultDensity="1000"
                                  defaultViscosity="0.001"
                                  referencePressure="1e5"
                                  compressibility="1e-9"
                                  referenceTemperature="293.15"
                                  thermalExpansionCoeff="0.0"/>

    <PorousSolid name="rock"
                 porosityModel="1.0"
                 permeabilityModel="1e-12"/>
  </Constitutive>

  <FieldSpecifications>
    <FieldSpecification name="initialPressure"
                        initialCondition="1"
                        setNames="{ all }"
                        objectPath="ElementRegions/region"
                        fieldName="pressure"
                        scale="1e5"/>

    <FieldSpecification name="leftBoundaryPressure"
                        objectPath="ElementRegions/region"
                        fieldName="pressure"
                        scale="1.2e5"
                        setNames="{ xneg }"/>

    <FieldSpecification name="rightBoundaryPressure"
                        objectPath="ElementRegions/region"
                        fieldName="pressure"
                        scale="1e5"
                        setNames="{ xpos }"/>
  </FieldSpecifications>

  <Outputs>
    <Silo name="siloOutput"/>
  </Outputs>

  <Events>
    <PeriodicEvent name="outputs"
                   forceDt="1.0"
                   target="/Outputs/siloOutput"/>
    
    <SolverApplication name="singlePhaseFlowApplication"
                       solver="singlePhaseFlow"
                       beginTime="0.0"
                       endTime="10.0"/>
  </Events>
</Problem>

6. 高级功能

耦合模拟示例

GEOS的强大之处在于其耦合模拟能力。以下是一个热-水-力(THM)耦合模拟的框架:

<Solvers>
  <!-- 热流动求解器 -->
  <SinglePhaseFVM name="flowSolver"
                  discretization="fluidFlow"
                  targetRegions="{ region }"/>
  
  <!-- 热传导求解器 -->
  <ThermalSinglePhaseFVM name="thermalSolver"
                         discretization="thermalFlow"
                         targetRegions="{ region }"/>
  
  <!-- 固体力学求解器 -->
  <SolidMechanicsLagrangeSSLE name="mechanicsSolver"
                              discretization="mechanics"
                              targetRegions="{ region }"/>
  
  <!-- 耦合求解器 -->
  <CoupledThermalSinglePhaseFlow name="coupledFlowThermal"
                                 flowSolverName="flowSolver"
                                 thermalSolverName="thermalSolver"
                                 solidSolverName="mechanicsSolver"/>
</Solvers>

并行计算

GEOS支持大规模并行计算,可通过以下方式配置:

mpirun -np 128 geos -i input.xml -x 4 -y 4 -z 8

其中-x,-y,-z参数指定各方向的域分解数量。

7. 可视化与后处理

GEOS支持多种输出格式:

  1. Silo格式:可使用VisIt或Paraview可视化
  2. HDF5格式:适合大规模数据
  3. VTK格式:通用可视化格式

示例输出配置:

<Outputs>
  <Silo name="siloOutput"
        plotLevel="1"
        writeFEMFaces="1"/>
  
  <TimeHistory name="wellData"
               filename="wellData.csv"
               source="/Solvers/wellSolver"/>
</Outputs>

8. 学习资源

  1. 官方文档:https://geosx-geosx.github.io
  2. 示例库:GitHub仓库中的src/coreComponents/physicsSolvers/unitTests目录
  3. 用户论坛:GitHub Discussions
  4. 论文
    • Settgast et al. (2017) “A fully coupled method for massively parallel simulation of hydraulically driven fractures in 3-dimensions”

9. 社区与贡献

GEOS是一个活跃的开源项目,欢迎贡献:

  • 报告问题:GitHub Issues
  • 提交代码:GitHub Pull Requests
  • 参与讨论:GitHub Discussions

项目遵循标准的开源开发流程,所有贡献都需要通过代码审查和CI测试。

10. 总结

GEOS是一个功能强大的多物理场耦合模拟框架,特别适合地下环境中的复杂过程模拟。其开源特性和模块化设计使得它既可用于学术研究,也可用于工业应用。通过合理配置输入文件,用户可以灵活地组合不同的物理过程,模拟从简单单相流动到复杂THM耦合的各种场景。

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐