|
6 | 6 |
|
7 | 7 | ----------------------------------------------------------- |
8 | 8 |
|
| 9 | +**PyGRT** 程序包由C和Python两个编程语言的代码组成,目的是兼并高效性和便捷性。 |
| 10 | +底层复杂运算由C语言编写,编译链接成动态库 ``libgrt.so`` 供Python调用。Python通过 ``ctypes`` 库导入动态库以使用外部函数,以此兼并了C语言的高效和Python语言的便捷。 |
9 | 11 |
|
10 | | -安装 **PyGRT** |
11 | | --------------------- |
| 12 | +除了Python脚本式运行, **PyGRT** 保留传统命令行式运行C程序 :command:`grt` 。 |
| 13 | +受 `GMT <https://www.generic-mapping-tools.org/>`_ 的启发, :command:`grt` 程序对多个计算功能使用模块化管理, |
| 14 | +可使用类似于以下格式来运行程序。每个模块可使用 ``-h`` 查看帮助。 |
| 15 | + |
| 16 | +.. code-block:: C |
| 17 | +
|
| 18 | + grt <module-name> [<module-options>] |
| 19 | +
|
| 20 | +**C程序的运行独立于Python,不需要Python环境,从而满足了更多计算场景。** |
| 21 | + |
| 22 | +计算 **动态解** 的主要计算流程如下: |
| 23 | + |
| 24 | ++ Python |
| 25 | + |
| 26 | +.. mermaid:: |
| 27 | + :zoom: |
| 28 | + |
| 29 | + flowchart TB |
| 30 | + |
| 31 | + GG(["compute_grn()"]) |
| 32 | + SS(["gen_syn_from_gf_*()"]) |
| 33 | + EE(["compute_strain()"]) |
| 34 | + RR(["compute_rotation()"]) |
| 35 | + TT(["compute_stress()"]) |
| 36 | + |
| 37 | + G["Compute Green's Functions |
| 38 | + (and its Spatial Derivatives)"] |
| 39 | + S["Compute displacements with focal mechanism |
| 40 | + (and its Spatial Derivatives)"] |
| 41 | + E["Compute Strain Tensor"] |
| 42 | + R["Compute Rotation Tensor"] |
| 43 | + T["Compute Stress Tensor"] |
| 44 | + |
| 45 | + GG --> G |
| 46 | + G --> SS --> S |
| 47 | + S --> EE --> E |
| 48 | + S --> RR --> R |
| 49 | + S --> TT --> T |
| 50 | + |
| 51 | + classDef cmdcls fill:#f9f2d9,stroke:#e8d174,stroke-width:2px,color:#333; |
| 52 | + class GG,SS,EE,RR,TT cmdcls |
| 53 | + |
| 54 | ++ C (module name) |
| 55 | + |
| 56 | +.. mermaid:: |
| 57 | + :zoom: |
| 58 | + |
| 59 | + flowchart TB |
| 60 | + |
| 61 | + GG(["greenfn"]) |
| 62 | + SS(["syn"]) |
| 63 | + EE(["strain"]) |
| 64 | + RR(["rotation"]) |
| 65 | + TT(["stress"]) |
| 66 | + |
| 67 | + G["Compute Green's Functions |
| 68 | + (and its Spatial Derivatives)"] |
| 69 | + S["Compute displacements with focal mechanism |
| 70 | + (and its Spatial Derivatives)"] |
| 71 | + E["Compute Strain Tensor"] |
| 72 | + R["Compute Rotation Tensor"] |
| 73 | + T["Compute Stress Tensor"] |
| 74 | + |
| 75 | + GG --> G |
| 76 | + G --> SS --> S |
| 77 | + S --> EE --> E |
| 78 | + S --> RR --> R |
| 79 | + S --> TT --> T |
| 80 | + |
| 81 | + classDef cmdcls fill:#f9f2d9,stroke:#e8d174,stroke-width:2px,color:#333; |
| 82 | + class GG,SS,EE,RR,TT cmdcls |
| 83 | + |
| 84 | +计算 **静态解** 的过程相同,只是在名称上有如下区别: |
| 85 | + |
| 86 | ++ Python 函数名称增加 "static\_" ,例如 :func:`compute_static_grn() <pygrt.pymod.PyModel1D.compute_static_grn>` 。 |
| 87 | ++ C 程序模块名增加 "static\_" 前缀,例如 :command:`static_greenfn` ;或者在 :command:`grt` 与无 "static\_" 前缀的模块名之间增加 "static" 命令, |
| 88 | + 即支持以下两种方式(以 :command:`greenfn` 模块为例): |
| 89 | + |
| 90 | + .. code-block:: bash |
| 91 | +
|
| 92 | + grt static_greenfn [<module-options>] |
| 93 | + grt static greenfn [<module-options>] |
| 94 | +
|
| 95 | +----------------- |
12 | 96 |
|
13 | | -详见 :doc:`/install` 。 |
| 97 | +入门部分包含一些示例与说明,可快速上手。Github主页的 :rst:dir:`example/` 文件夹中有更多示例,可在 `Github Releases <https://github.com/Dengda98/PyGRT/releases>`_ 中下载。 |
14 | 98 |
|
15 | 99 |
|
16 | 100 | 建立模型文件 |
|
0 commit comments