Files
CloudLab Deploy 4c312cac39
CloudLab CI/CD / 门禁 doctor (push) Failing after 38s
CloudLab CI/CD / 单元测试 (push) Skipped
CloudLab CI/CD / 归档完整性 (push) Skipped
CloudLab CI/CD / 构建站点与归档 (push) Skipped
CloudLab CI/CD / 部署到 lab.hdtime.space(rsync) (push) Skipped
CloudLab CI/CD / 构建镜像并推送 Gitea 容器仓库 (push) Skipped
CloudLab CI/CD / 容器部署到 lab.hdtime.space (push) Skipped
CloudLab CI/CD / 发布版本(Tag) (push) Skipped
feat(platform): add CloudLab execution platform and IDE web source
Freeze the real-execution control plane, runner, manifests, validation cases and tests under cloudlab-platform; preserve the IDE/static web source under cloudlab-web. Generated material library and runtime state are intentionally excluded.
2026-11-18 00:14:35 +08:00

55 lines
3.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
p=Path('/root/dsh_workspace/cloudlab-platform/tests/test_fidelity.py')
s=p.read_text()
marker=' def test_chem04_cardinal_surface_matches_snapshot(self):'
assert s.count(marker)==1
new=''' def test_chem03_kirchhoff_dcp(self):
result, metrics = self.run_case(next(c for c in self.cases if c["id"] == "chem-03-kirchhoff"))
self.assertEqual(len(result["metrics"]), 23)
self.assertEqual(len(result["tables"]), 4)
self.assertEqual(metrics["温度校正"], "Kirchhoff(ΔH° + ΔCp)")
self.assertAlmostEqual(float(metrics["ΔCp(用户输入)"]), 0.2, delta=1e-9)
self.assertAlmostEqual(float(metrics["ΔH°(T)"]), -22.6, delta=1e-9)
self.assertAlmostEqual(float(metrics["ΔS°(T)"]), -0.019946469237846078, delta=1e-9)
self.assertAlmostEqual(float(metrics["标准 K°′(T)"]), 581.1408660345892, delta=0.2)
self.assertAlmostEqual(float(metrics["标准 ΔG°′(T)"]), -16.41360256588204, delta=0.02)
self.assertAlmostEqual(float(metrics["实际 ΔG(T, Q)"]), -16.41360256588204, delta=0.02)
self.assertAlmostEqual(float(metrics["Q / K°′(T)"]), 0.0017207531916030847, delta=1e-9)
self.assertEqual(metrics["方向(T, Q)"], "正向有利")
self.assertIn("ΔH(T)", result["summary"])
self.assertIn("Kirchhoff", result["summary"])
kt, dht, dst, dgt = runner.kirchhoff_equilibrium_constant(842.7784450136623, -25, 0.2, 310.15)
self.assertAlmostEqual(kt, 581.1408660345892, delta=1e-12)
self.assertAlmostEqual(dht, -22.6, delta=1e-12)
self.assertAlmostEqual(dst, -0.019946469237846078, delta=1e-12)
self.assertAlmostEqual(dgt, -16.41360256588204, delta=1e-12)
kt_table = next(t for t in result["tables"] if "Kirchhoff" in t["title"])
self.assertEqual(len(kt_table["rows"]), 15)
rows = {r[0]: r[1] for r in kt_table["rows"]}
self.assertIn("ΔCp", rows)
self.assertIn("ΔS(T)", rows["方法"])
self.assertIn("ΔCp", rows["假设"])
self.assertIn("不是量热测量", kt_table["note"])
self.assertIn("温度远离", kt_table["note"])
_, metrics_dh = self.run_case({"id": "chem-03-vanthoff-only", "op": "chem_reaction",
"params": {"reaction": "gly_colysis_hk", "Q": "1", "dH": "-25", "T": "310.15"},
"inputs": {}})
self.assertEqual(len(metrics_dh), 20)
self.assertEqual(metrics_dh["温度校正"], "van't Hoff(常数 ΔH°)")
self.assertNotIn("ΔCp(用户输入)", metrics_dh)
with self.assertRaises(ValueError):
runner.op_chem_reaction({"reaction": "gly_colysis_hk", "Q": "1", "dCp": "0.2"}, {})
with self.assertRaises(ValueError):
runner.op_chem_reaction({"reaction": "gly_colysis_hk", "Q": "1", "dH": "-25", "dCp": "11"}, {})
with self.assertRaises(ValueError):
runner.op_chem_reaction({"reaction": "gly_colysis_hk", "Q": "1", "dH": "-25", "dCp": "abc"}, {})
'''
s=s.replace(marker,new+marker,1)
p.write_text(s)
print('test inserted')