PyREC scaffolding (from YREC development, 7be4133)/ physic.fGlossary

physic.f

191 lines · 1 definitions · on GitHub (7be4133)

Python version: physic.py, 171 lines, on the right (switch to Python above the code).

Variables on this page (20)

amuenv, cln, cp, hamu, iovim, json, ldh, qwrmax, sdel, so, sqdt, svel, xenv, xxdh, y3env, yenv, yydh, zdh, zenv, zzdh

Purpose

Recomputes the auxiliary physics at every shell of a model: equation of state, opacity, temperature gradients and convection, mean molecular weight, then the thermal diffusivity and viscosity, and the largest angular velocity gradient that is stable against the shear instability. Its comment: "find actual and adiabatic temperature gradients, opacity, and mean molecular weight for all radiative shells" (the loop in fact covers all shells).

The loop covers all shells. The comment speaks of "ALL RADIATIVE SHELLS" (lines 81–82↗), but the loop DO 30 IM = 1,M (line 86↗) skips no shell, convective ones included, so the comment could say "all shells."

How it fits

  • Inputs: the model (HCOMP, HD, HG (gravity), HL, HP, HR, HS, HT, all logarithmic except HL, HG and HCOMP), the rotational distortion factors FP, FT, M, TEFFL and the mixing length CMIXL (a new argument, formerly in /CONST3/), passed on to TPGRAD; the envelope composition from COMP_MOD and COMP2_MOD; the switch LDH (NMLPAR_MOD), with the Debye–Hückel abundances it sets in DEBHU_MOD; CLN from CONSTANTS_MOD.
  • Who calls it: GETW, HPOINT and STARIN.
  • What it calls: EQSTAT (the general equation of state), GETOPAC, TPGRAD (gradients and convective velocity), VISCOS, and INTRP2.
  • Outputs (all through modules, except LC):
  • LC, the convection flags (argument), overwritten from TPGRAD at every shell (line 116↗). All three callers use the new flags right after the call (settled from the code, Nov 9, 2026): HPOINT calls PHYSIC, as its comment says, "to accurately locate the edges of convection zones" (hpoint.f, lines 830–834↗); STARIN passes LC to OVROT (starin.f, lines 1031–1033↗) and GETW to GETTAU (getw.f, lines 240–244↗);
  • SCRTCH_MOD: SDEL(1..3,·) $= \nabla_\mathrm{rad}, \nabla, \nabla_\mathrm{ad}$, the opacity SO, the convective velocity SVEL;
  • TEMP_MOD: CP, HAMU (the mean molecular weight), SQDT ($(\partial\ln\rho/\partial\ln T)_P$), and through VISCOS THDIF and VISC;
  • DWMAX_MOD: QWRMAX, the critical $d\Omega/d\ln r$, which only HPOINT reads, to copy it into QWRMX0, which nothing reads (hpoint.f, line 855↗; unused?);
  • DPMIX_MOD: IOVIM, the current shell, for TPGRAD. These feed the rotational mixing and transport routines (MIDMOD interpolates them in time), and MICRODIFF_MTE (for microscopic diffusion) reads SDEL(2,·).

The method

  1. Per shell: the equation of state, always EQSTAT (with Debye–Hückel abundances set first when LDH), the opacity, and TPGRAD, without derivatives (LDERIV = .FALSE.). The flag LOCOND is set to false and never read (unused?, line 84↗); the counter of Saha-equation calls KSAHA, which EQSTAT updates, is never initialized or read here (unused?, lines 108–110↗).
  2. Mean molecular weight of a fully ionized gas. With $A$ = 1.007825, 4.002603, 12 and 3.01603 for H, ⁴He, the metals (as carbon) and ³He, $$\frac{1}{\mu_\mathrm{ion}} = \frac{1}{\mu_\mathrm{ion,env}} + \sum_k \frac{X_k - X_{k,\mathrm{env}}}{A_k},\qquad \frac{1}{\mu_e} = \frac{X}{A_\mathrm{H}} + 2\left(\frac{X_{^3\mathrm{He}}}{A_{^3\mathrm{He}}} + \frac{Y}{A_{^4\mathrm{He}}}\right) + \frac{Z}{2},\qquad \mu = \frac{\mu_\mathrm{ion}\,\mu_e}{\mu_\mathrm{ion}+\mu_e}.$$

  3. Shear stability (Endal & Sofia 1978, ApJ 220, 279, as cited). At each interface between shells, with $\rho$, $P$, $\nabla$, $\nabla_\mathrm{ad}$ and $g$ interpolated to the midpoint in $\log m$ (four-point Lagrange), $$\left(\frac{d\Omega}{d\ln r}\right)_\mathrm{max} = 2\sqrt{\frac{\rho}{P}\,g^2\,(\nabla_\mathrm{ad} - \nabla)}$$ where the root is real, and 0 otherwise. QWRMAX(IM) belongs to the interface between shells IM-1 and IM; it is 0 where both shells are convective, and QWRMAX(1) is never set. $\rho$ and $P$ are interpolated in their logarithms (HD, HP), $g$ (HG, not logarithmic) and the gradients directly.

Definitions

subroutinePHYSIC

lines 3–191 · GitHub

Uses modules COMP2_MOD, COMP_MOD, CONSTANTS_MOD, DEBHU_MOD, DIMENSIONS_MOD, DPMIX_MOD, DWMAX_MOD, NMLPAR_MOD, SCRTCH_MOD, TEMP_MOD

Called by GETW, HPOINT, STARIN

Flowchart of its calls, in order (5)
for IM = 1,M (DO 30), lines 86–145
for IM = 2,M (DO 100), lines 152–189

Change log

The changes since rp_1

Changed since rp_1. The MHD equation of state is removed (LMHD and the call to MEQOS, removed since rp_1), so every shell uses EQSTAT; the mixing length CMIXL is a new argument, passed to TPGRAD; the write-only /OPTAB/ settings (IDT = 15, IDD = 5) are gone; COMMON blocks to modules, IMPLICIT NONE. No question is settled.