Skip to content

Commit d749c12

Browse files
authored
Add files via upload
1 parent d132e52 commit d749c12

File tree

9 files changed

+333
-0
lines changed

9 files changed

+333
-0
lines changed

docs/f_approx_init_stress.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# `f_approx_init_stress.m` Documentation
2+
3+
## Overview
4+
`f_approx_init_stress` computes an approximate initial Cauchy stress at the bubble maximum radius using analytical corrections for viscoelastic, compressibility, and compressive effects.
5+
This provides a lower-fidelity but faster estimate compared to the numerical shooting method.
6+
7+
## Major Sections
8+
1. **Constant Definitions**: Compute `trc` (time constant) and coefficient `B`.
9+
2. **Barotropic Correction** (`fbarbc`): Accounts for vapor and compressibility effects.
10+
3. **Strain Correction** (`fbarst`): Originating from surface tension scaling.
11+
4. **Compressibility Correction** (`fbarc`): Based on Grüneisen parameter.
12+
5. **Viscous Correction** (`fbarv`): Derived from Reynolds number.
13+
6. **Elastic Correction** (`fbare`): Analytical term for elastic effects.
14+
7. **Stress Summation** (`fsum`): Aggregates all correction terms, with input validation.
15+
8. **Time Constant Calculation** (`tg`): Computes relaxation time for stress growth.
16+
9. **Stress Prediction** (`Smaxpred`): Final predicted maximum stress.
17+
18+
## Inputs
19+
20+
| Name | Description | Units |
21+
|----------|---------------------------------------------------|---------|
22+
| `Ro` | Non-dimensional bubble radius (`R/R_eq`) ||
23+
| `kappa` | Ratio of specific heats of gas ||
24+
| `al_nd` | Non-dimensional strain-softening exponent ||
25+
| `pwv_nd` | Non-dimensional vapor pressure ratio ||
26+
| `We` | Weber number (surface tension effects) ||
27+
| `Re` | Reynolds number (viscous effects) ||
28+
| `De` | Deborah number (viscoelastic relaxation effects) ||
29+
| `Ca` | Cauchy number (elastic to inertial ratio) ||
30+
| `alpha` | Quadratic KV model exponent ||
31+
32+
## Outputs
33+
34+
| Name | Description | Units |
35+
|-------------|-----------------------------------------|---------|
36+
| `Smaxpred` | Predicted maximum Cauchy stress ratio ||
37+
38+
## Notes
39+
- Throws an error if the aggregated stress correction (`fsum`) exceeds 1.
40+
- Analytical method is faster but less accurate than `f_init_stress` numerical shooting.

docs/f_init_stress.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `f_init_stress.m` Documentation
2+
3+
## Overview
4+
`f_init_stress` determines the initial stress by numerically solving bubble collapse dynamics with a shooting method, ensuring the stress at maximum radius matches the selected viscoelastic model.
5+
6+
## Major Sections
7+
1. **Shooting Setup**: Configure `fminsearch` options (`sopts`).
8+
2. **Initial Guess via Shooting**: Use `f_maxwell_growth_iter` to find wall velocity that maximizes stress integral.
9+
3. **Time Integration**: Run `ode23tb` on `f_RP_bub_collapse_comp` over nondimensional time span.
10+
4. **Stress Extraction**: Identify maximum stress from solution matrix.
11+
12+
### Internal Functions
13+
- `f_maxwell_growth_iter`: Computes max radius error for shooting.
14+
- `f_RP_bub_collapse_comp`: Nondimensional Rayleigh–Plesset ODE for collapse with stress evolution.
15+
16+
## Inputs
17+
18+
| Name | Description | Units |
19+
|-----------|----------------------------------------|---------|
20+
| `Req` | Equilibrium radius ||
21+
| `Re` | Reynolds number ||
22+
| `Ca` | Cauchy number ||
23+
| `De` | Deborah number ||
24+
| `We` | Weber number ||
25+
| `CL` | Speed of sound ratio (`C/C_ref`) ||
26+
| `Pv_star` | Non-dimensional vapor pressure ||
27+
28+
## Outputs
29+
30+
| Name | Description | Units |
31+
|------|----------------------------------|---------|
32+
| `S0` | Initial stress at bubble maximum ||
33+
34+
## Notes
35+
- Uses `ode23tb` for stiff ODE integration.
36+
- Requires consistency between stress model and dimensional parameters.

docs/f_odesolve.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# `f_odesolve.m` Documentation
2+
3+
## Overview
4+
`f_odesolve` is a wrapper that selects and executes MATLAB's ODE solvers (`ode15s`, `ode23tb`, `ode45`) with user-defined time stepping and tolerance options.
5+
6+
## Major Sections
7+
1. **Options Configuration**: Sets `RelTol`, `AbsTol`, and `MaxStep` based on `divisions`.
8+
2. **Solver Selection**: Routes to the correct solver based on `method` code:
9+
- 15 → `ode15s`
10+
- 23 → `ode23tb`
11+
- 45 → `ode45`
12+
3. **Execution**: Calls the selected solver and returns results.
13+
14+
## Inputs
15+
16+
| Name | Description | Units |
17+
|------------|----------------------------------------------|---------|
18+
| `bubble` | Function handle for ODE system ||
19+
| `init` | Initial condition vector ||
20+
| `method` | Solver choice (15, 23, or 45) ||
21+
| `divisions`| Maximum number of time steps (0 = auto) ||
22+
| `tspan` | Two-element time span `[t0 tf]` ||
23+
| `tfin` | Final time (for step size calculation) ||
24+
25+
## Outputs
26+
27+
| Name | Description | Units |
28+
|------|--------------------------|---------|
29+
| `t` | Time vector ||
30+
| `X` | Solution matrix (states) ||
31+
32+
## Notes
33+
- Throws an error for unsupported `method` codes.
34+
- `MaxStep` is set to `tfin/divisions` when `divisions > 0`.

docs/f_pinfinity.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# `f_pinfinity.m` Documentation
2+
3+
## Overview
4+
`f_pinfinity` calculates the time-dependent external pressure (`p8`) and its derivative (`p8dot`) that drive bubble dynamics, supporting multiple waveform types.
5+
6+
## Major Sections
7+
1. **Input Unpacking**: Extracts waveform parameters from `vararg`.
8+
2. **Custom Waveform Handling**: If `wave_type < 0`, uses polynomial fits (`wave_poly`, `wave_dpoly`).
9+
3. **Predefined Waveforms**:
10+
- **Impulse** (`wave_type = 0`)
11+
- **Gaussian** (`wave_type = 1`)
12+
- **Histotripsy** (`wave_type = 2`)
13+
- **Heaviside Impulse** (`wave_type = 3`)
14+
4. **Inner Functions**: Define `impulse`, `gaussian`, `histo`, and `heaviside_impulse`.
15+
16+
## Inputs
17+
18+
| Name | Description | Units |
19+
|-------------|-------------------------------------------------|---------|
20+
| `t` | Current time | s |
21+
| `vararg` | Vector `[om, ee, tw, dt, mn, wave_type]` ||
22+
23+
## Outputs
24+
25+
| Name | Description | Units |
26+
|----------|---------------------------------------------|---------|
27+
| `p8` | External pressure at time `t` | Pa |
28+
| `p8dot` | Time derivative of external pressure | Pa/s |
29+
30+
## Notes
31+
- `wave_poly` and `wave_dpoly` must be defined in the caller’s workspace for custom waveforms.
32+
- Gaussian and histotripsy waveforms depend on `ee` (amplitude), `om` (frequency), `tw` (width), `dt` (delay), and `mn` (exponent).

docs/f_pvsat.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# `f_pvsat.m` Documentation
2+
3+
## Overview
4+
`f_pvsat` returns the saturated water vapor pressure as a function of temperature using an empirical exponential fit.
5+
6+
## Major Sections
7+
1. **Empirical Formula**: Applies `Pv = 1.17e11 * exp(-5200/T)`.
8+
9+
## Inputs
10+
11+
| Name | Description | Units |
12+
|------|--------------------|-------|
13+
| `T` | Temperature | K |
14+
15+
## Outputs
16+
17+
| Name | Description | Units |
18+
|------|-------------------------------|-------|
19+
| `Pv` | Saturated vapor pressure | Pa |
20+
21+
## Notes
22+
- Source: A. Preston, 2004 (Thesis).
23+
- Valid for typical biological temperature ranges (290–310 K).

docs/f_radial_eq.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# `f_radial_eq.m` Documentation
2+
3+
## Overview
4+
`f_radial_eq` evaluates the radial acceleration (`Rddot`) of a bubble wall using various models (Rayleigh–Plesset, Keller–Miksis, Gilmore) and equations of state.
5+
6+
## Major Sections
7+
1. **Rayleigh–Plesset (Model 1)**
8+
2. **Keller–Miksis Pressure Form (Model 2)**
9+
3. **Keller–Miksis Enthalpy Form (Model 3)**
10+
4. **Gilmore with Tait EoS (Model 4)**
11+
5. **Keller–Miksis with Mie–Grüneisen EoS (Model 5)**
12+
6. **Gilmore with Mie–Grüneisen EoS (Model 6)**
13+
7. **EOS Helper Functions**:
14+
- `f_mie_gruneisen_eos_scalar`
15+
- `f_mie_rho_from_p_scalar`
16+
17+
## Inputs
18+
19+
| Name | Description | Units |
20+
|-------------|--------------------------------------------|-------|
21+
| `radial` | Model selector (1–6) ||
22+
| `P` | Internal bubble pressure (non-dim) ||
23+
| `Pdot` | Time derivative of `P` ||
24+
| `Pf8` | External pressure (non-dim) ||
25+
| `Pf8dot` | Time derivative of `Pf8` ||
26+
| `iWe` | Inverse Weber number ||
27+
| `R` | Bubble radius (non-dim) ||
28+
| `Rdot` | Bubble wall velocity (non-dim) ||
29+
| `S` | Stress term (non-dim) ||
30+
| `Sdot` | Time derivative of `S` ||
31+
| `Cstar` | Non-dim sound speed ||
32+
| `sam` | Tait EOS parameter ||
33+
| `no` | Tait exponent ||
34+
| `GAMa` | Mie–Grüneisen parameter ||
35+
| `nstate` | EOS exponent ||
36+
| `nog` | (nstate–1)/2 for MG EoS ||
37+
| `hugoniot_s`| Hugoniot slope ||
38+
| `JdotA` | Viscous and thermal coupling parameter ||
39+
| `ddintfnu` | Second derivative of non-Newtonian term ||
40+
| `iDRe` | Inverse Debye–Stokes number ||
41+
42+
## Outputs
43+
44+
| Name | Description | Units |
45+
|----------|-----------------------------------------|-------|
46+
| `Rddot` | Bubble wall acceleration ||
47+
48+
## Notes
49+
- EOS helper functions perform scalar EOS and density calculations.
50+
- Ensure physical consistency when mixing different models.

docs/f_stress_calc.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# `f_stress_calc.m` Documentation
2+
3+
## Overview
4+
`f_stress_calc` computes the stress integral and its time derivative for a range of viscoelastic models (Kelvin–Voigt, Maxwell, Jeffreys, Zener, Oldroyd-B).
5+
6+
## Major Sections
7+
1. **No Stress (Model 0)**
8+
2. **Kelvin–Voigt Neo-Hookean (Model 1)**
9+
3. **Quadratic KV Neo-Hookean (Model 2)**
10+
4. **Linear Maxwell/Jeffreys/Zener (Model 3)**
11+
5. **Quadratic Maxwell Variant (Model 4)**
12+
6. **Upper-Convected Maxwell / Oldroyd-B (Model 5)**
13+
7. **Special Placeholder (Model -1)**
14+
15+
## Inputs
16+
17+
| Name | Description | Units |
18+
|--------------|----------------------------------------|-------|
19+
| `stress` | Model selector (0–5, -1) ||
20+
| `X` | State vector containing auxiliary vars ||
21+
| `Req`, `R` | Equilibrium and current radius ||
22+
| `Ca`, `De` | Cauchy and Deborah numbers ||
23+
| `Re8` | Reynolds number ||
24+
| `Rdot` | Wall velocity ||
25+
| `alphax` | Quadratic KV exponent ||
26+
| `ivisco1` | Index of first viscous state variable ||
27+
| `ivisco2` | Index of second viscous state variable ||
28+
| `LAM` | Dimensionless elastic modulus ||
29+
| `zeNO`, `cdd`| Spectral coupling parameters ||
30+
| `intfnu`, `dintfnu` | Non-Newtonian integrals ||
31+
| `iDRe` | Inverse Debye–Stokes number ||
32+
33+
## Outputs
34+
35+
| Name | Description | Units |
36+
|---------|------------------------------------|-------|
37+
| `S` | Stress integral ||
38+
| `Sdot` | Time derivative of `S` ||
39+
| `Z1dot` | First auxiliary stress derivative ||
40+
| `Z2dot` | Second auxiliary stress derivative ||
41+
42+
## Notes
43+
- For spectral solvers, `zeNO` and coupling differ.
44+
- The placeholder model (-1) is for internal code consistency.

docs/f_stress_dissipation.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# `f_stress_dissipation.m` Documentation
2+
3+
## Overview
4+
`f_stress_dissipation` calculates the mechanical dissipation term (`τ:∇u`) contributing to energy loss, accounting for both finite-difference and spectral solvers.
5+
6+
## Major Sections
7+
1. **Radial Stretch Calculation**: Compute `Rst`, `x2`, `ix2`, `x4`.
8+
2. **Finite-Difference Dissipation**: Branch for models 0–5.
9+
3. **Spectral Dissipation**: Alternative calculation if `spectral == 1`.
10+
11+
## Inputs
12+
13+
| Name | Description | Units |
14+
|----------------|----------------------------------------|-------|
15+
| `stress` | Stress model selector (0–5) ||
16+
| `spectral` | Solver type flag ||
17+
| `Req`, `R` | Equilibrium and current radius ||
18+
| `Rdot` | Wall velocity ||
19+
| `Ca`, `Br` | Cauchy number and Brinkman number ||
20+
| `Re8`, `alphax`| Reynolds and quadratic exponent ||
21+
| `yT2`, `yT3` | Collocation grid vectors ||
22+
| `iyT3`, `iyT4`, `iyT6` | Inverses of grid powers ||
23+
| `X`, `ZZT` | State vectors and spectral matrix ||
24+
| `ivisco1`, `ivisco2` | Auxiliary stress indices ||
25+
| `fnu`, `DRe` | Non-Newtonian friction and number ||
26+
27+
## Outputs
28+
29+
| Name | Description | Units |
30+
|-------------|---------------------------------------|-------|
31+
| `taugradu` | Mechanical dissipation (`τ:∇u`) ||
32+
33+
## Notes
34+
- Spectral branch uses `ZZT*(X(ivisco1)-X(ivisco2))` for dissipation.

docs/f_viscosity.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# `f_viscosity.m` Documentation
2+
3+
## Overview
4+
`f_viscosity` computes non-Newtonian viscosity integrals for Carreau, Cross, Powell–Eyring, and related models, providing stress and its derivatives for bubble dynamics.
5+
6+
## Major Sections
7+
1. **Shear Rate Computation**: `gammadot_R`, `gammadot_num`, `dgammadot`, `ddgammadot`.
8+
2. **Model Selection**: Branch for `nu_model` (1–7).
9+
3. **Integral Calculations**: Perform numerical integration with `integral`.
10+
4. **Internal Functions**: Definitions for `sf_carreau`, `sf_carreau_yasuda`, etc.
11+
12+
## Inputs
13+
14+
| Name | Description | Units |
15+
|-------------|----------------------------------------|---------|
16+
| `nu_model` | Viscosity model selector (1–7) ||
17+
| `Rdot` | Wall velocity ||
18+
| `R` | Bubble radius ||
19+
| `a`, `nc` | Model parameters (exponents) ||
20+
| `lambda` | Time constant for viscosity model | s |
21+
22+
## Outputs
23+
24+
| Name | Description | Units |
25+
|----------|--------------------------------------------------|---------|
26+
| `f` | Local viscosity factor ||
27+
| `intf` | Stress integral for non-Newtonian term ||
28+
| `dintf` | First derivative of `intf` ||
29+
| `ddintf` | Second derivative of `intf` ||
30+
31+
## Notes
32+
- Use high tolerance (`1e-8`) for integrals.
33+
- Models:
34+
- 1: Carreau
35+
- 2: Carreau–Yasuda
36+
- 3: Powell–Eyring
37+
- 4: Modified Powell–Eyring
38+
- 5: Cross
39+
- 6: Simplified Cross
40+
- 7: Modified Cross

0 commit comments

Comments
 (0)