load_src("hgspy", "../torchpack/hgspy.py") import hgspy load_src("koo", "../torchpack/koo.py") import koo CM2PC = 3.24078e-19 PC2CM = 1.0 / CM2PC YR2S = 3.154e7 times = [2.0e4, 4.0e4, 6.0e4, 8.0e4, 10.0e4] def find_stromgren(logQ, nh): alpha = 2 rstar = 0.35 * PC2CM rc = 0.01 * PC2CM a = 1 + (rstar / rc)**2.0 n0 = nh * a**(alpha / 2.0) a = 1 + (rstar / rc)**2.0 b = (10.0**logQ) / (4.0 * math.pi * koo.calcAlphaB(8000.0) * (rc**3) * (n0**2)) def func(x): return -x / (2.0 * (a + x**2)) + math.atan2(x, math.sqrt(a)) / (2.0 * math.sqrt(a)) - b return optimize.brentq(func, 0, 100) * rc * CM2PC RS = find_stromgren(49.81, 3.2e4) print RS print koo.calcSpitzerRadius2(RS * PC2CM, times[0]*YR2S) * CM2PC
def printPaperTable(r, t, b, isWind, isMVD): T = 8000.0 mu = 0.5 diststr = "D_\\mathrm{s}" if isWind else "D_\\mathrm{i}" numstr = "4" if isWind else "4" for row in range(9): mass = massList[row] mdot = mdotList[row] vinf = vinfList[row] logQ = logQList[row] nhs_hii = mvd_iden if isMVD else mvt_iden times = mvd_times if isMVD else mvt_times nhs_init = mvd_nhs if isMVD else mvt_nhs inj = mvd_inj if isMVD else mvt_inj tableline = "\multirow{" + numstr + "}{*}{\\num{" + str(mass) + "}} & {$" + diststr + "(0)$}" for col in range(5): tableline = tableline + " & " tableline = tableline + str(t[col][row]) print tableline + " \\\\" tableline = "& {$" + diststr + "(\\frac{\\pi}{2})$}" for col in range(5): tableline = tableline + " & " tableline = tableline + str(r[col][row]) print tableline + " \\\\" tableline = "& {$" + diststr + "(\\pi)$}" for col in range(5): tableline = tableline + " & " tableline = tableline + str(b[col][row]) print tableline + " \\\\" if isWind: tableline = "& {$R_\\mathrm{P}$}" for col in range(5): tableline = tableline + " & " R = koo.calcFinalRadiusRB(mdot, vinf, mh*nhs_hii[col][row], T, mu) * CM2PC tableline = tableline + str(R) print tableline + " \\\\" else: tableline = "& {$R_\\mathrm{raga-1}$}" for col in range(5): tableline = tableline + " & " R = koo.calcStromgrenRadius(logQ, nhs_init[col]) #R = max(R, inj[col][row] / CM2PC) R = koo.calcSpitzerRadius2(R, times[col]*YR2S)*CM2PC R = koo.calcExactIF(300.0, T, 1.0, mu, nhs_init[col], 10.0**logQ, times[col] * YR2S, is_spitzer=True) * CM2PC tableline = tableline + str(R) print tableline + " \\\\" #tableline = "& {$R_\\mathrm{stag}$}" #for col in range(5): # tableline = tableline + " & " # R = koo.calcStromgrenRadius(logQ, nhs_init[col]) # #R = max(R, inj[col][row] / CM2PC) # R = koo.calcStagnationRadius2(R) * CM2PC # tableline = tableline + str(R) #print tableline + " \\\\" if row != 8: print "& & & & & & \\\\"