"""Generate sbc3d_order2.json from MATLAB case_config (2nd-order SBC scatter).""" from __future__ import annotations import json from pathlib import Path # Mirrors: 三维matlab代码/matlab 3D二阶基+散射边界条件/case_config.m OUT_FACES = [1, 2, 3, 5, 14] INC_FACES = [4] SBC_INDEX = OUT_FACES + [f for f in INC_FACES if f not in OUT_FACES] SBC_TYPE = [0 if f in OUT_FACES else 1 for f in SBC_INDEX] DOC = { "FemType": 4, "EletricType": 2, "ElementOrder": 2, "lambda": 2.0, "NbrBoundary": 14, "BoundaryFlag": [0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2], "sbc": { "Index": SBC_INDEX, "SBCType": SBC_TYPE, "E0x": ["1"] * len(SBC_INDEX), "E0y": ["0"] * len(SBC_INDEX), "E0z": ["0"] * len(SBC_INDEX), "kx": [0] * len(SBC_INDEX), "ky": [0] * len(SBC_INDEX), "kz": [0] * len(SBC_INDEX), }, "NbrDomain": 2, "domainType": [2, 2], "domainIndex": [0, 1], "matType": [0, 0], "epsilonrR": [1.0, 1.5], "epsilonrI": [0.0, 0.0], "murR": [1.0, 1.0], "murI": [0.0, 0.0], "chiheR": [0.0, 0.0], "chiehR": [0.0, 0.0], "chiheI": [0.0, 0.0], "chiehI": [0.0, 0.0], "sigma": [0.0, 0.0], "n": [1.0, 1.0], "k": [0.0, 0.0], "MeshFile": "SBCmesh.dat", "OutFile": "./OutFile", } def main() -> None: root = Path(__file__).resolve().parents[1] release = root / "scat3D_order2" / "Release" release.mkdir(parents=True, exist_ok=True) out_path = release / "sbc3d_order2.json" out_path.write_text(json.dumps(DOC, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") print(f"Wrote {out_path}") print(f" sbc Index={SBC_INDEX}, SBCType={SBC_TYPE}") print(f" lambda={DOC['lambda']}, ElementOrder={DOC['ElementOrder']}") if __name__ == "__main__": main()