ymf 0.3.0__tar.gz

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 (161) hide show
  1. ymf-0.3.0/.gitignore +21 -0
  2. ymf-0.3.0/LICENSE +21 -0
  3. ymf-0.3.0/MANIFEST.in +7 -0
  4. ymf-0.3.0/PKG-INFO +252 -0
  5. ymf-0.3.0/README.md +193 -0
  6. ymf-0.3.0/RELEASING.md +68 -0
  7. ymf-0.3.0/docs/README.md +47 -0
  8. ymf-0.3.0/docs/archive-format.md +627 -0
  9. ymf-0.3.0/docs/changes.md +396 -0
  10. ymf-0.3.0/docs/design/domains-beyond-box.md +179 -0
  11. ymf-0.3.0/docs/design/time-outside-space.md +364 -0
  12. ymf-0.3.0/docs/history/schema-v0.1.md +776 -0
  13. ymf-0.3.0/docs/history/schema-v0.2-delta.md +414 -0
  14. ymf-0.3.0/docs/history/session-2026-07-29.md +132 -0
  15. ymf-0.3.0/docs/problem-specification.md +1378 -0
  16. ymf-0.3.0/docs/research/csdms-bmi.md +469 -0
  17. ymf-0.3.0/docs/research/data-sources.md +514 -0
  18. ymf-0.3.0/docs/research/units.md +706 -0
  19. ymf-0.3.0/docs/xdmf-model.yaml +466 -0
  20. ymf-0.3.0/examples/README.md +96 -0
  21. ymf-0.3.0/examples/heat_equation.ymf +110 -0
  22. ymf-0.3.0/examples/kovasznay_flow.ymf +172 -0
  23. ymf-0.3.0/examples/navier_stokes/navier_stokes_model.ymf +52 -0
  24. ymf-0.3.0/examples/navier_stokes/planar_couette.ymf +120 -0
  25. ymf-0.3.0/examples/navier_stokes/plane_poiseuille.ymf +154 -0
  26. ymf-0.3.0/examples/navier_stokes/plane_poiseuille_re100.ymf +27 -0
  27. ymf-0.3.0/examples/navier_stokes/plane_poiseuille_refined.ymf +29 -0
  28. ymf-0.3.0/examples/nonlinear_diffusion.ymf +59 -0
  29. ymf-0.3.0/examples/notebooks/COMPARISON.md +51 -0
  30. ymf-0.3.0/examples/notebooks/YMF-original.ipynb +638 -0
  31. ymf-0.3.0/examples/notebooks/YMF-updated.ipynb +320 -0
  32. ymf-0.3.0/examples/notebooks/build_updated_notebook.py +231 -0
  33. ymf-0.3.0/examples/poisson.ymf +89 -0
  34. ymf-0.3.0/examples/poisson_spaces.ymf +37 -0
  35. ymf-0.3.0/examples/poisson_v02_enriched.ymf +69 -0
  36. ymf-0.3.0/examples/read_archive.py +117 -0
  37. ymf-0.3.0/examples/validate_spec.py +141 -0
  38. ymf-0.3.0/examples/write_archive.py +238 -0
  39. ymf-0.3.0/pyproject.toml +97 -0
  40. ymf-0.3.0/setup.cfg +4 -0
  41. ymf-0.3.0/src/ymf/__init__.py +149 -0
  42. ymf-0.3.0/src/ymf/archive.py +2104 -0
  43. ymf-0.3.0/src/ymf/boundaries.py +119 -0
  44. ymf-0.3.0/src/ymf/cli.py +307 -0
  45. ymf-0.3.0/src/ymf/closure.py +340 -0
  46. ymf-0.3.0/src/ymf/compose.py +613 -0
  47. ymf-0.3.0/src/ymf/conditions.py +193 -0
  48. ymf-0.3.0/src/ymf/data_sources.py +311 -0
  49. ymf-0.3.0/src/ymf/discretizations.py +303 -0
  50. ymf-0.3.0/src/ymf/dispersion.py +160 -0
  51. ymf-0.3.0/src/ymf/domain.py +235 -0
  52. ymf-0.3.0/src/ymf/explicit.py +213 -0
  53. ymf-0.3.0/src/ymf/generated.py +197 -0
  54. ymf-0.3.0/src/ymf/mesh.py +271 -0
  55. ymf-0.3.0/src/ymf/names.py +174 -0
  56. ymf-0.3.0/src/ymf/normalize.py +168 -0
  57. ymf-0.3.0/src/ymf/references.py +509 -0
  58. ymf-0.3.0/src/ymf/schema.py +764 -0
  59. ymf-0.3.0/src/ymf/spaces.py +145 -0
  60. ymf-0.3.0/src/ymf/stabilization.py +214 -0
  61. ymf-0.3.0/src/ymf/state.py +122 -0
  62. ymf-0.3.0/src/ymf/symbolic/__init__.py +17 -0
  63. ymf-0.3.0/src/ymf/symbolic/adr.py +357 -0
  64. ymf-0.3.0/src/ymf/symbolic/language.py +244 -0
  65. ymf-0.3.0/src/ymf/symbolic/notation.py +447 -0
  66. ymf-0.3.0/src/ymf/symbolic/printer.py +207 -0
  67. ymf-0.3.0/src/ymf/symbolic/problem.py +914 -0
  68. ymf-0.3.0/src/ymf/symbolic/split.py +568 -0
  69. ymf-0.3.0/src/ymf/units.py +1016 -0
  70. ymf-0.3.0/src/ymf/vocabulary.py +660 -0
  71. ymf-0.3.0/src/ymf/xdmf.py +728 -0
  72. ymf-0.3.0/src/ymf.egg-info/PKG-INFO +252 -0
  73. ymf-0.3.0/src/ymf.egg-info/SOURCES.txt +159 -0
  74. ymf-0.3.0/src/ymf.egg-info/dependency_links.txt +1 -0
  75. ymf-0.3.0/src/ymf.egg-info/entry_points.txt +2 -0
  76. ymf-0.3.0/src/ymf.egg-info/requires.txt +38 -0
  77. ymf-0.3.0/src/ymf.egg-info/scm_file_list.json +157 -0
  78. ymf-0.3.0/src/ymf.egg-info/scm_version.json +8 -0
  79. ymf-0.3.0/src/ymf.egg-info/top_level.txt +1 -0
  80. ymf-0.3.0/tests/_formulation.py +30 -0
  81. ymf-0.3.0/tests/fixtures/format1_two_spaces.xmf +82 -0
  82. ymf-0.3.0/tests/fixtures/format1_two_spaces.ymf +175 -0
  83. ymf-0.3.0/tests/fixtures/proteus/hexahedron.xmf +38 -0
  84. ymf-0.3.0/tests/fixtures/proteus/polyline.xmf +80 -0
  85. ymf-0.3.0/tests/fixtures/proteus/quadrilateral.xmf +38 -0
  86. ymf-0.3.0/tests/fixtures/proteus/tet_10.xmf +70 -0
  87. ymf-0.3.0/tests/fixtures/proteus/tetrahedron.xmf +53 -0
  88. ymf-0.3.0/tests/fixtures/proteus/tri_6.xmf +70 -0
  89. ymf-0.3.0/tests/fixtures/proteus/triangle.xmf +32 -0
  90. ymf-0.3.0/tests/fixtures/shallow_water/circular_dam_dispersive.ymf +35 -0
  91. ymf-0.3.0/tests/fixtures/shallow_water/dam3bumps.ymf +35 -0
  92. ymf-0.3.0/tests/fixtures/shallow_water/dispersive.ymf +28 -0
  93. ymf-0.3.0/tests/fixtures/shallow_water/dispersive_numerics.ymf +39 -0
  94. ymf-0.3.0/tests/fixtures/shallow_water/lake_at_rest.ymf +36 -0
  95. ymf-0.3.0/tests/fixtures/shallow_water/proteus_numerics.ymf +33 -0
  96. ymf-0.3.0/tests/fixtures/shallow_water/shallow_water.ymf +43 -0
  97. ymf-0.3.0/tests/fixtures/shallow_water/torino.ymf +59 -0
  98. ymf-0.3.0/tests/fixtures/two_phase/dambreak.ymf +104 -0
  99. ymf-0.3.0/tests/fixtures/two_phase/dambreak_clsvof.ymf +32 -0
  100. ymf-0.3.0/tests/fixtures/two_phase/dambreak_formulation.ymf +54 -0
  101. ymf-0.3.0/tests/fixtures/two_phase/dambreak_porous.ymf +32 -0
  102. ymf-0.3.0/tests/fixtures/two_phase/two_phase_level_set.ymf +50 -0
  103. ymf-0.3.0/tests/test_archive.py +927 -0
  104. ymf-0.3.0/tests/test_archive_spec_as_written.py +62 -0
  105. ymf-0.3.0/tests/test_boundary_declaration.py +193 -0
  106. ymf-0.3.0/tests/test_boundary_kinds.py +102 -0
  107. ymf-0.3.0/tests/test_cells_per_axis.py +150 -0
  108. ymf-0.3.0/tests/test_cli.py +245 -0
  109. ymf-0.3.0/tests/test_closure.py +256 -0
  110. ymf-0.3.0/tests/test_coefficient_roles.py +67 -0
  111. ymf-0.3.0/tests/test_compose.py +324 -0
  112. ymf-0.3.0/tests/test_condition_expansion.py +187 -0
  113. ymf-0.3.0/tests/test_condition_sets.py +97 -0
  114. ymf-0.3.0/tests/test_core_without_frontend.py +88 -0
  115. ymf-0.3.0/tests/test_data_sources.py +89 -0
  116. ymf-0.3.0/tests/test_decimals_as_written.py +32 -0
  117. ymf-0.3.0/tests/test_discrete_domains.py +147 -0
  118. ymf-0.3.0/tests/test_discretizations.py +112 -0
  119. ymf-0.3.0/tests/test_dispersion.py +174 -0
  120. ymf-0.3.0/tests/test_domain.py +246 -0
  121. ymf-0.3.0/tests/test_examples.py +106 -0
  122. ymf-0.3.0/tests/test_explicit.py +201 -0
  123. ymf-0.3.0/tests/test_extends_initial_conditions.py +55 -0
  124. ymf-0.3.0/tests/test_file_domains.py +121 -0
  125. ymf-0.3.0/tests/test_gauges.py +69 -0
  126. ymf-0.3.0/tests/test_generated.py +122 -0
  127. ymf-0.3.0/tests/test_indicator_conditions.py +66 -0
  128. ymf-0.3.0/tests/test_lagging.py +64 -0
  129. ymf-0.3.0/tests/test_linear_solver.py +44 -0
  130. ymf-0.3.0/tests/test_mesh.py +301 -0
  131. ymf-0.3.0/tests/test_mesh_fingerprint.py +74 -0
  132. ymf-0.3.0/tests/test_named_coefficients.py +131 -0
  133. ymf-0.3.0/tests/test_named_equations.py +153 -0
  134. ymf-0.3.0/tests/test_nesting.py +266 -0
  135. ymf-0.3.0/tests/test_normalize.py +46 -0
  136. ymf-0.3.0/tests/test_notation.py +175 -0
  137. ymf-0.3.0/tests/test_notation_functions.py +132 -0
  138. ymf-0.3.0/tests/test_periodic_regions.py +91 -0
  139. ymf-0.3.0/tests/test_printer.py +147 -0
  140. ymf-0.3.0/tests/test_proteus_archive.py +202 -0
  141. ymf-0.3.0/tests/test_references.py +235 -0
  142. ymf-0.3.0/tests/test_removal.py +198 -0
  143. ymf-0.3.0/tests/test_schema.py +190 -0
  144. ymf-0.3.0/tests/test_select.py +218 -0
  145. ymf-0.3.0/tests/test_shallow_water.py +142 -0
  146. ymf-0.3.0/tests/test_spaces.py +101 -0
  147. ymf-0.3.0/tests/test_split.py +265 -0
  148. ymf-0.3.0/tests/test_stabilization.py +191 -0
  149. ymf-0.3.0/tests/test_state.py +118 -0
  150. ymf-0.3.0/tests/test_state_coefficients.py +200 -0
  151. ymf-0.3.0/tests/test_subproblems.py +160 -0
  152. ymf-0.3.0/tests/test_symbolic.py +408 -0
  153. ymf-0.3.0/tests/test_tag_regions.py +121 -0
  154. ymf-0.3.0/tests/test_units.py +640 -0
  155. ymf-0.3.0/tests/test_values.py +166 -0
  156. ymf-0.3.0/tests/test_version.py +16 -0
  157. ymf-0.3.0/tests/test_vocabulary.py +239 -0
  158. ymf-0.3.0/tests/test_xdmf.py +665 -0
  159. ymf-0.3.0/tests/test_xdmf_fragments.py +87 -0
  160. ymf-0.3.0/tests/test_xdmf_model.py +62 -0
  161. ymf-0.3.0/tools/check_dist.sh +58 -0
ymf-0.3.0/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ .coverage
6
+ htmlcov/
7
+ .venv/
8
+ venv/
9
+ build/
10
+ dist/
11
+ .mypy_cache/
12
+ .ruff_cache/
13
+
14
+ # Generated notebook artifacts (regenerate via the notebooks themselves)
15
+ examples/notebooks/*.xmf
16
+ .ipynb_checkpoints/
17
+
18
+ # What ymf_run writes beside the examples
19
+ examples/**/*.archive.ymf
20
+ examples/**/*_[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]*.h5
21
+ examples/**/*_[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]*.xmf
ymf-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 cekees
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ymf-0.3.0/MANIFEST.in ADDED
@@ -0,0 +1,7 @@
1
+ # What the sdist ships: setuptools_scm adds every git-tracked file (source,
2
+ # tests with their fixtures, examples, docs, README, LICENSE), so this only
3
+ # prunes. Nothing generated or local may ride along.
4
+ prune .github
5
+ global-exclude *.pyc __pycache__ *.log .coverage .DS_Store
6
+ # What ymf_run and the examples write beside themselves
7
+ global-exclude examples/*.archive.ymf
ymf-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,252 @@
1
+ Metadata-Version: 2.4
2
+ Name: ymf
3
+ Version: 0.3.0
4
+ Summary: YAML Modeling Format for computational physics — problem specification, VVUQ, and multi-backend dispatch.
5
+ Author: cekees
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/proteustoolkit/ymf
8
+ Project-URL: Documentation, https://github.com/proteustoolkit/ymf/tree/main/docs
9
+ Project-URL: Source, https://github.com/proteustoolkit/ymf
10
+ Project-URL: Issues, https://github.com/proteustoolkit/ymf/issues
11
+ Project-URL: Changelog, https://github.com/proteustoolkit/ymf/blob/main/docs/changes.md
12
+ Keywords: yaml,simulation,computational-physics,pde,verification,uncertainty-quantification
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Classifier: Topic :: Scientific/Engineering :: Physics
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: pyyaml>=6.0
28
+ Provides-Extra: spec
29
+ Requires-Dist: strictyaml>=1.7; extra == "spec"
30
+ Provides-Extra: units
31
+ Requires-Dist: pint>=0.23; extra == "units"
32
+ Provides-Extra: symbolic
33
+ Requires-Dist: sympy>=1.12; extra == "symbolic"
34
+ Requires-Dist: strictyaml>=1.7; extra == "symbolic"
35
+ Provides-Extra: frontend
36
+ Requires-Dist: strictyaml>=1.7; extra == "frontend"
37
+ Requires-Dist: pint>=0.23; extra == "frontend"
38
+ Requires-Dist: sympy>=1.12; extra == "frontend"
39
+ Provides-Extra: examples
40
+ Requires-Dist: numpy; extra == "examples"
41
+ Requires-Dist: h5py; extra == "examples"
42
+ Provides-Extra: test
43
+ Requires-Dist: pytest>=7.0; extra == "test"
44
+ Requires-Dist: pytest-cov; extra == "test"
45
+ Requires-Dist: strictyaml>=1.7; extra == "test"
46
+ Requires-Dist: pint>=0.23; extra == "test"
47
+ Requires-Dist: numpy; extra == "test"
48
+ Requires-Dist: h5py; extra == "test"
49
+ Requires-Dist: sympy>=1.12; extra == "test"
50
+ Provides-Extra: dev
51
+ Requires-Dist: pytest>=7.0; extra == "dev"
52
+ Requires-Dist: pytest-cov; extra == "dev"
53
+ Requires-Dist: strictyaml>=1.7; extra == "dev"
54
+ Requires-Dist: pint>=0.23; extra == "dev"
55
+ Requires-Dist: numpy; extra == "dev"
56
+ Requires-Dist: h5py; extra == "dev"
57
+ Requires-Dist: sympy>=1.12; extra == "dev"
58
+ Dynamic: license-file
59
+
60
+ # YMF — YAML Modeling Format
61
+
62
+ YMF is a plain-YAML record of a computational physics problem: what it
63
+ models and why, the equations, how they were discretized and solved, and
64
+ what came out. It is meant to be written and reviewed by people and LLMs
65
+ together, and read and written by solvers.
66
+
67
+ It has two parts that share one format:
68
+
69
+ | | Problem specification | Archive |
70
+ |---|---|---|
71
+ | **What** | The problem from physics down to solver settings: processes and assumptions, strong form, weak forms, discretizations, verification plan | A solver's output: which mesh, time and field each HDF5 dataset holds |
72
+ | **Written by** | a person, an LLM, or both | the solver |
73
+ | **Checked by** | `ymf.schema` (strictyaml) and `ymf.units` (pint): schema, units, dimensional consistency | `ymf.archive`: structure and array shapes only, cheaply |
74
+ | **Depends on** | `ymf[frontend]` | `pyyaml` alone |
75
+ | **Guide** | [docs/problem-specification.md](docs/problem-specification.md) | [docs/archive-format.md](docs/archive-format.md) |
76
+
77
+ The two meet in the archive of a spec: the specification as realized,
78
+ followed by every output computed from it, each keyed by a hash of the part
79
+ of the spec that produced it and recording how it was produced. Such an
80
+ archive is itself a spec: rerunning it reproduces its outputs bitwise, and
81
+ another spec can `extends` it.
82
+
83
+ ## Why
84
+
85
+ Between "simulate this system" and "run this solver" sit a dozen decisions:
86
+ which physics to keep, which unknowns, which weak form, which elements,
87
+ which stabilization. They usually live in someone's head, a notebook, or a
88
+ solver input file that records the outcome but not the reasoning. YMF makes
89
+ each stage a structured, reviewable block, and tags each one with its
90
+ **provenance**: whether an LLM proposed it, a person wrote it, or a person
91
+ edited an LLM's proposal. One document can hold several **branches**
92
+ (competing weak forms and discretizations of the same problem) alongside
93
+ the plan for verifying them against each other. Branches can also be
94
+ separate files: an **abstract** document holding the model (the physics
95
+ and equations, often most of the work for multiphysics) is written once and
96
+ extended, file by file, into many well-posed specs. A document records how
97
+ far it has got -- `ymf_state`: abstract, well-posed, discretized, closed --
98
+ and the loader checks that its content gets that far.
99
+
100
+ On the output side, solver archives have usually been XDMF XML written by
101
+ hand-built element trees, with no data model behind them and nothing
102
+ checking that the metadata matches the arrays. The YMF archive is a small,
103
+ explicit data model that converts one-to-one to XDMF, so ParaView and VisIt
104
+ still read it.
105
+
106
+ ## Status
107
+
108
+ Pre-release (0.2.x). The format may still change; each document records the
109
+ ymf version that wrote it (`ymf:`), and a reader refuses one from a newer ymf.
110
+
111
+ | Piece | State |
112
+ |---|---|
113
+ | Archive data model, YAML I/O, structural checks (`ymf.archive`) | **Implemented.** Tested against real Proteus output; used by Proteus 2.0 (its `main` line) |
114
+ | `.ymf` → `.xmf` conversion (`ymf2xmf`, `ymf.xdmf`) | **Implemented.** Lossless round trip; output opens in ParaView. Reads XDMF from other tools too, refusing by name what the model can't hold ([docs/xdmf-model.yaml](docs/xdmf-model.yaml)) |
115
+ | Self-contained archives: arrays inline, no HDF5 | **Implemented.** `data_item_for(array, inline=True)`; `write_archive.py --inline` |
116
+ | Problem-spec schema v0.2 (`ymf.schema`) | **Implemented.** See the [known gaps](docs/problem-specification.md#known-gaps) |
117
+ | The notation, and strong form → advection-diffusion-reaction form (`ymf.symbolic`) | **Implemented.** Specs run end to end in Proteus, reproducibly, via `ymf_run` |
118
+ | Composing a spec from several files: a model extended into problems (`ymf.compose`) | **Implemented.** Overrides are recorded in the composed document |
119
+ | The archive of a spec: outputs keyed by their input, studies, make-like reruns (`ymf.closure`) | **Implemented.** `ymf_run` writes and checks them; an archive can be extended |
120
+ | Units, scales, dimensionless numbers (`ymf.units`) | **Implemented**, apart from rewriting the PDE in dimensionless form |
121
+ | Manning's n lookup and data-source catalog (`ymf.data_sources`) | Implemented; data fetching is a stub |
122
+ | Parsing the weak forms; dimensionless rewriting of the equations | **Planned.** Weak forms are free text; the solver derives its weak form from the strong one |
123
+ | Dispatch to several solver backends | Planned |
124
+ | Multi-component coupling through BMI (`System:` block) | Deferred to v0.3 |
125
+
126
+ ## Quick start
127
+
128
+ ```bash
129
+ git clone git@github.com:proteustoolkit/ymf.git && cd ymf
130
+ pip install -e '.[dev]' # front-end, examples and tests
131
+ pytest
132
+
133
+ python examples/validate_spec.py
134
+ python examples/write_archive.py --outdir /tmp/ymf-demo
135
+ python examples/read_archive.py /tmp/ymf-demo/heat.ymf
136
+ ymf2xmf -v /tmp/ymf-demo/heat.ymf # then open /tmp/ymf-demo/heat.xmf in ParaView
137
+ ```
138
+
139
+ A solver that only writes archives installs ymf with no extras, which
140
+ brings in `pyyaml` and nothing else. See [examples/README.md](examples/README.md) for
141
+ what each example demonstrates.
142
+
143
+ ## A first look
144
+
145
+ A specification, abridged from
146
+ [examples/kovasznay_flow.ymf](examples/kovasznay_flow.ymf):
147
+
148
+ ```yaml
149
+ model:
150
+ name: "Kovasznay flow, Re = 40"
151
+ physical_model:
152
+ provenance: llm_derived
153
+ processes: [incompressible_flow]
154
+ assumptions: [steady, newtonian, constant_density, two_dimensional]
155
+ dimensionless_numbers:
156
+ Re: {formula: "ρ U L / μ"} # resolved to 40.0
157
+ strong_form:
158
+ unknowns: [{name: v, units: m/s, rank: 1}, {name: p, units: Pa}]
159
+ equations:
160
+ - "ρ ∂v/∂t + ∇·(ρ v⊗v) − μΔv + ∇p = 0 in Ω"
161
+ - "∇·v = 0 in Ω"
162
+ domain: "Ω = [-0.5, 1.0] × [-0.5, 1.5]"
163
+ boundary_conditions:
164
+ - {region: outer, variable: v, type: dirichlet,
165
+ formula: "(1 - exp(λx) cos(2πy), λ/(2π) exp(λx) sin(2πy))"}
166
+ coefficients:
167
+ ρ: {value: 1.0, units: kg/m3}
168
+ μ: {value: 0.025, units: Pa*s}
169
+ λ: "ρ/(2μ) - sqrt(ρ²/(4μ²) + 4π²)"
170
+ ...
171
+ weak_forms:
172
+ - label: "mixed" # needs an inf-sup stable pair
173
+ - label: "stabilized_equal_order" # SUPG/PSPG
174
+ solution_paths:
175
+ discretizations:
176
+ - name: "taylor_hood"
177
+ from_weak_form: "mixed"
178
+ finite_element: {velocity: {family: CG, order: 2}, pressure: {family: CG, order: 1}}
179
+ - name: "equal_order_p1"
180
+ from_weak_form: "stabilized_equal_order"
181
+ finite_element: {velocity: {family: CG, order: 1}, pressure: {family: CG, order: 1}}
182
+ ```
183
+
184
+ Every equation, domain, region, coefficient and formula is written once,
185
+ in Unicode mathematics that `ymf[symbolic]` parses, so this file is also
186
+ what runs: Proteus's `ymf_run` solves it with each discretization and
187
+ measures the error against the exact solution
188
+ ([Running a spec](docs/problem-specification.md#running-a-spec)).
189
+
190
+ Writing an archive, from
191
+ [examples/write_archive.py](examples/write_archive.py):
192
+
193
+ ```python
194
+ from ymf.archive import (new_approximation, add_uniform_step, topology, geometry,
195
+ attribute, data_item_for, write_ymf)
196
+
197
+ domain = new_approximation("Mesh Spatial_Domain")
198
+ topo = topology("Triangle", len(elements), data_item_for(elements, "heat.h5:/elements"))
199
+ geom = geometry(data_item_for(nodes, "heat.h5:/nodes"))
200
+ for k, t in enumerate(times):
201
+ add_uniform_step(domain, t, topo, geom,
202
+ [attribute("T", data_item_for(T[k], "heat.h5:/T_t%d" % k))])
203
+ write_ymf(domain, "heat.ymf", extra=problem) # the spec: model, solution_paths, ...
204
+ ```
205
+
206
+ `data_item_for` reads shape, type and precision off the array, so the
207
+ metadata can't disagree with the data.
208
+
209
+ ## Design principles
210
+
211
+ - **Composable.** A new branch adds weak forms or discretizations and never
212
+ edits existing ones.
213
+ - **Provenance everywhere.** Each decision records whether it was
214
+ `llm_derived`, `human_specified`, `human_edited` or `proteus_derived`.
215
+ - **A trust boundary.** Validation of human/LLM input is thorough and runs
216
+ once, in the front-end. The solver trusts validated input and checks
217
+ only structure, cheaply. The archive core therefore depends on `pyyaml`
218
+ alone. strictyaml measured ~27× slower than libyaml-backed pyyaml
219
+ on archive metadata, too slow for a solver's write path.
220
+ - **XDMF is a consumer, not a dependency.** The archive maps one-to-one
221
+ onto XDMF, and `.xmf` files are derived from it on demand, carrying the
222
+ YMF-only content in a standard `<Information>` element that viewers
223
+ ignore.
224
+ - **Additive evolution.** Schema changes add optional fields where
225
+ possible. The one breaking change so far (structured `unknowns`) comes
226
+ with `normalize_unknowns()`.
227
+
228
+ ## Repository layout
229
+
230
+ ```text
231
+ src/ymf/
232
+ archive.py archive data model, YAML I/O, structural checks (pyyaml)
233
+ xdmf.py domain <-> XDMF conversion (stdlib)
234
+ closure.py the archive of a spec: output keys, studies (pyyaml)
235
+ cli.py the ymf2xmf command
236
+ normalize.py normalize_unknowns (stdlib)
237
+ schema.py problem-spec schema (strictyaml, ymf[spec])
238
+ compose.py `extends`: models, problems built on them (strictyaml, ymf[spec])
239
+ units.py unit checks, scales, dimensionless numbers (pint, ymf[units])
240
+ data_sources.py Manning's n lookup, data-source catalog (stdlib)
241
+ docs/ guides, design drafts, background reports -- start at docs/README.md
242
+ examples/ specs and runnable scripts -- start at examples/README.md
243
+ tests/ pytest suite, including real Proteus .xmf fixtures and the examples
244
+ ```
245
+
246
+ `import ymf` loads only the pyyaml/stdlib modules. `ymf.load_ymf`,
247
+ `ymf.check_units` and the other front-end names load strictyaml or pint on
248
+ first use, so an archive-only install never needs them.
249
+
250
+ ## License
251
+
252
+ MIT (see `LICENSE`).
ymf-0.3.0/README.md ADDED
@@ -0,0 +1,193 @@
1
+ # YMF — YAML Modeling Format
2
+
3
+ YMF is a plain-YAML record of a computational physics problem: what it
4
+ models and why, the equations, how they were discretized and solved, and
5
+ what came out. It is meant to be written and reviewed by people and LLMs
6
+ together, and read and written by solvers.
7
+
8
+ It has two parts that share one format:
9
+
10
+ | | Problem specification | Archive |
11
+ |---|---|---|
12
+ | **What** | The problem from physics down to solver settings: processes and assumptions, strong form, weak forms, discretizations, verification plan | A solver's output: which mesh, time and field each HDF5 dataset holds |
13
+ | **Written by** | a person, an LLM, or both | the solver |
14
+ | **Checked by** | `ymf.schema` (strictyaml) and `ymf.units` (pint): schema, units, dimensional consistency | `ymf.archive`: structure and array shapes only, cheaply |
15
+ | **Depends on** | `ymf[frontend]` | `pyyaml` alone |
16
+ | **Guide** | [docs/problem-specification.md](docs/problem-specification.md) | [docs/archive-format.md](docs/archive-format.md) |
17
+
18
+ The two meet in the archive of a spec: the specification as realized,
19
+ followed by every output computed from it, each keyed by a hash of the part
20
+ of the spec that produced it and recording how it was produced. Such an
21
+ archive is itself a spec: rerunning it reproduces its outputs bitwise, and
22
+ another spec can `extends` it.
23
+
24
+ ## Why
25
+
26
+ Between "simulate this system" and "run this solver" sit a dozen decisions:
27
+ which physics to keep, which unknowns, which weak form, which elements,
28
+ which stabilization. They usually live in someone's head, a notebook, or a
29
+ solver input file that records the outcome but not the reasoning. YMF makes
30
+ each stage a structured, reviewable block, and tags each one with its
31
+ **provenance**: whether an LLM proposed it, a person wrote it, or a person
32
+ edited an LLM's proposal. One document can hold several **branches**
33
+ (competing weak forms and discretizations of the same problem) alongside
34
+ the plan for verifying them against each other. Branches can also be
35
+ separate files: an **abstract** document holding the model (the physics
36
+ and equations, often most of the work for multiphysics) is written once and
37
+ extended, file by file, into many well-posed specs. A document records how
38
+ far it has got -- `ymf_state`: abstract, well-posed, discretized, closed --
39
+ and the loader checks that its content gets that far.
40
+
41
+ On the output side, solver archives have usually been XDMF XML written by
42
+ hand-built element trees, with no data model behind them and nothing
43
+ checking that the metadata matches the arrays. The YMF archive is a small,
44
+ explicit data model that converts one-to-one to XDMF, so ParaView and VisIt
45
+ still read it.
46
+
47
+ ## Status
48
+
49
+ Pre-release (0.2.x). The format may still change; each document records the
50
+ ymf version that wrote it (`ymf:`), and a reader refuses one from a newer ymf.
51
+
52
+ | Piece | State |
53
+ |---|---|
54
+ | Archive data model, YAML I/O, structural checks (`ymf.archive`) | **Implemented.** Tested against real Proteus output; used by Proteus 2.0 (its `main` line) |
55
+ | `.ymf` → `.xmf` conversion (`ymf2xmf`, `ymf.xdmf`) | **Implemented.** Lossless round trip; output opens in ParaView. Reads XDMF from other tools too, refusing by name what the model can't hold ([docs/xdmf-model.yaml](docs/xdmf-model.yaml)) |
56
+ | Self-contained archives: arrays inline, no HDF5 | **Implemented.** `data_item_for(array, inline=True)`; `write_archive.py --inline` |
57
+ | Problem-spec schema v0.2 (`ymf.schema`) | **Implemented.** See the [known gaps](docs/problem-specification.md#known-gaps) |
58
+ | The notation, and strong form → advection-diffusion-reaction form (`ymf.symbolic`) | **Implemented.** Specs run end to end in Proteus, reproducibly, via `ymf_run` |
59
+ | Composing a spec from several files: a model extended into problems (`ymf.compose`) | **Implemented.** Overrides are recorded in the composed document |
60
+ | The archive of a spec: outputs keyed by their input, studies, make-like reruns (`ymf.closure`) | **Implemented.** `ymf_run` writes and checks them; an archive can be extended |
61
+ | Units, scales, dimensionless numbers (`ymf.units`) | **Implemented**, apart from rewriting the PDE in dimensionless form |
62
+ | Manning's n lookup and data-source catalog (`ymf.data_sources`) | Implemented; data fetching is a stub |
63
+ | Parsing the weak forms; dimensionless rewriting of the equations | **Planned.** Weak forms are free text; the solver derives its weak form from the strong one |
64
+ | Dispatch to several solver backends | Planned |
65
+ | Multi-component coupling through BMI (`System:` block) | Deferred to v0.3 |
66
+
67
+ ## Quick start
68
+
69
+ ```bash
70
+ git clone git@github.com:proteustoolkit/ymf.git && cd ymf
71
+ pip install -e '.[dev]' # front-end, examples and tests
72
+ pytest
73
+
74
+ python examples/validate_spec.py
75
+ python examples/write_archive.py --outdir /tmp/ymf-demo
76
+ python examples/read_archive.py /tmp/ymf-demo/heat.ymf
77
+ ymf2xmf -v /tmp/ymf-demo/heat.ymf # then open /tmp/ymf-demo/heat.xmf in ParaView
78
+ ```
79
+
80
+ A solver that only writes archives installs ymf with no extras, which
81
+ brings in `pyyaml` and nothing else. See [examples/README.md](examples/README.md) for
82
+ what each example demonstrates.
83
+
84
+ ## A first look
85
+
86
+ A specification, abridged from
87
+ [examples/kovasznay_flow.ymf](examples/kovasznay_flow.ymf):
88
+
89
+ ```yaml
90
+ model:
91
+ name: "Kovasznay flow, Re = 40"
92
+ physical_model:
93
+ provenance: llm_derived
94
+ processes: [incompressible_flow]
95
+ assumptions: [steady, newtonian, constant_density, two_dimensional]
96
+ dimensionless_numbers:
97
+ Re: {formula: "ρ U L / μ"} # resolved to 40.0
98
+ strong_form:
99
+ unknowns: [{name: v, units: m/s, rank: 1}, {name: p, units: Pa}]
100
+ equations:
101
+ - "ρ ∂v/∂t + ∇·(ρ v⊗v) − μΔv + ∇p = 0 in Ω"
102
+ - "∇·v = 0 in Ω"
103
+ domain: "Ω = [-0.5, 1.0] × [-0.5, 1.5]"
104
+ boundary_conditions:
105
+ - {region: outer, variable: v, type: dirichlet,
106
+ formula: "(1 - exp(λx) cos(2πy), λ/(2π) exp(λx) sin(2πy))"}
107
+ coefficients:
108
+ ρ: {value: 1.0, units: kg/m3}
109
+ μ: {value: 0.025, units: Pa*s}
110
+ λ: "ρ/(2μ) - sqrt(ρ²/(4μ²) + 4π²)"
111
+ ...
112
+ weak_forms:
113
+ - label: "mixed" # needs an inf-sup stable pair
114
+ - label: "stabilized_equal_order" # SUPG/PSPG
115
+ solution_paths:
116
+ discretizations:
117
+ - name: "taylor_hood"
118
+ from_weak_form: "mixed"
119
+ finite_element: {velocity: {family: CG, order: 2}, pressure: {family: CG, order: 1}}
120
+ - name: "equal_order_p1"
121
+ from_weak_form: "stabilized_equal_order"
122
+ finite_element: {velocity: {family: CG, order: 1}, pressure: {family: CG, order: 1}}
123
+ ```
124
+
125
+ Every equation, domain, region, coefficient and formula is written once,
126
+ in Unicode mathematics that `ymf[symbolic]` parses, so this file is also
127
+ what runs: Proteus's `ymf_run` solves it with each discretization and
128
+ measures the error against the exact solution
129
+ ([Running a spec](docs/problem-specification.md#running-a-spec)).
130
+
131
+ Writing an archive, from
132
+ [examples/write_archive.py](examples/write_archive.py):
133
+
134
+ ```python
135
+ from ymf.archive import (new_approximation, add_uniform_step, topology, geometry,
136
+ attribute, data_item_for, write_ymf)
137
+
138
+ domain = new_approximation("Mesh Spatial_Domain")
139
+ topo = topology("Triangle", len(elements), data_item_for(elements, "heat.h5:/elements"))
140
+ geom = geometry(data_item_for(nodes, "heat.h5:/nodes"))
141
+ for k, t in enumerate(times):
142
+ add_uniform_step(domain, t, topo, geom,
143
+ [attribute("T", data_item_for(T[k], "heat.h5:/T_t%d" % k))])
144
+ write_ymf(domain, "heat.ymf", extra=problem) # the spec: model, solution_paths, ...
145
+ ```
146
+
147
+ `data_item_for` reads shape, type and precision off the array, so the
148
+ metadata can't disagree with the data.
149
+
150
+ ## Design principles
151
+
152
+ - **Composable.** A new branch adds weak forms or discretizations and never
153
+ edits existing ones.
154
+ - **Provenance everywhere.** Each decision records whether it was
155
+ `llm_derived`, `human_specified`, `human_edited` or `proteus_derived`.
156
+ - **A trust boundary.** Validation of human/LLM input is thorough and runs
157
+ once, in the front-end. The solver trusts validated input and checks
158
+ only structure, cheaply. The archive core therefore depends on `pyyaml`
159
+ alone. strictyaml measured ~27× slower than libyaml-backed pyyaml
160
+ on archive metadata, too slow for a solver's write path.
161
+ - **XDMF is a consumer, not a dependency.** The archive maps one-to-one
162
+ onto XDMF, and `.xmf` files are derived from it on demand, carrying the
163
+ YMF-only content in a standard `<Information>` element that viewers
164
+ ignore.
165
+ - **Additive evolution.** Schema changes add optional fields where
166
+ possible. The one breaking change so far (structured `unknowns`) comes
167
+ with `normalize_unknowns()`.
168
+
169
+ ## Repository layout
170
+
171
+ ```text
172
+ src/ymf/
173
+ archive.py archive data model, YAML I/O, structural checks (pyyaml)
174
+ xdmf.py domain <-> XDMF conversion (stdlib)
175
+ closure.py the archive of a spec: output keys, studies (pyyaml)
176
+ cli.py the ymf2xmf command
177
+ normalize.py normalize_unknowns (stdlib)
178
+ schema.py problem-spec schema (strictyaml, ymf[spec])
179
+ compose.py `extends`: models, problems built on them (strictyaml, ymf[spec])
180
+ units.py unit checks, scales, dimensionless numbers (pint, ymf[units])
181
+ data_sources.py Manning's n lookup, data-source catalog (stdlib)
182
+ docs/ guides, design drafts, background reports -- start at docs/README.md
183
+ examples/ specs and runnable scripts -- start at examples/README.md
184
+ tests/ pytest suite, including real Proteus .xmf fixtures and the examples
185
+ ```
186
+
187
+ `import ymf` loads only the pyyaml/stdlib modules. `ymf.load_ymf`,
188
+ `ymf.check_units` and the other front-end names load strictyaml or pint on
189
+ first use, so an archive-only install never needs them.
190
+
191
+ ## License
192
+
193
+ MIT (see `LICENSE`).
ymf-0.3.0/RELEASING.md ADDED
@@ -0,0 +1,68 @@
1
+ # Releasing ymf
2
+
3
+ A release is a git tag. `.github/workflows/release.yml` builds the sdist and
4
+ wheel from the tagged commit, checks them (`tools/check_dist.sh`: size,
5
+ contents, `twine check`, a fresh-venv install that runs), and publishes with
6
+ PyPI Trusted Publishing (OIDC: no API token, no secret). The version is
7
+ whatever `setuptools_scm` derives from the tag; the workflow refuses a tag that
8
+ does not equal `v<built version>`.
9
+
10
+ | tag | goes to |
11
+ |---|---|
12
+ | `v0.3.0rc1`, `v0.3.0a1`, `v0.3.0b1` | TestPyPI (environment `testpypi`) |
13
+ | `v0.3.0` | PyPI (environment `pypi`) |
14
+
15
+ The tag `v0.2.0` already exists from before this workflow; it is not re-pushed
16
+ and nothing publishes it. Pick the first published version knowing that.
17
+
18
+ ## What the maintainer does by hand (once)
19
+
20
+ Name check, 2026-11-16: `ymf` returns 404 on pypi.org and test.pypi.org (JSON
21
+ API and simple index), so it is free today. PyPI can still refuse a name that
22
+ is confusingly close to an existing project, and a project registered
23
+ meanwhile wins: do step 1 soon.
24
+
25
+ 1. **TestPyPI**: log in at test.pypi.org (a separate account from PyPI), then
26
+ *Your account → Publishing → Add a new pending publisher*: project name
27
+ `ymf`, owner `proteustoolkit` (or `cekees` to rehearse from the fork),
28
+ repository `ymf`, workflow `release.yml`, environment `testpypi`.
29
+ 2. **PyPI**: the same at pypi.org, environment `pypi`. A *pending* publisher
30
+ creates the project on the first upload, so nothing is uploaded to claim
31
+ the name.
32
+ 3. **GitHub environments** on the repository that will run the workflow:
33
+ Settings → Environments → create `testpypi` and `pypi`. For `pypi`, add
34
+ yourself as a required reviewer so a final tag waits for a click; leave
35
+ `testpypi` unprotected. No secrets are added to either.
36
+ 4. **Push a pre-release tag** from a commit on `main` whose CI is green:
37
+
38
+ ```bash
39
+ git tag -a v0.3.0rc1 -m "ymf 0.3.0rc1" && git push origin v0.3.0rc1
40
+ ```
41
+
42
+ Then try it the way a user would:
43
+
44
+ ```bash
45
+ python -m venv /tmp/t && /tmp/t/bin/pip install --index-url https://test.pypi.org/simple/ \
46
+ --extra-index-url https://pypi.org/simple/ "ymf[frontend]==0.3.0rc1"
47
+ ```
48
+
49
+ (the extra index supplies pyyaml and the extras' dependencies, which are
50
+ not on TestPyPI). A TestPyPI file name can never be reused: a mistake is
51
+ fixed by `rc2`, not by re-uploading.
52
+ 5. When rc installs and runs, tag `v0.3.0` the same way for PyPI.
53
+
54
+ To rehearse the build without publishing, run `tools/check_dist.sh` (set
55
+ `SETUPTOOLS_SCM_PRETEND_VERSION=0.3.0rc1` off a tag).
56
+
57
+ ## Pinning from proteus CI (not done here)
58
+
59
+ proteus's workflows install ymf from `git+https://github.com/proteustoolkit/ymf.git@main`,
60
+ a moving branch, in the environment files and in the comment block of
61
+ `.github/workflows/sdist.yml`. After a tagged release exists, the proteus-side
62
+ change is: replace `@main` with the tag (`@v0.3.0`, or `ymf==0.3.0` from PyPI
63
+ once it is there; before that, TestPyPI needs the extra-index form above and
64
+ is not worth using in CI), in every environment file and workflow that names
65
+ it, and update the comment. The pin moves by a one-line PR per ymf release; a
66
+ ymf change that proteus needs merges in ymf, is tagged, and then the proteus PR
67
+ bumps the pin. That is a proteus change: it needs its own PR and is not part of
68
+ this one.
@@ -0,0 +1,47 @@
1
+ # YMF documentation
2
+
3
+ Start with the two guides. They describe what exists today. Design notes say
4
+ what was decided and whether it is built. History and research are kept for
5
+ their reasoning, not as a description of the code.
6
+
7
+ ## Guides (current)
8
+
9
+ | Document | What it covers |
10
+ |---|---|
11
+ | [problem-specification.md](problem-specification.md) | Writing and validating a problem spec: structure, branching, composition, provenance, units, known gaps |
12
+ | [archive-format.md](archive-format.md) | Archives: the archive of a spec (outputs keyed by their input, studies, reruns, `extends`), and the archive a solver writes: files on disk, the domain model, parallel output, XDMF conversion, use in Proteus |
13
+ | [xdmf-model.yaml](xdmf-model.yaml) | The archive model laid out in the order of XDMF's own [Model and Format](https://xdmf.org/index.php/XDMF_Model_and_Format.html) page: each XDMF element and attribute, the `.ymf` key that holds it, and whether it is supported. For readers who know XDMF. Checked by `tests/test_xdmf_model.py`. |
14
+ | [changes.md](changes.md) | Gaps that have been closed, dated, with the commit that closed each. The guides describe the result; this says why it is that way. |
15
+
16
+ ## Design notes
17
+
18
+ A design note is written before the code, records the decisions taken on it,
19
+ and lands in `design/` with the code that implements it.
20
+
21
+ | Note | Status |
22
+ |---|---|
23
+ | [design/time-outside-space.md](design/time-outside-space.md) | **Implemented** 2026-10-26: archive format 2, one list of instants with the spaces inside each. |
24
+ | [design/domains-beyond-box.md](design/domains-beyond-box.md) | **Implemented** 2026-11-04 (C27 Phase 5): boundary regions by tag, periodic on a region whose faces match, `file` and `discrete` domains; decisions D1-D4. |
25
+
26
+ ## History
27
+
28
+ Superseded drafts, kept for the reasoning behind decisions still in force.
29
+ Each starts with a note saying what replaced it.
30
+
31
+ | Document | What it was |
32
+ |---|---|
33
+ | [history/schema-v0.1.md](history/schema-v0.1.md) | The original v0.1 schema draft. Its § 3 is still the only description of the intended `vvuq` shape. |
34
+ | [history/schema-v0.2-delta.md](history/schema-v0.2-delta.md) | The v0.2 changes on top of v0.1, which `ymf.schema` implements. |
35
+ | [history/session-2026-07-29.md](history/session-2026-07-29.md) | Notes from the session where YMF was designed, under its earlier name YDMF. |
36
+
37
+ ## Background research
38
+
39
+ Drafted with an LLM research agent, and not all checked against their
40
+ sources. Treat specific numbers and API names in them as leads to verify,
41
+ not facts. Each says so in its own header.
42
+
43
+ | Document | Covers | Caution |
44
+ |---|---|---|
45
+ | [research/units.md](research/units.md) | Unit libraries, dimensional analysis, non-dimensionalization | The basis for `ymf.units`. |
46
+ | [research/data-sources.md](research/data-sources.md) | Topography, bathymetry, land cover, roughness and forcing datasets | The basis for `ymf.data_sources`; dataset details not re-verified. |
47
+ | [research/csdms-bmi.md](research/csdms-bmi.md) | CSDMS Standard Names and the Basic Model Interface | **Contains known errors**, listed in its header. |