|
| 1 | +# `m_imr_fd.m` Documentation |
| 2 | + |
| 3 | +## Overview |
| 4 | +`m_imr_fd` is a fourth- and sixth-order accurate finite difference solver for Rayleigh–Plesset type equations, modeling bubble dynamics with optional thermal transport and viscoelastic material response. |
| 5 | +It uses a non-dimensionalized formulation and is capable of handling strong nonlinearities through adaptive finite difference schemes. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Major Sections of the Code |
| 10 | + |
| 11 | +### 1. Initialization |
| 12 | +- Calls `f_call_params(varargin{:})` to set up all problem parameters. |
| 13 | +- Unpacks solver settings, physical properties, initial conditions, and waveform settings. |
| 14 | + |
| 15 | +### 2. Mesh and Finite Difference Matrix Setup |
| 16 | +- Constructs spatial grids for velocity (`v`) and stress (`s`) fields. |
| 17 | +- Builds fourth- and sixth-order finite difference derivative matrices (using custom `f_create_matrix.m`). |
| 18 | +- Sets up boundary condition enforcement for non-trivial PDEs. |
| 19 | + |
| 20 | +### 3. Time Integration Loop |
| 21 | +- Advances the solution using implicit midpoint rule and Newton iteration (`ode_imr_fd.m`). |
| 22 | +- Updates radius, velocity, and stress fields over each time step. |
| 23 | +- Handles possible singularities or collapses with robustness checks. |
| 24 | + |
| 25 | +### 4. Output Assembly |
| 26 | +- Packages time histories of radius, velocity, stress fields, temperature fields, and other diagnostics. |
| 27 | +- Returns outputs through `varargout`, depending on simulation options. |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Inputs |
| 32 | + |
| 33 | +Inputs are passed via `varargin`, routed through `f_call_params`, and then 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 selection (0–7) | |
| 41 | +| `eps3` | Include second-order strain term (0/1) | |
| 42 | +| `masstrans` | Enable mass transfer (0/1) | |
| 43 | +| `method` | Solver method (1 = FD explicit, 2 = IMR) | |
| 44 | +| `spectral` | Enable spectral solver (should be 0 here) | |
| 45 | +| `divisions`, `Nv`, `Nt`, `Mt` | Spatial and angular resolution parameters | |
| 46 | +| `Lv`, `Lt` | Domain lengths in velocity and angle | |
| 47 | +| `Rzero`, `Uzero` | Initial radius and velocity (non-dimensional) | |
| 48 | +| `Pb_star`, `Pv_star`, `P8` | Non-dimensional pressures | |
| 49 | +| `T8` | Far-field temperature | |
| 50 | +| `Req` | Equilibrium radius | |
| 51 | +| `alphax` | Strain-softening parameter | |
| 52 | +| `Szero` | Initial stress field | |
| 53 | +| `tspan` | Time vector (non-dimensional) | |
| 54 | +| `tfin` | Final simulation time | |
| 55 | +| `dimensionalout` | Output in physical units (0/1) | |
| 56 | +| `progdisplay` | Show progress during run (0/1) | |
| 57 | +| `Cstar`, `GAMa`, `kappa`, `nstate`, `hugoniot_s` | Acoustic properties | |
| 58 | +| `om`, `ee`, `tw`, `dt`, `mn`, `wave_type` | Acoustic waveform parameters | |
| 59 | +| `wave_poly`, `wave_dpoly` | Waveform polynomial fits (if needed) | |
| 60 | +| `We`, `Re8`, `DRe` | Dimensionless fluid dynamics numbers | |
| 61 | +| `v_a`, `v_nc`, `Ca`, `LAM`, `De`, `JdotA` | Viscoelastic model parameters | |
| 62 | +| `nu_model`, `v_lambda_star`, `zeNO`, `iDRe` | Viscosity model settings | |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Outputs |
| 67 | + |
| 68 | +`m_imr_fd` uses `varargout` to dynamically return simulation results, which may include: |
| 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 active) | |
| 76 | +| `T` | Temperature field (if thermal transport is active) | |
| 77 | +| `mass fields` | Vapor/mass fraction fields (if mass transfer is active) | |
| 78 | +| `Diagnostic info` | Optional convergence/error diagnostics | |
| 79 | + |
| 80 | +Exact structure depends on solver options selected at runtime. |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## Notes |
| 85 | + |
| 86 | +- **Finite difference matrices** are constructed with optional sixth-order accuracy. |
| 87 | +- **IMR (implicit midpoint rule)** ensures stability during strong nonlinear collapse events. |
| 88 | +- Mesh resolution must be tuned carefully for high Weissenberg numbers or sharp waveforms. |
| 89 | +- This function expects to work with supporting scripts: `f_create_matrix.m`, `ode_imr_fd.m`, `f_call_params.m`, and waveform data files if applicable. |
0 commit comments