dustem_write_gas.pro
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
PRO dustem_write_gas,file,st,help=help
;+
; NAME:
; dustem_write_gas
;
; PURPOSE:
; writes information relating to gas properties in the
; corresponding .DAT file
;
; CATEGORY:
; DustEMWrap, Distributed, LowLevel, Initialization
;
; CALLING SEQUENCE:
; dustem_write_gas,file,st
;
; INPUTS:
; st : dustem data structure
; file : output file to be written
;
; OPTIONAL INPUT PARAMETERS:
; None
;
; OUTPUTS:
; None
;
; OPTIONAL OUTPUT PARAMETERS:
; None
;
; ACCEPTED KEY-WORDS:
; help : writes this help
;
; COMMON BLOCKS:
; None
;
; SIDE EFFECTS:
; Files are written
;
; RESTRICTIONS:
; The DustEM fortran code must be installed
; The DustEMWrap IDL code must be installed
;
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES:
;
; MODIFICATION HISTORY:
; Evolution details on the DustEMWrap gitlab.
; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
;-
IF keyword_set(help) THEN BEGIN
doc_library,'dustem_write_gas'
goto,the_end
ENDIF
;=== Note about format for DUSTEM_WHICH=RELEASE
;# DUSTEM : Gas quantities from Ysard, Juvela & Verstraete (2011)
;#
;# Gas temperature (K), hydrogen density, H2 density, CR rate, G0 (if>0 supersedes GRAIN.DAT)
;# number of charge type (electrons, H+, C+, ...)
;# ion density (cm-3), mass (amu), charge, polarizability (A^3)
;# >>>>> 1st line is electron <<<<<<<
;#
; 3.5550e+03 1e-1 -1e0 5e-17 1.0000e+00 3
;-1e0 5.4858e-04 -1e0 0.00
;0e0 1.00794e0 1e0 0.67
; -1.3000e-05 12.0107e0 1e0 1.54
Ncomments=n_elements(st.comments)
openw,unit,file,/get_lun
FOR i=0,Ncomments-1 DO BEGIN
printf,unit,st.comments[i]
ENDFOR
;st={file:file, $
; Tgas:0.D0,nH:0.D0,nh2:0.D0,CR_rate:0.D0,G0:0.D0,n_charges:0L, $
; charges_props:ptr_new(), $
; comments:strarr(Ncomments)}
;one_charge_st={density:0.D0,mass:0.D0,charge:0.D0,polarizability:0.D0}
frmt='(5E14.6,I4)'
printf,unit,st.Tgas,st.nH,st.nh2,st.CR_rate,st.G0,st.n_charges,format=frmt
frmt='(3E14.6,F5.2)'
FOR i=0L,st.n_charges-1 DO BEGIN
sst=(*st.charges_props)[i]
printf,unit,sst.density,sst.mass,sst.charge,sst.polarizability,format=frmt
IF !dustem_verbose EQ 1 THEN BEGIN
print,unit,sst.density,sst.mass,sst.charge,sst.polarizability,format=frmt
ENDIF
ENDFOR
close,unit
free_lun,unit
the_end:
END
; ;==== LEFT OVERS
;
; PRO dustem_write_gas,dir,st
;
;
; ;Writes ALL the GAS_xxx.DAT files
; ;stop
;
; comments=st.comments
; Ncomments=n_elements(comments)
;
; frmt='(A)'
;
; ;Get filename
; ffile=st.file
; fv=str_sep(ffile,'/')
; file=dir+fv(n_elements(fv)-1)
; ;Open file
; message,'Will write GAS file '+file,/continue
; openw,unit,file,/get_lun
; ;Print comments
; IF Ncomments NE 0 THEN BEGIN
; FOR ii=0,Ncomments-1 DO BEGIN
; printf,unit,comments[ii]
; ENDFOR
; ENDIF
; ;print data
; FOR k=0L,n_elements(st.fgas)-1 DO BEGIN
; printf,unit,(st.fgas)[k],format=frmt
; ENDFOR
; close,unit
; free_lun,unit
;
; END
;