|
| 1 | +# `m_imr_spectral.m` Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | +`m_imr_spectral` is a Chebyshev spectral collocation solver for Rayleigh–Plesset type equations, modeling bubble dynamics with optional thermal transport and viscoelastic material behavior. |
| 5 | +It uses high-accuracy spectral differentiation matrices to discretize spatial derivatives and advance the solution robustly in time. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Major Sections of the Code |
| 10 | + |
| 11 | +### 1. Initialization |
| 12 | +- Calls `f_call_params(varargin{:})` to load all simulation parameters. |
| 13 | +- Unpacks solver settings, material properties, and initial conditions. |
| 14 | + |
| 15 | +### 2. Spectral Grid and Matrix Construction |
| 16 | +- Constructs a Chebyshev collocation grid between [-1,1]. |
| 17 | +- Builds spectral differentiation matrices for first and second derivatives. |
| 18 | +- Scales matrices to the physical domain. |
| 19 | +- Enforces boundary conditions analytically within the spectral framework. |
| 20 | + |
| 21 | +### 3. Time Integration Loop |
| 22 | +- Solves the resulting system using an implicit midpoint rule and Newton iteration. |
| 23 | +- Advances radius, wall velocity, and (optionally) stress and temperature fields at each timestep. |
| 24 | + |
| 25 | +### 4. Output Assembly |
| 26 | +- Packages time histories of radius, velocity, stress, temperature, and mass transfer properties. |
| 27 | +- Returns output variables dynamically through `varargout`. |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Inputs |
| 32 | + |
| 33 | +Inputs are passed through `varargin` to `f_call_params` and unpacked locally. |
| 34 | + |
| 35 | +| Variable | Description | |
| 36 | +|-------------------|-------------| |
| 37 | +| `radial` | Radial dynamics model (1–4) | |
| 38 | +| `bubtherm` | Enable bubble thermal model (0 or 1) | |
| 39 | +| `medtherm` | Enable medium thermal model (0 or 1) | |
| 40 | +| `stress` | Stress model type (0–7) | |
| 41 | +| `eps3` | Include second-order strain term (0/1) | |
| 42 | +| `masstrans` | Enable mass transfer (0/1) | |
| 43 | +| `method` | Solver method (spectral here) | |
| 44 | +| `spectral` | Spectral mode flag (should be 1) | |
| 45 | +| `divisions`, `Nv`, `Nt`, `Mt` | Spectral resolution settings | |
| 46 | +| `Lv`, `Lt` | Physical domain lengths | |
| 47 | +| `Rzero`, `Uzero` | Initial bubble radius and wall velocity (non-dimensional) | |
| 48 | +| `Pb_star`, `Pv_star`, `P8` | Pressures | |
| 49 | +| `T8` | Far-field temperature | |
| 50 | +| `Req` | Equilibrium radius | |
| 51 | +| `alphax` | Strain-softening parameter | |
| 52 | +| `Szero` | Initial stress tensor or value | |
| 53 | +| `tspan` | Non-dimensional simulation times | |
| 54 | +| `tfin` | Final simulation time | |
| 55 | +| `dimensionalout` | Output in dimensional units (0/1) | |
| 56 | +| `progdisplay` | Display simulation progress (0/1) | |
| 57 | +| `Cstar`, `GAMa`, `kappa`, `nstate`, `hugoniot_s` | Acoustic medium properties | |
| 58 | +| `om`, `ee`, `tw`, `dt`, `mn`, `wave_type` | Driving waveform settings | |
| 59 | +| `wave_poly`, `wave_dpoly` | Waveform fits for custom shapes | |
| 60 | +| `We`, `Re8`, `DRe` | Dimensionless fluid dynamics numbers | |
| 61 | +| `v_a`, `v_nc`, `Ca`, `LAM`, `De`, `JdotA` | Viscoelastic material settings | |
| 62 | +| `nu_model`, `v_lambda_star`, `zeNO`, `iDRe` | Viscosity model settings | |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Outputs |
| 67 | + |
| 68 | +Outputs are dynamically assigned through `varargout`, typically: |
| 69 | + |
| 70 | +| Output | Description | |
| 71 | +|--------|-------------| |
| 72 | +| `tspan` | Time vector (non-dimensional) | |
| 73 | +| `R` | Bubble radius history | |
| 74 | +| `U` | Wall velocity history | |
| 75 | +| `S` | Stress field history (if stress model active) | |
| 76 | +| `T` | Temperature profile (if thermal modeling active) | |
| 77 | +| `mass fields` | Mass diffusion or vapor concentration fields (if enabled) | |
| 78 | +| `Diagnostics` | Optional convergence/error data | |
| 79 | + |
| 80 | +The actual number and type of outputs depend on solver settings and model features selected at runtime. |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## Notes |
| 85 | + |
| 86 | +- **Spectral accuracy** requires sufficient resolution (`Nv`, `Mt`) to capture steep gradients or oscillations. |
| 87 | +- **Boundary conditions** are enforced analytically to prevent spurious oscillations. |
| 88 | +- **IMR (implicit midpoint rule)** provides stability even under strong collapse dynamics. |
| 89 | +- Requires helper functions such as `f_create_spectral_matrix.m`, `ode_imr_spectral.m`, and waveform data files if applicable. |
0 commit comments