Commit a38807fca6c20a2d10bcf2d5862fe3340cdc2b09
1 parent
40772701
Exists in
master
first commit of fortran helper routines
Showing
5 changed files
with
143 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +FUNCTION DUSTEM_CUT_OFF, x, par | ||
2 | +; generates the large size cut-off | ||
3 | +; from Weingartner & Draine 2001 | ||
4 | +; x : grain size | ||
5 | +; par(0) : threshold for cut-off (At) | ||
6 | +; par(1) : shape As (roughly the size where cut_off=0.5) | ||
7 | + | ||
8 | + y = 0.d0*x + 1.d0 | ||
9 | + ix = WHERE( x GT par(0), cnt ) | ||
10 | + if CNT GT 0 then begin | ||
11 | + y(ix) = exp( -( (x(ix)-par(0)) / par(1))^3. ) | ||
12 | + endif else begin | ||
13 | + print,'(W) DUSTEM_CUT_OFF: no size larger than At found' | ||
14 | + endelse | ||
15 | +RETURN, y | ||
16 | +END |
@@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
1 | +FUNCTION DUSTEM_HABING_FIELD, x, unit=unit | ||
2 | +; computes the Habing interstellar radiation field SED (ISRF) | ||
3 | +; in W/m2 (4*!pi*nu*I_nu) | ||
4 | +; (from Draine & Bertoldi 1996) | ||
5 | +; X (I): X-grid for the ISRF | ||
6 | +; UNIT (I): unit of the ISRF. Choices are | ||
7 | +; 'W': wave in um [Default] | ||
8 | +; 'F': frequency in cm-1 | ||
9 | +; 'E': energy in eV | ||
10 | + | ||
11 | + if n_elements( UNIT ) EQ 0 then unit = 'W' $ | ||
12 | + else unit = strupcase( strcompress( unit,/rem) ) | ||
13 | + | ||
14 | + x = double( x ) | ||
15 | + | ||
16 | + CASE unit of | ||
17 | + | ||
18 | + 'W': x3 = 1.d1 * x | ||
19 | + | ||
20 | + 'F': x3 = 1.d5 / x | ||
21 | + | ||
22 | + 'E': x3 = 12.4 / x | ||
23 | + | ||
24 | + ENDCASE | ||
25 | + | ||
26 | + field = - x3^3*4.1667 + x3^2*12.5 - x3*4.3333 | ||
27 | + field = 1.d-1 * 3.d8 * 1.d-14 * field | ||
28 | + | ||
29 | + i_neg = where( field LT 0.d0, c_neg ) | ||
30 | + field( i_neg ) = 0.d0 | ||
31 | + | ||
32 | + RETURN, field | ||
33 | +END ;FUNCTION DUSTEM_HABING_FIELD |
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +FUNCTION DUSTEM_LOGN_VDIST, x, par | ||
2 | +; generates a volume normalized log-normal law | ||
3 | +; returns distribution in nr of grains : dn/da | ||
4 | +; x : grain size | ||
5 | +; par(0) : centroid of log-normal | ||
6 | +; par(1) : sigma of log-normal | ||
7 | +; par(2) : VOLUME normalization | ||
8 | + | ||
9 | + np = n_elements(x) | ||
10 | + x0 = par(0) | ||
11 | + sigma = par(1) | ||
12 | + y = exp(- 0.5 * ( alog(x/x0) / sigma )^2 ) / x | ||
13 | + vy = x^4 * y | ||
14 | + xm = par(0) * exp( -par(1)^2 ) ; x of max in dn/da | ||
15 | + print,'(W) DUSTEM_LOGN_VDIST: dn/da max @',xm*1e7,' nm' | ||
16 | + dx = alog(x(1:np-1)) - alog(x(0:np-2)) | ||
17 | + yi = TOTAL( (vy(1:np-1) + vy(0:np-2))*0.5*dx ) | ||
18 | + y = par(2) * y / yi | ||
19 | +RETURN, y | ||
20 | +END |
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +FUNCTION DUSTEM_MATHIS_FIELD, x, unit=unit | ||
2 | +; computes the Mathis interstellar radiation field SED (ISRF) | ||
3 | +; in W/m2 (4*!pi*nu*I_nu) | ||
4 | +; from Mathis et al. 1983, A&A 128, 212 | ||
5 | +; X (I): X-grid for the ISRF | ||
6 | +; UNIT (I): unit of the ISRF. Choices are | ||
7 | +; 'W': wave in um [Default] | ||
8 | +; 'F': frequency in cm-1 | ||
9 | +; 'E': energy in eV | ||
10 | + | ||
11 | + if n_elements( UNIT ) EQ 0 then unit = 'W' $ | ||
12 | + else unit = strupcase( strcompress( unit,/rem) ) | ||
13 | + | ||
14 | + ly_limit = 9.11267101235d-2 | ||
15 | + | ||
16 | + x = double( x ) | ||
17 | + | ||
18 | +; | ||
19 | +; visible part | ||
20 | +; | ||
21 | + wdil = 4.d0 * [ 4.d-13, 1.d-13, 1.d-14] ; Mathis definition | ||
22 | + ; 4*!pi*Wdil*B_nu | ||
23 | + field = !pi * x * DUSTEM_BLACKBODY( x, [ 3.d3, 4.d3, 7.5d3 ], wdil=wdil, unit=unit ) | ||
24 | + | ||
25 | +; | ||
26 | +; UV part | ||
27 | +; | ||
28 | + | ||
29 | +; first convert to (lambda / 1e3 AA) | ||
30 | + CASE unit of | ||
31 | + | ||
32 | + 'W': x3 = 1.d1 * x | ||
33 | + | ||
34 | + 'F': x3 = 1.d5 / x | ||
35 | + | ||
36 | + 'E': x3 = 12.4 / x | ||
37 | + | ||
38 | + ENDCASE | ||
39 | + | ||
40 | + il = where( x3 LE 2.46, cl ) | ||
41 | + if cl GT 0 then field(il) = 0.D0 | ||
42 | + | ||
43 | + il = where( x3 GE 1d1*ly_limit AND x3 LT 1.11, cl ) | ||
44 | + if cl GT 0 then field(il) = 1.4817d-6 * x3(il)^(4.4172) | ||
45 | + il = where( x3 GE 1.11 AND x3 LT 1.34, cl ) | ||
46 | + if cl GT 0 then field(il) = 2.0456d-6 * x3(il) | ||
47 | + il = where( x3 GE 1.34 AND x3 LT 2.46, cl ) | ||
48 | + if cl GT 0 then field(il) = 3.3105d-6 * x3(il)^(-0.6678) | ||
49 | + | ||
50 | + | ||
51 | + RETURN, field | ||
52 | +END ;FUNCTION DUSTEM_MATHIS_FIELD |
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +FUNCTION DUSTEM_PLAW_VDIST, x, par | ||
2 | +; generates a volume normalized power law x^par(0) | ||
3 | +; returns distribution in nr of grains : dn/da | ||
4 | +; x : grain size | ||
5 | +; par(0) : power law index | ||
6 | +; par(1) : VOLUME normalization | ||
7 | +; par(2) : curvature parameter beta | ||
8 | +; par(3) : large size threshold At | ||
9 | + | ||
10 | + np = n_elements(x) | ||
11 | + y = x^par(0) | ||
12 | +; curvature term | ||
13 | + if ((par(2) NE 0) AND (par(3) NE 0)) then begin | ||
14 | + psgn = par(2)/ABS(par(2)) | ||
15 | + y = y * ( 1.d0 + ABS(par(2))*x/par(3) )^psgn | ||
16 | + endif | ||
17 | + vy = x^4 * y | ||
18 | + dx = ALOG(x(1:np-1)) - ALOG(x(0:np-2)) | ||
19 | + yi = TOTAL( (vy(1:np-1) + vy(0:np-2))*0.5*dx ) | ||
20 | + y = par(1) * y / yi | ||
21 | +RETURN, y | ||
22 | +END |