Line data Source code
1 : ! ***********************************************************************
2 : !
3 : ! Copyright (C) 2010-2019 The MESA Team
4 : !
5 : ! This program is free software: you can redistribute it and/or modify
6 : ! it under the terms of the GNU Lesser General Public License
7 : ! as published by the Free Software Foundation,
8 : ! either version 3 of the License, or (at your option) any later version.
9 : !
10 : ! This program is distributed in the hope that it will be useful,
11 : ! but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 : ! See the GNU Lesser General Public License for more details.
14 : !
15 : ! You should have received a copy of the GNU Lesser General Public License
16 : ! along with this program. If not, see <https://www.gnu.org/licenses/>.
17 : !
18 : ! ***********************************************************************
19 :
20 : module pgstar_dynamo
21 :
22 : use star_private_def
23 : use const_def, only: dp
24 : use pgstar_support
25 : use star_pgstar
26 :
27 : implicit none
28 :
29 :
30 : contains
31 :
32 :
33 0 : subroutine Dynamo_plot(id, device_id, ierr)
34 : integer, intent(in) :: id, device_id
35 : integer, intent(out) :: ierr
36 :
37 : type (star_info), pointer :: s
38 :
39 : ierr = 0
40 0 : call get_star_ptr(id, s, ierr)
41 0 : if (ierr /= 0) return
42 :
43 0 : call pgslct(device_id)
44 0 : call pgbbuf()
45 0 : call pgeras()
46 :
47 : call do_Dynamo_plot(s, id, device_id, &
48 : s% pg% Dynamo_xleft, s% pg% Dynamo_xright, &
49 : s% pg% Dynamo_ybot, s% pg% Dynamo_ytop, .false., &
50 0 : s% pg% Dynamo_title, s% pg% Dynamo_txt_scale, ierr)
51 :
52 0 : call pgebuf()
53 :
54 : end subroutine Dynamo_plot
55 :
56 :
57 0 : subroutine do_Dynamo_plot(s, id, device_id, &
58 : winxmin, winxmax, winymin, winymax, subplot, &
59 : title, txt_scale, ierr)
60 : type (star_info), pointer :: s
61 : integer, intent(in) :: id, device_id
62 : real, intent(in) :: winxmin, winxmax, winymin, winymax
63 : logical, intent(in) :: subplot
64 : character (len=*), intent(in) :: title
65 : real, intent(in) :: txt_scale
66 : integer, intent(out) :: ierr
67 : call do_Dynamo_panel(s, id, device_id, &
68 : winxmin, winxmax, winymin, winymax, subplot, &
69 : title, txt_scale, s% pg% Dynamo_xaxis_name, &
70 : s% pg% Dynamo_xmin, s% pg% Dynamo_xmax, &
71 0 : s% pg% Dynamo_xaxis_reversed, .false., .true., ierr)
72 0 : end subroutine do_Dynamo_plot
73 :
74 :
75 0 : subroutine do_Dynamo_panel(s, id, device_id, &
76 : winxmin, winxmax, winymin, winymax, subplot, title, txt_scale, &
77 : xaxis_name, xmin, xmax, reverse_xaxis, &
78 : panel_flag, xaxis_numeric_labels_flag, ierr)
79 : type (star_info), pointer :: s
80 : integer, intent(in) :: id, device_id
81 : real, intent(in) :: &
82 : winxmin, winxmax, winymin, winymax, xmin, xmax
83 : character (len=*), intent(in) :: title, xaxis_name
84 : real, intent(in) :: txt_scale
85 : logical, intent(in) :: subplot, &
86 : reverse_xaxis, panel_flag, xaxis_numeric_labels_flag
87 : integer, intent(out) :: ierr
88 : call Dyn_plot(s, device_id, &
89 : s% pg% show_Dynamo_annotation1, s% pg% show_Dynamo_annotation2, &
90 : s% pg% show_Dynamo_annotation3, &
91 : xaxis_name, xmin, xmax, reverse_xaxis, &
92 : s% pg% Dynamo_ymin_left, s% pg% Dynamo_ymax_left, s% pg% Dynamo_dymin_left, &
93 : s% pg% Dynamo_ymin_right, s% pg% Dynamo_ymax_right, s% pg% Dynamo_dymin_right, &
94 : winxmin, winxmax, winymin, winymax, subplot, title, txt_scale, &
95 0 : panel_flag, xaxis_numeric_labels_flag, ierr)
96 0 : end subroutine do_Dynamo_panel
97 :
98 :
99 0 : subroutine Dyn_plot(s, device_id, &
100 : show_Dyn_annotation1, show_Dyn_annotation2, show_Dyn_annotation3, &
101 : Dyn_xaxis_name, Dyn_xmin, Dyn_xmax, Dyn_reverse_xaxis, &
102 : Dyn_ymin_left, Dyn_ymax_left, Dyn_dymin_left, &
103 : Dyn_ymin_right, Dyn_ymax_right, Dyn_dymin_right, &
104 : winxmin, winxmax, winymin, winymax, subplot, title, txt_scale, &
105 : panel_flag, xaxis_numeric_labels_flag, ierr)
106 :
107 : use utils_lib
108 :
109 : type (star_info), pointer :: s
110 : integer, intent(in) :: device_id
111 : logical, intent(in) :: subplot, &
112 : show_Dyn_annotation1, show_Dyn_annotation2, show_Dyn_annotation3
113 : character (len=*), intent(in) :: Dyn_xaxis_name, title
114 : real, intent(in) :: &
115 : Dyn_xmin, Dyn_xmax, &
116 : Dyn_ymin_left, Dyn_ymax_left, Dyn_dymin_left, &
117 : Dyn_ymin_right, Dyn_ymax_right, Dyn_dymin_right
118 : real, intent(in) :: winxmin, winxmax, winymin, winymax, txt_scale
119 : logical, intent(in) :: &
120 : Dyn_reverse_xaxis, panel_flag, xaxis_numeric_labels_flag
121 : integer, intent(out) :: ierr
122 :
123 : real :: xmargin
124 0 : real :: xmin, xmax, xleft, xright, dx, ymin, ymax, ymin2, ymax2, dy
125 : integer :: grid_min, grid_max, npts, nz
126 0 : real, allocatable, dimension(:) :: xvec, yvec, yvec2, yvec3
127 :
128 : include 'formats'
129 0 : ierr = 0
130 :
131 0 : if (.not. s% rotation_flag) return
132 :
133 0 : xmargin = 0
134 :
135 0 : nz = s% nz
136 0 : allocate (xvec(nz), yvec(nz), yvec2(nz), yvec3(nz))
137 :
138 : call set_xaxis_bounds( &
139 : s, Dyn_xaxis_name, Dyn_xmin, Dyn_xmax, Dyn_reverse_xaxis, xmargin, &
140 : xvec, xmin, xmax, xleft, xright, dx, &
141 0 : grid_min, grid_max, npts, ierr)
142 0 : if (ierr /= 0) return
143 :
144 0 : call pgsave
145 0 : call pgsch(txt_scale)
146 :
147 0 : call plot(ierr)
148 0 : if (ierr == 0) call show_annotations(s, &
149 0 : show_Dyn_annotation1, show_Dyn_annotation2, show_Dyn_annotation3)
150 :
151 0 : call pgunsa
152 :
153 0 : deallocate(xvec, yvec, yvec2, yvec3)
154 :
155 : contains
156 :
157 :
158 0 : subroutine plot(ierr)
159 : use pgstar_support, only: show_convective_section, show_semiconvective_section, &
160 : show_thermohaline_section, show_overshoot_section
161 : use pgstar_colors
162 : integer, intent(out) :: ierr
163 :
164 : integer :: lw, lw_sav, k
165 0 : real :: ybot, &
166 0 : default_ymax_left, default_ymin_left, &
167 0 : default_ymax_right, default_ymin_right
168 :
169 : include 'formats'
170 0 : ierr = 0
171 :
172 0 : lw = s% pg% pgstar_lw
173 0 : call pgqlw(lw_sav)
174 :
175 0 : if (.not. panel_flag) then
176 0 : call pgsvp(winxmin, winxmax, winymin, winymax)
177 0 : call show_title_pgstar(s, title)
178 0 : if (.not. subplot) then
179 0 : call show_model_number_pgstar(s)
180 0 : call show_age_pgstar(s)
181 : end if
182 0 : call pgsci(clr_Foreground)
183 0 : call show_xaxis_name(s,Dyn_xaxis_name,ierr)
184 0 : if (ierr /= 0) return
185 : end if
186 :
187 0 : default_ymax_left = 10
188 0 : default_ymin_left = -2
189 :
190 0 : do k=1,nz
191 0 : yvec(k) = safe_log10(s% dynamo_B_phi(k))
192 0 : yvec2(k) = safe_log10(s% dynamo_B_r(k))
193 : end do
194 :
195 0 : if (Dyn_ymax_left /= -101) then
196 0 : ymax = Dyn_ymax_left
197 : else
198 0 : ymax = max(default_ymax_left,maxval(yvec(grid_min:grid_max)))
199 0 : ymax2 = max(default_ymax_left,maxval(yvec2(grid_min:grid_max)))
200 0 : if (ymax2 > ymax) ymax = ymax2
201 : end if
202 :
203 0 : if (Dyn_ymin_left /= -101) then
204 0 : ymin = Dyn_ymin_left
205 : else
206 0 : ymin = max(default_ymin_left,minval(yvec(grid_min:grid_max)))
207 0 : ymin2 = max(default_ymin_left,minval(yvec2(grid_min:grid_max)))
208 0 : if (ymin2 < ymin) ymin = ymin2
209 : end if
210 :
211 0 : dy = ymax-ymin
212 0 : if (Dyn_dymin_left /= -101) dy = Dyn_dymin_left
213 :
214 0 : ymax = ymax + 0.1*dy
215 0 : ymin = ymin - 0.1*dy
216 :
217 0 : call pgswin(xleft, xright, ymin, ymax)
218 0 : call pgscf(1)
219 0 : call pgsci(clr_Foreground)
220 0 : call show_box_pgstar(s,'','BNSTV')
221 :
222 0 : call pgsci(clr_Teal)
223 0 : call pgsch(txt_scale*s% pg% Dynamo_legend_txt_scale_factor)
224 0 : call show_left_yaxis_label_pgstar(s,'log B\dphi\u (Gauss)',-0.5)
225 0 : call pgslw(lw)
226 0 : call pgline(npts, xvec(grid_min:grid_max), yvec(grid_min:grid_max))
227 0 : call pgslw(lw_sav)
228 :
229 0 : call pgsci(clr_Coral)
230 0 : call pgsch(txt_scale*s% pg% Dynamo_legend_txt_scale_factor)
231 0 : call show_left_yaxis_label_pgstar(s,'log B\dr\u (Gauss)',1.3)
232 0 : call pgslw(lw)
233 0 : call pgline(npts, xvec(grid_min:grid_max), yvec2(grid_min:grid_max))
234 0 : call pgslw(lw_sav)
235 :
236 :
237 : ! right axis
238 :
239 0 : lw = 8
240 :
241 0 : default_ymax_right = 0
242 0 : default_ymin_right = -10
243 :
244 : ! log omega
245 0 : do k=1,nz
246 0 : yvec(k) = safe_log10(s% omega(k))
247 0 : yvec2(k) = safe_log10(s% j_rot(k)) - 20d0
248 : end do
249 :
250 0 : if (Dyn_ymax_right /= -101) then
251 0 : ymax = Dyn_ymax_right
252 : else
253 0 : ymax = max(default_ymax_right,maxval(yvec(grid_min:grid_max)))
254 0 : ymax2 = max(default_ymax_right,maxval(yvec2(grid_min:grid_max)))
255 0 : if (ymax2 > ymax) ymax = ymax2
256 : end if
257 0 : if (Dyn_ymin_right /= -101) then
258 0 : ymin = Dyn_ymin_right
259 : else
260 0 : ymin = max(default_ymin_right,minval(yvec(grid_min:grid_max)))
261 0 : ymin2 = max(default_ymin_right,minval(yvec2(grid_min:grid_max)))
262 0 : if (ymin2 < ymin) ymin = ymin2
263 : end if
264 :
265 0 : dy = ymax-ymin
266 0 : if (Dyn_dymin_right /= -101) dy = Dyn_dymin_right
267 :
268 0 : ymax = ymax + 0.1*dy
269 0 : ymin = ymin - 0.1*dy
270 :
271 0 : call pgswin(xleft, xright, ymin, ymax)
272 :
273 0 : call pgscf(1)
274 0 : call pgsci(clr_Foreground)
275 0 : if (xaxis_numeric_labels_flag) then
276 0 : call show_box_pgstar(s,'BCNST','CMSTV')
277 : else
278 0 : call show_box_pgstar(s,'BCST','CMSTV')
279 : end if
280 :
281 0 : call pgsci(clr_FireBrick)
282 0 : call pgsch(txt_scale*s% pg% Dynamo_legend_txt_scale_factor)
283 : call show_right_yaxis_label_pgstar( &
284 0 : s,'log j (10\u20\d cm\u2\d/s)',1.3)
285 0 : call pgslw(lw)
286 0 : call pgline(npts, xvec(grid_min:grid_max), yvec2(grid_min:grid_max))
287 0 : call pgslw(lw_sav)
288 :
289 0 : call pgsci(clr_RoyalBlue)
290 0 : call pgsch(txt_scale*s% pg% Dynamo_legend_txt_scale_factor)
291 0 : call show_right_yaxis_label_pgstar(s,'log \(0650) (rad/s)',-0.5)
292 0 : call pgslw(lw)
293 0 : call pgline(npts, xvec(grid_min:grid_max), yvec(grid_min:grid_max))
294 0 : call pgslw(lw_sav)
295 :
296 :
297 0 : if (.not. panel_flag) then ! show mix regions at bottom of plot
298 0 : ybot = -0.05
299 0 : call pgswin(xleft, xright, ybot, 0.85)
300 0 : call pgslw(10)
301 : call show_mix_regions_on_xaxis( &
302 0 : s,ybot,0.85,grid_min,grid_max,xvec)
303 : end if
304 :
305 : call show_pgstar_decorator(s%id,s% pg% dynamo_use_decorator, &
306 0 : s% pg% dynamo_pgstar_decorator, 0, ierr)
307 :
308 :
309 0 : end subroutine plot
310 :
311 :
312 : end subroutine Dyn_plot
313 :
314 :
315 : end module pgstar_dynamo
316 :
|