polarism 0.3.2__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.
- polarism-0.3.2/LICENSE +21 -0
- polarism-0.3.2/PKG-INFO +223 -0
- polarism-0.3.2/README.md +179 -0
- polarism-0.3.2/polarism/__init__.py +57 -0
- polarism-0.3.2/polarism/analysis/__init__.py +28 -0
- polarism-0.3.2/polarism/analysis/condensation.py +328 -0
- polarism-0.3.2/polarism/boundary_conditions/__init__.py +4 -0
- polarism-0.3.2/polarism/boundary_conditions/absorption/__init__.py +24 -0
- polarism-0.3.2/polarism/boundary_conditions/absorption/absorption_cap_strategy.py +50 -0
- polarism-0.3.2/polarism/boundary_conditions/absorption/absorption_mask_strategy.py +59 -0
- polarism-0.3.2/polarism/boundary_conditions/absorption/absorption_registry.py +22 -0
- polarism-0.3.2/polarism/boundary_conditions/absorption/absorption_strategy.py +80 -0
- polarism-0.3.2/polarism/boundary_conditions/absorption/create_absorption_strategy.py +35 -0
- polarism-0.3.2/polarism/boundary_conditions/absorption/no_absorption_strategy.py +46 -0
- polarism-0.3.2/polarism/boundary_conditions/boundary_condition.py +45 -0
- polarism-0.3.2/polarism/cli.py +16 -0
- polarism-0.3.2/polarism/compute_engine.py +85 -0
- polarism-0.3.2/polarism/config/__init__.py +16 -0
- polarism-0.3.2/polarism/config/dtype_utils.py +14 -0
- polarism-0.3.2/polarism/config/simulation_parameters.py +151 -0
- polarism-0.3.2/polarism/config/validation.py +247 -0
- polarism-0.3.2/polarism/env_metadata.py +119 -0
- polarism-0.3.2/polarism/grid/__init__.py +16 -0
- polarism-0.3.2/polarism/grid/closed_interval_simulation_grid_2d.py +60 -0
- polarism-0.3.2/polarism/grid/create_grid.py +27 -0
- polarism-0.3.2/polarism/grid/grid_registry.py +30 -0
- polarism-0.3.2/polarism/grid/periodic_simulation_grid_2d.py +55 -0
- polarism-0.3.2/polarism/grid/simulation_grid_2d.py +27 -0
- polarism-0.3.2/polarism/init_condition.py +122 -0
- polarism-0.3.2/polarism/laser/__init__.py +18 -0
- polarism-0.3.2/polarism/laser/abstract_laser.py +90 -0
- polarism-0.3.2/polarism/laser/continuous_exp.py +55 -0
- polarism-0.3.2/polarism/laser/continuous_exp_length.py +25 -0
- polarism-0.3.2/polarism/laser/continuous_gaussian.py +35 -0
- polarism-0.3.2/polarism/laser/laser_factory.py +100 -0
- polarism-0.3.2/polarism/laser/laser_registy.py +27 -0
- polarism-0.3.2/polarism/laser/pulse_gaussian.py +113 -0
- polarism-0.3.2/polarism/laser/pump_field.py +39 -0
- polarism-0.3.2/polarism/laser/uniform_laser.py +43 -0
- polarism-0.3.2/polarism/plugins.py +34 -0
- polarism-0.3.2/polarism/potential/__init__.py +7 -0
- polarism-0.3.2/polarism/potential/create_potential.py +25 -0
- polarism-0.3.2/polarism/potential/potential_double_well_supergaussian.py +31 -0
- polarism-0.3.2/polarism/potential/potential_registy.py +23 -0
- polarism-0.3.2/polarism/potential/potential_zero.py +23 -0
- polarism-0.3.2/polarism/reservoir/__init__.py +6 -0
- polarism-0.3.2/polarism/reservoir/abstract_reservoir.py +69 -0
- polarism-0.3.2/polarism/reservoir/create_reservoir.py +26 -0
- polarism-0.3.2/polarism/reservoir/double_reservoir.py +196 -0
- polarism-0.3.2/polarism/reservoir/laplacian.py +71 -0
- polarism-0.3.2/polarism/reservoir/quadratic_double_reservoir.py +278 -0
- polarism-0.3.2/polarism/reservoir/reservoir_registry.py +26 -0
- polarism-0.3.2/polarism/reservoir/single_reservoir.py +131 -0
- polarism-0.3.2/polarism/results/__init__.py +38 -0
- polarism-0.3.2/polarism/results/real_time_visualization.py +194 -0
- polarism-0.3.2/polarism/results/rendering/__init__.py +1 -0
- polarism-0.3.2/polarism/results/rendering/gpu_movie.py +135 -0
- polarism-0.3.2/polarism/results/rendering/video_encoder.py +333 -0
- polarism-0.3.2/polarism/results/result_groups.py +26 -0
- polarism-0.3.2/polarism/results/result_node.py +75 -0
- polarism-0.3.2/polarism/results/result_provider.py +16 -0
- polarism-0.3.2/polarism/results/results_manager.py +87 -0
- polarism-0.3.2/polarism/results/storage/__init__.py +25 -0
- polarism-0.3.2/polarism/results/storage/appendable_hdf5.py +449 -0
- polarism-0.3.2/polarism/results/storage/base_storage.py +84 -0
- polarism-0.3.2/polarism/results/storage/hdf5_storage.py +104 -0
- polarism-0.3.2/polarism/results/storage/json_storage.py +54 -0
- polarism-0.3.2/polarism/results/storage/npy_storage.py +50 -0
- polarism-0.3.2/polarism/results/visitors/__init__.py +13 -0
- polarism-0.3.2/polarism/results/visitors/animation_visitor.py +390 -0
- polarism-0.3.2/polarism/results/visitors/result_visitor.py +23 -0
- polarism-0.3.2/polarism/results/visitors/storage_visitor.py +63 -0
- polarism-0.3.2/polarism/results/visitors/visualization_visitor.py +44 -0
- polarism-0.3.2/polarism/simulation_controller.py +370 -0
- polarism-0.3.2/polarism/simulation_state.py +82 -0
- polarism-0.3.2/polarism/solver/__init__.py +26 -0
- polarism-0.3.2/polarism/solver/abstract_solver.py +41 -0
- polarism-0.3.2/polarism/solver/create_solver.py +22 -0
- polarism-0.3.2/polarism/solver/etd_rk2_solver.py +133 -0
- polarism-0.3.2/polarism/solver/ifrk4_fft_cuda_solver.py +187 -0
- polarism-0.3.2/polarism/solver/ip_rk4_solver.py +144 -0
- polarism-0.3.2/polarism/solver/rk4_cuda_solver.py +1108 -0
- polarism-0.3.2/polarism/solver/rk4_fdm_fused_solver.py +270 -0
- polarism-0.3.2/polarism/solver/rk4_fdm_solver.py +189 -0
- polarism-0.3.2/polarism/solver/solver_compatibility.py +257 -0
- polarism-0.3.2/polarism/solver/solver_registry.py +27 -0
- polarism-0.3.2/polarism/solver/split_step_fft_cuda_solver.py +252 -0
- polarism-0.3.2/polarism/solver/split_step_fft_solver.py +87 -0
- polarism-0.3.2/polarism.egg-info/PKG-INFO +223 -0
- polarism-0.3.2/polarism.egg-info/SOURCES.txt +99 -0
- polarism-0.3.2/polarism.egg-info/dependency_links.txt +1 -0
- polarism-0.3.2/polarism.egg-info/entry_points.txt +2 -0
- polarism-0.3.2/polarism.egg-info/requires.txt +22 -0
- polarism-0.3.2/polarism.egg-info/top_level.txt +1 -0
- polarism-0.3.2/pyproject.toml +78 -0
- polarism-0.3.2/setup.cfg +4 -0
- polarism-0.3.2/tests/test_phoenix_benchmark.py +1200 -0
- polarism-0.3.2/tests/test_reservoir_0d_stationary.py +67 -0
- polarism-0.3.2/tests/test_solver_compliance.py +294 -0
- polarism-0.3.2/tests/test_solver_decay.py +76 -0
- polarism-0.3.2/tests/test_solver_uniformity.py +93 -0
polarism-0.3.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jakub Rogala
|
|
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.
|
polarism-0.3.2/PKG-INFO
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polarism
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: High-performance tools for driven-dissipative exciton-polariton simulations
|
|
5
|
+
Author: Jakub Rogala
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/jakrog01/Polarism
|
|
8
|
+
Project-URL: Repository, https://github.com/jakrog01/Polarism
|
|
9
|
+
Project-URL: Documentation, https://jakrog01.github.io/Polarism/
|
|
10
|
+
Project-URL: Issues, https://github.com/jakrog01/Polarism/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/jakrog01/Polarism/releases
|
|
12
|
+
Keywords: exciton-polariton,gross-pitaevskii,driven-dissipative,physics-simulation,cuda
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
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 :: Physics
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: h5py>=3.15
|
|
27
|
+
Requires-Dist: matplotlib>=3.10
|
|
28
|
+
Requires-Dist: numpy>=2.0
|
|
29
|
+
Requires-Dist: PyYAML>=6.0
|
|
30
|
+
Requires-Dist: tqdm>=4.67
|
|
31
|
+
Requires-Dist: tyro>=0.9
|
|
32
|
+
Provides-Extra: cuda12
|
|
33
|
+
Requires-Dist: cupy-cuda12x>=13; extra == "cuda12"
|
|
34
|
+
Provides-Extra: cuda13
|
|
35
|
+
Requires-Dist: cupy-cuda13x>=14; extra == "cuda13"
|
|
36
|
+
Provides-Extra: docs
|
|
37
|
+
Requires-Dist: mkdocs-material>=9.7; extra == "docs"
|
|
38
|
+
Provides-Extra: test
|
|
39
|
+
Requires-Dist: pytest>=8.3; extra == "test"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: mkdocs-material>=9.7; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest>=8.3; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
> "The test of a first-rate intelligence is the ability to hold two opposed ideas in the mind at the same time, and still retain the ability to function." ~ F. Scott Fitzgerald
|
|
46
|
+
|
|
47
|
+
# Polarism
|
|
48
|
+
|
|
49
|
+
High-performance tools for 2-D driven-dissipative Gross-Pitaevskii
|
|
50
|
+
simulations of exciton-polariton systems.
|
|
51
|
+
|
|
52
|
+
The repository is organized around one clear boundary:
|
|
53
|
+
|
|
54
|
+
- `polarism/` is the physics engine: model configuration, grids, lasers,
|
|
55
|
+
reservoirs, solvers, state evolution, and result storage.
|
|
56
|
+
- `tests/` contains the validation layer for the engine and solver behavior.
|
|
57
|
+
- `examples/` contains runnable usage examples.
|
|
58
|
+
|
|
59
|
+
The full documentation site is in `docs/` and is configured by `mkdocs.yml`.
|
|
60
|
+
|
|
61
|
+
Documentation site:
|
|
62
|
+
https://jakrog01.github.io/Polarism/#getting-started
|
|
63
|
+
|
|
64
|
+
## Repository Layout
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
polarism/ Physics engine and reusable Python package
|
|
68
|
+
config/ Dataclasses and validation helpers
|
|
69
|
+
grid/ Periodic and closed-interval 2-D grids
|
|
70
|
+
laser/ Continuous and pulsed pump definitions
|
|
71
|
+
reservoir/ Single, double, and quadratic-double reservoirs
|
|
72
|
+
solver/ CPU, CuPy, CUDA RK4, FFT, and ETD/IP solvers
|
|
73
|
+
results/ Storage and visualization support
|
|
74
|
+
|
|
75
|
+
tests/ CPU, compliance, and benchmark-style tests
|
|
76
|
+
|
|
77
|
+
docs/ MkDocs Material documentation site
|
|
78
|
+
examples/ Runnable usage examples
|
|
79
|
+
pyproject.toml Project metadata and dependency groups
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Installation
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install polarism
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
GPU solvers additionally need a CuPy build matching the local CUDA toolkit,
|
|
89
|
+
e.g. `pip install "polarism[cuda12]"` or `pip install "polarism[cuda13]"`; see
|
|
90
|
+
[`docs/getting-started/installation.md`](https://github.com/jakrog01/Polarism/blob/master/docs/getting-started/installation.md).
|
|
91
|
+
|
|
92
|
+
## Quick Local Setup
|
|
93
|
+
|
|
94
|
+
For development, use the project virtual environment. The global Python on the target systems is
|
|
95
|
+
not expected to contain the required packages.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python -m venv .venv
|
|
99
|
+
source .venv/bin/activate
|
|
100
|
+
pip install --upgrade pip
|
|
101
|
+
pip install -e ".[dev]"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Run the default CPU-oriented checks:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
.venv/bin/pytest
|
|
108
|
+
.venv/bin/mkdocs build
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The default pytest selection excludes slow and compliance-marked suites. See
|
|
112
|
+
[`docs/development/testing-and-ci.md`](https://github.com/jakrog01/Polarism/blob/master/docs/development/testing-and-ci.md) for
|
|
113
|
+
the heavier validation commands.
|
|
114
|
+
|
|
115
|
+
For the complete CPU/GPU validation, including the Phoenix reference matrix:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
.venv/bin/pytest -q -m '' --use-gpu --tb=short \
|
|
119
|
+
--junitxml=artifacts/reports/full_verification.xml
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Run this command as a single process with exclusive access to the GPU.
|
|
123
|
+
|
|
124
|
+
## Minimal API Example
|
|
125
|
+
|
|
126
|
+
The same script is available as [`examples/basic_run.py`](https://github.com/jakrog01/Polarism/blob/master/examples/basic_run.py).
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
import polarism as ps
|
|
130
|
+
from polarism.compute_engine import compute_engine
|
|
131
|
+
|
|
132
|
+
cfg = ps.Config()
|
|
133
|
+
|
|
134
|
+
cfg.grid.nx = 128
|
|
135
|
+
cfg.grid.ny = 128
|
|
136
|
+
cfg.grid.lx = 100.0
|
|
137
|
+
cfg.grid.ly = 100.0
|
|
138
|
+
cfg.grid.grid_type = "periodic"
|
|
139
|
+
|
|
140
|
+
cfg.reservoir.reservoir_type = "single"
|
|
141
|
+
cfg.potential.potential_type = "zero"
|
|
142
|
+
|
|
143
|
+
cfg.laser.mode = "single"
|
|
144
|
+
cfg.laser.laser_type = "continuous-gaussian"
|
|
145
|
+
cfg.laser.P0 = 0.02
|
|
146
|
+
cfg.laser.sigma_space = 12.0
|
|
147
|
+
|
|
148
|
+
cfg.solver.method = "rk4-fdm"
|
|
149
|
+
cfg.solver.dt = 1e-3
|
|
150
|
+
cfg.solver.total_time = 2.0
|
|
151
|
+
|
|
152
|
+
cfg.result.save_results = True
|
|
153
|
+
cfg.result.save_hdf5 = True
|
|
154
|
+
cfg.result.output_directory = "quickstart_results"
|
|
155
|
+
|
|
156
|
+
cfg.compute_engine.use_gpu = False
|
|
157
|
+
compute_engine.configure(cfg.compute_engine)
|
|
158
|
+
|
|
159
|
+
ps.SimulationController(cfg).run()
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For the command-line interface generated from `polarism.Config`:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
.venv/bin/polarism --help
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
More examples are documented in
|
|
169
|
+
[`docs/getting-started/quickstart.md`](https://github.com/jakrog01/Polarism/blob/master/docs/getting-started/quickstart.md).
|
|
170
|
+
|
|
171
|
+
## Pump Power Conventions
|
|
172
|
+
|
|
173
|
+
For pulsed pumps, prefer explicit physical semantics in the laser YAML:
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
lasers:
|
|
177
|
+
- laser_type: pulse-gaussian
|
|
178
|
+
power_definition: pulse_energy
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`pulse_energy` means that `power` / `P` is the integrated dose of one pulse
|
|
182
|
+
over space and time. This keeps spot-size sweeps meaningful: increasing
|
|
183
|
+
`sigma_space` lowers the local peak pump while preserving the total pulse dose.
|
|
184
|
+
The legacy `peak_amplitude` mode is still available for reproducing old runs.
|
|
185
|
+
|
|
186
|
+
Numerical choices such as grid spacing, timestep, boundary condition, kinetic
|
|
187
|
+
relaxation, and Laplacian stencil should be treated as convergence parameters,
|
|
188
|
+
not as cosmetic post-processing settings. The model background and rationale are
|
|
189
|
+
summarized in
|
|
190
|
+
[`docs/development/physics-background.md`](https://github.com/jakrog01/Polarism/blob/master/docs/development/physics-background.md).
|
|
191
|
+
|
|
192
|
+
## Documentation
|
|
193
|
+
|
|
194
|
+
Build and serve the documentation locally:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
.venv/bin/mkdocs serve
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Key entry points:
|
|
201
|
+
|
|
202
|
+
- [`docs/index.md`](https://github.com/jakrog01/Polarism/blob/master/docs/index.md) for the documentation map.
|
|
203
|
+
- [`docs/getting-started/installation.md`](https://github.com/jakrog01/Polarism/blob/master/docs/getting-started/installation.md)
|
|
204
|
+
for setup.
|
|
205
|
+
- [`docs/user-guide/grid-and-parameters.md`](https://github.com/jakrog01/Polarism/blob/master/docs/user-guide/grid-and-parameters.md)
|
|
206
|
+
for spatial discretization and physical parameters.
|
|
207
|
+
- [`docs/user-guide/potentials-and-pumps.md`](https://github.com/jakrog01/Polarism/blob/master/docs/user-guide/potentials-and-pumps.md)
|
|
208
|
+
for laser and pump definitions.
|
|
209
|
+
- [`docs/user-guide/output-and-visualization.md`](https://github.com/jakrog01/Polarism/blob/master/docs/user-guide/output-and-visualization.md)
|
|
210
|
+
for HDF5 output, plots, and movies.
|
|
211
|
+
|
|
212
|
+
## Development Notes
|
|
213
|
+
|
|
214
|
+
- Keep reusable physics logic inside `polarism/`.
|
|
215
|
+
- Keep tests for engine behavior inside `tests/`.
|
|
216
|
+
- Use `.venv/bin/python`, `.venv/bin/pytest`, and `.venv/bin/mkdocs` in this
|
|
217
|
+
repository.
|
|
218
|
+
|
|
219
|
+
## Acknowledgements
|
|
220
|
+
|
|
221
|
+
This project is developed with the Exciton-Polariton research group at the
|
|
222
|
+
Faculty of Physics, University of Warsaw, with support from NCN OPUS grant work
|
|
223
|
+
and ICM computing infrastructure.
|
polarism-0.3.2/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
> "The test of a first-rate intelligence is the ability to hold two opposed ideas in the mind at the same time, and still retain the ability to function." ~ F. Scott Fitzgerald
|
|
2
|
+
|
|
3
|
+
# Polarism
|
|
4
|
+
|
|
5
|
+
High-performance tools for 2-D driven-dissipative Gross-Pitaevskii
|
|
6
|
+
simulations of exciton-polariton systems.
|
|
7
|
+
|
|
8
|
+
The repository is organized around one clear boundary:
|
|
9
|
+
|
|
10
|
+
- `polarism/` is the physics engine: model configuration, grids, lasers,
|
|
11
|
+
reservoirs, solvers, state evolution, and result storage.
|
|
12
|
+
- `tests/` contains the validation layer for the engine and solver behavior.
|
|
13
|
+
- `examples/` contains runnable usage examples.
|
|
14
|
+
|
|
15
|
+
The full documentation site is in `docs/` and is configured by `mkdocs.yml`.
|
|
16
|
+
|
|
17
|
+
Documentation site:
|
|
18
|
+
https://jakrog01.github.io/Polarism/#getting-started
|
|
19
|
+
|
|
20
|
+
## Repository Layout
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
polarism/ Physics engine and reusable Python package
|
|
24
|
+
config/ Dataclasses and validation helpers
|
|
25
|
+
grid/ Periodic and closed-interval 2-D grids
|
|
26
|
+
laser/ Continuous and pulsed pump definitions
|
|
27
|
+
reservoir/ Single, double, and quadratic-double reservoirs
|
|
28
|
+
solver/ CPU, CuPy, CUDA RK4, FFT, and ETD/IP solvers
|
|
29
|
+
results/ Storage and visualization support
|
|
30
|
+
|
|
31
|
+
tests/ CPU, compliance, and benchmark-style tests
|
|
32
|
+
|
|
33
|
+
docs/ MkDocs Material documentation site
|
|
34
|
+
examples/ Runnable usage examples
|
|
35
|
+
pyproject.toml Project metadata and dependency groups
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install polarism
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
GPU solvers additionally need a CuPy build matching the local CUDA toolkit,
|
|
45
|
+
e.g. `pip install "polarism[cuda12]"` or `pip install "polarism[cuda13]"`; see
|
|
46
|
+
[`docs/getting-started/installation.md`](https://github.com/jakrog01/Polarism/blob/master/docs/getting-started/installation.md).
|
|
47
|
+
|
|
48
|
+
## Quick Local Setup
|
|
49
|
+
|
|
50
|
+
For development, use the project virtual environment. The global Python on the target systems is
|
|
51
|
+
not expected to contain the required packages.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python -m venv .venv
|
|
55
|
+
source .venv/bin/activate
|
|
56
|
+
pip install --upgrade pip
|
|
57
|
+
pip install -e ".[dev]"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Run the default CPU-oriented checks:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
.venv/bin/pytest
|
|
64
|
+
.venv/bin/mkdocs build
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The default pytest selection excludes slow and compliance-marked suites. See
|
|
68
|
+
[`docs/development/testing-and-ci.md`](https://github.com/jakrog01/Polarism/blob/master/docs/development/testing-and-ci.md) for
|
|
69
|
+
the heavier validation commands.
|
|
70
|
+
|
|
71
|
+
For the complete CPU/GPU validation, including the Phoenix reference matrix:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
.venv/bin/pytest -q -m '' --use-gpu --tb=short \
|
|
75
|
+
--junitxml=artifacts/reports/full_verification.xml
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Run this command as a single process with exclusive access to the GPU.
|
|
79
|
+
|
|
80
|
+
## Minimal API Example
|
|
81
|
+
|
|
82
|
+
The same script is available as [`examples/basic_run.py`](https://github.com/jakrog01/Polarism/blob/master/examples/basic_run.py).
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import polarism as ps
|
|
86
|
+
from polarism.compute_engine import compute_engine
|
|
87
|
+
|
|
88
|
+
cfg = ps.Config()
|
|
89
|
+
|
|
90
|
+
cfg.grid.nx = 128
|
|
91
|
+
cfg.grid.ny = 128
|
|
92
|
+
cfg.grid.lx = 100.0
|
|
93
|
+
cfg.grid.ly = 100.0
|
|
94
|
+
cfg.grid.grid_type = "periodic"
|
|
95
|
+
|
|
96
|
+
cfg.reservoir.reservoir_type = "single"
|
|
97
|
+
cfg.potential.potential_type = "zero"
|
|
98
|
+
|
|
99
|
+
cfg.laser.mode = "single"
|
|
100
|
+
cfg.laser.laser_type = "continuous-gaussian"
|
|
101
|
+
cfg.laser.P0 = 0.02
|
|
102
|
+
cfg.laser.sigma_space = 12.0
|
|
103
|
+
|
|
104
|
+
cfg.solver.method = "rk4-fdm"
|
|
105
|
+
cfg.solver.dt = 1e-3
|
|
106
|
+
cfg.solver.total_time = 2.0
|
|
107
|
+
|
|
108
|
+
cfg.result.save_results = True
|
|
109
|
+
cfg.result.save_hdf5 = True
|
|
110
|
+
cfg.result.output_directory = "quickstart_results"
|
|
111
|
+
|
|
112
|
+
cfg.compute_engine.use_gpu = False
|
|
113
|
+
compute_engine.configure(cfg.compute_engine)
|
|
114
|
+
|
|
115
|
+
ps.SimulationController(cfg).run()
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For the command-line interface generated from `polarism.Config`:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
.venv/bin/polarism --help
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
More examples are documented in
|
|
125
|
+
[`docs/getting-started/quickstart.md`](https://github.com/jakrog01/Polarism/blob/master/docs/getting-started/quickstart.md).
|
|
126
|
+
|
|
127
|
+
## Pump Power Conventions
|
|
128
|
+
|
|
129
|
+
For pulsed pumps, prefer explicit physical semantics in the laser YAML:
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
lasers:
|
|
133
|
+
- laser_type: pulse-gaussian
|
|
134
|
+
power_definition: pulse_energy
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`pulse_energy` means that `power` / `P` is the integrated dose of one pulse
|
|
138
|
+
over space and time. This keeps spot-size sweeps meaningful: increasing
|
|
139
|
+
`sigma_space` lowers the local peak pump while preserving the total pulse dose.
|
|
140
|
+
The legacy `peak_amplitude` mode is still available for reproducing old runs.
|
|
141
|
+
|
|
142
|
+
Numerical choices such as grid spacing, timestep, boundary condition, kinetic
|
|
143
|
+
relaxation, and Laplacian stencil should be treated as convergence parameters,
|
|
144
|
+
not as cosmetic post-processing settings. The model background and rationale are
|
|
145
|
+
summarized in
|
|
146
|
+
[`docs/development/physics-background.md`](https://github.com/jakrog01/Polarism/blob/master/docs/development/physics-background.md).
|
|
147
|
+
|
|
148
|
+
## Documentation
|
|
149
|
+
|
|
150
|
+
Build and serve the documentation locally:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
.venv/bin/mkdocs serve
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Key entry points:
|
|
157
|
+
|
|
158
|
+
- [`docs/index.md`](https://github.com/jakrog01/Polarism/blob/master/docs/index.md) for the documentation map.
|
|
159
|
+
- [`docs/getting-started/installation.md`](https://github.com/jakrog01/Polarism/blob/master/docs/getting-started/installation.md)
|
|
160
|
+
for setup.
|
|
161
|
+
- [`docs/user-guide/grid-and-parameters.md`](https://github.com/jakrog01/Polarism/blob/master/docs/user-guide/grid-and-parameters.md)
|
|
162
|
+
for spatial discretization and physical parameters.
|
|
163
|
+
- [`docs/user-guide/potentials-and-pumps.md`](https://github.com/jakrog01/Polarism/blob/master/docs/user-guide/potentials-and-pumps.md)
|
|
164
|
+
for laser and pump definitions.
|
|
165
|
+
- [`docs/user-guide/output-and-visualization.md`](https://github.com/jakrog01/Polarism/blob/master/docs/user-guide/output-and-visualization.md)
|
|
166
|
+
for HDF5 output, plots, and movies.
|
|
167
|
+
|
|
168
|
+
## Development Notes
|
|
169
|
+
|
|
170
|
+
- Keep reusable physics logic inside `polarism/`.
|
|
171
|
+
- Keep tests for engine behavior inside `tests/`.
|
|
172
|
+
- Use `.venv/bin/python`, `.venv/bin/pytest`, and `.venv/bin/mkdocs` in this
|
|
173
|
+
repository.
|
|
174
|
+
|
|
175
|
+
## Acknowledgements
|
|
176
|
+
|
|
177
|
+
This project is developed with the Exciton-Polariton research group at the
|
|
178
|
+
Faculty of Physics, University of Warsaw, with support from NCN OPUS grant work
|
|
179
|
+
and ICM computing infrastructure.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Public package exports for polarism."""
|
|
2
|
+
from polarism.boundary_conditions.boundary_condition import BoundaryCondition
|
|
3
|
+
from polarism.config import Config
|
|
4
|
+
from polarism.laser.laser_factory import LaserFactory
|
|
5
|
+
from polarism.plugins import load_plugins
|
|
6
|
+
from polarism.potential import create_potential
|
|
7
|
+
from polarism.reservoir import create_reservoir
|
|
8
|
+
from polarism.results import (
|
|
9
|
+
RealTimeVisualization,
|
|
10
|
+
ResultNode,
|
|
11
|
+
ResultProvider,
|
|
12
|
+
Results2D,
|
|
13
|
+
ResultScalar,
|
|
14
|
+
ResultScalarGroup,
|
|
15
|
+
ResultsManager,
|
|
16
|
+
ResultVisitor,
|
|
17
|
+
StorageVisitor,
|
|
18
|
+
VisualizationVisitor,
|
|
19
|
+
base_storage,
|
|
20
|
+
hdf5_storage,
|
|
21
|
+
json_storage,
|
|
22
|
+
npy_storage,
|
|
23
|
+
)
|
|
24
|
+
from polarism.simulation_controller import SimulationController
|
|
25
|
+
from polarism.grid.simulation_grid_2d import SimulationGrid2D
|
|
26
|
+
from polarism.simulation_state import SimulationState
|
|
27
|
+
from polarism.solver import AbstractSolver, create_solver, RK4CudaSolver
|
|
28
|
+
|
|
29
|
+
__version__ = "0.3.2"
|
|
30
|
+
__all__ = [
|
|
31
|
+
"BoundaryCondition",
|
|
32
|
+
"Config",
|
|
33
|
+
"create_potential",
|
|
34
|
+
"create_reservoir",
|
|
35
|
+
"create_solver",
|
|
36
|
+
"AbstractSolver",
|
|
37
|
+
"RK4CudaSolver",
|
|
38
|
+
"LaserFactory",
|
|
39
|
+
"load_plugins",
|
|
40
|
+
"RealTimeVisualization",
|
|
41
|
+
"ResultNode",
|
|
42
|
+
"ResultProvider",
|
|
43
|
+
"SimulationController",
|
|
44
|
+
"SimulationGrid2D",
|
|
45
|
+
"SimulationState",
|
|
46
|
+
"Results2D",
|
|
47
|
+
"ResultScalar",
|
|
48
|
+
"ResultScalarGroup",
|
|
49
|
+
"ResultsManager",
|
|
50
|
+
"StorageVisitor",
|
|
51
|
+
"VisualizationVisitor",
|
|
52
|
+
"ResultVisitor",
|
|
53
|
+
"hdf5_storage",
|
|
54
|
+
"json_storage",
|
|
55
|
+
"npy_storage",
|
|
56
|
+
"base_storage",
|
|
57
|
+
]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Shared analysis primitives for polariton simulations."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from polarism.analysis.condensation import (
|
|
5
|
+
CONDENSATION_PSI_SQ_FLOOR,
|
|
6
|
+
CondensationVerdict,
|
|
7
|
+
CrossingResult,
|
|
8
|
+
classify,
|
|
9
|
+
count_upward_crossings,
|
|
10
|
+
critical_reservoir_density,
|
|
11
|
+
gain_loss_signal,
|
|
12
|
+
integrate_zero_dim,
|
|
13
|
+
psi_sq_floor,
|
|
14
|
+
validate_sampling,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"CONDENSATION_PSI_SQ_FLOOR",
|
|
19
|
+
"CondensationVerdict",
|
|
20
|
+
"CrossingResult",
|
|
21
|
+
"classify",
|
|
22
|
+
"count_upward_crossings",
|
|
23
|
+
"critical_reservoir_density",
|
|
24
|
+
"gain_loss_signal",
|
|
25
|
+
"integrate_zero_dim",
|
|
26
|
+
"psi_sq_floor",
|
|
27
|
+
"validate_sampling",
|
|
28
|
+
]
|