/* ********************************************************************* */ void Radiat (double *v, double *rhs) /*! * Cooling for optically thin plasma up to about 200,000 K * Plasma composition: H, HeI-II, CI-V, NI-V, OI-V, NeI-V, SI-V * Assumed abundances in elem_ab * Uses S : Array = Variables vector x line points * rhs : output for the system of ODE * ibeg, iend : begin and end points of the current line * * *********************************************************************** */ { int nv, j, k, cooling_nT, cooling_nNe, jj; int ti1, ti2, ne1, ne2, nrt; double mu, sT, scrh, tmpT, tmpNe, tt1, tt2, nn1, nn2, tf1, tf2, nf1, nf2; double N, n_el, rlosst, em, cf1, cf2; double T, *X, *RS; static double ***tab; static double N_rho; static double E_cost, Unit_Time; /* -- for dimensionalization purposes -- */ double em2, em3; double prs; /* -------------------------------------------------------------------- Load tables from disk at first call. Tables are 2-D with T and Ne being the coordinates. -------------------------------------------------------------------- */ if (tab == NULL) { E_cost = UNIT_LENGTH/UNIT_DENSITY/ (UNIT_VELOCITY*UNIT_VELOCITY*UNIT_VELOCITY); Unit_Time = UNIT_LENGTH/UNIT_VELOCITY; /* --------------------------------------- Compute cooling function tables --------------------------------------- */ for (nv = 0; nv < NIONS; nv++) CoolCoeffs.dLIR_dX[nv] = 0.0; n_el = C_NeMIN; ne1 = 0; while (n_el < C_NeMAX) { T = C_TMIN; ne2 = 0; while (T < C_TMAX) { tmpT = T; T = T*exp(C_TSTEP); /* should be *exp(0.02) */ ne2 = ne2 + 1; } tmpNe = n_el; n_el = n_el*exp(C_NeSTEP); /* should be *exp(0.06) */ ne1 = ne1 + 1; } tab = ARRAY_3D(NIONS, ne1, ne2, double); Create_Losses_Tables(tab, &cooling_nT, &cooling_nNe); N_rho = find_N_rho(); } /* end load tables */
delta[k][l] = (k == l ? 1.0:0.0); }} } Radiat (v, rhs); L = CoolCoeffs.Lrate; La = CoolCoeffs.La; Lb = CoolCoeffs.Lb; Lc = CoolCoeffs.Lc; C = CoolCoeffs.Crate; Ca = CoolCoeffs.Ca; Cb = CoolCoeffs.Cb; Cc = CoolCoeffs.Cc; R = CoolCoeffs.Rrate; Ra = CoolCoeffs.Ra; Rb = CoolCoeffs.Rb; Rc = CoolCoeffs.Rc; de = CoolCoeffs.de; X = v + NFLX; dnel_dX = CoolCoeffs.dnel_dX; N = v[RHO]*find_N_rho(); /* -- Total number density -- */ mu = MeanMolecularWeight(v); T = v[PRS]/v[RHO]*KELVIN*mu; /* -- compute the vector grad_X (mu) -- */ scrh = 1.0/CoolCoeffs.muD; for (k = 0; k < n - 1; k++){ dmu_dX[k] = (CoolCoeffs.dmuN_dX[k] - CoolCoeffs.dmuD_dX[k]*mu)*scrh; } /* ------------------------------------------------- Compute dX'/dX, dp'/dX with k = 0....n - 2