Animation Module
animation
Animation utilities for visualizing lattice field evolution.
This package provides tools to create animations of scalar field dynamics across different dimensionalities (1D, 2D, 3D), phase space visualizations, and comparison plots.
Functions are organized by category:
- 1d: 1D field animations and phase space
- 2d: 2D field animations and phase portraits
- 3d: 3D slice and isosurface animations
- comparison: Side-by-side and dimensional comparisons
animate_multi_snapshot_grid(times, snapshots, potential=None, n_snapshots=6, interval=100, save_path=None, figsize=(16, 10), title='Field Evolution Snapshots', cmap='RdBu_r', show_energy=True)
Create an animation showing a grid of snapshots at different times.
This provides a "time-lapse" view where you can see multiple moments of the evolution simultaneously. Particularly useful for understanding the overall dynamics and identifying key transition moments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
Array
|
Array of snapshot times |
required |
snapshots
|
list[Lattice]
|
List of Lattice objects |
required |
potential
|
Callable | None
|
Potential function for energy computation |
None
|
n_snapshots
|
int
|
Number of time snapshots to show in grid (2, 4, 6, or 9) |
6
|
interval
|
int
|
Delay between frames in milliseconds |
100
|
save_path
|
str | None
|
If provided, save animation to this path |
None
|
figsize
|
tuple[int, int]
|
Figure size |
(16, 10)
|
title
|
str
|
Animation title |
'Field Evolution Snapshots'
|
cmap
|
str
|
Colormap for 2D/3D visualizations |
'RdBu_r'
|
show_energy
|
bool
|
Whether to include energy evolution plot |
True
|
Returns:
| Type | Description |
|---|---|
FuncAnimation
|
FuncAnimation object |
Example
Source code in jaxlatt/animation/comparison.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
create_comparison_animation(times_list, snapshots_list, labels, potential=None, interval=50, save_path=None, figsize=(16, 5), title='Field Comparison')
Create side-by-side comparison animation for multiple simulations.
Useful for comparing different initial conditions, potentials, or parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times_list
|
list[Array]
|
List of time arrays for each simulation |
required |
snapshots_list
|
list[list[Lattice]]
|
List of snapshot lists for each simulation |
required |
labels
|
list[str]
|
Labels for each simulation |
required |
potential
|
Callable | None
|
Potential function (for energy computation) |
None
|
interval
|
int
|
Delay between frames in milliseconds |
50
|
save_path
|
str | None
|
If provided, save animation to this path |
None
|
figsize
|
tuple[int, int]
|
Figure size |
(16, 5)
|
title
|
str
|
Animation title |
'Field Comparison'
|
Returns:
| Type | Description |
|---|---|
FuncAnimation
|
FuncAnimation object |
Source code in jaxlatt/animation/comparison.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
field_1d(times, snapshots, potential=None, interval=50, save_path=None, figsize=(14, 5), show_energy=True, title='1D Scalar Field Evolution', ylim=None)
Create an animation of 1D scalar field evolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
Array
|
Array of snapshot times |
required |
snapshots
|
list[Lattice]
|
List of Lattice objects at each snapshot time |
required |
potential
|
Callable | None
|
Potential function (needed if show_energy=True) |
None
|
interval
|
int
|
Delay between frames in milliseconds |
50
|
save_path
|
str | None
|
If provided, save animation to this path (e.g., 'anim.gif') |
None
|
figsize
|
tuple[int, int]
|
Figure size (width, height) |
(14, 5)
|
show_energy
|
bool
|
Whether to show energy evolution subplot |
True
|
title
|
str
|
Animation title |
'1D Scalar Field Evolution'
|
ylim
|
tuple[float, float] | None
|
Y-axis limits for field plot (auto if None) |
None
|
Returns:
| Type | Description |
|---|---|
FuncAnimation
|
FuncAnimation object |
Example
Source code in jaxlatt/animation/dim1.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
phase_space_1d(times, snapshots, x_index=None, interval=50, save_path=None, figsize=(10, 8), title='Phase Space Evolution')
Create a phase space animation showing φ vs φ̇ at a specific spatial point.
Useful for visualizing oscillatory dynamics and energy exchange.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
Array
|
Array of snapshot times |
required |
snapshots
|
list[Lattice]
|
List of Lattice objects |
required |
x_index
|
int | None
|
Spatial index to track (center if None) |
None
|
interval
|
int
|
Delay between frames in milliseconds |
50
|
save_path
|
str | None
|
If provided, save animation to this path |
None
|
figsize
|
tuple[int, int]
|
Figure size |
(10, 8)
|
title
|
str
|
Animation title |
'Phase Space Evolution'
|
Returns:
| Type | Description |
|---|---|
FuncAnimation
|
FuncAnimation object |
Source code in jaxlatt/animation/dim1.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
field_2d(times, snapshots, potential=None, interval=50, save_path=None, figsize=(5, 5), show_energy=False, title=None, cmap='RdBu_r', vmin=None, vmax=None, dark=False)
Create an animation of 2D scalar field evolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
Array
|
Array of snapshot times |
required |
snapshots
|
list[Lattice]
|
List of Lattice objects at each snapshot time |
required |
potential
|
Callable | None
|
Potential function (needed if show_energy=True) |
None
|
interval
|
int
|
Delay between frames in milliseconds |
50
|
save_path
|
str | None
|
If provided, save animation to this path |
None
|
figsize
|
tuple[int, int]
|
Figure size (width, height) |
(5, 5)
|
show_energy
|
bool
|
Whether to show energy evolution subplot |
False
|
title
|
str | None
|
Animation title |
None
|
cmap
|
str
|
Colormap for field visualization |
'RdBu_r'
|
vmin
|
float | None
|
Minimum value for colormap (auto if None) |
None
|
vmax
|
float | None
|
Maximum value for colormap (auto if None) |
None
|
dark
|
bool
|
Whether to use dark mode styling (white text/labels) |
False
|
Returns:
| Type | Description |
|---|---|
FuncAnimation
|
FuncAnimation object |
Source code in jaxlatt/animation/dim2.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
field_3d(times, snapshots, potential=None, interval=100, save_path=None, figsize=(10, 8), title='3D Scalar Field Evolution', isosurface_levels=None, fps=20)
Create a 3D isosurface animation of scalar field evolution.
This function creates volumetric visualizations showing isosurfaces of constant field value, which is ideal for visualizing topological structures like bubbles, domain walls, and defects in 3D field configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
Array
|
Array of snapshot times |
required |
snapshots
|
list[Lattice]
|
List of Lattice objects (must be 3D) |
required |
potential
|
Callable | None
|
Potential function (optional) |
None
|
interval
|
int
|
Delay between frames in milliseconds |
100
|
save_path
|
str | None
|
If provided, save animation to this path |
None
|
figsize
|
tuple[int, int]
|
Figure size (width, height) |
(10, 8)
|
title
|
str
|
Animation title |
'3D Scalar Field Evolution'
|
isosurface_levels
|
list[float] | None
|
List of field values to show as isosurfaces |
None
|
fps
|
int
|
Frames per second for saved animation |
20
|
Returns:
| Type | Description |
|---|---|
FuncAnimation
|
FuncAnimation object |
Note
Requires matplotlib with 3D support. Isosurface rendering uses contour slices with moderate detail for performance.
Source code in jaxlatt/animation/dim3.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
slices_3d(times, snapshots, potential=None, interval=100, save_path=None, figsize=(14, 6), title='3D Scalar Field Central Slices', cmap='RdBu_r', vmin=None, vmax=None)
Animate central XY, XZ, YZ slices of a 3D scalar field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
times
|
Array
|
Snapshot times |
required |
snapshots
|
list[Lattice]
|
Lattice states (ndim must be 3) |
required |
potential
|
Callable | None
|
Potential function (optional; if provided energy displayed) |
None
|
interval
|
int
|
Frame delay ms |
100
|
save_path
|
str | None
|
Optional path to save animation (GIF or MP4) |
None
|
figsize
|
tuple[int, int]
|
Figure size |
(14, 6)
|
title
|
str
|
Overall title |
'3D Scalar Field Central Slices'
|
cmap
|
str
|
Colormap |
'RdBu_r'
|
vmin/vmax
|
Explicit color scale limits |
required |
Returns:
| Type | Description |
|---|---|
FuncAnimation
|
FuncAnimation |
Source code in jaxlatt/animation/dim3.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |