flow.EnergyConfig

flow.EnergyConfig(
    shape,
    fluid_diffusivity,
    conductivity_ratio=200.0,
    inlet_temperature=0.0,
    wall_temperature=None,
    scheme='exponential',
    tol=1e-10,
    max_steps=4000,
    restart=60,
)

Static settings for one conjugate energy solve.

Attributes

Name Type Description
shape tuple[int, int, int] (NX, NY, NZ) lattice, duct axis along +Y, matching the momentum solve’s grid exactly.
fluid_diffusivity float The air’s thermal diffusivity in lattice units, nu / Pr. Numerically also its conductivity, because (rho cp)_f is the unit of this system.
conductivity_ratio float k_solid / k_fluid. Aluminium in air is about 8000; a ratio that large is physically right and numerically punishing (see the module docstring on conditioning), so a study that only needs “much better than air” is better served by a few hundred.
inlet_temperature float Temperature carried in at the inlet plane.
wall_temperature float | None Temperature of the duct’s lateral walls, or None (the default) for adiabatic walls — the right choice for a duct that is not itself a heat exchanger.
scheme str "exponential" or "upwind"; see the module docstring.
tol float Relative residual the linear solve stops at.
max_steps int Iteration cap for the linear solve.
restart int Krylov subspace size before GMRES restarts, and the one setting here that can silently return a wrong answer. Restarted GMRES stagnates when the subspace is too small for the operator’s spectrum, and the conductivity ratio is what sets that spectrum: on a 14x26x14 duct, restart = 30 converges to 2.9e-12 at a ratio of 50 and stalls at a relative residual of 0.23 at a ratio of 200 – reporting a peak temperature of 0.014 where the answer is 0.602, with no error and no warning. 60 converges at both. It costs restart stored fields, which is the reason not to simply set it very high on a large lattice. :func:energy_imbalance is the check that catches a stall, and :attr:~cadjoint.flow.study.FlowStudyResult.warnings runs it.

Raises

Name Type Description
ValueError On a non-positive diffusivity or conductivity ratio, or an unknown scheme.