pyphasediagram 0.1.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 (48) hide show
  1. pyphasediagram-0.1.0/.github/workflows/release_pip.yml +37 -0
  2. pyphasediagram-0.1.0/.github/workflows/tests.yml +34 -0
  3. pyphasediagram-0.1.0/.gitignore +15 -0
  4. pyphasediagram-0.1.0/.pre-commit-config.yaml +12 -0
  5. pyphasediagram-0.1.0/LICENSE +9 -0
  6. pyphasediagram-0.1.0/PKG-INFO +63 -0
  7. pyphasediagram-0.1.0/README.md +27 -0
  8. pyphasediagram-0.1.0/docs/Makefile +20 -0
  9. pyphasediagram-0.1.0/docs/make.bat +35 -0
  10. pyphasediagram-0.1.0/docs/package-architecture.md +284 -0
  11. pyphasediagram-0.1.0/docs/paper/Makefile +15 -0
  12. pyphasediagram-0.1.0/docs/paper/paper.bib +129 -0
  13. pyphasediagram-0.1.0/docs/paper/paper.md +128 -0
  14. pyphasediagram-0.1.0/docs/source/api.rst +15 -0
  15. pyphasediagram-0.1.0/docs/source/conf.py +62 -0
  16. pyphasediagram-0.1.0/docs/source/index.rst +19 -0
  17. pyphasediagram-0.1.0/examples/different_ensembles.py +180 -0
  18. pyphasediagram-0.1.0/examples/fourcomp.py +228 -0
  19. pyphasediagram-0.1.0/examples/simple_usage.py +27 -0
  20. pyphasediagram-0.1.0/pyproject.toml +121 -0
  21. pyphasediagram-0.1.0/requirements.txt +1 -0
  22. pyphasediagram-0.1.0/scripts/flory_validate.py +628 -0
  23. pyphasediagram-0.1.0/setup.cfg +4 -0
  24. pyphasediagram-0.1.0/src/pyphasediagram/__init__.py +19 -0
  25. pyphasediagram-0.1.0/src/pyphasediagram/_version.py +24 -0
  26. pyphasediagram-0.1.0/src/pyphasediagram/binodal.py +901 -0
  27. pyphasediagram-0.1.0/src/pyphasediagram/diagram.py +426 -0
  28. pyphasediagram-0.1.0/src/pyphasediagram/point.py +588 -0
  29. pyphasediagram-0.1.0/src/pyphasediagram/spinodal.py +894 -0
  30. pyphasediagram-0.1.0/src/pyphasediagram/stepper/__init__.py +1 -0
  31. pyphasediagram-0.1.0/src/pyphasediagram/stepper/base.py +682 -0
  32. pyphasediagram-0.1.0/src/pyphasediagram/stepper/flory_stepper.py +346 -0
  33. pyphasediagram-0.1.0/src/pyphasediagram/utils.py +213 -0
  34. pyphasediagram-0.1.0/src/pyphasediagram.egg-info/PKG-INFO +63 -0
  35. pyphasediagram-0.1.0/src/pyphasediagram.egg-info/SOURCES.txt +46 -0
  36. pyphasediagram-0.1.0/src/pyphasediagram.egg-info/dependency_links.txt +1 -0
  37. pyphasediagram-0.1.0/src/pyphasediagram.egg-info/requires.txt +14 -0
  38. pyphasediagram-0.1.0/src/pyphasediagram.egg-info/scm_file_list.json +42 -0
  39. pyphasediagram-0.1.0/src/pyphasediagram.egg-info/scm_version.json +8 -0
  40. pyphasediagram-0.1.0/src/pyphasediagram.egg-info/top_level.txt +1 -0
  41. pyphasediagram-0.1.0/tests/conftest.py +5 -0
  42. pyphasediagram-0.1.0/tests/test_binodal.py +474 -0
  43. pyphasediagram-0.1.0/tests/test_diagram.py +200 -0
  44. pyphasediagram-0.1.0/tests/test_point.py +118 -0
  45. pyphasediagram-0.1.0/tests/test_spinodal.py +933 -0
  46. pyphasediagram-0.1.0/tests/test_stepper_base.py +344 -0
  47. pyphasediagram-0.1.0/tests/test_stepper_ternary.py +188 -0
  48. pyphasediagram-0.1.0/tests/test_utils.py +235 -0
@@ -0,0 +1,37 @@
1
+ name: Upload Python Package
2
+
3
+ on:
4
+ release:
5
+ types: [released]
6
+
7
+ jobs:
8
+ deploy:
9
+ runs-on: ubuntu-latest
10
+ timeout-minutes: 15
11
+
12
+ steps:
13
+ - uses: actions/checkout@v7
14
+
15
+ - name: Set up Python
16
+ uses: actions/setup-python@v7
17
+ with:
18
+ python-version: "3.12"
19
+
20
+ - name: Install dependencies
21
+ run: |
22
+ python -m pip install --upgrade pip
23
+ pip install build twine
24
+
25
+ - name: Prepare build
26
+ run: |
27
+ python -m build 2>&1 | tee build.log
28
+ # exit `fgrep -i warning build.log | wc -l`
29
+
30
+ - name: Check the package
31
+ run: twine check --strict dist/*
32
+
33
+ - name: Build and publish
34
+ env:
35
+ TWINE_USERNAME: __token__
36
+ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
37
+ run: python -m twine upload dist/*
@@ -0,0 +1,34 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths-ignore:
8
+ - 'README.md'
9
+ pull_request:
10
+ paths-ignore:
11
+ - 'README.md'
12
+
13
+ jobs:
14
+ pytest:
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.12"
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install -e ".[dev]"
29
+
30
+ - name: Run tests
31
+ env:
32
+ MPLBACKEND: Agg
33
+ run: |
34
+ pytest -q
@@ -0,0 +1,15 @@
1
+ .venv
2
+ data
3
+ report
4
+ **/__pycache__/
5
+ *.png
6
+ *.egg-info
7
+ src/pyphasediagram/depr
8
+ .DS_Store
9
+ .vscode
10
+ delete
11
+ debug
12
+ docs/build/
13
+ docs/source/generated/
14
+ docs/paper/paper.crossref
15
+ docs/paper/paper.pdf
@@ -0,0 +1,12 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v6.0.0
4
+ hooks:
5
+ - id: check-yaml
6
+
7
+ - repo: https://github.com/astral-sh/ruff-pre-commit
8
+ rev: v0.17.3
9
+ hooks:
10
+ - id: ruff
11
+ args: [--fix, --show-fixes]
12
+ - id: ruff-format
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Malcolm Steen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyphasediagram
3
+ Version: 0.1.0
4
+ Summary: A Python package implementing fast calculations of binodals of ternary systems.
5
+ Author-email: Malcolm Steen <malcolm.steen@stud.uni-goettingen.de>, David Zwicker <david.zwicker@ds.mpg.de>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Malcolm Steen
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ Project-URL: repository, https://github.com/steenmalcolm/pyphasediagram
16
+ Keywords: Phase diagrams
17
+ Classifier: Development Status :: 3 - Alpha
18
+ Classifier: Intended Audience :: Science/Research
19
+ Classifier: Programming Language :: Python :: 3
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: jax>=0.4
24
+ Requires-Dist: matplotlib
25
+ Requires-Dist: mpltern<2,>=1.0.5
26
+ Requires-Dist: networkx
27
+ Requires-Dist: numpy
28
+ Requires-Dist: scipy
29
+ Requires-Dist: shapely>=2
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=6.0.0; extra == "dev"
32
+ Provides-Extra: docs
33
+ Requires-Dist: sphinx; extra == "docs"
34
+ Requires-Dist: sphinx-rtd-theme; extra == "docs"
35
+ Dynamic: license-file
36
+
37
+ # Phase Diagram Analysis for Ternary Flory–Huggins Systems
38
+
39
+ This project provides tools to **compute and analyze ternary phase diagrams** based on the **Flory–Huggins free energy model**.
40
+ It includes a core class:
41
+
42
+ - **`PhaseDiagram`** – add binodal branches to a full ternary phase diagram and locate three-phase coexistence points and critical points
43
+
44
+ ## Installation
45
+
46
+ After cloning the repository and navigating into the project directory, install the package using pip:
47
+
48
+ ```bash
49
+ pip install -e .
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ There is a simple example in the `examples` folder.
55
+
56
+ ## Development
57
+
58
+ Install the pre-commit hooks to ensure code formatting using
59
+
60
+ ```bash
61
+ pip install pre-commit
62
+ pre-commit install
63
+ ```
@@ -0,0 +1,27 @@
1
+ # Phase Diagram Analysis for Ternary Flory–Huggins Systems
2
+
3
+ This project provides tools to **compute and analyze ternary phase diagrams** based on the **Flory–Huggins free energy model**.
4
+ It includes a core class:
5
+
6
+ - **`PhaseDiagram`** – add binodal branches to a full ternary phase diagram and locate three-phase coexistence points and critical points
7
+
8
+ ## Installation
9
+
10
+ After cloning the repository and navigating into the project directory, install the package using pip:
11
+
12
+ ```bash
13
+ pip install -e .
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ There is a simple example in the `examples` folder.
19
+
20
+ ## Development
21
+
22
+ Install the pre-commit hooks to ensure code formatting using
23
+
24
+ ```bash
25
+ pip install pre-commit
26
+ pre-commit install
27
+ ```
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,284 @@
1
+ This document was created with AI assistance and only serves as a reference for the package architecture.
2
+ # `pyphasediagram` package architecture
3
+
4
+ This document describes the modules under `src/pyphasediagram`. The diagrams use
5
+ [Mermaid](https://mermaid.js.org/) and render directly in GitHub and many Markdown
6
+ viewers.
7
+
8
+ ## Module dependencies
9
+
10
+ Solid arrows are internal imports. Dashed arrows point to third-party packages.
11
+ The two package `__init__.py` files form the public import paths shown at the top.
12
+
13
+ ```mermaid
14
+ flowchart LR
15
+ package_init["pyphasediagram<br/>__init__.py"]
16
+ diagram["diagram.py<br/>PhaseDiagram"]
17
+ binodal["binodal.py<br/>Binodal, BinodalSection"]
18
+ spinodal["spinodal.py<br/>Spinodal"]
19
+ point["point.py<br/>point/value classes"]
20
+ stepper_init["stepper/__init__.py<br/>exports Stepper"]
21
+ flory["stepper/flory_stepper.py<br/>Stepper"]
22
+ base["stepper/base.py<br/>BaseStepper"]
23
+
24
+ package_init -->|exports| diagram
25
+ diagram --> binodal
26
+ diagram --> spinodal
27
+ binodal --> point
28
+ binodal --> stepper_init
29
+ spinodal --> point
30
+ stepper_init -->|exports| flory
31
+ flory --> base
32
+
33
+ subgraph third_party[Third-party dependencies]
34
+ numpy[NumPy]
35
+ matplotlib[Matplotlib]
36
+ shapely[Shapely]
37
+ networkx[NetworkX]
38
+ jax[JAX]
39
+ scipy[SciPy]
40
+ end
41
+
42
+ diagram -.-> numpy
43
+ diagram -.-> matplotlib
44
+ diagram -.-> shapely
45
+ binodal -.-> numpy
46
+ binodal -.-> matplotlib
47
+ binodal -.-> shapely
48
+ binodal -.-> networkx
49
+ spinodal -.-> numpy
50
+ spinodal -.-> matplotlib
51
+ spinodal -.-> shapely
52
+ spinodal -.-> networkx
53
+ point -.-> numpy
54
+ point -.-> matplotlib
55
+ point -.-> networkx
56
+ flory -.-> numpy
57
+ flory -.-> jax
58
+ flory -.-> scipy
59
+ base -.-> numpy
60
+ base -.-> jax
61
+ ```
62
+
63
+ ## Classes, attributes, and methods
64
+
65
+ `+` denotes public API, `-` denotes an internal implementation detail, and `{static}`
66
+ or `{abstract}` describes special methods. Attributes marked "after build" are added
67
+ by `build()` rather than by the constructor.
68
+
69
+ ```mermaid
70
+ classDiagram
71
+ direction LR
72
+
73
+ class PhaseDiagram {
74
+ +ndarray chis
75
+ +Spinodal spinodal (after build)
76
+ +Binodal binodal (after build)
77
+ +__init__(chis)
78
+ -_free_energy(phi) ndarray
79
+ +build() None
80
+ +get_compositions(phi_m) ndarray
81
+ +plot_phase_counts(ax=None)
82
+ +plot(ax=None)
83
+ +plot_summary()
84
+ }
85
+
86
+ class Spinodal {
87
+ +tuple DOMAIN_CORNERS
88
+ +ndarray chis
89
+ +Graph spinodal_graph
90
+ +int node_id
91
+ +list~CriticalPoint~ critical_points
92
+ +list~Polygon~ polygons
93
+ +__init__(chis)
94
+ +build(num_points=10000)
95
+ -_get_quadratic_coefficients(phi, is_calculate_phi2=True)
96
+ -_polynomial_degree_masks(quadratic, linear, constant)
97
+ +get_spinodal_coords()
98
+ -_phi2_from_phi1(phi1)
99
+ +eigenvalues_from_phi(phi1, phi2)
100
+ -_domain_data(phi1_i, phi1_f, num_points=5000)
101
+ -_spinodal_domains()
102
+ -_in_domain(phi1, phi2) bool
103
+ -_clip_to_domain()
104
+ -_connect_branches()
105
+ -_coords_from_subgraph(sg)
106
+ -_third_derivative(phi1, phi2)
107
+ -_find_critical_points()
108
+ -_build_polygons()
109
+ +get_unstable_manifold()
110
+ +plot(**kwargs)
111
+ }
112
+
113
+ class Binodal {
114
+ +float SV_BRANCH_THRESHOLD
115
+ +ndarray chis
116
+ +list~CriticalPoint~ critical_points
117
+ +list~BinodalSection~ binodal_sections
118
+ +list~Polygon~ three_phase_polygons
119
+ +list~Polygon~ two_phase_polygons
120
+ -Stepper _stepper
121
+ -list~BinodalInitialPoint~ _bipt_task_list
122
+ -list~BinodalInitialPoint~ _bipt_hist
123
+ +__init__(chis, critical_points=[])
124
+ -_build_section(phi_init, v_init)
125
+ +build(unstable_manifold=None) None
126
+ -_remove_duplicate_sections()
127
+ -_find_branching_points(section)
128
+ -_find_phase_polygons()
129
+ -_find_three_phase_polygons(overlap_threshold=0.98)
130
+ -_find_two_phase_polygons()
131
+ -_remove_unstable_sections(unstable_manifold=None)
132
+ -_free_energy(phi)
133
+ +decomposition_from_composition(phi_means)
134
+ +plot_sections(**kwargs)
135
+ +plot_polygons(**kwargs)
136
+ }
137
+
138
+ class BinodalSection {
139
+ +ndarray phis
140
+ +ndarray svs
141
+ +LineString line_a
142
+ +LineString line_b
143
+ -tuple _lines
144
+ -tuple _coords
145
+ +__init__(phis, svs)
146
+ +plot(colora="red", colorb="blue", is_tie_lines=False, **kwargs)
147
+ -_interpolate_on_segment(coords, point) tuple
148
+ -_intersection_params(self_idx, other, other_idx)
149
+ +intersects_with(other)
150
+ +contained_in(other, n_samples=1000) bool
151
+ -_degenerate_points(sv_branch_threshold=1e-2)
152
+ +__len__() int
153
+ }
154
+
155
+ class BaseStepper {
156
+ <<abstract>>
157
+ +float MAX_STEPS
158
+ +int CYCLE_MIN_STEPS
159
+ +float CYCLE_INIT_TOL
160
+ -callable _residual_jit
161
+ -callable _jac_fn
162
+ -callable _svd_fn
163
+ -callable _run_jit
164
+ +__init__()
165
+ +residual(phi)* ndarray
166
+ +is_terminate(phi)* ndarray
167
+ -_svd(J, full_matrices=False)
168
+ -_tangent_vec(phi)
169
+ -_projection(phi)
170
+ -_hit_initial_cycle(step, phi, phi_hist)
171
+ -_decode_status(status)
172
+ -_projection_loop(phi)
173
+ -_step_once(...)
174
+ -_loop_cond(carry)
175
+ -_loop_body(...)
176
+ -_run_impl(...)
177
+ +run(phi_init, v_init, delta_0=2e-4, delta_1=1e-3)
178
+ }
179
+
180
+ class Stepper {
181
+ +ndarray chis
182
+ +__init__(chis)
183
+ +residual(phi) ndarray
184
+ +is_terminate(phi) ndarray
185
+ +binary_state(chi) float
186
+ +binary_init(which_comp=0) ndarray
187
+ }
188
+
189
+ class Point {
190
+ +int idx
191
+ +float phi1
192
+ +float phi2
193
+ +__init__(idx, phi1, phi2)
194
+ +dist(pt)
195
+ +__repr__() str
196
+ +__add__(pt)
197
+ +__sub__(pt)
198
+ +plot(s=10, **kwargs)
199
+ +is_between(pt1, pt2, tol=pi/8) bool
200
+ +is_close_to(pt, tol=1e-3) bool
201
+ +__iter__()
202
+ }
203
+
204
+ class SpinodalPoint {
205
+ +__repr__() str
206
+ }
207
+
208
+ class CriticalPoint {
209
+ +float dphi1
210
+ +float dphi2
211
+ +__init__(idx, phi1, phi2, dphi1, dphi2)
212
+ +from_points(idx, pt1, pt2) CriticalPoint
213
+ +get_phi_and_v_init()
214
+ +plot(s=10, **kwargs)
215
+ +__repr__() str
216
+ }
217
+
218
+ class BinodalPoint {
219
+ +Point pta
220
+ +Point ptb
221
+ +__init__(phi1a, phi2a, phi1b, phi2b)
222
+ +from_points(pt1, pt2, sv) BinodalPoint
223
+ +__repr__() str
224
+ +to_numpy() ndarray
225
+ +plot(s=20, **kwargs)
226
+ }
227
+
228
+ class BinodalInitialPoint {
229
+ +ndarray phi_init
230
+ +ndarray v_init
231
+ +__init__(phi_init, v_init)
232
+ +is_similar_to(bipt, dist_tol=1e-3, angle_tol=pi/8) bool
233
+ +plot(**kwargs)
234
+ +__repr__() str
235
+ +__iter__()
236
+ }
237
+
238
+ BaseStepper <|-- Stepper
239
+ Point <|-- SpinodalPoint
240
+ Point <|-- CriticalPoint
241
+ BinodalPoint <|-- BinodalInitialPoint
242
+
243
+ PhaseDiagram *-- Spinodal : builds
244
+ PhaseDiagram *-- Binodal : builds
245
+ Spinodal *-- SpinodalPoint : graph nodes
246
+ Spinodal *-- CriticalPoint : finds
247
+ Binodal *-- BinodalSection : contains
248
+ Binodal *-- Stepper : traces with
249
+ Binodal o-- CriticalPoint : initialized from
250
+ Binodal *-- BinodalInitialPoint : queues/history
251
+ BinodalPoint *-- Point : phase endpoints
252
+ ```
253
+
254
+ ## Main build flow
255
+
256
+ ```mermaid
257
+ flowchart TD
258
+ start["PhaseDiagram(chis)"] --> build["PhaseDiagram.build()"]
259
+ build --> spinodal_create["Create Spinodal"]
260
+ spinodal_create --> spinodal_build["Spinodal.build()"]
261
+ spinodal_build --> graph["Construct spinodal graph and polygons"]
262
+ graph --> critical["Find CriticalPoint objects"]
263
+ critical --> binodal_create["Create Binodal with critical points"]
264
+ binodal_create --> manifold["Get unstable manifold from Spinodal"]
265
+ manifold --> binodal_build["Binodal.build(unstable_manifold)"]
266
+ binodal_build --> seeds["Seed from binary limits and critical points"]
267
+ seeds --> trace["Stepper.run() traces coexistence sections"]
268
+ trace --> branch["Detect and queue branch points"]
269
+ branch --> clean["Remove unstable and duplicate sections"]
270
+ clean --> polygons["Build two- and three-phase polygons"]
271
+ polygons --> ready["Diagram ready for plotting/decomposition"]
272
+ ```
273
+
274
+ ## Reading guide
275
+
276
+ - `diagram.py` is the facade: start with `PhaseDiagram.build()` and its plotting
277
+ methods.
278
+ - `spinodal.py` finds instability boundaries and critical points.
279
+ - `binodal.py` traces coexistence curves, detects intersections, and builds the
280
+ two- and three-phase regions.
281
+ - `stepper/base.py` contains the generic JAX predictor/projector loop;
282
+ `stepper/flory_stepper.py` supplies the Flory-Huggins residual and initialization.
283
+ - `point.py` provides the small point and initialization objects shared by the
284
+ spinodal and binodal calculations.
@@ -0,0 +1,15 @@
1
+ # OUTPUT_NAME must always be paper
2
+ INPUT_NAME = paper
3
+ OUTPUT_NAME = paper
4
+
5
+ ALL_OUTPUTS = $(OUTPUT_NAME).pdf $(OUTPUT_NAME).crossref
6
+
7
+ all: $(ALL_OUTPUTS)
8
+
9
+ $(ALL_OUTPUTS): $(INPUT_NAME).md $(INPUT_NAME).bib
10
+ @docker run --rm -it -v $(PWD):/data -u $(id -u):$(id -g) openjournals/inara -o pdf,crossref $(INPUT_NAME).md
11
+
12
+ .PHONY: clean
13
+
14
+ clean:
15
+ @rm -f ${ALL_OUTPUTS}
@@ -0,0 +1,129 @@
1
+ @article{Huang1995,
2
+ author = {Huang, C. and Olvera de la Cruz, M. and Swift, B. W.},
3
+ title = {Phase Separation of Ternary Mixtures: Symmetric Polymer Blends},
4
+ journal = {Macromolecules},
5
+ year = {1995},
6
+ volume = {28},
7
+ number = {24},
8
+ pages = {7996--8005},
9
+ doi = {10.1021/ma00128a005},
10
+ url = {https://doi.org/10.1021/ma00128a005}
11
+ }
12
+
13
+ @article{Shek2022,
14
+ author = {Shek, Alvin C. M. and Kusumaatmaja, Halim},
15
+ title = {Spontaneous phase separation of ternary fluid mixtures},
16
+ journal = {Soft Matter},
17
+ year = {2022},
18
+ volume = {18},
19
+ pages = {5807--5814},
20
+ doi = {10.1039/D2SM00413E},
21
+ url = {https://doi.org/10.1039/D2SM00413E}
22
+ }
23
+
24
+ @article{Qiang2025,
25
+ author = {Qiang, Yicheng and Zwicker, David},
26
+ title = {flory: A {Python} package for finding coexisting phases in multicomponent mixtures},
27
+ journal = {Journal of Open Source Software},
28
+ year = {2025},
29
+ volume = {10},
30
+ number = {107},
31
+ pages = {7388},
32
+ doi = {10.21105/joss.07388},
33
+ url = {https://doi.org/10.21105/joss.07388}
34
+ }
35
+
36
+
37
+ @misc{Kostler2026,
38
+ author = {Stefan K{\"o}stler and Malcolm Steen and David Zwicker},
39
+ title = {Phase diagram morphology shapes droplet propulsion in chemical gradients},
40
+ year = {2026}}
41
+
42
+ @article{Mao2019,
43
+ author = {Mao, Sheng and Kuldinow, Derek and Haataja, Mikko and Ko{\v s}mrlj, Andrej},
44
+ journal = {Soft Matter},
45
+ pages = {1297},
46
+ title = {Phase behavior and morphology of multicomponent liquid mixtures},
47
+ volume = {15},
48
+ year = {2019}}
49
+
50
+
51
+ @article{Shcherbakova2023,
52
+ author = {Shcherbakova, Nataliya and Gerbaud, Vincent and Roger, Kevin},
53
+ title = {Using the Intrinsic Geometry of Binodal Curves to Simplify the Computation of Ternary Liquid--Liquid Phase Diagrams},
54
+ journal = {Entropy},
55
+ year = {2023},
56
+ volume = {25},
57
+ number = {9},
58
+ pages = {1329},
59
+ doi = {10.3390/e25091329},
60
+ url = {https://doi.org/10.3390/e25091329}
61
+ }
62
+
63
+ @book{Allgower1990,
64
+ author = {Allgower, Eugene L. and Georg, Kurt},
65
+ title = {Numerical Continuation Methods: An Introduction},
66
+ publisher = {Springer-Verlag},
67
+ series = {Springer Series in Computational Mathematics},
68
+ volume = {13},
69
+ year = {1990},
70
+ doi = {10.1007/978-3-642-61257-2},
71
+ url = {https://doi.org/10.1007/978-3-642-61257-2}
72
+ }
73
+
74
+
75
+ @article{Milani2007,
76
+ author = {Milani, Gabriele and Milani, Federico},
77
+ title = {Genetic algorithm for the determination of binodal curves in ternary systems polymer--liquid(1)--liquid(2) and polymer(1)--polymer(2)--solvent},
78
+ journal = {Journal of Computational Chemistry},
79
+ year = {2007},
80
+ volume = {28},
81
+ number = {13},
82
+ pages = {2203--2215},
83
+ doi = {10.1002/jcc.20735},
84
+ url = {https://doi.org/10.1002/jcc.20735}
85
+ }
86
+
87
+ @article{Wei2006,
88
+ author = {Wei, Yong-Ming and Xu, Zhen-Liang and Yang, Xiao-Tian and Liu, Hong-Lai},
89
+ title = {Mathematical calculation of binodal curves of a polymer/solvent/nonsolvent system in the phase inversion process},
90
+ journal = {Desalination},
91
+ year = {2006},
92
+ volume = {192},
93
+ number = {1--3},
94
+ pages = {91--104},
95
+ doi = {10.1016/j.desal.2005.07.035},
96
+ url = {https://doi.org/10.1016/j.desal.2005.07.035}
97
+ }
98
+
99
+ @article{Otis2017,
100
+ author = {Otis, Richard and Liu, Zi-Kui},
101
+ title = {pycalphad: {CALPHAD}-based Computational Thermodynamics in {Python}},
102
+ journal = {Journal of Open Research Software},
103
+ year = {2017},
104
+ volume = {5},
105
+ number = {1},
106
+ pages = {1},
107
+ doi = {10.5334/jors.140},
108
+ url = {https://doi.org/10.5334/jors.140}
109
+ }
110
+
111
+ @article{Kwon2024,
112
+ author = {Kwon, Sun Yong and Thibodeau, Eric and Plotkowski, Alex and Yang, Ying},
113
+ title = {{Equilipy}: a python package for calculating phase equilibria},
114
+ journal = {Journal of Open Source Software},
115
+ year = {2024},
116
+ volume = {9},
117
+ number = {100},
118
+ pages = {6875},
119
+ doi = {10.21105/joss.06875},
120
+ url = {https://doi.org/10.21105/joss.06875}
121
+ }
122
+
123
+ @software{Bradbury2018,
124
+ author = {Bradbury, James and Frostig, Roy and Hawkins, Peter and Johnson, Matthew James and Katariya, Yash and Leary, Chris and Maclaurin, Dougal and Necula, George and Paszke, Adam and Vander{P}las, Jake and Wanderman-{M}ilne, Skye and Zhang, Qiao},
125
+ title = {{JAX}: composable transformations of {Python}+{NumPy} programs},
126
+ year = {2018},
127
+ url = {https://github.com/jax-ml/jax}
128
+ }
129
+