ajthor commited on
Commit
d681572
·
verified ·
1 Parent(s): 65d0351

Upload folder using huggingface_hub

Browse files
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/python
3
+ {
4
+ "name": "Python 3 - Dedalus",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
7
+
8
+ // Features to add to the dev container. More info: https://containers.dev/features.
9
+ "features": {
10
+ "ghcr.io/rocker-org/devcontainer-features/miniforge:2": {},
11
+ "ghcr.io/devcontainers/features/node:1": {}
12
+ },
13
+
14
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
15
+ // "forwardPorts": [],
16
+
17
+ // Use 'postCreateCommand' to run commands after the container is created.
18
+ "postCreateCommand": "bash .devcontainer/setup.sh",
19
+ "containerEnv": {
20
+ "CONDA_DEFAULT_ENV": "dedalus3"
21
+ },
22
+
23
+ // Configure tool-specific properties.
24
+ "customizations": {
25
+ "vscode": {
26
+ "extensions":[
27
+ "ms-python.python",
28
+ "ms-python.vscode-pylance"
29
+ ],
30
+ "settings": {
31
+ "python.pythonPath": "/opt/conda/envs/dedalus3/bin/python"
32
+ }
33
+ }
34
+ }
35
+
36
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
37
+ // "remoteUser": "root"
38
+ }
.devcontainer/setup.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Download the Dedalus install script to a temporary location
5
+ DEDALUS_INSTALL_SCRIPT="$(mktemp)"
6
+ curl -fsSL https://raw.githubusercontent.com/DedalusProject/dedalus_conda/master/conda_install_dedalus3.sh -o "$DEDALUS_INSTALL_SCRIPT"
7
+
8
+ # Ensure conda is initialized (adjust path if needed for your container)
9
+ if [ -f /opt/conda/etc/profile.d/conda.sh ]; then
10
+ source /opt/conda/etc/profile.d/conda.sh
11
+ elif [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then
12
+ source "$HOME/miniconda3/etc/profile.d/conda.sh"
13
+ fi
14
+
15
+ # Install Dedalus only if the environment does not exist
16
+ if ! conda info --envs | grep -q dedalus3; then
17
+ conda activate base
18
+ bash "$DEDALUS_INSTALL_SCRIPT"
19
+ fi
20
+
21
+
22
+ conda activate dedalus3
23
+
24
+ conda env config vars set OMP_NUM_THREADS=1
25
+ conda env config vars set NUMEXPR_MAX_THREADS=1
26
+
27
+ # Install additional Python packages from requirements.txt
28
+ if [ -f requirements.txt ]; then
29
+ pip install -r requirements.txt
30
+ fi
31
+
32
+ # Clean up the temporary install script
33
+ rm -f "$DEDALUS_INSTALL_SCRIPT"
.gitignore ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by https://www.toptal.com/developers/gitignore/api/linux,macos,windows,python
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,windows,python
3
+
4
+ ### Linux ###
5
+ *~
6
+
7
+ # temporary files which can be created if a process still has a handle open of a deleted file
8
+ .fuse_hidden*
9
+
10
+ # KDE directory preferences
11
+ .directory
12
+
13
+ # Linux trash folder which might appear on any partition or disk
14
+ .Trash-*
15
+
16
+ # .nfs files are created when an open file is removed but is still being accessed
17
+ .nfs*
18
+
19
+ ### macOS ###
20
+ # General
21
+ .DS_Store
22
+ .AppleDouble
23
+ .LSOverride
24
+
25
+ # Icon must end with two \r
26
+ Icon
27
+
28
+
29
+ # Thumbnails
30
+ ._*
31
+
32
+ # Files that might appear in the root of a volume
33
+ .DocumentRevisions-V100
34
+ .fseventsd
35
+ .Spotlight-V100
36
+ .TemporaryItems
37
+ .Trashes
38
+ .VolumeIcon.icns
39
+ .com.apple.timemachine.donotpresent
40
+
41
+ # Directories potentially created on remote AFP share
42
+ .AppleDB
43
+ .AppleDesktop
44
+ Network Trash Folder
45
+ Temporary Items
46
+ .apdisk
47
+
48
+ ### macOS Patch ###
49
+ # iCloud generated files
50
+ *.icloud
51
+
52
+ ### Python ###
53
+ # Byte-compiled / optimized / DLL files
54
+ __pycache__/
55
+ *.py[cod]
56
+ *$py.class
57
+
58
+ # C extensions
59
+ *.so
60
+
61
+ # Distribution / packaging
62
+ .Python
63
+ build/
64
+ develop-eggs/
65
+ dist/
66
+ downloads/
67
+ eggs/
68
+ .eggs/
69
+ lib/
70
+ lib64/
71
+ parts/
72
+ sdist/
73
+ var/
74
+ wheels/
75
+ share/python-wheels/
76
+ *.egg-info/
77
+ .installed.cfg
78
+ *.egg
79
+ MANIFEST
80
+
81
+ # PyInstaller
82
+ # Usually these files are written by a python script from a template
83
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
84
+ *.manifest
85
+ *.spec
86
+
87
+ # Installer logs
88
+ pip-log.txt
89
+ pip-delete-this-directory.txt
90
+
91
+ # Unit test / coverage reports
92
+ htmlcov/
93
+ .tox/
94
+ .nox/
95
+ .coverage
96
+ .coverage.*
97
+ .cache
98
+ nosetests.xml
99
+ coverage.xml
100
+ *.cover
101
+ *.py,cover
102
+ .hypothesis/
103
+ .pytest_cache/
104
+ cover/
105
+
106
+ # Translations
107
+ *.mo
108
+ *.pot
109
+
110
+ # Django stuff:
111
+ *.log
112
+ local_settings.py
113
+ db.sqlite3
114
+ db.sqlite3-journal
115
+
116
+ # Flask stuff:
117
+ instance/
118
+ .webassets-cache
119
+
120
+ # Scrapy stuff:
121
+ .scrapy
122
+
123
+ # Sphinx documentation
124
+ docs/_build/
125
+
126
+ # PyBuilder
127
+ .pybuilder/
128
+ target/
129
+
130
+ # Jupyter Notebook
131
+ .ipynb_checkpoints
132
+
133
+ # IPython
134
+ profile_default/
135
+ ipython_config.py
136
+
137
+ # pyenv
138
+ # For a library or package, you might want to ignore these files since the code is
139
+ # intended to run in multiple environments; otherwise, check them in:
140
+ # .python-version
141
+
142
+ # pipenv
143
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
144
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
145
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
146
+ # install all needed dependencies.
147
+ #Pipfile.lock
148
+
149
+ # poetry
150
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
151
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
152
+ # commonly ignored for libraries.
153
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
154
+ #poetry.lock
155
+
156
+ # pdm
157
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
158
+ #pdm.lock
159
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
160
+ # in version control.
161
+ # https://pdm.fming.dev/#use-with-ide
162
+ .pdm.toml
163
+
164
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
165
+ __pypackages__/
166
+
167
+ # Celery stuff
168
+ celerybeat-schedule
169
+ celerybeat.pid
170
+
171
+ # SageMath parsed files
172
+ *.sage.py
173
+
174
+ # Environments
175
+ .env
176
+ .venv
177
+ env/
178
+ venv/
179
+ ENV/
180
+ env.bak/
181
+ venv.bak/
182
+
183
+ # Spyder project settings
184
+ .spyderproject
185
+ .spyproject
186
+
187
+ # Rope project settings
188
+ .ropeproject
189
+
190
+ # mkdocs documentation
191
+ /site
192
+
193
+ # mypy
194
+ .mypy_cache/
195
+ .dmypy.json
196
+ dmypy.json
197
+
198
+ # Pyre type checker
199
+ .pyre/
200
+
201
+ # pytype static type analyzer
202
+ .pytype/
203
+
204
+ # Cython debug symbols
205
+ cython_debug/
206
+
207
+ # PyCharm
208
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
209
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
210
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
211
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
212
+ #.idea/
213
+
214
+ ### Python Patch ###
215
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
216
+ poetry.toml
217
+
218
+ # ruff
219
+ .ruff_cache/
220
+
221
+ # LSP config files
222
+ pyrightconfig.json
223
+
224
+ ### Windows ###
225
+ # Windows thumbnail cache files
226
+ Thumbs.db
227
+ Thumbs.db:encryptable
228
+ ehthumbs.db
229
+ ehthumbs_vista.db
230
+
231
+ # Dump file
232
+ *.stackdump
233
+
234
+ # Folder config file
235
+ [Dd]esktop.ini
236
+
237
+ # Recycle Bin used on file shares
238
+ $RECYCLE.BIN/
239
+
240
+ # Windows Installer files
241
+ *.cab
242
+ *.msi
243
+ *.msix
244
+ *.msm
245
+ *.msp
246
+
247
+ # Windows shortcuts
248
+ *.lnk
249
+
250
+ # End of https://www.toptal.com/developers/gitignore/api/linux,macos,windows,python
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Adam Thorpe
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.
README.md ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Schrödinger Equation Dataset
2
+
3
+ Numerical solutions to the 1D time-dependent Schrödinger equation with harmonic oscillator potential.
4
+
5
+ ![Sample Plot](sample_plot.png)
6
+
7
+ ## Equation
8
+
9
+ **Time-dependent Schrödinger equation**:
10
+ ```
11
+ iℏ ∂ψ/∂t = Ĥψ
12
+ ```
13
+
14
+ where the Hamiltonian is:
15
+ ```
16
+ Ĥ = -ℏ²/2m ∇² + V(x)
17
+ ```
18
+
19
+ **Harmonic oscillator potential**:
20
+ ```
21
+ V(x) = ½mω²x²
22
+ ```
23
+
24
+ The complex wavefunction ψ = ψᵣ + iψᵢ is split into real and imaginary parts:
25
+ - Real part: ∂ψᵣ/∂t = (ℏ/2m)∇²ψᵢ - V(x)ψᵢ/ℏ
26
+ - Imaginary part: ∂ψᵢ/∂t = -(ℏ/2m)∇²ψᵣ + V(x)ψᵣ/ℏ
27
+
28
+ ## Variables
29
+
30
+ The dataset returns a dictionary with the following fields:
31
+
32
+ ### Coordinates
33
+ - `spatial_coordinates`: `(Nx,)` - 1D spatial grid points x ∈ [-Lx/2, Lx/2]
34
+ - `time_coordinates`: `(time_steps,)` - Time evolution points
35
+
36
+ ### Solution Fields
37
+ - `psi_r_initial`: `(Nx,)` - Real part of initial wavefunction
38
+ - `psi_i_initial`: `(Nx,)` - Imaginary part of initial wavefunction
39
+ - `psi_r_trajectory`: `(time_steps, Nx)` - Real part evolution
40
+ - `psi_i_trajectory`: `(time_steps, Nx)` - Imaginary part evolution
41
+ - `state_trajectory`: `(time_steps, 2*Nx)` - Concatenated [ψᵣ, ψᵢ] for ML
42
+ - `probability_density`: `(time_steps, Nx)` - |ψ|² probability density
43
+
44
+ ### Physical Quantities
45
+ - `potential`: `(Nx,)` - Harmonic oscillator potential V(x) = ½mω²x²
46
+ - `total_energy`: `(time_steps,)` - Total energy over time (conservation check)
47
+
48
+ ### Physical Parameters
49
+ - `hbar`: Reduced Planck constant
50
+ - `mass`: Particle mass
51
+ - `omega`: Harmonic oscillator frequency
52
+
53
+ ## Dataset Parameters
54
+
55
+ - **Domain**: x ∈ [-10, 10] (symmetric around origin for harmonic oscillator)
56
+ - **Grid points**: Nx = 256 (spectral resolution with Fourier basis)
57
+ - **Time range**: [0, 2.0] (sufficient to see wave packet oscillations)
58
+ - **Spatial resolution**: Δx ≈ 0.078 (domain length / grid points)
59
+ - **Temporal resolution**: Δt = 1e-3 (RK4 time stepping)
60
+
61
+ ### Physical Parameters
62
+ - **Reduced Planck constant**: ℏ = 1.0
63
+ - **Particle mass**: m = 1.0
64
+ - **Harmonic oscillator frequency**: ω = 1.0
65
+ - **Boundary conditions**: Periodic (suitable for localized wave packets)
66
+
67
+ ### Initial Conditions
68
+ - **Wave packet type**: Gaussian wave packets with random parameters
69
+ - **Center position**: x₀ ∼ Uniform([-5, 5])
70
+ - **Wave packet width**: σ ∼ Uniform([0.5, 2.0])
71
+ - **Initial momentum**: k₀ ∼ Uniform([-2.0, 2.0])
72
+ - **Amplitude**: A ∼ Uniform([0.5, 2.0]) (normalized after generation)
73
+
74
+ ## Physical Context
75
+
76
+ This dataset simulates **quantum harmonic oscillator dynamics** governed by the time-dependent Schrödinger equation. The equation models the quantum mechanical evolution of a particle in a harmonic potential well V(x) = ½mω²x².
77
+
78
+ **Key Physical Phenomena**:
79
+ - **Wave packet oscillation**: Gaussian wave packets oscillate back and forth in the harmonic potential
80
+ - **Quantum tunneling**: Wave function can extend into classically forbidden regions
81
+ - **Energy quantization**: Total energy is conserved and quantized in bound states
82
+ - **Probability conservation**: |ψ|² integrates to 1 at all times
83
+ - **Phase evolution**: Real and imaginary parts evolve with quantum phase relationships
84
+
85
+ **Applications**:
86
+ - **Quantum mechanics education**: Fundamental model system in quantum physics courses
87
+ - **Atomic physics**: Models trapped atoms in harmonic potentials (laser cooling, optical traps)
88
+ - **Quantum optics**: Describes coherent states and squeezed states of light
89
+ - **Neural operator learning**: Provides rich training data for physics-informed machine learning
90
+ - **Bose-Einstein condensates**: Mean-field dynamics in harmonic traps
91
+
92
+ ## Usage
93
+
94
+ ```python
95
+ from dataset import SchrodingerDataset
96
+
97
+ # Create dataset
98
+ dataset = SchrodingerDataset(
99
+ Lx=20.0, # Domain size
100
+ Nx=256, # Grid resolution
101
+ hbar=1.0, mass=1.0, omega=1.0, # Physical parameters
102
+ stop_sim_time=2.0, # Simulation time
103
+ timestep=1e-3
104
+ )
105
+
106
+ # Generate a sample
107
+ sample = next(iter(dataset))
108
+
109
+ # Access solution data
110
+ x = sample["spatial_coordinates"] # Spatial grid
111
+ t = sample["time_coordinates"] # Time points
112
+ psi_r = sample["psi_r_trajectory"] # Real part evolution
113
+ psi_i = sample["psi_i_trajectory"] # Imaginary part evolution
114
+ state = sample["state_trajectory"] # Combined [ψᵣ, ψᵢ] for ML
115
+ prob = sample["probability_density"] # |ψ|² probability
116
+ energy = sample["total_energy"] # Energy conservation
117
+ ```
118
+
119
+ ## Visualization
120
+
121
+ Run the plotting scripts to visualize samples:
122
+
123
+ ```bash
124
+ python plot_sample.py # Static visualization
125
+ python plot_animation.py # Animated evolution
126
+ ```
127
+
128
+ ## Data Generation
129
+
130
+ Generate the full dataset:
131
+
132
+ ```bash
133
+ python generate_data.py
134
+ ```
135
+
136
+ This creates train/test splits saved as chunked parquet files in the `data/` directory.
data/test-00000-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:198996730dc120415309f4c34901d1ebdab5fa228adec1f5b06023027226599b
3
+ size 43505176
data/test-00001-of-00002.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ecdbf32bdc2ad1d4b646c77657678647f66dc2f020467c610f75f07e6694da5
3
+ size 43522059
data/train-00000-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21c36efd23340874c460515f803c360528eaef09328806b91ff314fad780c1bf
3
+ size 43470185
data/train-00001-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ea82a9f89ff789c35fea227fd006f13599d48e15680a4965a685c4dcabed4041
3
+ size 43482115
data/train-00002-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed12c190977bc5a4b5c1ecc8ace79f5f6f4b51b045a5fc232eb8c2c512579a3d
3
+ size 43487667
data/train-00003-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:686ce1fecc0a108f8cdb9b0fecaf5f44afa02c025825801ebcaf79a2ebc4b169
3
+ size 43500716
data/train-00004-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:df7401ed8e4c1eb1508ad7aa5eb289c70f7240926eebf2582ac34c7962003434
3
+ size 43503940
data/train-00005-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e23fa81d2a55125c1e5816acbe697c759d7e4c1e640cc518d08fa0a159c5dcf
3
+ size 43496416
data/train-00006-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f3581cf66099455624e3d61ab9718599b7bf4bdf4be58b84648bf94c207ae26
3
+ size 43502140
data/train-00007-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa4afc017d37d4ed5467c4eac7e11499db37b5cece0a70d9a64df9a6e8fff472
3
+ size 43474362
data/train-00008-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:df1d887d8bf42f4d5220372ae2adbc5c2bd46965cc18d61e6960ecc8580c5e51
3
+ size 43489652
data/train-00009-of-00010.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64be8b11724925526eedc4126e50b401b05d72fd24c2a70bb96334a94ca1f76a
3
+ size 43500408
dataset.py ADDED
@@ -0,0 +1,448 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 1D Time-Dependent Schrödinger Equation Dataset with Harmonic Oscillator Potential.
3
+
4
+ Solves the time-dependent Schrödinger equation:
5
+ iℏ ∂ψ/∂t = Ĥψ
6
+ where Ĥ = -ℏ²/2m ∇² + V(x) and V(x) = ½mω²x²
7
+
8
+ The complex wavefunction ψ = ψᵣ + iψᵢ is split into real and imaginary parts,
9
+ which are evolved separately and concatenated into a 2×Nx state vector.
10
+
11
+ Physical applications: quantum mechanics, atom optics, Bose-Einstein condensates.
12
+ """
13
+
14
+ import numpy as np
15
+ from torch.utils.data import IterableDataset
16
+
17
+ import dedalus.public as d3
18
+ import logging
19
+
20
+ logger = logging.getLogger(__name__)
21
+
22
+
23
+ def generate_gaussian_wave_packet(x, x0, sigma, k0, amplitude=1.0):
24
+ """
25
+ Generate a Gaussian wave packet initial condition for the Schrödinger equation.
26
+
27
+ Creates a localized wave packet: ψ(x) = A * exp[-(x-x₀)²/(2σ²)] * exp(ik₀x)
28
+ This represents a particle localized around position x₀ with momentum k₀.
29
+
30
+ Args:
31
+ x: Spatial coordinates array
32
+ x0: Center position of the wave packet
33
+ sigma: Width parameter (standard deviation of Gaussian envelope)
34
+ k0: Initial momentum (wave number)
35
+ amplitude: Amplitude scaling factor
36
+
37
+ Returns:
38
+ Complex wavefunction ψ = ψᵣ + iψᵢ as numpy array
39
+
40
+ Notes:
41
+ The wave packet satisfies the normalization ∫|ψ|²dx = 1 after normalization
42
+ in the calling code.
43
+ """
44
+ envelope = amplitude * np.exp(-(x - x0)**2 / (2 * sigma**2))
45
+ phase = np.exp(1j * k0 * x)
46
+ return envelope * phase
47
+
48
+
49
+ class SchrodingerDataset(IterableDataset):
50
+ """
51
+ Dataset for 1D time-dependent Schrödinger equation with harmonic oscillator potential.
52
+
53
+ This dataset generates solutions to the quantum harmonic oscillator by solving:
54
+ iℏ ∂ψ/∂t = Ĥψ
55
+ where the Hamiltonian is:
56
+ Ĥ = -ℏ²/2m ∇² + V(x)
57
+ and the potential is:
58
+ V(x) = ½mω²x²
59
+
60
+ The complex wavefunction ψ = ψᵣ + iψᵢ is split into real and imaginary parts
61
+ that are evolved separately using coupled PDEs:
62
+ ∂ψᵣ/∂t = (ℏ/2m)∇²ψᵢ - V(x)ψᵢ/ℏ
63
+ ∂ψᵢ/∂t = -(ℏ/2m)∇²ψᵣ + V(x)ψᵣ/ℏ
64
+
65
+ For machine learning applications, the solution is provided as:
66
+ - Individual trajectories: ψᵣ(x,t) and ψᵢ(x,t)
67
+ - Combined state vector: [ψᵣ, ψᵢ] with shape (2×Nx,)
68
+ - Probability density: |ψ|² = ψᵣ² + ψᵢ²
69
+ - Energy conservation: Total energy ⟨ψ|Ĥ|ψ⟩
70
+
71
+ Physical Applications:
72
+ - Quantum mechanics education and visualization
73
+ - Trapped atom dynamics in optical/magnetic traps
74
+ - Bose-Einstein condensate mean-field dynamics
75
+ - Neural operator learning for quantum systems
76
+
77
+ Mathematical Properties:
78
+ - Unitary evolution (probability conservation)
79
+ - Energy conservation in the absence of dissipation
80
+ - Spectral accuracy via Fourier pseudospectral methods
81
+ """
82
+ def __init__(
83
+ self,
84
+ # Domain parameters
85
+ Lx=20.0, # Domain length (centered around 0)
86
+ Nx=1024, # Number of grid points
87
+
88
+ # Physical parameters
89
+ hbar=1.0, # Reduced Planck constant
90
+ mass=1.0, # Particle mass
91
+ omega=1.0, # Harmonic oscillator frequency
92
+
93
+ # Solver parameters
94
+ dealias=3/2, # Dealiasing factor
95
+ stop_sim_time=5.0, # Final simulation time
96
+ timestep=1e-3, # Time step size
97
+ timestepper=d3.RK443, # Time integration scheme
98
+ dtype=np.float64,
99
+ ):
100
+ """
101
+ Initialize Schrödinger equation dataset with harmonic oscillator potential.
102
+
103
+ Sets up the numerical infrastructure to solve the time-dependent Schrödinger
104
+ equation using Dedalus spectral methods. Creates Fourier basis functions
105
+ for spatial derivatives and configures the coupled PDE system for real
106
+ and imaginary parts of the wavefunction.
107
+
108
+ Mathematical Setup:
109
+ Domain: x ∈ [-Lx/2, Lx/2] with periodic boundary conditions
110
+ Grid: Nx Fourier modes with dealiasing for nonlinear terms
111
+ Time Integration: High-order Runge-Kutta schemes (RK443 recommended)
112
+
113
+ Args:
114
+ Lx: Spatial domain length. Domain extends from -Lx/2 to +Lx/2.
115
+ Should be large enough to contain the wave packet throughout
116
+ the simulation without significant boundary effects.
117
+ Nx: Number of Fourier modes. Higher values give better spatial
118
+ resolution. Recommended: 256-1024 for typical simulations.
119
+ hbar: Reduced Planck constant (ℏ). In natural units, often set to 1.
120
+ mass: Particle mass (m). Controls kinetic energy scale.
121
+ omega: Harmonic oscillator frequency (ω). Sets potential energy scale
122
+ and oscillation period T = 2π/ω.
123
+ dealias: Dealiasing factor for spectral methods. 3/2 removes aliasing
124
+ for quadratic nonlinearities (standard for Schrödinger eq).
125
+ stop_sim_time: Maximum simulation time. Should be several oscillation
126
+ periods (>> 2π/ω) to see full dynamics.
127
+ timestep: Time step size. Should satisfy CFL condition for stability.
128
+ Recommended: dt ≤ 0.01 * (2π/ω) for accuracy.
129
+ timestepper: Dedalus time integration scheme. RK443 (4th order)
130
+ provides good accuracy/stability balance.
131
+ dtype: Floating point precision. np.float64 recommended for accuracy.
132
+
133
+ Raises:
134
+ ValueError: If domain or grid parameters are invalid.
135
+ ImportError: If Dedalus is not properly installed.
136
+ """
137
+ super().__init__()
138
+
139
+ # Basic parameter validation
140
+ if Lx <= 0:
141
+ raise ValueError("Domain length Lx must be positive")
142
+ if Nx <= 0 or not isinstance(Nx, int):
143
+ raise ValueError("Grid points Nx must be a positive integer")
144
+ if hbar <= 0:
145
+ raise ValueError("Reduced Planck constant hbar must be positive")
146
+ if mass <= 0:
147
+ raise ValueError("Particle mass must be positive")
148
+ if omega <= 0:
149
+ raise ValueError("Oscillator frequency omega must be positive")
150
+ if timestep <= 0:
151
+ raise ValueError("Time step must be positive")
152
+ if stop_sim_time <= 0:
153
+ raise ValueError("Simulation time must be positive")
154
+
155
+ # Store domain and grid parameters
156
+ self.Lx = Lx # Physical domain size [-Lx/2, Lx/2]
157
+ self.Nx = Nx # Number of Fourier modes for spatial resolution
158
+
159
+ # Store physical parameters (in natural units where convenient)
160
+ self.hbar = hbar # Reduced Planck constant - sets quantum scale
161
+ self.mass = mass # Particle mass - affects kinetic energy
162
+ self.omega = omega # Oscillator frequency - sets energy and time scales
163
+
164
+ # Store numerical solver parameters
165
+ self.dealias = dealias # Prevents aliasing in spectral methods
166
+ self.stop_sim_time = stop_sim_time # Total evolution time
167
+ self.timestep = timestep # Time step (must satisfy CFL condition)
168
+ self.timestepper = timestepper # Runge-Kutta integration scheme
169
+ self.dtype = dtype # Floating point precision
170
+
171
+ # Setup Dedalus spectral method infrastructure
172
+ self.xcoord = d3.Coordinate("x") # Define spatial coordinate
173
+ self.dist = d3.Distributor(self.xcoord, dtype=dtype) # Handle parallel distribution
174
+
175
+ # Create Fourier basis: periodic functions on [-Lx/2, Lx/2]
176
+ # RealFourier uses cosines/sines, ideal for real-valued problems
177
+ self.xbasis = d3.RealFourier(self.xcoord, size=Nx, bounds=(-Lx/2, Lx/2), dealias=dealias)
178
+
179
+ # Generate physical grid points for visualization and analysis
180
+ self.x = self.dist.local_grid(self.xbasis)
181
+
182
+ def __iter__(self):
183
+ """
184
+ Generate infinite samples from the dataset.
185
+
186
+ Creates diverse quantum wave packet initial conditions by randomly sampling
187
+ Gaussian wave packet parameters. Each sample represents a different physical
188
+ scenario with varying localization, momentum, and energy.
189
+
190
+ Initial Condition Generation:
191
+ 1. Random wave packet center x₀ ~ U[-Lx/4, Lx/4]
192
+ 2. Random width σ ~ U[0.5, 2.0] (controls localization)
193
+ 3. Random momentum k₀ ~ U[-2.0, 2.0] (initial velocity)
194
+ 4. Random amplitude A ~ U[0.5, 2.0] (before normalization)
195
+ 5. Normalize to ensure ∫|ψ|²dx = 1 (probability conservation)
196
+
197
+ Physics:
198
+ - Narrow wave packets (small σ) are highly localized but spread quickly
199
+ - Wide wave packets (large σ) are delocalized but maintain shape longer
200
+ - Higher |k₀| gives faster initial motion and higher kinetic energy
201
+ - All initial conditions are proper quantum states (normalized)
202
+
203
+ Yields:
204
+ Dict containing complete solution trajectory and physical quantities
205
+ """
206
+ while True:
207
+ # Generate random physical parameters for wave packet diversity
208
+ # Center position: avoid boundaries to prevent edge effects
209
+ x0 = np.random.uniform(-self.Lx/4, self.Lx/4)
210
+
211
+ # Wave packet width: balance between localization and numerical stability
212
+ sigma = np.random.uniform(0.5, 2.0)
213
+
214
+ # Initial momentum: determines kinetic energy and motion direction
215
+ k0 = np.random.uniform(-2.0, 2.0)
216
+
217
+ # Initial amplitude: will be normalized, but affects relative scales
218
+ amplitude = np.random.uniform(0.5, 2.0)
219
+
220
+ # Generate complex Gaussian wave packet: ψ(x) = A*exp[-(x-x₀)²/2σ²]*exp(ik₀x)
221
+ # This represents a localized particle with definite momentum
222
+ # Use full grid from Dedalus (includes dealiasing padding)
223
+ x_grid = self.x.ravel() # Get full dealiased grid for initialization
224
+ psi_init = generate_gaussian_wave_packet(
225
+ x_grid, x0, sigma, k0, amplitude
226
+ )
227
+
228
+ # Normalize wavefunction to satisfy quantum probability condition ∫|ψ|²dx = 1
229
+ # This ensures proper quantum state throughout evolution
230
+ norm = np.sqrt(np.trapezoid(np.abs(psi_init)**2, x_grid))
231
+ psi_init /= norm
232
+
233
+ # Solve time-dependent Schrödinger equation and return full solution data
234
+ # Pass the complex initial condition (splitting happens in solve method)
235
+ yield self.solve(psi_init)
236
+
237
+ def solve(self, initial_condition):
238
+ """
239
+ Solve the time-dependent Schrödinger equation using spectral methods.
240
+
241
+ Integrates the coupled PDE system forward in time using high-order
242
+ Runge-Kutta methods, storing snapshots of the solution and computing
243
+ physical quantities like energy for validation.
244
+
245
+ Numerical Method:
246
+ - Spectral differentiation for spatial derivatives (machine precision)
247
+ - High-order Runge-Kutta time stepping (4th order RK443)
248
+ - Adaptive time step control via Dedalus CFL condition
249
+ - Energy monitoring for conservation verification
250
+
251
+ Args:
252
+ initial_condition: Complex initial wavefunction ψ(x,0) = ψᵣ + iψᵢ
253
+
254
+ Returns:
255
+ Dictionary containing:
256
+ - Solution trajectories: ψᵣ(x,t), ψᵢ(x,t), |ψ(x,t)|²
257
+ - Coordinate arrays: spatial grid x, time points t
258
+ - ML-ready state vector: concatenated [ψᵣ, ψᵢ]
259
+ - Physical quantities: total energy, potential V(x)
260
+ - System parameters: ℏ, m, ω for reproducibility
261
+
262
+ Note:
263
+ Energy should be conserved to within numerical precision.
264
+ Large energy drift indicates time step is too large or
265
+ simulation time exceeds numerical stability limits.
266
+ """
267
+ # Setup PDE fields for real and imaginary parts of wavefunction
268
+ # These will store ψᵣ(x,t) and ψᵢ(x,t) at each time step
269
+ psi_r = self.dist.Field(name="psi_r", bases=self.xbasis) # Real part ψᵣ
270
+ psi_i = self.dist.Field(name="psi_i", bases=self.xbasis) # Imaginary part ψᵢ
271
+
272
+ # Define spatial derivative operator for kinetic energy term
273
+ # d/dx operator using spectral differentiation (exact for polynomials)
274
+ dx = lambda A: d3.Differentiate(A, self.xcoord)
275
+
276
+ # Create harmonic oscillator potential V(x) = ½mω²x²
277
+ # This confines the quantum particle to oscillate around x=0
278
+ V = self.dist.Field(name="V", bases=self.xbasis)
279
+ V['g'] = 0.5 * self.mass * (self.omega * self.x)**2 # Set grid values
280
+
281
+ # Setup coupled PDE system for real and imaginary parts
282
+ #
283
+ # Starting from the Schrödinger equation: iℏ ∂ψ/∂t = Ĥψ
284
+ # where Ĥ = -ℏ²/2m ∇² + V(x) and ψ = ψᵣ + iψᵢ
285
+ #
286
+ # Substituting ψ = ψᵣ + iψᵢ and separating real/imaginary parts:
287
+ # Real part: ∂ψᵣ/∂t = (ℏ/2m)∇²ψᵢ - V(x)ψᵢ/ℏ
288
+ # Imaginary part: ∂ψᵢ/∂t = -(ℏ/2m)∇²ψᵣ + V(x)ψᵣ/ℏ
289
+ #
290
+ # These equations are coupled: ψᵣ evolution depends on ψᵢ and vice versa
291
+ # This preserves the unitary evolution and probability conservation
292
+
293
+ # Create namespace with all variables for Dedalus equation parser
294
+ hbar = self.hbar
295
+ mass = self.mass
296
+ namespace = locals() # Include all local variables (hbar, mass, dx, etc.)
297
+
298
+ # Define the initial value problem with two coupled fields
299
+ problem = d3.IVP([psi_r, psi_i], namespace=namespace)
300
+
301
+ # Add the coupled evolution equations
302
+ # Note: dx(dx(field)) computes the second derivative ∇²field
303
+ problem.add_equation("dt(psi_r) - (hbar/(2*mass))*dx(dx(psi_i)) = - V*psi_i/hbar")
304
+ problem.add_equation("dt(psi_i) + (hbar/(2*mass))*dx(dx(psi_r)) = V*psi_r/hbar")
305
+
306
+ # Split complex initial condition into real and imaginary parts
307
+ # This converts ψ = ψᵣ + iψᵢ to two real-valued fields for the PDE solver
308
+ psi_r_init = np.real(initial_condition) # Real component ψᵣ(x,0)
309
+ psi_i_init = np.imag(initial_condition) # Imaginary component ψᵢ(x,0)
310
+
311
+ # Set initial conditions in Dedalus fields
312
+ # ['g'] accessor sets grid point values directly
313
+ psi_r['g'] = psi_r_init # Initialize real part ψᵣ(x,0)
314
+ psi_i['g'] = psi_i_init # Initialize imaginary part ψᵢ(x,0)
315
+
316
+ # Build time integrator from the PDE system
317
+ # This compiles the equations and sets up the Runge-Kutta stepper
318
+ solver = problem.build_solver(self.timestepper)
319
+ solver.stop_sim_time = self.stop_sim_time # Set maximum evolution time
320
+
321
+ # Initialize storage arrays for solution snapshots
322
+ # ['g', 1] gets grid values in proper layout for post-processing
323
+ psi_r_list = [psi_r['g', 1].copy()] # Store ψᵣ(x,t) snapshots
324
+ psi_i_list = [psi_i['g', 1].copy()] # Store ψᵢ(x,t) snapshots
325
+ t_list = [solver.sim_time] # Store corresponding time values
326
+ energy_list = [] # Store energy for conservation check
327
+
328
+ # Calculate initial total energy E = ⟨ψ|Ĥ|ψ⟩
329
+ # This should be conserved throughout the evolution (Hamiltonian is Hermitian)
330
+ x_1d = self.x.ravel() # Get full grid for energy calculation
331
+ dx = x_1d[1] - x_1d[0] # Uniform grid spacing for integration
332
+ energy_initial = self._compute_energy(psi_r_init, psi_i_init, V, dx)
333
+ energy_list.append(energy_initial)
334
+
335
+ # Main time evolution loop
336
+ # Save snapshots periodically to avoid memory issues while capturing dynamics
337
+ save_frequency = max(1, int(0.05 / self.timestep)) # Save every ~0.05 time units
338
+
339
+ while solver.proceed: # Continue until stop_sim_time reached
340
+ # Advance solution by one time step using Runge-Kutta
341
+ solver.step(self.timestep)
342
+
343
+ # Periodically store snapshots for analysis/visualization
344
+ if solver.iteration % save_frequency == 0:
345
+ # Extract current wavefunction components from Dedalus fields
346
+ psi_r_current = psi_r['g', 1].copy() # Current real part
347
+ psi_i_current = psi_i['g', 1].copy() # Current imaginary part
348
+
349
+ # Store snapshot data
350
+ psi_r_list.append(psi_r_current)
351
+ psi_i_list.append(psi_i_current)
352
+ t_list.append(solver.sim_time)
353
+
354
+ # Monitor energy conservation (should remain constant)
355
+ energy = self._compute_energy(psi_r_current, psi_i_current, V, dx)
356
+ energy_list.append(energy)
357
+
358
+ # Convert to numpy arrays
359
+ psi_r_trajectory = np.array(psi_r_list)
360
+ psi_i_trajectory = np.array(psi_i_list)
361
+ time_coordinates = np.array(t_list)
362
+ energy_trajectory = np.array(energy_list)
363
+
364
+ # Compute probability density |ψ|²
365
+ prob_density = psi_r_trajectory**2 + psi_i_trajectory**2
366
+
367
+ # Create combined state vector (concatenate real and imaginary parts)
368
+ state_trajectory = np.concatenate([psi_r_trajectory, psi_i_trajectory], axis=1)
369
+
370
+ # Compute potential energy at grid points
371
+ V_values = V['g', 1].copy()
372
+
373
+ return {
374
+ # Coordinates
375
+ "spatial_coordinates": self.x.ravel(),
376
+ "time_coordinates": time_coordinates,
377
+
378
+ # Initial conditions
379
+ "psi_r_initial": psi_r_init,
380
+ "psi_i_initial": psi_i_init,
381
+
382
+ # Solution trajectories
383
+ "psi_r_trajectory": psi_r_trajectory,
384
+ "psi_i_trajectory": psi_i_trajectory,
385
+ "state_trajectory": state_trajectory, # Combined (2*Nx,) for ML
386
+ "probability_density": prob_density, # |ψ|²
387
+
388
+ # Physical quantities
389
+ "potential": V_values, # Harmonic oscillator potential
390
+ "total_energy": energy_trajectory, # Energy conservation check
391
+
392
+ # Physical parameters
393
+ "hbar": self.hbar,
394
+ "mass": self.mass,
395
+ "omega": self.omega,
396
+ }
397
+
398
+ def _compute_energy(self, psi_r, psi_i, V_field, dx):
399
+ """
400
+ Compute total energy of the quantum system using wavefunction components.
401
+
402
+ Calculates the expectation value of the Hamiltonian: E = ⟨ψ|Ĥ|ψ⟩
403
+ where Ĥ = -ℏ²/2m ∇² + V(x) is the quantum harmonic oscillator Hamiltonian.
404
+
405
+ The energy should be conserved during unitary evolution, making this
406
+ a crucial diagnostic for numerical accuracy and stability.
407
+
408
+ Mathematical Details:
409
+ Total Energy: E = T + V
410
+ Kinetic Energy: T = -ℏ²/2m ∫ ψ*(x) ∇²ψ(x) dx
411
+ Potential Energy: V = ∫ |ψ(x)|² V(x) dx
412
+
413
+ For split wavefunction ψ = ψᵣ + iψᵢ:
414
+ T = -ℏ²/2m ∫ [ψᵣ ∇²ψᵣ + ψᵢ ∇²ψᵢ] dx
415
+ V = ∫ [ψᵣ² + ψᵢ²] V(x) dx
416
+
417
+ Args:
418
+ psi_r: Real part of wavefunction at current time
419
+ psi_i: Imaginary part of wavefunction at current time
420
+ V_field: Potential field from Dedalus
421
+ dx: Spatial grid spacing for numerical integration
422
+
423
+ Returns:
424
+ Total energy (float): Should be conserved throughout evolution
425
+
426
+ Note:
427
+ Uses finite differences for spatial derivatives. For high accuracy,
428
+ the Dedalus spectral derivatives could be used instead, but this
429
+ simple approach is sufficient for energy monitoring.
430
+ """
431
+ # Compute kinetic energy: T = -ℏ²/2m ⟨ψ|∇²ψ⟩
432
+ # For complex ψ = ψᵣ + iψᵢ: T = -ℏ²/2m ∫[ψᵣ∇²ψᵣ + ψᵢ∇²ψᵢ] dx
433
+ # Use second-order finite differences for ∇² approximation
434
+ psi_r_xx = np.gradient(np.gradient(psi_r, dx), dx) # ∂²ψᵣ/∂x²
435
+ psi_i_xx = np.gradient(np.gradient(psi_i, dx), dx) # ∂²ψᵢ/∂x²
436
+
437
+ # Integrate kinetic energy density over space
438
+ kinetic = -(self.hbar**2)/(2*self.mass) * np.trapezoid(
439
+ psi_r * psi_r_xx + psi_i * psi_i_xx, dx=dx
440
+ )
441
+
442
+ # Compute potential energy: V = ⟨ψ|V|ψ⟩ = ∫ |ψ(x)|² V(x) dx
443
+ # Probability density |ψ|² = ψᵣ² + ψᵢ² weighted by potential
444
+ V_values = V_field['g', 1] # Extract potential values from Dedalus field
445
+ potential = np.trapezoid((psi_r**2 + psi_i**2) * V_values, dx=dx)
446
+
447
+ # Total energy = kinetic + potential (should be conserved)
448
+ return kinetic + potential
generate_data.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Generate Schrödinger equation dataset and save to parquet files in chunks.
4
+
5
+ Creates samples of 1D time-dependent Schrödinger equation solutions
6
+ with harmonic oscillator potential and random Gaussian wave packet
7
+ initial conditions.
8
+ """
9
+
10
+ import os
11
+ import numpy as np
12
+ import pyarrow as pa
13
+ import pyarrow.parquet as pq
14
+ from dataset import SchrodingerDataset
15
+
16
+
17
+ def generate_dataset_split(
18
+ split_name="train", num_samples=1000, chunk_size=100, output_dir="data"
19
+ ):
20
+ """
21
+ Generate a dataset split and save as chunked parquet files.
22
+
23
+ INSTRUCTIONS FOR CLAUDE:
24
+ - This function should work as-is for any dataset following the template
25
+ - Only modify the dataset instantiation below if you need custom parameters
26
+ """
27
+
28
+ os.makedirs(output_dir, exist_ok=True)
29
+
30
+ # Create Schrödinger dataset with appropriate parameters
31
+ dataset = SchrodingerDataset(
32
+ Lx=20.0, # Domain length
33
+ Nx=256, # Grid points (reduced for faster generation)
34
+ hbar=1.0, # Physical parameters
35
+ mass=1.0,
36
+ omega=1.0,
37
+ stop_sim_time=2.0, # Shorter simulation time for dataset generation
38
+ timestep=1e-3,
39
+ )
40
+
41
+ num_chunks = (num_samples + chunk_size - 1) // chunk_size # Ceiling division
42
+
43
+ print(f"Generating {num_samples} {split_name} samples in {num_chunks} chunks...")
44
+
45
+ dataset_iter = iter(dataset)
46
+ chunk_data = None
47
+
48
+ for i in range(num_samples):
49
+ sample = next(dataset_iter)
50
+
51
+ if chunk_data is None:
52
+ # Initialize chunk data on first sample
53
+ chunk_data = {key: [] for key in sample.keys()}
54
+
55
+ # Add sample to current chunk
56
+ for key, value in sample.items():
57
+ chunk_data[key].append(value)
58
+
59
+ # Save chunk when full or at end
60
+ if (i + 1) % chunk_size == 0 or i == num_samples - 1:
61
+ chunk_idx = i // chunk_size
62
+
63
+ # Convert data to PyArrow-compatible format
64
+ table_data = {}
65
+ for key, values in chunk_data.items():
66
+ # Handle both arrays and scalars
67
+ converted_values = []
68
+ for value in values:
69
+ if hasattr(value, 'tolist'):
70
+ converted_values.append(value.tolist())
71
+ else:
72
+ converted_values.append(value)
73
+ table_data[key] = converted_values
74
+
75
+ # Convert to PyArrow table
76
+ table = pa.table(table_data)
77
+
78
+ # Save chunk
79
+ filename = f"{split_name}-{chunk_idx:05d}-of-{num_chunks:05d}.parquet"
80
+ filepath = os.path.join(output_dir, filename)
81
+ pq.write_table(table, filepath)
82
+
83
+ print(f"Saved chunk {chunk_idx + 1}/{num_chunks}: {filepath}")
84
+
85
+ # Reset for next chunk
86
+ chunk_data = {key: [] for key in sample.keys()}
87
+
88
+ print(f"Generated {num_samples} {split_name} samples")
89
+ return num_samples
90
+
91
+
92
+ if __name__ == "__main__":
93
+ np.random.seed(42)
94
+
95
+ # Generate train split
96
+ generate_dataset_split("train", num_samples=1000, chunk_size=100)
97
+
98
+ # Generate test split
99
+ generate_dataset_split("test", num_samples=200, chunk_size=100)
plot_animation.py ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Generate an animation GIF of a single Schrödinger equation sample time evolution.
4
+
5
+ Animates quantum wave packet dynamics including:
6
+ - Real and imaginary parts of wavefunction
7
+ - Probability density |ψ|²
8
+ - Wave packet motion in harmonic potential
9
+ """
10
+
11
+ import numpy as np
12
+ import matplotlib.pyplot as plt
13
+ import matplotlib.animation as animation
14
+ from dataset import SchrodingerDataset
15
+
16
+
17
+ def create_schrodinger_animation(sample, save_path="sample_animation.gif", fps=15):
18
+ """Create an animation GIF from a Schrödinger sample"""
19
+ # Extract data
20
+ x = sample['spatial_coordinates']
21
+ t = sample['time_coordinates']
22
+ psi_r = sample['psi_r_trajectory']
23
+ psi_i = sample['psi_i_trajectory']
24
+ prob = sample['probability_density']
25
+ V = sample['potential']
26
+ energy = sample['total_energy']
27
+
28
+ # Set up the figure with subplots
29
+ fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(12, 10))
30
+ fig.suptitle(f'Quantum Harmonic Oscillator Evolution\n' +
31
+ f'ℏ={sample["hbar"]}, m={sample["mass"]}, ω={sample["omega"]}',
32
+ fontsize=14, fontweight='bold')
33
+
34
+ # Colors for consistency
35
+ color_real = '#1f77b4'
36
+ color_imag = '#ff7f0e'
37
+ color_prob = '#2ca02c'
38
+ color_potential = '#d62728'
39
+
40
+ # Subplot 1: Wavefunction components
41
+ ax1.set_xlim(x[0], x[-1])
42
+ psi_max = max(np.max(np.abs(psi_r)), np.max(np.abs(psi_i))) * 1.1
43
+ ax1.set_ylim(-psi_max, psi_max)
44
+ ax1.set_ylabel('ψ(x,t)')
45
+ ax1.set_title('Wavefunction Components')
46
+ ax1.grid(True, alpha=0.3)
47
+
48
+ # Plot potential well (scaled for background)
49
+ V_scaled = V / np.max(V) * psi_max * 0.2
50
+ ax1.fill_between(x, -psi_max, V_scaled - psi_max, alpha=0.1, color=color_potential)
51
+ ax1.plot(x, V_scaled - psi_max, '--', alpha=0.5, color=color_potential, linewidth=1, label='V(x)')
52
+
53
+ real_line, = ax1.plot([], [], color=color_real, linewidth=2, label='ψᵣ(x,t)')
54
+ imag_line, = ax1.plot([], [], color=color_imag, linewidth=2, label='ψᵢ(x,t)')
55
+ ax1.legend(loc='upper right')
56
+
57
+ # Subplot 2: Probability density
58
+ ax2.set_xlim(x[0], x[-1])
59
+ prob_max = np.max(prob) * 1.1
60
+ ax2.set_ylim(0, prob_max)
61
+ ax2.set_ylabel('|ψ(x,t)|²')
62
+ ax2.set_title('Probability Density')
63
+ ax2.grid(True, alpha=0.3)
64
+
65
+ # Plot potential well (scaled for background)
66
+ V_scaled_prob = V / np.max(V) * prob_max * 0.3
67
+ ax2.fill_between(x, V_scaled_prob, alpha=0.2, color=color_potential)
68
+
69
+ prob_line, = ax2.plot([], [], color=color_prob, linewidth=2, label='|ψ|²')
70
+ ax2.legend(loc='upper right')
71
+
72
+ # Subplot 3: Energy over time
73
+ ax3.set_xlim(t[0], t[-1])
74
+ E_mean = np.mean(energy)
75
+ E_range = np.max(energy) - np.min(energy)
76
+ if E_range > 0:
77
+ ax3.set_ylim(np.min(energy) - 0.1*E_range, np.max(energy) + 0.1*E_range)
78
+ else:
79
+ ax3.set_ylim(E_mean - 0.1*abs(E_mean), E_mean + 0.1*abs(E_mean))
80
+
81
+ ax3.set_xlabel('Time t')
82
+ ax3.set_ylabel('Total Energy')
83
+ ax3.set_title('Energy Conservation')
84
+ ax3.grid(True, alpha=0.3)
85
+
86
+ # Plot full energy trace as background
87
+ ax3.plot(t, energy, 'k-', alpha=0.3, linewidth=1)
88
+ ax3.axhline(E_mean, color='red', linestyle='--', alpha=0.7, linewidth=1)
89
+
90
+ # Current energy point
91
+ energy_point, = ax3.plot([], [], 'o', color='darkgreen', markersize=8)
92
+ energy_line, = ax3.plot([], [], color='darkgreen', linewidth=2)
93
+
94
+ # Time text
95
+ time_text = fig.text(0.02, 0.02, '', fontsize=12, fontweight='bold',
96
+ bbox=dict(boxstyle="round,pad=0.3", facecolor='yellow', alpha=0.7))
97
+
98
+ # Store fill object
99
+ prob_fill = None
100
+
101
+ def animate(frame):
102
+ """Animation function"""
103
+ nonlocal prob_fill
104
+
105
+ # Update wavefunction components
106
+ real_line.set_data(x, psi_r[frame])
107
+ imag_line.set_data(x, psi_i[frame])
108
+
109
+ # Update probability density
110
+ prob_line.set_data(x, prob[frame])
111
+
112
+ # Remove old fill and create new one
113
+ if prob_fill is not None:
114
+ prob_fill.remove()
115
+ prob_fill = ax2.fill_between(x, prob[frame], alpha=0.3, color=color_prob)
116
+
117
+ # Update energy plot
118
+ current_t = t[:frame+1]
119
+ current_e = energy[:frame+1]
120
+ energy_line.set_data(current_t, current_e)
121
+ energy_point.set_data([t[frame]], [energy[frame]])
122
+
123
+ # Update time display
124
+ time_text.set_text(f'Time: {t[frame]:.3f} / {t[-1]:.3f}')
125
+
126
+ return real_line, imag_line, prob_line, energy_line, energy_point, time_text
127
+
128
+ # Create animation with more frames for smoother motion
129
+ print(f"Creating animation with {len(t)} frames...")
130
+ anim = animation.FuncAnimation(
131
+ fig, animate, frames=len(t),
132
+ interval=1000/fps, blit=False, repeat=True # blit=False due to fill_between
133
+ )
134
+
135
+ # Save as GIF
136
+ print(f"Saving animation to {save_path}...")
137
+ anim.save(save_path, writer='pillow', fps=fps)
138
+ plt.close()
139
+
140
+ print(f"Animation saved to {save_path}")
141
+
142
+
143
+ def create_simple_animation(sample, save_path="simple_animation.gif", fps=15):
144
+ """Create a simpler single-panel animation focusing on probability density"""
145
+ # Extract data
146
+ x = sample['spatial_coordinates']
147
+ t = sample['time_coordinates']
148
+ prob = sample['probability_density']
149
+ V = sample['potential']
150
+
151
+ # Set up single plot
152
+ fig, ax = plt.subplots(figsize=(10, 6))
153
+ ax.set_xlim(x[0], x[-1])
154
+ prob_max = np.max(prob) * 1.1
155
+ ax.set_ylim(0, prob_max)
156
+ ax.set_xlabel('Position x')
157
+ ax.set_ylabel('Probability Density |ψ|²')
158
+ ax.set_title(f'Quantum Wave Packet in Harmonic Oscillator\n' +
159
+ f'ℏ={sample["hbar"]}, m={sample["mass"]}, ω={sample["omega"]}')
160
+ ax.grid(True, alpha=0.3)
161
+
162
+ # Plot potential well (scaled)
163
+ V_scaled = V / np.max(V) * prob_max * 0.3
164
+ ax.fill_between(x, V_scaled, alpha=0.2, color='red', label='V(x) (scaled)')
165
+ ax.plot(x, V_scaled, 'r--', alpha=0.7, linewidth=1)
166
+
167
+ # Initialize probability line
168
+ prob_line, = ax.plot([], [], 'b-', linewidth=3, label='|ψ(x,t)|²')
169
+
170
+ # Time text
171
+ time_text = ax.text(0.02, 0.95, '', transform=ax.transAxes, fontsize=12,
172
+ bbox=dict(boxstyle="round", facecolor='white', alpha=0.8))
173
+
174
+ ax.legend()
175
+
176
+ # Store fill object
177
+ prob_fill = None
178
+
179
+ def animate(frame):
180
+ """Simple animation function"""
181
+ nonlocal prob_fill
182
+
183
+ # Update probability line
184
+ prob_line.set_data(x, prob[frame])
185
+
186
+ # Remove previous fill if it exists
187
+ if prob_fill is not None:
188
+ prob_fill.remove()
189
+
190
+ # Create new fill
191
+ prob_fill = ax.fill_between(x, prob[frame], alpha=0.4, color='blue')
192
+
193
+ # Update time text
194
+ time_text.set_text(f'Time: {t[frame]:.3f}')
195
+ return prob_line, time_text
196
+
197
+ # Create animation
198
+ anim = animation.FuncAnimation(
199
+ fig, animate, frames=len(t),
200
+ interval=1000/fps, blit=False, repeat=True
201
+ )
202
+
203
+ # Save as GIF
204
+ anim.save(save_path, writer='pillow', fps=fps)
205
+ plt.close()
206
+
207
+ print(f"Simple animation saved to {save_path}")
208
+
209
+
210
+ if __name__ == "__main__":
211
+ # Set random seed for reproducibility
212
+ np.random.seed(42)
213
+
214
+ # Create dataset
215
+ dataset = SchrodingerDataset(
216
+ Lx=20.0,
217
+ Nx=128, # Lower resolution for faster animation generation
218
+ stop_sim_time=3.0,
219
+ timestep=2e-3 # Slightly larger timestep for fewer frames
220
+ )
221
+
222
+ # Generate a single sample
223
+ sample = next(iter(dataset))
224
+
225
+ print("Creating animations...")
226
+ print(f"Time steps: {len(sample['time_coordinates'])}")
227
+ print(f"Spatial points: {len(sample['spatial_coordinates'])}")
228
+
229
+ # Create both animations
230
+ create_simple_animation(sample, "simple_animation.gif", fps=12)
231
+ create_schrodinger_animation(sample, "sample_animation.gif", fps=10)
plot_sample.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Plot a single sample from the Schrödinger equation dataset.
4
+
5
+ Visualizes quantum wave packet evolution including:
6
+ - Real and imaginary parts
7
+ - Probability density |ψ|²
8
+ - Potential well
9
+ - Energy conservation
10
+ """
11
+
12
+ import numpy as np
13
+ import matplotlib.pyplot as plt
14
+ from dataset import SchrodingerDataset
15
+
16
+
17
+ def plot_schrodinger_sample(sample, save_path="sample_plot.png"):
18
+ """Plot a single sample from the Schrödinger dataset"""
19
+ fig = plt.figure(figsize=(16, 12))
20
+
21
+ # Create subplot layout
22
+ gs = fig.add_gridspec(3, 2, height_ratios=[1, 1, 0.8], hspace=0.3, wspace=0.3)
23
+
24
+ # Extract data
25
+ x = sample["spatial_coordinates"]
26
+ t = sample["time_coordinates"]
27
+ psi_r = sample["psi_r_trajectory"]
28
+ psi_i = sample["psi_i_trajectory"]
29
+ prob = sample["probability_density"]
30
+ V = sample["potential"]
31
+ energy = sample["total_energy"]
32
+
33
+ # Colors for consistency
34
+ color_real = "#1f77b4"
35
+ color_imag = "#ff7f0e"
36
+ color_prob = "#2ca02c"
37
+ color_potential = "#d62728"
38
+
39
+ # Plot 1: Initial and final wavefunction components
40
+ ax1 = fig.add_subplot(gs[0, 0])
41
+ ax1.plot(x, psi_r[0], color=color_real, linewidth=2, label="ψᵣ(x,t=0)")
42
+ ax1.plot(x, psi_i[0], color=color_imag, linewidth=2, label="ψᵢ(x,t=0)")
43
+ ax1.plot(
44
+ x,
45
+ psi_r[-1],
46
+ "--",
47
+ color=color_real,
48
+ alpha=0.7,
49
+ linewidth=2,
50
+ label=f"ψᵣ(x,t={t[-1]:.1f})",
51
+ )
52
+ ax1.plot(
53
+ x,
54
+ psi_i[-1],
55
+ "--",
56
+ color=color_imag,
57
+ alpha=0.7,
58
+ linewidth=2,
59
+ label=f"ψᵢ(x,t={t[-1]:.1f})",
60
+ )
61
+ ax1.set_xlabel("Position x")
62
+ ax1.set_ylabel("ψ(x)")
63
+ ax1.set_title("Wavefunction Components")
64
+ ax1.grid(True, alpha=0.3)
65
+ ax1.legend()
66
+
67
+ # Plot 2: Probability density evolution
68
+ ax2 = fig.add_subplot(gs[0, 1])
69
+ ax2.plot(x, prob[0], color=color_prob, linewidth=2, label="|ψ(x,t=0)|²")
70
+ ax2.plot(
71
+ x,
72
+ prob[-1],
73
+ "--",
74
+ color=color_prob,
75
+ alpha=0.7,
76
+ linewidth=2,
77
+ label=f"|ψ(x,t={t[-1]:.1f})|²",
78
+ )
79
+
80
+ # Add potential well (scaled for visibility)
81
+ V_scaled = V / np.max(V) * np.max(prob[0]) * 0.3
82
+ ax2.fill_between(
83
+ x, V_scaled, alpha=0.2, color=color_potential, label="V(x) (scaled)"
84
+ )
85
+
86
+ ax2.set_xlabel("Position x")
87
+ ax2.set_ylabel("Probability Density")
88
+ ax2.set_title("Quantum Probability |ψ|²")
89
+ ax2.grid(True, alpha=0.3)
90
+ ax2.legend()
91
+
92
+ # Plot 3: Real part space-time evolution
93
+ ax3 = fig.add_subplot(gs[1, 0])
94
+ vmax = np.max(np.abs(psi_r))
95
+ im1 = ax3.pcolormesh(
96
+ x, t, psi_r, cmap="RdBu", vmin=-vmax, vmax=vmax, shading="gouraud"
97
+ )
98
+ ax3.set_xlabel("Position x")
99
+ ax3.set_ylabel("Time t")
100
+ ax3.set_title("Real Part Evolution ψᵣ(x,t)")
101
+ plt.colorbar(im1, ax=ax3, label="ψᵣ")
102
+
103
+ # Plot 4: Imaginary part space-time evolution
104
+ ax4 = fig.add_subplot(gs[1, 1])
105
+ vmax = np.max(np.abs(psi_i))
106
+ im2 = ax4.pcolormesh(
107
+ x, t, psi_i, cmap="RdBu", vmin=-vmax, vmax=vmax, shading="gouraud"
108
+ )
109
+ ax4.set_xlabel("Position x")
110
+ ax4.set_ylabel("Time t")
111
+ ax4.set_title("Imaginary Part Evolution ψᵢ(x,t)")
112
+ plt.colorbar(im2, ax=ax4, label="ψᵢ")
113
+
114
+ # Plot 5: Bottom spanning plots - Probability density heatmap and energy
115
+ ax5 = fig.add_subplot(gs[2, 0])
116
+ im3 = ax5.pcolormesh(x, t, prob, cmap="viridis", shading="gouraud")
117
+ ax5.set_xlabel("Position x")
118
+ ax5.set_ylabel("Time t")
119
+ ax5.set_title("Probability Density Evolution |ψ(x,t)|²")
120
+ plt.colorbar(im3, ax=ax5, label="|ψ|²")
121
+
122
+ # Plot 6: Energy conservation
123
+ ax6 = fig.add_subplot(gs[2, 1])
124
+ ax6.plot(t, energy, "o-", color="darkgreen", linewidth=2, markersize=4)
125
+ ax6.set_xlabel("Time t")
126
+ ax6.set_ylabel("Total Energy")
127
+ ax6.set_title("Energy Conservation")
128
+ ax6.grid(True, alpha=0.3)
129
+
130
+ # Add energy statistics
131
+ E_mean = np.mean(energy)
132
+ E_std = np.std(energy)
133
+ ax6.axhline(
134
+ E_mean, color="red", linestyle="--", alpha=0.7, label=f"Mean: {E_mean:.3f}"
135
+ )
136
+ ax6.text(
137
+ 0.02,
138
+ 0.95,
139
+ f"σ/⟨E⟩ = {E_std/E_mean:.2e}",
140
+ transform=ax6.transAxes,
141
+ bbox=dict(boxstyle="round", facecolor="white", alpha=0.8),
142
+ verticalalignment="top",
143
+ )
144
+ ax6.legend()
145
+
146
+ # Add main title with physical parameters
147
+ hbar = sample["hbar"]
148
+ mass = sample["mass"]
149
+ omega = sample["omega"]
150
+ fig.suptitle(
151
+ f"Quantum Harmonic Oscillator (ℏ={hbar}, m={mass}, ω={omega})",
152
+ fontsize=16,
153
+ fontweight="bold",
154
+ )
155
+
156
+ plt.savefig(save_path, dpi=200, bbox_inches="tight")
157
+ plt.close()
158
+
159
+ print(f"Schrödinger sample visualization saved to {save_path}")
160
+
161
+
162
+ if __name__ == "__main__":
163
+ # Set random seed for reproducibility
164
+ np.random.seed(42)
165
+
166
+ # Create dataset with reasonable parameters for visualization
167
+ dataset = SchrodingerDataset(Lx=20.0, Nx=256, stop_sim_time=2.0, timestep=1e-3)
168
+
169
+ # Generate a single sample
170
+ dataset_iter = iter(dataset)
171
+ sample = next(dataset_iter)
172
+ sample = next(dataset_iter)
173
+
174
+ print("Sample keys:", list(sample.keys()))
175
+ for key, value in sample.items():
176
+ if hasattr(value, "shape"):
177
+ print(f"{key}: shape {value.shape}")
178
+ else:
179
+ print(f"{key}: {type(value)} - {value}")
180
+
181
+ # Plot the sample
182
+ plot_schrodinger_sample(sample)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ numpy
2
+ torch
3
+ scikit-learn
4
+ matplotlib
5
+ pyarrow
6
+ pillow
7
+ dedalus
sample_animation.gif ADDED

Git LFS Details

  • SHA256: 955c5fc0866d1552a511bf95ff54f368c8979de13cc6d7d4906971ae62153ad0
  • Pointer size: 132 Bytes
  • Size of remote file: 1.27 MB
sample_plot.png ADDED

Git LFS Details

  • SHA256: 78a68cf31842f0ac73dc3165aa3787a6fbcb3995317d23e0b3b8d5a4ec73efb2
  • Pointer size: 131 Bytes
  • Size of remote file: 804 kB