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

midmod.f

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

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

Variables on this page (52)

amum, amuo, cc23, cln, cmsun, cp, cpm, cpo, delam, delao, delm, delo, delrm, delro, drate, drate0, epsm, epso, esumm, esumo, hamu, hcompp, hdo, hgo, hlo, hpo, hro, hto, impjmod, json, lco, lexcom, lsolid, om, oo, qdtm, qdto, sdel, seg, sesum, so, sqdt, svel, tcut, thdif, thdifm, thdifo, velm, velo, visc, viscm, visco

Purpose

In the rotational-mixing and angular-momentum transport loop, a model time step is divided into shorter "diffusion" steps. MIDMOD builds the structure at an intermediate time of the model step by linear interpolation between the old model (start of the step) and the new one (end of the step). Its comments say it also accounts for nuclear burning, recomputes the angular velocity from the conserved specific angular momentum, and finds the edges of the central and surface convection zones and the moment of inertia of the surface convection zone.

How it fits

  • Inputs: the new model in the arguments (HD, HL, HP, HR, HT, HG, the convection flags LC); the old model in OLDMOD_MOD, OLDPHY_MOD and OLDROT_MOD (HGO); the new auxiliary physics in SCRTCH_MOD (SDEL, SESUM, SEG, SO, SVEL) and TEMP_MOD (CP, HAMU, SQDT, THDIF, VISC); the fraction of the step FX and the diffusion step DT (of the model step DELTS); the specific angular momentum HJM.
  • Who calls it: only GETW, once per diffusion step, with FX = SUMDT/DELTS.
  • What it calls: OVROT (convective overshoot for the mixing zones), ROTMIX (burning and mixing over the short step), DBURNM (deuterium burning), and GETROT or SOLID (the rotation variables).
  • Outputs: the intermediate structure (HDM, HLM, HPM, HRM, HTM, HGM, LCM, LCZM), the rotation variables (OMEGAM, HIM, ETA2M, QIWM, R0M), IMIN, IMAX, HSTOP, HSBOT, HICZ, LCZSUR, LALLCZ, the mixing zones (MRZONE, MXZONE, NRZONE, NZONE), and the interpolated physics in MDPHY_MOD (DELM, DELAM, DELRM, VELM, VISCM, THDIFM, CPM, QDTM, OM, AMUM, EPSM, ESUMM), which GETW and the transport routines (CODIFF, MIXGRID, MIXCZ and others) read. It saves the composition after mixing in the argument HCOMPS (formerly /OLDAB/), an array GETW owns and passes on to SECULR.
  • Modules: NMLPAR_MOD (LSOLID, IMPJMOD, TCUT, LEXCOM), DEUTER_MOD (DRATE, DRATE0), CONSTANTS_MOD (CLN, CC23, CMSUN), OLDROT_MOD (the old model's HGO) and the modules above. The values of the previous intermediate step (DDELP, DDELN, HRP, LCP, formerly /PREVMID/) are local saved arrays.

The method

  1. The first diffusion step (LFIRSTIT): HCOMP (rows 1–11, or 1–15 with LEXCOM) is reset to the old model's composition HCOMPP, and AMUM to AMUO, so that burning and mixing start from the start of the model step.
  2. Interpolation in time. For each variable $q$ (logarithmic structure variables and the physics), $$q_\mathrm{mid} = q_\mathrm{old} + f\,(q_\mathrm{new} - q_\mathrm{old}),\qquad f = \texttt{FX}.$$ The mean molecular weight AMUM is instead incremented: $\mu_\mathrm{mid} \mathrel{+}= (\Delta t/\Delta t_\mathrm{model})(\mu_\mathrm{new}-\mu_\mathrm{old})$ (line 165↗). This is the same as interpolating: it starts from AMUO at the first substep (line 130↗), GETW's substeps add up to the model step (getw.f, lines 262–268↗), and a substep that is redone is subtracted again (getw.f, lines 355–359↗) (settled from the code, Nov 9, 2026). The total energy generation EPSM interpolates SESUM + SEG(6) + SEG(7). The interpolation is at fixed shell because the two models share a mass grid: when HPOINT rezones at the start of the step it interpolates the old model onto the new points (HPO, HTO, HRO, HLO, HDO in OLDMOD_MOD), and otherwise the main program copies the old model into them unchanged.

  3. Convection. A shell keeps its convective state if it is the same at both ends of the step; otherwise it is convective if $\nabla_\mathrm{ad} < \nabla_\mathrm{rad}$ at the intermediate time, with the larger of the two convective velocities.

  4. Receding convection zones (MHP 06/02): a block meant to correct the specific angular momentum of shells that leave a convection zone during the step. It is unused?: LNEWCZ, set by loop 50 when any shell changes state, is reset to .FALSE. at line 192↗, just before IF(LNEWCZ) (lines 197–318↗). As written it could not be revived unchanged: It overwrites the argument FX, which GETW uses (line 253↗, line 292↗); RR = HJM2/HJM(J) comes after HJM(J) = HJM2, so it is always 1 (lines 268–269↗); the zone's moment of inertia uses HR(II)-HRO(II) but the shell's HR(J)-HRP(J) (line 257↗, line 264↗); the envelope branch sums $J$ over J+1..ICZ1 but rescales J+1..M (lines 295–299↗, lines 310–312↗); and DDELN(I0-1) is read at index 0 when the first shell changes state (lines 214–215↗, line 220↗).

  5. Mixing and burning. OVROT sets the mixed zones with overshoot; ROTMIX burns and mixes over DT, using the intermediate temperature HTM "for thermodynamic consistency" (MHP 6/00). If the surface deuterium abundance at the start of the step (HCOMPP(12,M)) exceeds $10^{-14}$, the deuterium rate is interpolated and burnt by DBURNM, shell by shell in radiative zones (down to the burning cutoff TCUT(1)) and zone by zone in convective ones. This is where the header's "nuclear burning is accounted for here" (line 112↗) is done: The update by HCOMPM is commented out (lines 151–154↗), and ROTMIX and DBURNM burn instead (lines 326–328↗, lines 335–371↗) (settled from the code, Nov 9, 2026). The radiative loop leaves both loops at the first shell at or below TCUT(1) (line 353↗); this skips no hotter shell, since CONVEC lists the radiative zones from the center outward (convec.f, lines 184–205↗) and the temperature falls outward (settled from the code, Nov 9, 2026; convec.f, suspected bug 1 aside).
  6. Convection zone edges. IMIN $= \max(2, I-1)$, where $I$ is the first shell that is not convective, so it is the outermost shell of a central convection zone, or 2; IMAX the lowest shell of the surface convection zone (or M). HSTOP is the total mass, HSBOT the mass at the base of the surface zone.

  7. Rotation. Unless rotation is forced to be solid (LSOLID, or IMPJMOD = 1), the first guess of each shell's moment of inertia per unit mass is that of a thin spherical shell, $i = \tfrac23 r^2$, so $\Omega = j/i$; GETROT then solves for the distorted shells. HICZ sums the moments of inertia of the surface convection zone. For solid rotation, SOLID gives the run, and HICZ sums all shells.

Design

A long block for a local convective turnover time (MHP 3/09) is commented out; GETW and other routines handle TAUCZ through OVRTRN_MOD. The routine prints to the screen (WRITE(*,*)) inside the dead block only.

Definitions

subroutineMIDMOD

lines 2–523 · GitHub

Uses modules CONSTANTS_MOD, DEUTER_MOD, DIMENSIONS_MOD, MDPHY_MOD, NMLPAR_MOD, OLDMOD_MOD, OLDPHY_MOD, OLDROT_MOD, SCRTCH_MOD, TEMP_MOD

Called by GETW

Flowchart of its calls, in order (6)
if (HCOMPP(12,M).GT.1.0D-14), lines 335–371
for K = 1,NRZONE, lines 350–359
for J = MRZONE(K,1),MRZONE(K,2), lines 351–358
for K = 1,NZONE, lines 365–370
if (.NOT.LSOLID .AND. (IMPJMOD.NE.1)), lines 486–509

Change log

The changes since rp_1

Changed since rp_1. HCOMPS is a new last argument (formerly /OLDAB/), and LFIRST is renamed LFIRSTIT; COMMON blocks to modules (the unused /BURN/, /CWIND/, /DWMAX/, /OVRTRN/ and /CTLIM/ are gone, TCUT now from NMLPAR_MOD; /PREVMID/ to local saved arrays), IMPLICIT NONE. No question is settled.