Add jet, surface and fixed-patch tests and runnable examples

This commit is contained in:
Frank14f
2026-10-15 10:13:49 +08:00
parent ed1a6ee54e
commit cdbb9c42f6
48 changed files with 9267 additions and 210 deletions
+11 -5
View File
@@ -25,7 +25,7 @@ sys.path.insert(0, str(_REPO / "src"))
from CelerisLab import Simulation
def test_sensor_accuracy() -> dict:
def run_sensor_accuracy() -> dict:
"""Run sensor accuracy validation with multiple sensor positions."""
cfg = json.loads(
(Path(_REPO) / "src" / "CelerisLab" / "configs" / "config_lbm.json").read_text()
@@ -45,7 +45,9 @@ def test_sensor_accuracy() -> dict:
with open(lbm_path, "w") as f:
json.dump(cfg, f)
sim = Simulation(lbm_config_path=lbm_path)
body_path = os.path.join(tmpd, "config_body.json")
Path(body_path).write_text('{"objects": []}')
sim = Simulation(lbm_config_path=lbm_path, body_config_path=body_path)
sim.add_body("circle", center=(80, 64), radius=15)
positions = [(120, 50), (120, 64), (120, 78), (150, 64)]
@@ -63,8 +65,7 @@ def test_sensor_accuracy() -> dict:
sim.run(20)
# Get macroscopic field after one more step (with sensor accumulation)
import pycuda.driver as cuda
stream = cuda.Stream()
stream = sim.stream
sim.run(1, zero_obs=True, upload_act=False, sync_obs=True, stream=stream)
# stream.synchronize() is called inside run()
@@ -118,6 +119,11 @@ def test_sensor_accuracy() -> dict:
return summary
def test_sensor_accuracy():
result = run_sensor_accuracy()
assert result["all_pass"], result
if __name__ == "__main__":
result = test_sensor_accuracy()
result = run_sensor_accuracy()
sys.exit(0 if result["all_pass"] else 1)