excel-codegen 0.9.0__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.
Files changed (82) hide show
  1. excel_codegen/__init__.py +160 -0
  2. excel_codegen/__main__.py +8 -0
  3. excel_codegen/cli.py +1250 -0
  4. excel_codegen/derived.py +465 -0
  5. excel_codegen/example_pack.py +107 -0
  6. excel_codegen/examples/README.md +69 -0
  7. excel_codegen/examples/abs_fpi/ABS_FPI_load_cases.xlsx +0 -0
  8. excel_codegen/examples/abs_fpi/ABS_FPI_load_cases_render.bat +22 -0
  9. excel_codegen/examples/abs_fpi/ABS_FPI_load_cases_render.sh +23 -0
  10. excel_codegen/examples/abs_fpi/README.md +121 -0
  11. excel_codegen/examples/abs_fpi/abs_fpi.yaml +310 -0
  12. excel_codegen/examples/abs_fpi/abs_fpi_external.xlsx +0 -0
  13. excel_codegen/examples/abs_fpi/abs_fpi_external.yaml +162 -0
  14. excel_codegen/examples/abs_fpi/abs_fpi_external_render.bat +22 -0
  15. excel_codegen/examples/abs_fpi/abs_fpi_external_render.sh +23 -0
  16. excel_codegen/examples/abs_fpi/abs_fpi_internal.xlsx +0 -0
  17. excel_codegen/examples/abs_fpi/abs_fpi_internal.yaml +266 -0
  18. excel_codegen/examples/abs_fpi/abs_fpi_internal_render.bat +22 -0
  19. excel_codegen/examples/abs_fpi/abs_fpi_internal_render.sh +23 -0
  20. excel_codegen/examples/abs_fpi/compose.yaml +20 -0
  21. excel_codegen/examples/abs_fpi/generated/COT1-d20.559-mu60.js +124 -0
  22. excel_codegen/examples/abs_fpi/generated/COT1-d20.559-mu60_summary.md +30 -0
  23. excel_codegen/examples/abs_fpi/generated/EXT-T15-mu0-kf-1.js +91 -0
  24. excel_codegen/examples/abs_fpi/generated/EXT-T15-mu0-kf-1_summary.md +23 -0
  25. excel_codegen/examples/abs_fpi/generated/EXT-T15-mu90-kf+1.js +91 -0
  26. excel_codegen/examples/abs_fpi/generated/EXT-T15-mu90-kf+1_summary.md +23 -0
  27. excel_codegen/examples/abs_fpi/generated/EXT-T20.559-mu90-kf+1.js +91 -0
  28. excel_codegen/examples/abs_fpi/generated/EXT-T20.559-mu90-kf+1_summary.md +23 -0
  29. excel_codegen/examples/abs_fpi/generated/WBT6-d15.059-mu0.js +124 -0
  30. excel_codegen/examples/abs_fpi/generated/WBT6-d15.059-mu0_summary.md +30 -0
  31. excel_codegen/examples/abs_fpi/generated/WBT6-d8-mu90.js +124 -0
  32. excel_codegen/examples/abs_fpi/generated/WBT6-d8-mu90_summary.md +30 -0
  33. excel_codegen/examples/abs_fpi/generated/WBT7-d20.559-mu90.js +124 -0
  34. excel_codegen/examples/abs_fpi/generated/WBT7-d20.559-mu90_summary.md +30 -0
  35. excel_codegen/examples/abs_fpi/templates/ext_body.js.j2 +91 -0
  36. excel_codegen/examples/abs_fpi/templates/ext_summary.md.j2 +23 -0
  37. excel_codegen/examples/abs_fpi/templates/int_body.js.j2 +124 -0
  38. excel_codegen/examples/abs_fpi/templates/int_summary.md.j2 +30 -0
  39. excel_codegen/examples/basic/example.yaml +97 -0
  40. excel_codegen/examples/basic/example_formula.yaml +86 -0
  41. excel_codegen/examples/basic/generated/uart_init_Case1.c +6 -0
  42. excel_codegen/examples/basic/generated/uart_init_Case2.c +6 -0
  43. excel_codegen/examples/basic/generated/uart_summary_Case1.md +4 -0
  44. excel_codegen/examples/basic/generated/uart_summary_Case2.md +4 -0
  45. excel_codegen/examples/basic/generated_formula/uart_init_Case1.c +5 -0
  46. excel_codegen/examples/basic/generated_formula/uart_init_Case2.c +5 -0
  47. excel_codegen/examples/basic/generated_formula/uart_pins_Case1.csv +1 -0
  48. excel_codegen/examples/basic/generated_formula/uart_pins_Case2.csv +1 -0
  49. excel_codegen/examples/basic/template.xlsx +0 -0
  50. excel_codegen/examples/basic/template_formula.xlsx +0 -0
  51. excel_codegen/examples/basic/template_formula_render.bat +22 -0
  52. excel_codegen/examples/basic/template_formula_render.sh +23 -0
  53. excel_codegen/examples/basic/template_render.bat +22 -0
  54. excel_codegen/examples/basic/template_render.sh +23 -0
  55. excel_codegen/examples/nastran/generated/case_control.deck +18 -0
  56. excel_codegen/examples/nastran/generated/cc_01_LC1.inc +8 -0
  57. excel_codegen/examples/nastran/generated/cc_02_LC2.inc +8 -0
  58. excel_codegen/examples/nastran/generated/cc_03_LC3.inc +8 -0
  59. excel_codegen/examples/nastran/generated/cc_04_COMB4.inc +8 -0
  60. excel_codegen/examples/nastran/generated/cc_05_LC5.inc +8 -0
  61. excel_codegen/examples/nastran/generated/cc_summary_01_LC1.md +1 -0
  62. excel_codegen/examples/nastran/generated/cc_summary_02_LC2.md +1 -0
  63. excel_codegen/examples/nastran/generated/cc_summary_03_LC3.md +1 -0
  64. excel_codegen/examples/nastran/generated/cc_summary_04_COMB4.md +1 -0
  65. excel_codegen/examples/nastran/generated/cc_summary_05_LC5.md +1 -0
  66. excel_codegen/examples/nastran/nastran_case_control.xlsx +0 -0
  67. excel_codegen/examples/nastran/nastran_case_control.yaml +141 -0
  68. excel_codegen/examples/nastran/nastran_case_control_render.bat +22 -0
  69. excel_codegen/examples/nastran/nastran_case_control_render.sh +23 -0
  70. excel_codegen/excel_io.py +1885 -0
  71. excel_codegen/formula.py +674 -0
  72. excel_codegen/formula_eval.py +685 -0
  73. excel_codegen/jinja_env.py +92 -0
  74. excel_codegen/models.py +1008 -0
  75. excel_codegen/renderer.py +558 -0
  76. excel_codegen/utils.py +225 -0
  77. excel_codegen-0.9.0.dist-info/METADATA +179 -0
  78. excel_codegen-0.9.0.dist-info/RECORD +82 -0
  79. excel_codegen-0.9.0.dist-info/WHEEL +5 -0
  80. excel_codegen-0.9.0.dist-info/entry_points.txt +2 -0
  81. excel_codegen-0.9.0.dist-info/licenses/LICENSE +21 -0
  82. excel_codegen-0.9.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+ # ===========================================================================
3
+ # 由 excel_codegen 生成 —— 改完参数跑一次本文件即可把结果写回 Output 表。
4
+ # 重新生成工作簿(init)时会一并覆盖本文件。
5
+ # ===========================================================================
6
+ set -uo pipefail
7
+ cd "$(dirname "$0")"
8
+
9
+ if command -v uv >/dev/null 2>&1; then
10
+ uv run excel-codegen render -c "abs_fpi.yaml" -x "ABS_FPI_load_cases.xlsx" --write-excel
11
+ else
12
+ excel-codegen render -c "abs_fpi.yaml" -x "ABS_FPI_load_cases.xlsx" --write-excel
13
+ fi
14
+ status=$?
15
+
16
+ echo
17
+ if [ "$status" -ne 0 ]; then
18
+ echo "[失败] 上面有报错信息。常见原因:依赖没装(跑一次 ./setup.sh 或 uv sync)、"
19
+ echo " 或者 Excel / WPS 正开着这个文件(先关掉再试)。"
20
+ else
21
+ echo "[完成] 回到 Excel 打开「Output」表看结果。"
22
+ fi
23
+ exit "$status"
@@ -0,0 +1,121 @@
1
+ # 现场用例:ABS FPI 内外压 → GeniE
2
+
3
+ 用 `excel_codegen` 生成 **GeniE 面载荷函数体**(ABS FPI 2025 Part 5A Ch.3 Sec.2 的内压与外压)。
4
+
5
+ **成品是一本 Excel**:在 `Global Parameter` / `Local Parameter` 表里填参数,`Code` 表里就是
6
+ 可以直接粘进 GeniE 的整段函数体 —— 而且是 **Excel 公式**,改参数后 Excel / WPS 打开即重算,
7
+ **不需要跑任何脚本**。
8
+
9
+ ```
10
+ function(x, y, z) {
11
+ // 把 Code 表某一列的内容粘在这里
12
+ }
13
+ ```
14
+
15
+ 或整段函数交给 `Pressure2dJavascript(userFunction, refinement, positionSystem)`
16
+ (GeniE Help 8.12,8. Loads → 8.1.3.3 Intensity/Pressure,Javascript 项)。
17
+ GeniE 会对被加载面的**每一个离散点**调用它,所以 x/y/z 是当前加载点。
18
+
19
+ > 这是随包发布的**示例**。开发侧的现场脚本、探针与逐轮实测报告在仓库根的
20
+ > [`abs_fpi/`](../../../abs_fpi/)(不进包)。
21
+
22
+ ---
23
+
24
+ ## 1. 三本工作簿
25
+
26
+ | 工作簿 | 内容 | 工况 |
27
+ |---|---|---|
28
+ | `abs_fpi_external.xlsx` | 外压 5A-3-2/5.5 单用 | 3 |
29
+ | `abs_fpi_internal.xlsx` | 内压 5A-3-2/5.7 单用 | 4 |
30
+ | `ABS_FPI_load_cases.xlsx` | **项目工作簿**:两套规则、**共用一张 Global 表**(主尺度只填一次) | 7 |
31
+
32
+ 打开任意一本就能改参数 —— 三本都已经填好样例数值。
33
+
34
+ 第三本由 `compose.yaml` 的配方把前两个规则集合并而成,用 `case_filter` 分流
35
+ (`genie_ext` 只对 `kind == 'EXT'` 的工况出代码,`genie_int` 只对 `INT`),
36
+ 输出表分成 `Code EXT` / `Summary EXT` / `Code INT` / `Summary INT`。
37
+
38
+ 后两本还有一张 **`Tank Data` 成员表**:一行一个舱(WBT6 / WBT7 / COT1),
39
+ B 列起一个变量一列。舱的参数只写一遍,工况用 `tank_ref` 指向它(指南 §18)。
40
+
41
+ ## 2. 怎么用
42
+
43
+ ```bash
44
+ # 打开工作簿改参数即可;要把代码导出成文件时:
45
+ excel-codegen render -c abs_fpi_internal.yaml -x abs_fpi_internal.xlsx --outdir generated
46
+
47
+ # 核对「Excel 里算出来的」与「Python 渲染的」是否一致:
48
+ excel-codegen check -c abs_fpi_internal.yaml -x abs_fpi_internal.xlsx
49
+
50
+ # 改了模板 / YAML 之后,要把新公式写回 Excel:
51
+ excel-codegen render -c abs_fpi_internal.yaml -x abs_fpi_internal.xlsx --write-excel
52
+ ```
53
+
54
+ 同目录的 `*_render.bat`(Windows 双击)/ `*_render.sh` 就是最后一条命令。
55
+
56
+ ## 3. 公式模式:什么免重跑、什么不免
57
+
58
+ **改参数** → 免重跑。打开 Excel 就重算(写公式时同时设了 `fullCalcOnLoad`)。
59
+
60
+ **改模板 / YAML** → 要重跑 `--write-excel`(公式是写进格子的文本,得刷新一遍)。
61
+
62
+ **改结构** → 分两种,都实测过:
63
+
64
+ | 动作 | 结果 |
65
+ |---|---|
66
+ | 插 / 删 **变量行** | ✅ 不用重跑。公式用 `INDEX/MATCH` **按变量名**定位,插行不指错 |
67
+ | 增 / 删 / 移动 **Case 列** | ❌ 必须重跑。公式里的列标是绝对字母,工况一移位就指着别的工况了 |
68
+ | 改 **Tank Data** 里的舱数据 | ✅ 不用重跑。公式按"Case → `tank_ref` → 成员行 → 变量列"两级 `INDEX/MATCH` 定位 |
69
+ | 增 / 删 **Tank Data** 的成员行 | ✅ 不用重跑(同上,按成员名 `MATCH` 找行) |
70
+
71
+ 顺带一个坑:**手加 Case 列时一定要填 `kind`**。留空会回落 `default`(本例是 `EXT`),
72
+ 于是这一列会**悄悄进外压规则集**。
73
+
74
+ ## 4. 生成物长什么样
75
+
76
+ `generated/EXT-T20.559-mu90-kf+1.js`:
77
+
78
+ ```javascript
79
+ // EXT-T20.559-mu90-kf+1
80
+ var t1 = x;
81
+ var t2 = y;
82
+ var t3 = z;
83
+ x = t1;
84
+ y = t2;
85
+ z = t3;
86
+ // --- global parameters (same for every case)
87
+ var L = 340 m;
88
+ ...
89
+ var p_s = Math.max(rho_sea * g * (draft - z), 0 Pa); // still-water pressure, ...
90
+ var p_d = rho_sea * g * ESF_side * k_u * h_de; // hydrodynamic pressure, ...
91
+ return Math.max(p_s + p_d, 0 Pa); // the pressure the function returns
92
+ ```
93
+
94
+ 坐标映射由 6 个变量纯替换而成(`x = {{ neg_x }}t{{ ax_x }};`),
95
+ 所以**公式模式也能表达**:把 `ax_y` 填 `3`、`neg_z` 填 `-` 再打开 Excel,
96
+ 变换语句立刻变成 `y = t3; z = -t2;`。
97
+
98
+ > 恒等映射下这 3 行是空操作(`x = t1;`),仍然会输出 —— 公式模式没有条件,
99
+ > 没法"恒等就不输出"。GeniE 侧无副作用。
100
+
101
+ ## 5. 已知边界
102
+
103
+ - **`case_filter` 的 Case 必须成块连续**(公式模式横向相对列靠恒定偏移),
104
+ 所以项目工作簿里 EXT 的工况在前、INT 的工况在后。
105
+ - **公式的 `TEXT()` 格式串受区域设置影响**:中文/英文区域小数点是 `.`;
106
+ 换到欧洲区域(`,`)之前要重验一遍。
107
+ - **公式值只活在 Excel / WPS 里**:`--outdir` 导出的文件由 Python 渲染(内容等价,
108
+ 因为模板是纯替换),但"改参数自动同步文件"做不到,要再跑一次 `render`。
109
+
110
+ ## 6. 这个目录里有什么
111
+
112
+ | 文件 | 作用 |
113
+ |---|---|
114
+ | `abs_fpi_external.yaml` / `abs_fpi_internal.yaml` | 两个规则集真源(变量 + 模板声明) |
115
+ | `abs_fpi.yaml` | 项目工作簿 YAML(由 `compose.yaml` 的配方合并生成) |
116
+ | `compose.yaml` | 合并配方:把哪些规则集并进一本、各自用什么 `case_filter` |
117
+ | `templates/*.j2` | GeniE 函数体与摘要模板 |
118
+ | `generated/` | 导出产物(提交进仓库的实测结果,可用来对照) |
119
+ | `*.xlsx` | 三本已经填好样例参数的工作簿 |
120
+
121
+ > 用例里的舱容与工况组合只是**示意数值**(随手取的几个数),不代表任何真实船舶。
@@ -0,0 +1,310 @@
1
+ # =========================================================================== #
2
+ # 本文件由 compose.py 生成,请不要手改 —— 改了会在下次 compose 时被覆盖。
3
+ #
4
+ # 真源是各规则集 YAML(见 compose.yaml 的 rulesets):
5
+ # - abs_fpi_external.yaml
6
+ # - abs_fpi_internal.yaml
7
+ # 改参数请改工作簿;加规则集请加规则集 YAML 再跑 python compose.py。
8
+ # =========================================================================== #
9
+ version: 1
10
+ excel:
11
+ output: ABS_FPI_load_cases.xlsx
12
+ template_sheet: Template
13
+ howto_sheet: HOWTO
14
+ sheets:
15
+ global: Global Parameter
16
+ local: Local Parameter
17
+ outputs:
18
+ - Code EXT
19
+ - Summary EXT
20
+ - Code INT
21
+ - Summary INT
22
+ variables:
23
+ global:
24
+ - name: L
25
+ description: 规范船长 [m](3-1-1/3);同时驱动 C_1 / k_lo / k_f
26
+ default: 340
27
+ type: float
28
+ suffix: ' m'
29
+ - name: B
30
+ description: 规范型宽 [m];B/2 决定舭部位置
31
+ default: 64
32
+ type: float
33
+ suffix: ' m'
34
+ - name: D
35
+ description: 规范型深 [m](基线到甲板)
36
+ default: 32
37
+ type: float
38
+ suffix: ' m'
39
+ - name: r_b
40
+ description: 舭圆半径 [m]:z_bilge = r_b,平底宽 = B/2 - r_b
41
+ default: 0.703
42
+ type: float
43
+ suffix: ' m'
44
+ - name: freeboard
45
+ description: 甲板边线在载重线以上的余量 [m];Fig. 10 的截断高度用它算
46
+ default: 0.5
47
+ type: float
48
+ suffix: ' m'
49
+ - name: rho_sea
50
+ description: 海水密度 [kg/m^3];规范下限 1.005 N/cm^2-m 即 1025 kg/m^3
51
+ default: 1025
52
+ type: float
53
+ suffix: ' kg/m^3'
54
+ - name: g
55
+ description: 重力加速度 [m/s^2]
56
+ default: 9.81
57
+ type: float
58
+ suffix: ' m/s^2'
59
+ - name: Cb
60
+ description: 方形系数 [-](3-1-1/13.3)
61
+ default: 1
62
+ type: float
63
+ - name: ax_x
64
+ description: 规范 x(自 AP)取自模型哪个轴:1=x, 2=y, 3=z
65
+ default: '1'
66
+ type: string
67
+ - name: ax_y
68
+ description: 规范 y(自中线,向右舷为正)取自模型哪个轴
69
+ default: '2'
70
+ type: string
71
+ - name: ax_z
72
+ description: 规范 z(基线以上,向上为正)取自模型哪个轴
73
+ default: '3'
74
+ type: string
75
+ - name: neg_x
76
+ description: 规范 x 是否取反:填 - 表示取反,留空表示不取反
77
+ default: ''
78
+ type: string
79
+ - name: neg_y
80
+ description: 规范 y 是否取反:填 - 表示取反,留空表示不取反
81
+ default: ''
82
+ type: string
83
+ - name: neg_z
84
+ description: 规范 z 是否取反:填 - 表示取反,留空表示不取反
85
+ default: ''
86
+ type: string
87
+ - name: d_f
88
+ description: 结构吃水 [m];规范表按它给出,GM 四点表也按它插值
89
+ default: 20.559
90
+ type: float
91
+ suffix: ' m'
92
+ - name: rho_g_lo
93
+ description: k_s = 0.878 对应的 rho g [N/m^3](1.005 N/cm^2-m = 10050)
94
+ default: 10050
95
+ type: float
96
+ suffix: ' N/m^3'
97
+ - name: rho_g_hi
98
+ description: k_s 达到 1.0 的 rho g [N/m^3](1.118 N/cm^2-m = 11180)
99
+ default: 11180
100
+ type: float
101
+ suffix: ' N/m^3'
102
+ local:
103
+ - name: kind
104
+ description: 这个 Case 属于哪一套规则:EXT / INT(多规则集合用时用 case_filter 分流)
105
+ default: EXT
106
+ type: string
107
+ - name: draft
108
+ description: 工况吃水 [m];h_s = draft - z,负值截断为 0
109
+ default: 20.559
110
+ type: float
111
+ suffix: ' m'
112
+ - name: mu_deg
113
+ description: 浪向角 [deg],0 = 顶浪,90 = 右舷来浪(Table 1A D)
114
+ default: 90
115
+ type: float
116
+ suffix: ' deg'
117
+ - name: k_c
118
+ description: 组合工况相关系数 [-],进 h_de = k_c h_di(Table 1A B)
119
+ default: 1
120
+ type: float
121
+ - name: k_f0
122
+ description: 相位因子 +1 / -1 [-],决定参考站落在哪一端(Table 1A B)
123
+ default: 1
124
+ type: float
125
+ - name: k_u
126
+ description: 载荷系数 [-];规范默认 1.0,1.1 用于板与纵骨的工况
127
+ default: 1.1
128
+ type: float
129
+ - name: beta_EPS
130
+ description: 外压 ESF,右舷 [-](5A-3-A1/3)
131
+ default: 0.733
132
+ type: float
133
+ - name: beta_EPP
134
+ description: 外压 ESF,左舷 [-](5A-3-A1/3)
135
+ default: 0.733
136
+ type: float
137
+ - name: k_esf
138
+ description: 项目对 ESF 的分项系数 [-]
139
+ default: 1.1
140
+ type: float
141
+ - name: x_o
142
+ description: 参考站 [m],自 AP 量起(Fig. 9 脚注)
143
+ default: 51
144
+ type: float
145
+ suffix: ' m'
146
+ - name: beta_VAC
147
+ description: 垂向加速度 ESF [-](5A-3-A1/3)
148
+ default: 0.66
149
+ type: float
150
+ - name: beta_LAC
151
+ description: 纵向加速度 ESF [-]
152
+ default: 0.758
153
+ type: float
154
+ - name: beta_TAC
155
+ description: 横向加速度 ESF [-]
156
+ default: 0.557
157
+ type: float
158
+ - name: beta_PMO
159
+ description: 纵摇 ESF [-]
160
+ default: 0.686
161
+ type: float
162
+ - name: beta_RMO
163
+ description: 横摇 ESF [-]
164
+ default: 0.492
165
+ type: float
166
+ - name: w_v
167
+ description: 垂向加速度权重 [-](Table 1A B)
168
+ default: 0.75
169
+ type: float
170
+ - name: w_l
171
+ description: 纵向加速度权重 [-]
172
+ default: 0.25
173
+ type: float
174
+ - name: w_t
175
+ description: 横向加速度权重 [-]
176
+ default: 0.75
177
+ type: float
178
+ - name: xi
179
+ description: 舱长方向参考位置 [m](5.7.2(b))
180
+ default: 21
181
+ type: float
182
+ suffix: ' m'
183
+ - name: delta_b
184
+ description: 舱宽方向修正 [m](5.7.2(b));无则填 0
185
+ default: 0
186
+ type: float
187
+ suffix: ' m'
188
+ - name: delta_h
189
+ description: 舱高方向修正 [m](5.7.2(b));无则填 0
190
+ default: 0
191
+ type: float
192
+ suffix: ' m'
193
+ - name: tank_ref
194
+ description: 本 Case 用哪个舱(成员表的行名)
195
+ default: WBT6
196
+ type: string
197
+ choices:
198
+ - WBT6
199
+ - WBT7
200
+ - COT1
201
+ group:
202
+ sheet: Tank Data
203
+ key: tank_ref
204
+ members:
205
+ - WBT6
206
+ - WBT7
207
+ - COT1
208
+ variables:
209
+ - name: rho_tank
210
+ description: 舱内液体密度 [kg/m^3]
211
+ default: 1025
212
+ type: float
213
+ suffix: ' kg/m^3'
214
+ - name: l_tank
215
+ description: 舱长 [m](Fig. 11)
216
+ default: 42
217
+ type: float
218
+ suffix: ' m'
219
+ - name: b_tank
220
+ description: 舱宽 [m](Fig. 11)
221
+ default: 32
222
+ type: float
223
+ suffix: ' m'
224
+ - name: h_tank
225
+ description: 舱高 [m](Fig. 11)
226
+ default: 32
227
+ type: float
228
+ suffix: ' m'
229
+ - name: eta_deck
230
+ description: 甲板以上高度 [m]
231
+ default: 0
232
+ type: float
233
+ suffix: ' m'
234
+ - name: eta_overflow
235
+ description: 溢流管高度 [m];Fig. 12 要求取 2/3 且不低于 760 mm
236
+ default: 0
237
+ type: float
238
+ suffix: ' m'
239
+ - name: C_dp
240
+ description: 舱形系数 [-](5.7.2(d)):矩形 1.0,J 形 0.7
241
+ default: 1
242
+ type: float
243
+ - name: C_ru
244
+ description: 舱形系数 [-](5.7.2(d)):矩形 1.0,U 形 0.7
245
+ default: 1
246
+ type: float
247
+ - name: p_vp
248
+ description: 真空/压力阀整定压力 [N/cm^2]
249
+ default: 0
250
+ type: float
251
+ suffix: ' N/cm^2'
252
+ - name: GM_full_in
253
+ description: 完整稳性 GM [m];填 0 时用规范估算 0.12 B
254
+ default: 0
255
+ type: float
256
+ suffix: ' m'
257
+ - name: k_r_in
258
+ description: 横摇惯性半径 [m];填 0 时用规范估算(0.35 B / 0.45 B)
259
+ default: 0
260
+ type: float
261
+ suffix: ' m'
262
+ - name: tank_is_ballast
263
+ description: 压载舱 1 / 货舱 0;决定 k_s 是否取 1
264
+ default: 1
265
+ type: int
266
+ - name: member_11_17
267
+ description: 构件是否属于 5.7 表 3 的 11..17 项(1 = 是)
268
+ default: 0
269
+ type: int
270
+ templates:
271
+ - name: genie_ext
272
+ description: ABS FPI 5A-3-2/5.5 外压 -- GeniE 强度函数体
273
+ output_sheet: Code EXT
274
+ start_cell: B2
275
+ direction: horizontal
276
+ write_case_headers: true
277
+ engine: excel
278
+ filename: '{{ case_name }}.js'
279
+ template_file: templates/ext_body.js.j2
280
+ case_filter: kind == 'EXT'
281
+ - name: ext_summary
282
+ description: 外压工况输入汇总(Markdown)
283
+ output_sheet: Summary EXT
284
+ start_cell: B2
285
+ direction: vertical
286
+ write_case_headers: true
287
+ engine: excel
288
+ filename: '{{ case_name }}_summary.md'
289
+ template_file: templates/ext_summary.md.j2
290
+ case_filter: kind == 'EXT'
291
+ - name: genie_int
292
+ description: ABS FPI 5A-3-2/5.7 内压 -- GeniE 强度函数体
293
+ output_sheet: Code INT
294
+ start_cell: B2
295
+ direction: horizontal
296
+ write_case_headers: true
297
+ engine: excel
298
+ filename: '{{ case_name }}.js'
299
+ template_file: templates/int_body.js.j2
300
+ case_filter: kind == 'INT'
301
+ - name: int_summary
302
+ description: 内压工况输入汇总(Markdown)
303
+ output_sheet: Summary INT
304
+ start_cell: B2
305
+ direction: vertical
306
+ write_case_headers: true
307
+ engine: excel
308
+ filename: '{{ case_name }}_summary.md'
309
+ template_file: templates/int_summary.md.j2
310
+ case_filter: kind == 'INT'
@@ -0,0 +1,162 @@
1
+ version: 1
2
+
3
+ # =========================================================================== #
4
+ # 规则集:ABS FPI 5A-3-2/5.5 外压(external sea pressures)
5
+ #
6
+ # 这是"模板数据库"里的一个单元:自带变量定义与模板,可以单独生成一本工作簿,
7
+ # 也可以被 compose.py 合进一本项目工作簿(与内压共用一张 Global 表)。
8
+ #
9
+ # engine: excel → Code 表写的是 Excel 公式:改参数后 Excel / WPS 打开即重算,
10
+ # 不需要重跑任何脚本。代价是模板只能用"占位符替换 + 单行 {% if %}"
11
+ # ({{ x }} / .value / .text / .prefix / .suffix / case_name;
12
+ # {% if %} 会编译成 Excel 的 IF(),见指南 §14.1.1),
13
+ # 不支持 {% for %} / 过滤器 / 多行 {% if %}。
14
+ # 本模板的 if/else 是**GeniE 的字面文本**,不是 Jinja 控制流,
15
+ # 所以公式模式照样能用;坐标映射也用 6 个变量做纯替换表达。
16
+ # =========================================================================== #
17
+ excel:
18
+ output: "abs_fpi_external.xlsx"
19
+ sheets:
20
+ global: "Global Parameter"
21
+ local: "Local Parameter"
22
+ outputs: ["Code", "Summary"]
23
+
24
+ variables:
25
+ # ------------------------------------------------------------------ 船 / 海 --
26
+ global:
27
+ - name: L
28
+ description: "规范船长 [m](3-1-1/3);同时驱动 C_1 / k_lo / k_f"
29
+ default: 340
30
+ type: float
31
+ suffix: " m"
32
+ - name: B
33
+ description: "规范型宽 [m];B/2 决定舭部位置"
34
+ default: 64
35
+ type: float
36
+ suffix: " m"
37
+ - name: D
38
+ description: "规范型深 [m](基线到甲板)"
39
+ default: 32
40
+ type: float
41
+ suffix: " m"
42
+ - name: r_b
43
+ description: "舭圆半径 [m]:z_bilge = r_b,平底宽 = B/2 - r_b"
44
+ default: 0.703
45
+ type: float
46
+ suffix: " m"
47
+ - name: freeboard
48
+ description: "甲板边线在载重线以上的余量 [m];Fig. 10 的截断高度用它算"
49
+ default: 0.5
50
+ type: float
51
+ suffix: " m"
52
+ - name: rho_sea
53
+ description: "海水密度 [kg/m^3];规范下限 1.005 N/cm^2-m 即 1025 kg/m^3"
54
+ default: 1025
55
+ type: float
56
+ suffix: " kg/m^3"
57
+ - name: g
58
+ description: "重力加速度 [m/s^2]"
59
+ default: 9.81
60
+ type: float
61
+ suffix: " m/s^2"
62
+ - name: Cb
63
+ description: "方形系数 [-](3-1-1/13.3)"
64
+ default: 1
65
+ type: float
66
+
67
+ # ------------------------------------------------------- 坐标映射(纯替换)--
68
+ # 公式模式不能写 {% if %},所以这里把"取哪个轴 + 是否取反"直接做成可替换的文本:
69
+ # x = {{ neg_x }}t{{ ax_x }}; → x = t1; 或 x = -t3;
70
+ - name: ax_x
71
+ description: "规范 x(自 AP)取自模型哪个轴:1=x, 2=y, 3=z"
72
+ default: "1"
73
+ type: string
74
+ - name: ax_y
75
+ description: "规范 y(自中线,向右舷为正)取自模型哪个轴"
76
+ default: "2"
77
+ type: string
78
+ - name: ax_z
79
+ description: "规范 z(基线以上,向上为正)取自模型哪个轴"
80
+ default: "3"
81
+ type: string
82
+ - name: neg_x
83
+ description: "规范 x 是否取反:填 - 表示取反,留空表示不取反"
84
+ default: ""
85
+ type: string
86
+ - name: neg_y
87
+ description: "规范 y 是否取反:填 - 表示取反,留空表示不取反"
88
+ default: ""
89
+ type: string
90
+ - name: neg_z
91
+ description: "规范 z 是否取反:填 - 表示取反,留空表示不取反"
92
+ default: ""
93
+ type: string
94
+
95
+ # ---------------------------------------------------------------- 每个工况 --
96
+ local:
97
+ - name: kind
98
+ description: "这个 Case 属于哪一套规则:EXT / INT(多规则集合用时用 case_filter 分流)"
99
+ default: "EXT"
100
+ type: string
101
+ - name: draft
102
+ description: "工况吃水 [m];h_s = draft - z,负值截断为 0"
103
+ default: 20.559
104
+ type: float
105
+ suffix: " m"
106
+ - name: mu_deg
107
+ description: "浪向角 [deg],0 = 顶浪,90 = 右舷来浪(Table 1A D)"
108
+ default: 90
109
+ type: float
110
+ suffix: " deg"
111
+ - name: k_c
112
+ description: "组合工况相关系数 [-],进 h_de = k_c h_di(Table 1A B)"
113
+ default: 1
114
+ type: float
115
+ - name: k_f0
116
+ description: "相位因子 +1 / -1 [-],决定参考站落在哪一端(Table 1A B)"
117
+ default: 1
118
+ type: float
119
+ - name: k_u
120
+ description: "载荷系数 [-];规范默认 1.0,1.1 用于板与纵骨的工况"
121
+ default: 1.1
122
+ type: float
123
+ - name: beta_EPS
124
+ description: "外压 ESF,右舷 [-](5A-3-A1/3)"
125
+ default: 0.733
126
+ type: float
127
+ - name: beta_EPP
128
+ description: "外压 ESF,左舷 [-](5A-3-A1/3)"
129
+ default: 0.733
130
+ type: float
131
+ - name: k_esf
132
+ description: "项目对 ESF 的分项系数 [-]"
133
+ default: 1.1
134
+ type: float
135
+ - name: x_o
136
+ description: "参考站 [m],自 AP 量起(Fig. 9 脚注)"
137
+ default: 51
138
+ type: float
139
+ suffix: " m"
140
+
141
+ templates:
142
+ # 一列一个工况:整段 GeniE 函数体,逐行铺在 Code 表里(公式模式 → 自动重算)
143
+ - name: genie_ext
144
+ description: "ABS FPI 5A-3-2/5.5 外压 -- GeniE 强度函数体"
145
+ output_sheet: "Code"
146
+ start_cell: "B2"
147
+ direction: "horizontal"
148
+ write_case_headers: true
149
+ engine: "excel"
150
+ filename: "{{ case_name }}.js"
151
+ template_file: "templates/ext_body.js.j2"
152
+
153
+ # 一行一个工况:输入参数汇总(Markdown),随代码归档
154
+ - name: ext_summary
155
+ description: "外压工况输入汇总(Markdown)"
156
+ output_sheet: "Summary"
157
+ start_cell: "B2"
158
+ direction: "vertical"
159
+ write_case_headers: true
160
+ engine: "excel"
161
+ filename: "{{ case_name }}_summary.md"
162
+ template_file: "templates/ext_summary.md.j2"
@@ -0,0 +1,22 @@
1
+ @echo off
2
+ REM ===========================================================================
3
+ REM 由 excel_codegen 生成 —— 改完参数双击本文件即可把结果写回 Output 表。
4
+ REM 重新生成工作簿(init)时会一并覆盖本文件。
5
+ REM ===========================================================================
6
+ cd /d "%~dp0"
7
+
8
+ where uv >nul 2>nul
9
+ if %errorlevel%==0 (
10
+ uv run excel-codegen render -c "abs_fpi_external.yaml" -x "abs_fpi_external.xlsx" --write-excel
11
+ ) else (
12
+ excel-codegen render -c "abs_fpi_external.yaml" -x "abs_fpi_external.xlsx" --write-excel
13
+ )
14
+
15
+ echo.
16
+ if errorlevel 1 (
17
+ echo [失败] 上面有报错信息。常见原因:依赖没装(跑一次 setup.sh / uv sync)、
18
+ echo 或者 Excel 正开着这个文件(先关掉再试)。
19
+ ) else (
20
+ echo [完成] 回到 Excel 打开「Output」表看结果。
21
+ )
22
+ pause
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+ # ===========================================================================
3
+ # 由 excel_codegen 生成 —— 改完参数跑一次本文件即可把结果写回 Output 表。
4
+ # 重新生成工作簿(init)时会一并覆盖本文件。
5
+ # ===========================================================================
6
+ set -uo pipefail
7
+ cd "$(dirname "$0")"
8
+
9
+ if command -v uv >/dev/null 2>&1; then
10
+ uv run excel-codegen render -c "abs_fpi_external.yaml" -x "abs_fpi_external.xlsx" --write-excel
11
+ else
12
+ excel-codegen render -c "abs_fpi_external.yaml" -x "abs_fpi_external.xlsx" --write-excel
13
+ fi
14
+ status=$?
15
+
16
+ echo
17
+ if [ "$status" -ne 0 ]; then
18
+ echo "[失败] 上面有报错信息。常见原因:依赖没装(跑一次 ./setup.sh 或 uv sync)、"
19
+ echo " 或者 Excel / WPS 正开着这个文件(先关掉再试)。"
20
+ else
21
+ echo "[完成] 回到 Excel 打开「Output」表看结果。"
22
+ fi
23
+ exit "$status"