flow.solve_temperature
flow.solve_temperature(
chi,
velocity,
config,
*,
density=1.0,
wall=None,
source=0.0,
fixed_mask=None,
fixed_value=0.0,
)
Solve the conjugate energy equation on the lattice.
Differentiable in chi, velocity, source and fixed_value: the linear solve carries :func:jax.lax.custom_linear_solve’s implicit adjoint, so reverse mode is one transposed solve rather than a tape through the Krylov iterations. That is what lets this compose with the momentum solve’s fixed-point adjoint without either knowing the other exists.
Parameters
| chi |
jax.Array |
Solid fraction, (NX, NY, NZ). |
required |
| velocity |
jax.Array |
Velocity in lattice units, (3, NX, NY, NZ). Pass zeros for a pure-conduction solve. |
required |
| config |
EnergyConfig |
The energy configuration. |
required |
| density |
Any |
Density, (NX, NY, NZ) or a scalar. Multiplied into velocity to form the convective flux; the default 1.0 is the incompressible reading, and a solve fed a lattice Boltzmann field should pass that field’s own density so the flux is the one the momentum solve actually conserves (see the module docstring). |
1.0 |
| wall |
np.ndarray | None |
Boolean duct-wall mask; None builds :func:~cadjoint.flow.lbm.duct_walls for the shape. |
None |
| source |
Any |
Volumetric power per cell — a scalar or an (NX, NY, NZ) array. |
0.0 |
| fixed_mask |
np.ndarray | None |
Cells held at a prescribed temperature (concrete boolean array), or None for none. |
None |
| fixed_value |
Any |
The prescribed temperatures, scalar or (NX, NY, NZ). |
0.0 |
Returns
|
jax.Array |
(NX, NY, NZ) temperature, zero on duct-wall cells (which the |
|
jax.Array |
system does not solve for), or all-NaN when velocity is not |
|
jax.Array |
finite – see the note in the body on why that is better than the |
|
jax.Array |
zeros GMRES would otherwise return. |
Raises
|
ValueError |
If chi or velocity does not match the configured shape. |