flash-sim 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flash/__init__.py +157 -0
- flash/_bootstrap.py +35 -0
- flash/_core/__init__.py +39 -0
- flash/_core/credentials/__init__.py +44 -0
- flash/_core/credentials/_config.py +191 -0
- flash/_core/credentials/_core.py +277 -0
- flash/_core/credentials/_flash_entries.py +83 -0
- flash/_core/credentials/_minimal.py +73 -0
- flash/_core/credentials/api_keys.py +225 -0
- flash/_core/credentials/deepseek.py +187 -0
- flash/_core/credentials/flash_ssh.py +472 -0
- flash/_core/credentials/gitee.py +220 -0
- flash/_core/credentials/manage.py +359 -0
- flash/_core/credentials/pypi.py +144 -0
- flash/_core/credentials.py +1103 -0
- flash/_core/interface.py +90 -0
- flash/_core/registry.py +35 -0
- flash/_core/schema.py +118 -0
- flash/config/__init__.py +105 -0
- flash/flash_run/PROCESS.md +435 -0
- flash/flash_run/README.md +205 -0
- flash/flash_run/__init__.py +25 -0
- flash/flash_run/env/README.md +272 -0
- flash/flash_run/env/__init__.py +12 -0
- flash/flash_run/env/env_manager.py +535 -0
- flash/flash_run/env/resource_config.py +650 -0
- flash/flash_run/remote/README.md +313 -0
- flash/flash_run/remote/__init__.py +20 -0
- flash/flash_run/remote/remote_check.py +70 -0
- flash/flash_run/remote/remote_deploy.py +792 -0
- flash/flash_run/remote/remote_workflow.py +142 -0
- flash/flash_run/remote/route_tester.py +465 -0
- flash/flash_run/remote/ssh_check.py +107 -0
- flash/input_gen/README.md +535 -0
- flash/input_gen/__init__.py +170 -0
- flash/input_gen/gen_Grid_markRefineDerefine/GEN_GRID_GUIDE.md +68 -0
- flash/input_gen/gen_Grid_markRefineDerefine/README.md +327 -0
- flash/input_gen/gen_Grid_markRefineDerefine/__init__.py +0 -0
- flash/input_gen/gen_Grid_markRefineDerefine/generator.py +567 -0
- flash/input_gen/gen_checker/GEN_CHECKER_GUIDE.md +148 -0
- flash/input_gen/gen_checker/__init__.py +6 -0
- flash/input_gen/gen_checker/checker.py +274 -0
- flash/input_gen/gen_checker/ploter/__init__.py +13 -0
- flash/input_gen/gen_checker/ploter/density_plotter.py +195 -0
- flash/input_gen/gen_checker/ploter/pulse_plotter.py +158 -0
- flash/input_gen/gen_checker/ploter/ray_plotter.py +277 -0
- flash/input_gen/gen_config/GEN_CONFIG_GUIDE.md +534 -0
- flash/input_gen/gen_config/__init__.py +9 -0
- flash/input_gen/gen_config/generator.py +205 -0
- flash/input_gen/gen_eos_op/GEN_EOS_OP_GUIDE.md +224 -0
- flash/input_gen/gen_eos_op/__init__.py +10 -0
- flash/input_gen/gen_eos_op/generator.py +481 -0
- flash/input_gen/gen_f90/__init__.py +0 -0
- flash/input_gen/gen_makefile/GEN_MAKEFILE_GUIDE.md +56 -0
- flash/input_gen/gen_makefile/__init__.py +9 -0
- flash/input_gen/gen_makefile/generator.py +32 -0
- flash/input_gen/gen_newpara/README.md +400 -0
- flash/input_gen/gen_newpara/RP_Reference.md +639 -0
- flash/input_gen/gen_newpara/__init__.py +19 -0
- flash/input_gen/gen_newpara/generator.py +643 -0
- flash/input_gen/gen_otherf90s/GEN_OTHER_F90S_GUIDE.md +231 -0
- flash/input_gen/gen_otherf90s/__init__.py +0 -0
- flash/input_gen/gen_par/GEN_PAR_GUIDE.md +657 -0
- flash/input_gen/gen_par/__init__.py +18 -0
- flash/input_gen/gen_par/defaults.py +510 -0
- flash/input_gen/gen_par/generator.py +445 -0
- flash/input_gen/gen_par/materials.py +141 -0
- flash/input_gen/gen_shell_script/GEN_SHELL_SCRIPT_GUIDE.md +120 -0
- flash/input_gen/gen_shell_script/__init__.py +12 -0
- flash/input_gen/gen_shell_script/generator.py +850 -0
- flash/input_gen/gen_sim_data/GEN_SIM_DATA_GUIDE.md +306 -0
- flash/input_gen/gen_sim_data/__init__.py +10 -0
- flash/input_gen/gen_sim_data/generator.py +87 -0
- flash/input_gen/gen_sim_init/GEN_SIM_INIT_GUIDE.md +216 -0
- flash/input_gen/gen_sim_init/__init__.py +9 -0
- flash/input_gen/gen_sim_init/generator.py +104 -0
- flash/input_gen/gen_sim_initblock/GEN_SIM_INITBLOCK_GUIDE.md +330 -0
- flash/input_gen/gen_sim_initblock/__init__.py +17 -0
- flash/input_gen/gen_sim_initblock/generator.py +432 -0
- flash/input_gen/gen_sim_initblock/grid.py +278 -0
- flash/input_gen/gen_sim_initblock/visualizer.py +250 -0
- flash/interface.py +398 -0
- flash/output_processors/__init__.py +50 -0
- flash/output_processors/conftest.py +41 -0
- flash/output_processors/docs/api_reference.md +597 -0
- flash/output_processors/docs/how_to_add_custom_variables.md +417 -0
- flash/output_processors/docs/output_processors_usage.md +596 -0
- flash/output_processors/docs/performance_tuning.md +365 -0
- flash/output_processors/docs/workflow.md +101 -0
- flash/output_processors/hdf5processor/__init__.py +21 -0
- flash/output_processors/hdf5processor/flash_hdf5.py +1224 -0
- flash/output_processors/loader/__init__.py +7 -0
- flash/output_processors/loader/data_loader.py +392 -0
- flash/output_processors/parallel.py +580 -0
- flash/output_processors/plotter/__init__.py +8 -0
- flash/output_processors/plotter/plot_generator.py +471 -0
- flash/output_processors/plotter/plot_style.py +240 -0
- flash/physics/ele_nonlocal/Knudsen_Nonlocal_Summary.md +576 -0
- flash/projects/__init__.py +0 -0
- flash/projects/projects_demo/README.md +94 -0
- flash/projects/projects_demo/__init__.py +17 -0
- flash/projects/projects_demo/ch_center_demo/__init__.py +16 -0
- flash/projects/projects_demo/ch_center_demo/plot_compare.py +169 -0
- flash/projects/projects_demo/ch_center_demo/run_compare.py +148 -0
- flash/scenarios/README.md +669 -0
- flash/scenarios/SNBtest/__init__.py +0 -0
- flash/scenarios/__init__.py +18 -0
- flash/scenarios/base.py +50 -0
- flash/scenarios/center_evolution/__init__.py +2 -0
- flash/scenarios/center_evolution/ch_center/__init__.py +361 -0
- flash/scenarios/center_evolution/ch_center/laserslab1d_local_custom.py +804 -0
- flash/scenarios/collision_compression/__init__.py +38 -0
- flash/scenarios/flash_demo/__init__.py +0 -0
- flash/scenarios/flash_demo/demo_hpc/__init__.py +0 -0
- flash/scenarios/flash_demo/demo_hpc/_plot_utils.py +128 -0
- flash/scenarios/flash_demo/demo_hpc/laserslab1d_hpc_demo_batch.py +1035 -0
- flash/scenarios/flash_demo/demo_hpc/laserslab1d_supercomputer_demo.py +778 -0
- flash/scenarios/flash_demo/demo_hpc/remote_analysis.py +428 -0
- flash/scenarios/flash_demo/demo_hpc/remote_plot_script.py +444 -0
- flash/scenarios/flash_demo/demo_hpc/remote_ssh_helper.py +457 -0
- flash/scenarios/flash_demo/demo_local/__init__.py +0 -0
- flash/scenarios/flash_demo/demo_local/laserslab1d_local_demo.py +343 -0
- flash/scenarios/flash_demo/hello_flash/README.md +447 -0
- flash/scenarios/flash_demo/hello_flash/analyze_density.py +416 -0
- flash/scenarios/flash_demo/hello_flash/deploy_flash.py +828 -0
- flash/scenarios/interpolator.py +286 -0
- flash/scenarios/plasma_preparation/__init__.py +1 -0
- flash/scenarios/registry.py +61 -0
- flash/scenarios/simulator.py +1045 -0
- flash/test/__init__.py +1 -0
- flash/test/flash_mathtest_custom01.py +413 -0
- flash/test/math_test.py +596 -0
- flash/utils/__init__.py +9 -0
- flash/utils/check_hdf5_time.py +22 -0
- flash/utils/convert_pdf_to_md.py +134 -0
- flash/utils/convert_text_to_md.py +102 -0
- flash/utils/extract_knowledge.py +200 -0
- flash_sim-0.0.1.dist-info/METADATA +811 -0
- flash_sim-0.0.1.dist-info/RECORD +143 -0
- flash_sim-0.0.1.dist-info/WHEEL +4 -0
- flash_sim-0.0.1.dist-info/entry_points.txt +3 -0
- flash_sim-0.0.1.dist-info/licenses/LICENSE +386 -0
- flash_sim-0.0.1.dist-info/licenses/NOTICE +138 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
# gen_sim_data 说明文档
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
`gen_sim_data` 子包用于生成 FLASH 仿真的 `Simulation_data.F90` 文件。该文件是 FLASH 仿真 setup 的核心模块之一,用于**定义和存储仿真的运行时参数变量**。
|
|
6
|
+
|
|
7
|
+
**生成器类型**: 自包含生成器(硬编码模板)
|
|
8
|
+
**输出文件**: `Simulation_data.F90`
|
|
9
|
+
**输出位置**: `SimulationMain/<SetupName>/Simulation_data.F90`
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Simulation_data.F90 文件结构
|
|
14
|
+
|
|
15
|
+
### 标准格式
|
|
16
|
+
|
|
17
|
+
```fortran
|
|
18
|
+
!!****if* source/Simulation/SimulationMain/<SetupName>/Simulation_data
|
|
19
|
+
!!
|
|
20
|
+
!! NAME
|
|
21
|
+
!! Simulation_data
|
|
22
|
+
!!
|
|
23
|
+
!! SYNOPSIS
|
|
24
|
+
!! Use Simulation_data
|
|
25
|
+
!!
|
|
26
|
+
!! DESCRIPTION
|
|
27
|
+
!! Stores the local data for Simulation setup: <SetupName>
|
|
28
|
+
!!
|
|
29
|
+
!! PARAMETERS
|
|
30
|
+
!! <参数说明>
|
|
31
|
+
!!
|
|
32
|
+
!!***
|
|
33
|
+
|
|
34
|
+
module Simulation_data
|
|
35
|
+
|
|
36
|
+
implicit none
|
|
37
|
+
#include "constants.h" ! 或 #include "Eos.h" 等
|
|
38
|
+
|
|
39
|
+
!! *** Runtime Parameters *** !!
|
|
40
|
+
real, save :: sim_param1, sim_param2
|
|
41
|
+
integer, save :: sim_intParam
|
|
42
|
+
logical, save :: sim_boolParam
|
|
43
|
+
|
|
44
|
+
!! *** Variables pertaining to this Simulation *** !!
|
|
45
|
+
integer, parameter :: sim_nProfile = 1000
|
|
46
|
+
real, dimension(sim_nProfile), save :: sim_rProf, sim_rhoProf
|
|
47
|
+
|
|
48
|
+
end module Simulation_data
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 参数分类(基于 139 个 refs 示例)
|
|
54
|
+
|
|
55
|
+
### 1. 通用参数(几乎所有仿真)
|
|
56
|
+
|
|
57
|
+
| 参数名 | 类型 | 说明 |
|
|
58
|
+
|--------|------|------|
|
|
59
|
+
| `sim_smallX` | real | 最小物质分数 |
|
|
60
|
+
| `sim_smallRho` | real | 最小密度 |
|
|
61
|
+
| `sim_smallP` | real | 最小压力 |
|
|
62
|
+
| `sim_pi` | real | π 常数 |
|
|
63
|
+
| `sim_meshMe` | integer | MPI 进程 ID |
|
|
64
|
+
| `sim_killdivb` | logical | 是否清除磁场散度 |
|
|
65
|
+
|
|
66
|
+
### 2. 域定义参数
|
|
67
|
+
|
|
68
|
+
| 参数名 | 类型 | 说明 |
|
|
69
|
+
|--------|------|------|
|
|
70
|
+
| `sim_xMin`, `sim_xMax` | real | X 轴范围 |
|
|
71
|
+
| `sim_yMin`, `sim_yMax` | real | Y 轴范围 |
|
|
72
|
+
| `sim_zMin`, `sim_zMax` | real | Z 轴范围 |
|
|
73
|
+
| `sim_Lx`, `sim_Ly`, `sim_Lz` | real | 域长度 |
|
|
74
|
+
| `sim_initGeom` | character | 初始几何类型 |
|
|
75
|
+
|
|
76
|
+
### 3. 流体仿真参数
|
|
77
|
+
|
|
78
|
+
#### 3.1 欧拉流体(Hydro)
|
|
79
|
+
|
|
80
|
+
| 参数名 | 说明 |
|
|
81
|
+
|--------|------|
|
|
82
|
+
| `sim_rhoAmbient` | 环境密度 |
|
|
83
|
+
| `sim_pAmbient` | 环境压力 |
|
|
84
|
+
| `sim_gamma` | 绝热指数 |
|
|
85
|
+
| `sim_expEnergy` | 爆炸能量(Sedov) |
|
|
86
|
+
| `sim_rInit` | 初始激波位置 |
|
|
87
|
+
|
|
88
|
+
#### 3.2 磁流体(MHD)
|
|
89
|
+
|
|
90
|
+
| 参数名 | 说明 |
|
|
91
|
+
|--------|------|
|
|
92
|
+
| `sim_BxAmbient` | X 方向环境磁场 |
|
|
93
|
+
| `sim_betaAmbient` | 环境等离子体 β |
|
|
94
|
+
| `sim_neAmbient` | 环境电子密度 |
|
|
95
|
+
| `sim_dBPert` | 磁场扰动幅度 |
|
|
96
|
+
| `sim_modeNumb` | 波模数 |
|
|
97
|
+
|
|
98
|
+
### 4. 激光-等离子体参数(LaserSlab 系列)
|
|
99
|
+
|
|
100
|
+
| 参数名 | 说明 |
|
|
101
|
+
|--------|------|
|
|
102
|
+
| `sim_rhoTarg` | 靶密度 |
|
|
103
|
+
| `sim_teleTarg` | 靶电子温度 |
|
|
104
|
+
| `sim_tionTarg` | 靶离子温度 |
|
|
105
|
+
| `sim_tradTarg` | 靶辐射温度 |
|
|
106
|
+
| `sim_eosTarg` | 靶 EOS 类型 |
|
|
107
|
+
| `sim_rhoCham` | 腔密度 |
|
|
108
|
+
| `sim_teleCham` | 腔电子温度 |
|
|
109
|
+
| `sim_targetRadius` | 靶半径 |
|
|
110
|
+
| `sim_targetHeight` | 靶高度 |
|
|
111
|
+
| `sim_vacuumHeight` | 真空区域高度 |
|
|
112
|
+
|
|
113
|
+
### 5. 辐射流体参数(RadSlab 等)
|
|
114
|
+
|
|
115
|
+
| 参数名 | 说明 |
|
|
116
|
+
|--------|------|
|
|
117
|
+
| `sim_radSourceType` | 辐射源类型 |
|
|
118
|
+
| `sim_radSourceTMax` | 辐射源最大时间 |
|
|
119
|
+
| `sim_radSourcePeak` | 辐射源峰值 |
|
|
120
|
+
| `sim_radSourceFWHM` | 辐射源半高宽 |
|
|
121
|
+
| `sim_nGroups` | 辐射能群数量 |
|
|
122
|
+
| `sim_mgdDomainBC` | 多群边界条件 |
|
|
123
|
+
|
|
124
|
+
### 6. 重力/天体物理参数
|
|
125
|
+
|
|
126
|
+
| 参数名 | 说明 |
|
|
127
|
+
|--------|------|
|
|
128
|
+
| `sim_boltz` | 玻尔兹曼常数 |
|
|
129
|
+
| `sim_mH` | 氢原子质量 |
|
|
130
|
+
| `sim_newt` | 万有引力常数 |
|
|
131
|
+
| `sim_absErrMax` | 绝对误差上限 |
|
|
132
|
+
| `sim_relErrMax` | 相对误差上限 |
|
|
133
|
+
|
|
134
|
+
### 7. EOS 相关参数
|
|
135
|
+
|
|
136
|
+
| 参数名 | 说明 |
|
|
137
|
+
|--------|------|
|
|
138
|
+
| `sim_eosArr` | EOS 参数数组 |
|
|
139
|
+
| `sim_vecLen` | 向量长度 |
|
|
140
|
+
| `sim_mode` | EOS 模式 |
|
|
141
|
+
| `sim_abar_1`, `sim_abar_2` | 平均原子量 |
|
|
142
|
+
| `sim_gamma_1`, `sim_gamma_2` | 绝热指数 |
|
|
143
|
+
|
|
144
|
+
### 8. 剖面数据数组(用于复杂初始条件)
|
|
145
|
+
|
|
146
|
+
```fortran
|
|
147
|
+
integer, parameter :: sim_nProfile = 1000
|
|
148
|
+
real, dimension(sim_nProfile), save :: sim_rProf ! 径向坐标
|
|
149
|
+
real, dimension(sim_nProfile), save :: sim_rhoProf ! 密度剖面
|
|
150
|
+
real, dimension(sim_nProfile), save :: sim_pProf ! 压力剖面
|
|
151
|
+
real, dimension(sim_nProfile), save :: sim_vProf ! 速度剖面
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 生成器 API
|
|
157
|
+
|
|
158
|
+
### 当前实现(硬编码模板)
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from gen_sim_data import SimDataGenerator
|
|
162
|
+
|
|
163
|
+
generator = SimDataGenerator()
|
|
164
|
+
content = generator.generate() # 返回 LaserSlab1d 模板
|
|
165
|
+
generator.save("path/to/Simulation_data.F90")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 模板来源
|
|
169
|
+
|
|
170
|
+
当前模板从 `LaserSlab1d/Simulation_data.F90` 提取,包含:
|
|
171
|
+
- 靶参数(`sim_rhoTarg`, `sim_teleTarg` 等)
|
|
172
|
+
- 腔参数(`sim_rhoCham`, `sim_teleCham` 等)
|
|
173
|
+
- 几何参数(`sim_targetRadius`, `sim_initGeom` 等)
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 扩展生成器(未来工作)
|
|
178
|
+
|
|
179
|
+
当前生成器使用单一硬编码模板。如果需要支持多种仿真类型,可以扩展为:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
class SimDataGenerator:
|
|
183
|
+
TEMPLATES = {
|
|
184
|
+
"LaserSlab": "...", # 激光等离子体模板
|
|
185
|
+
"Sedov": "...", # Sedov 爆炸模板
|
|
186
|
+
"MHD": "...", # 磁流体模板
|
|
187
|
+
"RadHydro": "...", # 辐射流体模板
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
def generate(self, setup_type: str = "LaserSlab", **params):
|
|
191
|
+
"""根据 setup_type 选择模板并填充参数。"""
|
|
192
|
+
template = self.TEMPLATES[setup_type]
|
|
193
|
+
return template.format(**params)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 使用示例
|
|
199
|
+
|
|
200
|
+
### 示例 1:生成 LaserSlab 的 Simulation_data.F90
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
from physimx_sim.flash.input_gen.gen_sim_data import SimDataGenerator
|
|
204
|
+
|
|
205
|
+
generator = SimDataGenerator()
|
|
206
|
+
output_path = generator.save(
|
|
207
|
+
"FLASH4.8/source/Simulation/SimulationMain/LaserSlab1d/Simulation_data.F90"
|
|
208
|
+
)
|
|
209
|
+
print(f"Generated: {output_path}")
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### 示例 2:典型 Simulation_data.F90 内容(LaserSlab)
|
|
213
|
+
|
|
214
|
+
```fortran
|
|
215
|
+
module Simulation_data
|
|
216
|
+
|
|
217
|
+
implicit none
|
|
218
|
+
#include "constants.h"
|
|
219
|
+
|
|
220
|
+
!! *** Runtime Parameters *** !!
|
|
221
|
+
real, save :: sim_targetRadius
|
|
222
|
+
real, save :: sim_targetHeight
|
|
223
|
+
real, save :: sim_vacuumHeight
|
|
224
|
+
|
|
225
|
+
real, save :: sim_rhoTarg
|
|
226
|
+
real, save :: sim_teleTarg
|
|
227
|
+
real, save :: sim_tionTarg
|
|
228
|
+
real, save :: sim_tradTarg
|
|
229
|
+
real, save :: sim_zminTarg
|
|
230
|
+
integer, save :: sim_eosTarg
|
|
231
|
+
|
|
232
|
+
real, save :: sim_rhoCham
|
|
233
|
+
real, save :: sim_teleCham
|
|
234
|
+
real, save :: sim_tionCham
|
|
235
|
+
real, save :: sim_tradCham
|
|
236
|
+
integer, save :: sim_eosCham
|
|
237
|
+
|
|
238
|
+
logical, save :: sim_killdivb = .FALSE.
|
|
239
|
+
real, save :: sim_smallX
|
|
240
|
+
character(len=MAX_STRING_LENGTH), save :: sim_initGeom
|
|
241
|
+
|
|
242
|
+
end module Simulation_data
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## 与其他生成器的关系
|
|
248
|
+
|
|
249
|
+
`Simulation_data.F90` 通常与以下文件配合使用:
|
|
250
|
+
|
|
251
|
+
| 文件 | 生成器 | 关系 |
|
|
252
|
+
|------|--------|------|
|
|
253
|
+
| `Config` | `gen_config` | 定义运行时参数默认值 |
|
|
254
|
+
| `Simulation_init.F90` | `gen_sim_init` | 读取 Config 参数并初始化 Simulation_data |
|
|
255
|
+
| `Simulation_initBlock.F90` | `gen_sim_initblock` | 使用 Simulation_data 中的参数设置初始条件 |
|
|
256
|
+
| `example.par` | `gen_par` | 设置仿真参数(部分参数与 Simulation_data 对应) |
|
|
257
|
+
|
|
258
|
+
**重要**: `Config` 中定义的参数会在仿真启动时读入,然后在 `Simulation_init.F90` 中存储到 `Simulation_data` 模块的变量中。
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 常见仿真类型的 Simulation_data 示例
|
|
263
|
+
|
|
264
|
+
### 1. LaserSlab(激光等离子体)
|
|
265
|
+
|
|
266
|
+
**文件**: `refs/Simulation_data (10).F90`, `(50).F90`, `(100).F90` 等
|
|
267
|
+
**关键参数**: `sim_rhoTarg`, `sim_teleTarg`, `sim_rhoCham`
|
|
268
|
+
|
|
269
|
+
### 2. Sedov(爆炸波)
|
|
270
|
+
|
|
271
|
+
**文件**: `refs/Simulation_data (113).F90` 等
|
|
272
|
+
**关键参数**: `sim_expEnergy`, `sim_rhoAmbient`, `sim_pAmbient`
|
|
273
|
+
|
|
274
|
+
### 3. MHD(磁流体)
|
|
275
|
+
|
|
276
|
+
**文件**: `refs/Simulation_data (10).F90` (HallWhistlerWaves)
|
|
277
|
+
**关键参数**: `sim_BxAmbient`, `sim_betaAmbient`, `sim_modeNumb`
|
|
278
|
+
|
|
279
|
+
### 4. 辐射流体(RadSlab)
|
|
280
|
+
|
|
281
|
+
**文件**: `refs/Simulation_data (100).F90`
|
|
282
|
+
**关键参数**: `sim_radSourceType`, `sim_nGroups`
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 注意事项
|
|
287
|
+
|
|
288
|
+
1. **参数命名约定**: 所有参数以 `sim_` 开头,后接驼峰命名(如 `sim_rhoTarg`)
|
|
289
|
+
2. **保存属性**: 所有变量必须使用 `save` 属性,确保在仿真过程中持久化
|
|
290
|
+
3. **include 文件**: 根据使用的 FLASH 模块选择 `#include "constants.h"` 或 `#include "Eos.h"`
|
|
291
|
+
4. **数组剖面**: 复杂初始条件可能需要 allocatable 数组存储剖面数据
|
|
292
|
+
5. **与 Config 同步**: `Simulation_data.F90` 中声明的变量必须在 `Config` 中有对应的运行时参数定义
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## 文件清单
|
|
297
|
+
|
|
298
|
+
- **生成器**: `gen_sim_data/generator.py`
|
|
299
|
+
- ** refs 示例**: `gen_sim_data/refs/Simulation_data (*).F90` (139 个)
|
|
300
|
+
- **输出文件**: `SimulationMain/<SetupName>/Simulation_data.F90`
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## 更新日期
|
|
305
|
+
|
|
306
|
+
2026-07-03
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Simulation_data.F90 文件生成器 (自包含)
|
|
3
|
+
═══════════════════════════════════════
|
|
4
|
+
|
|
5
|
+
内容从 LaserSlab1d/Simulation_data.F90 模板提取后硬编码。
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import List, Optional, Union
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
DEFAULT_SIM_DATA_F90 = """\
|
|
13
|
+
!!****if* source/Simulation/SimulationMain/LaserSlab/Simulation_data
|
|
14
|
+
!!
|
|
15
|
+
!! NAME
|
|
16
|
+
!! Simulation_data
|
|
17
|
+
!!
|
|
18
|
+
!! SYNOPSIS
|
|
19
|
+
!! Use Simulation_data
|
|
20
|
+
!!
|
|
21
|
+
!! DESCRIPTION
|
|
22
|
+
!!
|
|
23
|
+
!! Store the simulation data
|
|
24
|
+
!!
|
|
25
|
+
!!
|
|
26
|
+
!!***
|
|
27
|
+
module Simulation_data
|
|
28
|
+
|
|
29
|
+
implicit none
|
|
30
|
+
|
|
31
|
+
#include "constants.h"
|
|
32
|
+
|
|
33
|
+
!! *** Runtime Parameters *** !!
|
|
34
|
+
real, save :: sim_targetRadius
|
|
35
|
+
real, save :: sim_targetHeight
|
|
36
|
+
real, save :: sim_vacuumHeight
|
|
37
|
+
|
|
38
|
+
real, save :: sim_rhoTarg
|
|
39
|
+
real, save :: sim_teleTarg
|
|
40
|
+
real, save :: sim_tionTarg
|
|
41
|
+
real, save :: sim_tradTarg
|
|
42
|
+
real, save :: sim_zminTarg
|
|
43
|
+
integer, save :: sim_eosTarg
|
|
44
|
+
|
|
45
|
+
real, save :: sim_rhoCham
|
|
46
|
+
real, save :: sim_teleCham
|
|
47
|
+
real, save :: sim_tionCham
|
|
48
|
+
real, save :: sim_tradCham
|
|
49
|
+
integer, save :: sim_eosCham
|
|
50
|
+
|
|
51
|
+
logical, save :: sim_killdivb = .FALSE.
|
|
52
|
+
real, save :: sim_smallX
|
|
53
|
+
character(len=MAX_STRING_LENGTH), save :: sim_initGeom
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
end module Simulation_data
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class SimDataGenerator:
|
|
61
|
+
"""Simulation_data.F90 文件生成器 (自包含)。
|
|
62
|
+
|
|
63
|
+
内容从 LaserSlab1d/Simulation_data.F90 提取并硬编码。
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def generate(self, species: Optional[List[str]] = None) -> str:
|
|
67
|
+
"""生成 Simulation_data.F90 内容。
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
species: species 列表(预留,暂不处理)
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
Simulation_data.F90 内容字符串
|
|
74
|
+
"""
|
|
75
|
+
return DEFAULT_SIM_DATA_F90
|
|
76
|
+
|
|
77
|
+
def save(
|
|
78
|
+
self,
|
|
79
|
+
output_path: Union[str, Path],
|
|
80
|
+
species: Optional[List[str]] = None,
|
|
81
|
+
) -> Path:
|
|
82
|
+
"""生成并保存 Simulation_data.F90。"""
|
|
83
|
+
content = self.generate(species=species)
|
|
84
|
+
out = Path(output_path)
|
|
85
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
86
|
+
out.write_text(content, encoding="utf-8")
|
|
87
|
+
return out
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# gen_sim_init — Simulation_init.F90 生成器说明文档
|
|
2
|
+
|
|
3
|
+
## 目录
|
|
4
|
+
1. [概述](#概述)
|
|
5
|
+
2. [Simulation_init.F90 文件格式](#simulation_initf90-文件格式)
|
|
6
|
+
3. [gen_sim_init 生成器 API](#gen_sim_init-生成器-api)
|
|
7
|
+
4. [使用示例](#使用示例)
|
|
8
|
+
5. [参考示例 (refs/)](#参考示例-refs)
|
|
9
|
+
6. [常见问题](#常见问题)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 概述
|
|
14
|
+
|
|
15
|
+
`gen_sim_init` 子包用于生成 FLASH 仿真的 `Simulation_init.F90` 文件。这个Fortran子程序初始化仿真参数,从 `.par` 文件中读取运行时参数并存储在模块变量中。
|
|
16
|
+
|
|
17
|
+
**生成器类型**: 自包含(硬编码默认模板)
|
|
18
|
+
**默认模板来源**: `SimulationMain/LaserSlab/Simulation_init.F90`
|
|
19
|
+
**输出文件**: `Simulation_init.F90`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Simulation_init.F90 文件格式
|
|
24
|
+
|
|
25
|
+
### 基本结构
|
|
26
|
+
|
|
27
|
+
```fortran
|
|
28
|
+
!!****if* source/Simulation/SimulationMain/LaserSlab/Simulation_init
|
|
29
|
+
!!
|
|
30
|
+
!! NAME
|
|
31
|
+
!!
|
|
32
|
+
!! Simulation_init
|
|
33
|
+
!!
|
|
34
|
+
!! SYNOPSIS
|
|
35
|
+
!!
|
|
36
|
+
!! Simulation_init()
|
|
37
|
+
!!
|
|
38
|
+
!! DESCRIPTION
|
|
39
|
+
!!
|
|
40
|
+
!! Initializes all the parameters needed for a particular simulation
|
|
41
|
+
!!
|
|
42
|
+
!! PARAMETERS
|
|
43
|
+
!!
|
|
44
|
+
!!***
|
|
45
|
+
|
|
46
|
+
subroutine Simulation_init()
|
|
47
|
+
use Simulation_data
|
|
48
|
+
use RuntimeParameters_interface, ONLY : RuntimeParameters_get
|
|
49
|
+
|
|
50
|
+
implicit none
|
|
51
|
+
|
|
52
|
+
#include "constants.h"
|
|
53
|
+
#include "Flash.h"
|
|
54
|
+
|
|
55
|
+
! 读取运行时参数
|
|
56
|
+
call RuntimeParameters_get('sim_targetRadius', sim_targetRadius)
|
|
57
|
+
call RuntimeParameters_get('sim_rhoTarg', sim_rhoTarg)
|
|
58
|
+
! ...
|
|
59
|
+
|
|
60
|
+
end subroutine Simulation_init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 关键部分
|
|
64
|
+
|
|
65
|
+
1. **头注释**: 遵循FLASH文档规范
|
|
66
|
+
2. **use声明**: 引入需要的模块
|
|
67
|
+
3. **参数读取**: 使用 `RuntimeParameters_get` 读取 `.par` 文件中的参数
|
|
68
|
+
4. **初始化逻辑**: 可选的特殊初始化代码
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## gen_sim_init 生成器 API
|
|
73
|
+
|
|
74
|
+
### 类: SimInitGenerator
|
|
75
|
+
|
|
76
|
+
**位置**: `gen_sim_init/generator.py`
|
|
77
|
+
|
|
78
|
+
### 方法: generate(params)
|
|
79
|
+
|
|
80
|
+
生成 `Simulation_init.F90` 内容。
|
|
81
|
+
|
|
82
|
+
**签名**:
|
|
83
|
+
```python
|
|
84
|
+
def generate(self, params: Optional[Dict[str, Any]] = None) -> str:
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**参数**:
|
|
88
|
+
- `params`: 可选参数字典(预留,当前未使用)
|
|
89
|
+
|
|
90
|
+
**返回**: Fortran源代码字符串
|
|
91
|
+
|
|
92
|
+
### 方法: save(output_path, params)
|
|
93
|
+
|
|
94
|
+
生成并保存文件。
|
|
95
|
+
|
|
96
|
+
**签名**:
|
|
97
|
+
```python
|
|
98
|
+
def save(
|
|
99
|
+
self,
|
|
100
|
+
output_path: Union[str, Path],
|
|
101
|
+
params: Optional[Dict[str, Any]] = None,
|
|
102
|
+
) -> Path:
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 使用示例
|
|
108
|
+
|
|
109
|
+
### 示例 1: 生成默认 Simulation_init.F90
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from gen_sim_init import SimInitGenerator
|
|
113
|
+
|
|
114
|
+
generator = SimInitGenerator()
|
|
115
|
+
|
|
116
|
+
# 生成默认内容(基于LaserSlab模板)
|
|
117
|
+
content = generator.generate()
|
|
118
|
+
|
|
119
|
+
# 保存
|
|
120
|
+
output_path = generator.save("path/to/Simulation/Simulation_init.F90")
|
|
121
|
+
print(f"Saved to: {output_path}")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 示例 2: 自定义 Simulation_init.F90(高级)
|
|
125
|
+
|
|
126
|
+
当前生成器使用硬编码模板。如需自定义,可以修改生成的字符串:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
generator = SimInitGenerator()
|
|
130
|
+
|
|
131
|
+
# 生成默认内容
|
|
132
|
+
content = generator.generate()
|
|
133
|
+
|
|
134
|
+
# 修改内容(例如,添加自定义参数读取)
|
|
135
|
+
custom_lines = """
|
|
136
|
+
! 读取自定义参数
|
|
137
|
+
call RuntimeParameters_get('my_custom_param', my_custom_param)
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
# 在 "implicit none" 之后插入
|
|
141
|
+
lines = content.split("\n")
|
|
142
|
+
insert_idx = 0
|
|
143
|
+
for i, line in enumerate(lines):
|
|
144
|
+
if "implicit none" in line:
|
|
145
|
+
insert_idx = i + 1
|
|
146
|
+
break
|
|
147
|
+
lines.insert(insert_idx, custom_lines)
|
|
148
|
+
content = "\n".join(lines)
|
|
149
|
+
|
|
150
|
+
# 保存
|
|
151
|
+
with open("path/to/Simulation/Simulation_init.F90", "w") as f:
|
|
152
|
+
f.write(content)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 参考示例 (refs/)
|
|
158
|
+
|
|
159
|
+
`gen_sim_init/refs/` 目录包含 143+ 个 `Simulation_init.F90` 示例,来自不同的FLASH仿真。
|
|
160
|
+
|
|
161
|
+
### 主要示例
|
|
162
|
+
|
|
163
|
+
| 示例 | 描述 |
|
|
164
|
+
|------|------|
|
|
165
|
+
| `Simulation_init.F90` | 基础LaserSlab版本 |
|
|
166
|
+
| `Simulation_init (10).F90` ... | 各种变体 |
|
|
167
|
+
|
|
168
|
+
### 如何参考这些示例
|
|
169
|
+
|
|
170
|
+
1. **查看示例**: 直接读取 `refs/` 中的文件
|
|
171
|
+
2. **了解初始化模式**: 不同仿真如何读取和初始化参数
|
|
172
|
+
3. **提取关键代码**: 复制需要的代码片段
|
|
173
|
+
|
|
174
|
+
**示例**: 参考 Sod 的 `Simulation_init.F90`
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
cat gen_sim_init/refs/Simulation_init.F90 | head -50
|
|
178
|
+
|
|
179
|
+
# 提取关键部分:
|
|
180
|
+
# - 如何读取左右状态参数
|
|
181
|
+
# - 如何设置初始条件
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 常见问题
|
|
187
|
+
|
|
188
|
+
### 1. 如何为新的仿真类型生成 Simulation_init.F90?
|
|
189
|
+
|
|
190
|
+
**答**: 当前生成器使用硬编码的LaserSlab模板。如需其他类型:
|
|
191
|
+
1. 生成默认版本
|
|
192
|
+
2. 手动修改以匹配目标仿真的初始化需求
|
|
193
|
+
3. 或将需要的示例复制到 `refs/` 目录,并扩展生成器
|
|
194
|
+
|
|
195
|
+
### 2. Simulation_init.F90 和 Simulation_initBlock.F90 有什么区别?
|
|
196
|
+
|
|
197
|
+
**答**:
|
|
198
|
+
- `Simulation_init.F90`: 初始化仿真级参数(一次)
|
|
199
|
+
- `Simulation_initBlock.F90`: 初始化每个块的流体数据(每个块调用一次)
|
|
200
|
+
|
|
201
|
+
### 3. 如何验证生成的 Fortran 代码是否正确?
|
|
202
|
+
|
|
203
|
+
**答**: 使用FLASH编译:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
cd /path/to/FLASH4.8
|
|
207
|
+
make
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
如果Fortran代码有语法错误,编译时会报错。
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
**文档版本**: 1.0
|
|
215
|
+
**最后更新**: 2026-07-03
|
|
216
|
+
**维护**: PhySimX Team
|