pyFracAggregate 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. pyfracaggregate-0.1.0/.gitignore +169 -0
  2. pyfracaggregate-0.1.0/CLAUDE.md +58 -0
  3. pyfracaggregate-0.1.0/LICENSE +21 -0
  4. pyfracaggregate-0.1.0/PKG-INFO +24 -0
  5. pyfracaggregate-0.1.0/README.md +3 -0
  6. pyfracaggregate-0.1.0/examples/pyFracAggregate_demo.ipynb +434 -0
  7. pyfracaggregate-0.1.0/pyproject.toml +50 -0
  8. pyfracaggregate-0.1.0/src/pyFracAggregate/__init__.py +105 -0
  9. pyfracaggregate-0.1.0/src/pyFracAggregate/analysis/__init__.py +1 -0
  10. pyfracaggregate-0.1.0/src/pyFracAggregate/analysis/correlation.py +207 -0
  11. pyfracaggregate-0.1.0/src/pyFracAggregate/analysis/morphology.py +72 -0
  12. pyfracaggregate-0.1.0/src/pyFracAggregate/core/__init__.py +1 -0
  13. pyfracaggregate-0.1.0/src/pyFracAggregate/core/aggregate.py +93 -0
  14. pyfracaggregate-0.1.0/src/pyFracAggregate/core/distributions.py +62 -0
  15. pyfracaggregate-0.1.0/src/pyFracAggregate/core/math_utils.py +124 -0
  16. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/__init__.py +21 -0
  17. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/base.py +53 -0
  18. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/cca.py +95 -0
  19. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/factory.py +35 -0
  20. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/fracval.py +258 -0
  21. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/optimizer_flage.py +171 -0
  22. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/pca.py +46 -0
  23. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/placement/__init__.py +3 -0
  24. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/placement/_helpers.py +113 -0
  25. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/placement/algebraic.py +135 -0
  26. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/placement/base.py +81 -0
  27. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/placement/random_.py +46 -0
  28. pyfracaggregate-0.1.0/src/pyFracAggregate/generators/tdcca.py +251 -0
  29. pyfracaggregate-0.1.0/src/pyFracAggregate/io/__init__.py +1 -0
  30. pyfracaggregate-0.1.0/src/pyFracAggregate/io/data.py +57 -0
  31. pyfracaggregate-0.1.0/src/pyFracAggregate/io/visualization.py +123 -0
  32. pyfracaggregate-0.1.0/src/pyFracAggregate/io/vtk.py +28 -0
  33. pyfracaggregate-0.1.0/tests/test_analysis/test_correlation.py +45 -0
  34. pyfracaggregate-0.1.0/tests/test_analysis/test_morphology.py +60 -0
  35. pyfracaggregate-0.1.0/tests/test_core/test_aggregate.py +60 -0
  36. pyfracaggregate-0.1.0/tests/test_core/test_distributions.py +43 -0
  37. pyfracaggregate-0.1.0/tests/test_core/test_math_utils.py +89 -0
  38. pyfracaggregate-0.1.0/tests/test_density.py +31 -0
  39. pyfracaggregate-0.1.0/tests/test_generators/test_benchmark.py +28 -0
  40. pyfracaggregate-0.1.0/tests/test_generators/test_cca.py +47 -0
  41. pyfracaggregate-0.1.0/tests/test_generators/test_cca_fracval.py +62 -0
  42. pyfracaggregate-0.1.0/tests/test_generators/test_factory.py +31 -0
  43. pyfracaggregate-0.1.0/tests/test_generators/test_optimizer_flage.py +98 -0
  44. pyfracaggregate-0.1.0/tests/test_generators/test_pca.py +48 -0
  45. pyfracaggregate-0.1.0/tests/test_generators/test_placement.py +193 -0
  46. pyfracaggregate-0.1.0/tests/test_generators/test_tdcca_thouy.py +34 -0
  47. pyfracaggregate-0.1.0/tests/test_io/test_data.py +84 -0
  48. pyfracaggregate-0.1.0/tests/test_io/test_visualization.py +50 -0
@@ -0,0 +1,169 @@
1
+ # Claude Code
2
+ .claude/worktrees/
3
+ docs/superpowers/
4
+
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ bin/
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .pytest_cache/
55
+ .hypothesis/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the Python version is
90
+ # usually managed by the user.
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#1181, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or even
97
+ # not install all dependencies needed on a specific platform.
98
+ # Pipfile.lock
99
+
100
+ # poetry
101
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102
+ # poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ # pdm.lock
107
+
108
+ # PEP 582; used by e.g. github.com/pdm-project/pdm
109
+ __pypackages__/
110
+
111
+ # Celery stuff
112
+ celerybeat-schedule
113
+ celerybeat.pid
114
+
115
+ # SageMath parsed files
116
+ *.sage.py
117
+
118
+ # Environments
119
+ .env
120
+ .venv
121
+ env/
122
+ venv/
123
+ ENV/
124
+ env.bak/
125
+ venv.bak/
126
+
127
+ # Spyder project settings
128
+ .spyderproject
129
+ .spyproject
130
+
131
+ # Rope project settings
132
+ .ropeproject
133
+
134
+ # mkdocs documentation
135
+ /site
136
+
137
+ # mypy
138
+ .mypy_cache/
139
+ .dmypy.json
140
+ dmypy.json
141
+
142
+ # ruff
143
+ .ruff_cache/
144
+
145
+ # Pyre type checker
146
+ .pyre/
147
+
148
+ # pytype static type analyzer
149
+ .pytype/
150
+
151
+ # Cython debug symbols
152
+ cython_debug/
153
+
154
+ # OS generated files
155
+ .DS_Store
156
+ .DS_Store?
157
+ ._*
158
+ .Spotlight-V100
159
+ .Trashes
160
+ ehthumbs.db
161
+ Thumbs.db
162
+
163
+ # Project specific
164
+ debug_cca.py
165
+ debug_pca.py
166
+ *.py.bak
167
+
168
+ # Output data and artifacts
169
+ output/
@@ -0,0 +1,58 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Build & Development Commands
6
+
7
+ ```bash
8
+ pip install -e ".[dev]" # Editable install with dev tools (pytest, ruff, mypy)
9
+ pip install -e ".[plot]" # Include matplotlib for plotting
10
+ pytest # Run all tests
11
+ pytest tests/test_core/test_aggregate.py # Run a single test file
12
+ pytest -k "test_pca" # Run tests matching a name pattern
13
+ ruff check src/ # Lint source code
14
+ mypy src/ # Static type checking
15
+ ```
16
+
17
+ No CLI entry point exists — the package is a library used via `import pyFracAggregate as pfa`.
18
+
19
+ ## Architecture
20
+
21
+ **Four-layer design**: core → generators → analysis → io
22
+
23
+ ### Core (`src/pyFracAggregate/core/`)
24
+ - **Aggregate**: Central data structure. Pre-allocated `(max_particles, 5)` NumPy array storing `[x, y, z, radius, mass]`. Properties `positions`, `radii`, `masses` return zero-copy views into the backing array.
25
+ - **ParticleDistribution**: ABC with `Monodisperse(radius)` and `LognormalDistribution(mean, std)` implementations. Generators call `sample(n)` to get particle sizes.
26
+
27
+ ### Generators (`src/pyFracAggregate/generators/`)
28
+ - **BaseGenerator**: ABC accepting `(n_particles, df, kf, particle_dist, overlap_tolerance, placement='algebraic')`. All generators produce an `Aggregate` via `generate()`.
29
+ - **Factory**: `get_generator(method, ...)` dispatches to:
30
+ - `'pca'` → `PCAGenerator` — particle-cluster aggregation
31
+ - `'cca'` → `CCAGenerator` — cluster-cluster aggregation
32
+ - `'fracval'` → `FracVALGenerator` — FracVAL algorithm
33
+ - `'tdcca'` → `ThouyJullienGenerator` — Thouy & Jullien (2004) algorithm
34
+ - All generators share the same constructor signature from `BaseGenerator`.
35
+
36
+ #### Placement Strategy Layer (`src/pyFracAggregate/generators/placement/`)
37
+ - **PlacementStrategy** ABC with `place_particle()` (PCA stage) and `merge_clusters()` (CCA stage).
38
+ - **AlgebraicPlacement** (FLAGE, Skorupski et al., 2014): Algebraic touching-point computation with random Monte Carlo fallback. Default strategy.
39
+ - **RandomPlacement** (Filippov et al., 2000): Pure random Monte Carlo sampling with tolerance relaxation.
40
+ - **`get_placement(name)`** factory returns a `PlacementStrategy` by name (`'algebraic'` or `'random'`).
41
+ - **`_helpers.py`**: Shared Monte Carlo helpers (`random_monte_carlo_place`, `random_monte_carlo_merge`) used by both strategies.
42
+
43
+ ### Analysis (`src/pyFracAggregate/analysis/`)
44
+ - `morphology`: `radius_of_gyration()`, `center_of_mass()`
45
+ - `correlation`: `pair_correlation_function()`, `estimate_fractal_dimension()`, `plot_pair_correlation()`
46
+
47
+ ### IO (`src/pyFracAggregate/io/`)
48
+ - **data.py**: `export_yaml()` — full aggregate snapshot (data, generation params, analysis results)
49
+ - **vtk.py**: `export_vtm()` (MultiBlock) and `export_vtk()` (point cloud) via pyvista
50
+
51
+ ### Top-level API (`__init__.py`)
52
+ `pfa.generate(n_particles, df, kf, method, placement='algebraic')` and `pfa.analyze(aggregate)` are the primary entry points. `generate()` delegates to the factory. The `placement` parameter selects the placement strategy (`'algebraic'` or `'random'`). IO exports include `export_yaml()` (full snapshot), `export_vtk()` (point cloud), and `export_vtm()` (MultiBlock).
53
+
54
+ ## Key Conventions
55
+ - Python 3.9+, type hints throughout
56
+ - Physical units (`length_unit`, `mass_unit`, `density`) are part of `Aggregate` and `BaseGenerator`
57
+ - `mathutils` package used for 3D math (with scipy fallback)
58
+ - Tests live in `tests/` mirroring the source layout (`test_core/`, `test_generators/`, `test_analysis/`, `test_io/`)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Fan Zhang
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.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyFracAggregate
3
+ Version: 0.1.0
4
+ Summary: 通用分形团簇生成框架 (General Fractal Aggregate Generation Framework)
5
+ Author-email: Fan Zhang <vanvonzhang@gmail.com>
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.9
8
+ Requires-Dist: mathutils>=3.0.0
9
+ Requires-Dist: numpy>=1.21.0
10
+ Requires-Dist: pyvista
11
+ Requires-Dist: pyyaml
12
+ Requires-Dist: scipy>=1.7.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: mypy; extra == 'dev'
15
+ Requires-Dist: pytest; extra == 'dev'
16
+ Requires-Dist: ruff; extra == 'dev'
17
+ Provides-Extra: plot
18
+ Requires-Dist: imageio[ffmpeg]>=2.9.0; extra == 'plot'
19
+ Requires-Dist: matplotlib>=3.5.0; extra == 'plot'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # pyFracAggregate
23
+
24
+ 通用分形团簇生成框架 (General Fractal Aggregate Generation Framework).
@@ -0,0 +1,3 @@
1
+ # pyFracAggregate
2
+
3
+ 通用分形团簇生成框架 (General Fractal Aggregate Generation Framework).