|
| 1 | +# MiniWeather - Distributed Weather Simulation Mini-App |
| 2 | + |
| 3 | +MiniWeather is a high-performance atmospheric dynamics simulation mini-app that demonstrates distributed computing and GPU acceleration techniques using Charm4Py. This example showcases how to combine Charm4Py's distributed parallel computing capabilities with Numba CUDA for GPU acceleration to simulate atmospheric flows with various physical phenomena. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Charm4Py Distributed Computing**: Demonstrates scalable parallel execution across multiple processes/nodes |
| 8 | +- **GPU Acceleration**: Leverages Numba CUDA for high-performance computation on NVIDIA GPUs |
| 9 | +- **Multiple Physics Models**: Supports various atmospheric phenomena including: |
| 10 | + - Collision dynamics |
| 11 | + - Thermal convection |
| 12 | + - Mountain wave propagation |
| 13 | + - Turbulence modeling |
| 14 | + - Density current flows |
| 15 | + - Injection dynamics |
| 16 | +- **Domain Decomposition**: Automatic 2D domain decomposition for distributed memory parallelism |
| 17 | +- **Conservation Tracking**: Monitors mass and energy conservation throughout simulation |
| 18 | +- **Flexible Output**: Configurable data output at specified intervals |
| 19 | +- **Visualization Support**: Built-in tools for creating animated visualizations |
| 20 | + |
| 21 | +## Requirements |
| 22 | + |
| 23 | +### Dependencies |
| 24 | +- Python 3.7+ |
| 25 | +- NumPy |
| 26 | +- Numba (with CUDA support) |
| 27 | +- Matplotlib (for visualization) |
| 28 | +- imageio (for GIF creation) |
| 29 | + |
| 30 | +### Hardware Requirements |
| 31 | +- NVIDIA GPU with CUDA support (for GPU acceleration) |
| 32 | +- Multiple CPU cores recommended for distributed execution |
| 33 | + |
| 34 | +## Installation |
| 35 | + |
| 36 | +1. Install required Python packages: |
| 37 | +```bash |
| 38 | +pip install numpy numba matplotlib imageio |
| 39 | +``` |
| 40 | + |
| 41 | +2. Ensure CUDA is properly installed and configured for Numba: |
| 42 | +```bash |
| 43 | +python -c "from numba import cuda; print(cuda.gpus)" |
| 44 | +``` |
| 45 | + |
| 46 | +## Usage |
| 47 | + |
| 48 | +### Basic Simulation |
| 49 | + |
| 50 | +Run a basic thermal convection simulation: |
| 51 | +```bash |
| 52 | +python3 -m charmrun.start +p4 miniweather/miniweather.py --data_spec thermal --sim_time 10.0 --nx_glob 400 --nz_glob 200 |
| 53 | +``` |
| 54 | + |
| 55 | +### Distributed Execution |
| 56 | + |
| 57 | +Run with domain decomposition across multiple chares: |
| 58 | +```bash |
| 59 | +python3 -m charmrun.start +p8 miniweather/miniweather.py \ |
| 60 | + --data_spec mountain_waves \ |
| 61 | + --num_chares_x 2 \ |
| 62 | + --num_chares_z 2 \ |
| 63 | + --nx_glob 800 \ |
| 64 | + --nz_glob 400 \ |
| 65 | + --sim_time 20.0 \ |
| 66 | + --output_freq 50 \ |
| 67 | + --output_dir simulation_output |
| 68 | +``` |
| 69 | + |
| 70 | +### Command Line Options |
| 71 | + |
| 72 | +| Option | Default | Description | |
| 73 | +|--------|---------|-------------| |
| 74 | +| `--nx_glob` | 200 | Number of global cells in x-direction | |
| 75 | +| `--nz_glob` | 100 | Number of global cells in z-direction | |
| 76 | +| `--sim_time` | 1.0 | Simulation time in seconds | |
| 77 | +| `--max_iters` | 10000 | Maximum number of iterations | |
| 78 | +| `--data_spec` | thermal | Physics model to simulate | |
| 79 | +| `--num_chares_x` | 1 | Number of chares in x-direction | |
| 80 | +| `--num_chares_z` | 1 | Number of chares in z-direction | |
| 81 | +| `--output_freq` | 0 | Output frequency (0 = no output) | |
| 82 | +| `--output_dir` | output_data_charm | Output directory | |
| 83 | + |
| 84 | +### Physics Models |
| 85 | + |
| 86 | +Available `--data_spec` options: |
| 87 | +- `collision`: Collision dynamics |
| 88 | +- `thermal`: Thermal convection (default) |
| 89 | +- `mountain_waves`: Mountain wave propagation |
| 90 | +- `turbulence`: Turbulence modeling |
| 91 | +- `density_current`: Density current flows |
| 92 | +- `injection`: Injection dynamics |
| 93 | + |
| 94 | +## Output Format |
| 95 | + |
| 96 | +When `--output_freq` > 0, the simulation outputs `.npz` files containing: |
| 97 | +- `state`: 4D array with simulation variables (density, momentum, temperature) |
| 98 | +- `etime`: Simulation time |
| 99 | +- `chare_nx`, `chare_nz`: Local domain sizes |
| 100 | +- `chare_i_beg`, `chare_k_beg`: Global starting indices |
| 101 | + |
| 102 | +File naming convention: `data_iter_XXXXXX_chare_YY_ZZ.npz` |
| 103 | + |
| 104 | +## Visualization |
| 105 | + |
| 106 | +### Creating Animated GIFs |
| 107 | + |
| 108 | +Use the visualization script to create animated GIFs from simulation output: |
| 109 | + |
| 110 | +```bash |
| 111 | +python miniweather/create_visualization.py simulation_output --out density_evolution.gif --qoi 0 |
| 112 | +``` |
| 113 | + |
| 114 | +### Visualization Options |
| 115 | + |
| 116 | +| Option | Default | Description | |
| 117 | +|--------|---------|-------------| |
| 118 | +| `input_dir` | (required) | Directory containing .npz output files | |
| 119 | +| `--out` | simulation_qoi0.gif | Output GIF filename | |
| 120 | +| `--qoi` | 0 | Quantity of Interest index to visualize | |
| 121 | + |
| 122 | +### Quantities of Interest (QoI) |
| 123 | + |
| 124 | +The simulation tracks 4 primary variables: |
| 125 | +- **QoI 0**: Density perturbations |
| 126 | +- **QoI 1**: Horizontal wind velocity (u-component) |
| 127 | +- **QoI 2**: Vertical wind velocity (w-component) |
| 128 | +- **QoI 3**: Potential temperature perturbations |
| 129 | + |
| 130 | +### Visualization Examples |
| 131 | + |
| 132 | +Create visualizations for different variables: |
| 133 | +```bash |
| 134 | +# Density evolution |
| 135 | +python miniweather/create_visualization.py output_data_charm --out density.gif --qoi 0 |
| 136 | + |
| 137 | +# Horizontal wind patterns |
| 138 | +python miniweather/create_visualization.py output_data_charm --out u_wind.gif --qoi 1 |
| 139 | + |
| 140 | +# Vertical wind patterns |
| 141 | +python miniweather/create_visualization.py output_data_charm --out w_wind.gif --qoi 2 |
| 142 | + |
| 143 | +# Temperature perturbations |
| 144 | +python miniweather/create_visualization.py output_data_charm --out temperature.gif --qoi 3 |
| 145 | +``` |
| 146 | + |
| 147 | +## Example Workflows |
| 148 | + |
| 149 | +### Medium Size Simulation |
| 150 | +```bash |
| 151 | +# High-resolution thermal convection study |
| 152 | +python3 -m charmrun.start +p16 miniweather/miniweather.py \ |
| 153 | + --data_spec thermal \ |
| 154 | + --nx_glob 1600 \ |
| 155 | + --nz_glob 800 \ |
| 156 | + --num_chares_x 4 \ |
| 157 | + --num_chares_z 4 \ |
| 158 | + --sim_time 100.0 \ |
| 159 | + --output_freq 100 \ |
| 160 | + --output_dir thermal_highres |
| 161 | + |
| 162 | +# Create visualization |
| 163 | +python miniweather/create_visualization.py thermal_highres --out thermal_simulation.gif --qoi 0 |
| 164 | +``` |
| 165 | + |
| 166 | +### Mountain Wave Study |
| 167 | +```bash |
| 168 | +# Mountain wave propagation |
| 169 | +python3 -m charmrun.start +p8 miniweather/miniweather.py \ |
| 170 | + --data_spec mountain_waves \ |
| 171 | + --nx_glob 800 \ |
| 172 | + --nz_glob 400 \ |
| 173 | + --num_chares_x 2 \ |
| 174 | + --num_chares_z 2 \ |
| 175 | + --sim_time 50.0 \ |
| 176 | + --output_freq 25 |
| 177 | + |
| 178 | +# Visualize vertical velocity (mountain waves) |
| 179 | +python miniweather/create_visualization.py output_data_charm --out mountain_waves.gif --qoi 2 |
| 180 | +``` |
0 commit comments