Debian Codegraph @

src/options_particleplots.f90

raw
1 !-----------------------------------------------------------------
2 !
3 ! This file is (or was) part of SPLASH, a visualisation tool
4 ! for Smoothed Particle Hydrodynamics written by Daniel Price:
5 !
6 ! http://users.monash.edu.au/~dprice/splash
7 !
8 ! SPLASH comes with ABSOLUTELY NO WARRANTY.
9 ! This is free software; and you are welcome to redistribute
10 ! it under the terms of the GNU General Public License
11 ! (see LICENSE file for details) and the provision that
12 ! this notice remains intact. If you modify this file, please
13 ! note section 2a) of the GPLv2 states that:
14 !
15 ! a) You must cause the modified files to carry prominent notices
16 ! stating that you changed the files and the date of any change.
17 !
18 ! Copyright (C) 2005-2019 Daniel Price. All rights reserved.
19 ! Contact: [email protected]
20 !
21 !-----------------------------------------------------------------
22
23 !-------------------------------------------------------------------------
24 ! Module containing settings and options relating to particle plots
25 ! includes default values of these options and submenu for changing them
26 !-------------------------------------------------------------------------
27 module settings_part
28 use params
29 use settings_data, only:icoordsnew,iexact
30 implicit none
31 integer, dimension(maxparttypes) :: imarktype,idefaultcolourtype,itypeorder
32 integer, dimension(100) :: icircpart
33 integer, dimension(maxplot) :: ilocerrbars
34 logical, dimension(maxparttypes) :: iplotpartoftype,PlotOnRenderings,UseTypeInContours
35 integer :: ncircpart,ismooth_particle_plots
36 integer :: linestyle, linecolour,linestylethisstep,linecolourthisstep,ErrorBarType
37 logical :: iplotline,ilabelpart,ifastparticleplot,iploterrbars
38 real :: hfacmarkers,rref,betaflare,mstari
39
40 namelist /plotopts/ iplotline,linestyle,linecolour, &
41 imarktype,iplotpartoftype,PlotOnRenderings, &
42 iexact,icoordsnew,ifastparticleplot,idefaultcolourtype,&
43 itypeorder,UseTypeInContours,iploterrbars,ilocerrbars,hfacmarkers,&
44 ErrorBarType,ismooth_particle_plots,rref,betaflare,mstari
45
46 contains
47
48 !---------------------------------------------
49 ! set default values for these options
50 !---------------------------------------------
51 subroutine defaults_set_part
52 use settings_data, only:icoords
53 integer :: i
54
55 ncircpart = 0
56 iplotline = .false. ! plot line joining the particles
57 linestyle = 1 ! line style for above
58 linecolour = 1
59 linestylethisstep = 1
60 linecolourthisstep = 1
61 iexact = 0 ! exact solution to plot
62 ilabelpart = .false. ! plot particle numbers
63 icoordsnew = icoords
64 icircpart(:) = 0
65
66 iplotpartoftype(1) = .true. ! whether or not to plot particles of certain types
67 iplotpartoftype(2:maxparttypes) = .false.
68 PlotOnRenderings = .false.
69 imarktype = 1 ! marker type for all particles
70 imarktype(2) = 4 ! marker type for ghost/dark matter particles
71 imarktype(3) = 17 ! marker type for sink particles
72 imarktype(5) = 3 ! marker type for star particles (gadget)
73 idefaultcolourtype = -1 ! default colour for each particle type
74 ifastparticleplot = .true. ! allow crowded-field elimination on particle plots
75 do i=1,maxparttypes
76 itypeorder(i) = i
77 enddo
78 UseTypeInContours(:) = iplotpartoftype(:)
79 iploterrbars = .false. ! plot error bars for a particular column
80 ilocerrbars(:) = 0 ! location of data for error bars in dat array
81 hfacmarkers = 1.0
82 ErrorBarType = 0
83 ismooth_particle_plots = 0
84 rref = 1.
85 betaflare = 1.25
86 mstari = 1. ! used in Toomre Q calculation
87
88 return
89 end subroutine defaults_set_part
90
91 !---------------------------------------------
92 ! changed default values for these options
93 !---------------------------------------------
94 subroutine defaults_set_part_ev
95
96 iplotline = .true. ! plot line joining the particles
97 iplotpartoftype(1:maxparttypes) = .false. ! whether or not to plot particles of certain types
98 UseTypeInContours(:) = iplotpartoftype(:)
99
100 return
101 end subroutine defaults_set_part_ev
102
103 !---------------------------------------------
104 ! changed default values for these options
105 !---------------------------------------------
106 subroutine initialise_coord_transforms
107 use geometry, only:set_flaring_index
108
109 call set_flaring_index(rref,betaflare)
110
111 end subroutine initialise_coord_transforms
112
113 !----------------------------------------------------------------------
114 ! submenu with options relating to particle plots
115 !----------------------------------------------------------------------
116 subroutine submenu_particleplots(ichoose)
117 use exact, only:options_exact,submenu_exact
118 use labels, only:labeltype,ih,label,get_sink_type
119 use limits, only:lim
120 use settings_data, only:icoords,ntypes,ndim,UseTypeInRenderings, &
121 ndataplots,idustfrac_plot,ideltav_plot
122 use settings_render, only:iplotcont_nomulti
123 use particle_data, only:npartoftype,iamtype
124 use prompting, only:prompt,print_logical,print_logicals
125 use geometry, only:maxcoordsys,labelcoordsys,coord_transform_limits,&
126 igeom_flaredcyl,igeom_logflared,set_flaring_index,&
127 igeom_planetwake,set_planet_wake
128 use multiplot, only:itrans
129 use plotlib, only:plotlib_maxlinestyle,plotlib_maxlinecolour
130 use calcquantities, only:calc_quantities
131 use settings_data, only:DataIsBuffered,numplot
132 use filenames, only:nsteps,nstepsinfile,ifileopen
133 use geomutils, only:set_coordlabels
134 use calcquantities, only:setup_calculated_quantities
135 use asciiutils, only:enumerate
136 use exact, only:HonR,rplanet,q_index,phase
137 integer, intent(in) :: ichoose
138 integer :: i,iaction,n,itype,icoordsprev,ierr,icol,isinktype,nt
139 character(len=2) :: charntypes
140 character(len=20) :: substring2,substring3
141 character(len=1000) :: fmtstring
142 character(len=120) :: contline
143 logical :: ians
144 integer :: itypes(maxparttypes)
145
146 iaction = ichoose
147
148 !--we require some tricks with the format string to print only the actual number of
149 ! particle types rather than the whole array
150 !
151 isinktype = get_sink_type(ntypes)
152 nt = 0
153 do i=1,ntypes
154 if (any(npartoftype(i,:) > 0) .or. i==isinktype) then
155 nt = nt + 1
156 itypes(nt) = i
157 endif
158 enddo
159 if (nt <= 0) then
160 substring2 = "not applicable"
161 elseif (nt==1) then
162 substring2 = "i2"
163 else
164 write(charntypes,"(i2)") nt-1
165 substring2 = charntypes//"(i2,',',1x),i2"
166 endif
167 substring3 = enumerate(ismooth_particle_plots+1,(/'OFF ','FIXED','ADAPT'/),default=1)
168 if (iplotcont_nomulti) then
169 contline = "' use in contour plots: ( ',a,' )',/,"
170 else
171 contline = ' '
172 endif
173
174 fmtstring="("// &
175 "' 0) exit ',/,"// &
176 "' 1) turn on/off particles by type ( ',a,' )',/,"//trim(contline)// &
177 "' 2) change graph markers for each type ( ',"//trim(substring2)//",' )',/,"// &
178 "' 3) set colour for each particle type ( ',"//trim(substring2)//",' )',/,"// &
179 "' 4) smooth particle plots ( ',a,' )',/,"// &
180 "' 5) plot line joining particles ( ',a,' ) ',/,"// &
181 "' 6) plot error bars/smoothing circles ( ',a,' ) ',/,"// &
182 "' 7) change coordinate systems ( ',i2,' ) ',/,"// &
183 "' 8) plot exact solution ( ',i2,' ) ',/,"// &
184 "' 9) exact solution plot options ')"
185
186 print "(a)",'------------- particle plot options -------------------'
187 if (iaction <= 0 .or. iaction > 9) then
188 if (iplotcont_nomulti) then
189 print fmtstring,trim(print_logicals(iplotpartoftype(itypes(1:nt)))), &
190 trim(print_logicals(UseTypeInContours(itypes(1:nt)),mask=UseTypeInRenderings(itypes(1:nt)))), &
191 imarktype(itypes(1:nt)),idefaultcolourtype(itypes(1:nt)),trim(substring3), &
192 print_logical(iplotline),print_logical(ncircpart > 0 .or.iploterrbars),icoordsnew,iexact
193 else
194 print fmtstring,trim(print_logicals(iplotpartoftype(itypes(1:nt)))), &
195 imarktype(itypes(1:nt)),idefaultcolourtype(itypes(1:nt)),trim(substring3), &
196 print_logical(iplotline),print_logical(ncircpart > 0 .or.iploterrbars),icoordsnew,iexact
197 endif
198 call prompt('enter option',iaction,0,9)
199 endif
200 !
201 select case(iaction)
202 !------------------------------------------------------------------------
203 case(1)
204 ! plot particles by type?
205 over_types: do itype=1,ntypes
206 if (all(npartoftype(itype,:) == 0) .and. itype/=isinktype) cycle over_types
207 if (UseTypeinRenderings(itype) .and. ndim > 1) then
208 call prompt('Plot '//trim(labeltype(itype))//' particles / use in renderings?',iplotpartoftype(itype))
209 if (iplotcont_nomulti) then
210 call prompt('Use '//trim(labeltype(itype))//' particles in contour plots?',UseTypeInContours(itype))
211 endif
212 else
213 call prompt('Plot '//trim(labeltype(itype))//' particles?',iplotpartoftype(itype))
214 UseTypeInContours(itype) = .false.
215 endif
216 if (iplotpartoftype(itype) .and. itype > 1) then
217 if (.not.UseTypeInRenderings(itype)) then
218 call prompt('>> Plot '//trim(labeltype(itype))//' particles on top of rendered plots?',PlotOnRenderings(itype))
219 else
220 PlotonRenderings(itype) = .false.
221 endif
222 elseif (.not.iplotpartoftype(itype)) then
223 PlotonRenderings(itype) = .false.
224 endif
225 enddo over_types
226 return
227 !------------------------------------------------------------------------
228 case(2)
229 print "(/,' Marker options (for all from -8->31, see plot library userguide):',11(/,i2,') ',a))", &
230 0,'square',1,'.',2,'+',3,'*',4,'o',5,'x',17,'bold circle',-8,'large bold circle', &
231 32,'solid circle, size proportional to h', &
232 33,'open circle, size proportional to h', &
233 34,'outlined solid circle, size prop. to h'
234
235 !print*,'(0 Square) (1 .) (2 +) (3 *) (4 o) (5 x) (17 bold circle) (-8 bigger bold circle)'
236 over_types2: do itype=1,ntypes
237 if (all(npartoftype(itype,:) == 0) .and. itype/=isinktype) cycle over_types2
238
239 call prompt(' Enter marker to use for '//trim(labeltype(itype)) &
240 //' particles:',imarktype(itype),-8,35)
241 enddo over_types2
242 if (any(imarktype(1:ntypes) >= 32)) then
243 print*
244 call prompt(' Enter proportionality factor for scalable markers (radius = fac*h)',hfacmarkers)
245 endif
246
247 return
248 !------------------------------------------------------------------------
249 case(3)
250 print "(2(a,/),/,4(a,/))", &
251 ' Warning: setting a colour for a particle type overrides', &
252 ' (at each new timestep) colours set interactively ', &
253 ' -1 = retain interactively set colours between timesteps', &
254 ' 0 = background ',&
255 ' 1 = foreground ',&
256 ' 2->10 = various colours (see default colour indices for plot library)'
257 over_types3: do itype=1,ntypes
258 if (all(npartoftype(itype,:) == 0) .and. itype/=isinktype) cycle over_types3
259 call prompt(' Enter default colour for '//trim(labeltype(itype)) &
260 //' particles:',idefaultcolourtype(itype),-1,14)
261 enddo over_types3
262 return
263 !------------------------------------------------------------------------
264 case(4)
265 !print "(3(/,a))",' 0) no smoothing, raw particle plots',&
266 ! ' 1) render particle plots with fixed h', &
267 ! ' 2) render particle plots with adaptive h (slower)'
268 call prompt('smooth particle plots? (0=none 1=fixed 2=adaptive)',ismooth_particle_plots,0,2)
269 if (ismooth_particle_plots==0) then
270 if (size(iamtype(:,1)) > 1) then
271 print "(3(/,a),/)", &
272 ' WARNING: changing type plotting order currently has no effect ', &
273 ' when particle types are mixed in the dump file', &
274 ' (for sphNG read disable this using -lowmem on the command line)'
275 endif
276 if (ntypes > 1) then
277 ians = .false.
278 call prompt('set plot order of particle types manually?',ians)
279 if (ians) then
280 print "(9(i1,'=',a,', '))",(i,trim(labeltype(i)),i=1,ntypes)
281 call prompt('enter first particle type to plot',itypeorder(1),1,ntypes)
282 do i=2,ntypes
283 ierr = 1
284 do while (ierr /= 0)
285 itype = itypeorder(i)
286 call prompt('enter next particle type to plot',itype,1,ntypes)
287 if (any(itypeorder(1:i-1)==itype)) then
288 print "(a)",' error: cannot be same as previous type'
289 ierr = 1
290 else
291 itypeorder(i) = itype
292 ierr = 0
293 endif
294 enddo
295 enddo
296 endif
297 endif
298
299 print "(/,a,/,a,/)",' Fast particle plotting excludes particles in crowded regions', &
300 ' Turn this option off to always plot every particle'
301 call prompt('Allow fast particle plotting?',ifastparticleplot)
302 endif
303 return
304 !------------------------------------------------------------------------
305 case(5)
306 call prompt('plot line joining particles?',iplotline)
307 if (iplotline) then
308 call prompt('Enter line style to use ',linestyle,1,plotlib_maxlinestyle)
309 call prompt('Enter colour for line ',linecolour,0,plotlib_maxlinecolour)
310 endif
311 return
312 !------------------------------------------------------------------------
313 case(6)
314 if (ndim <= 1 .or. ih <= 0) then
315 icol = 0
316 do icol=1,ndataplots
317 if (ilocerrbars(icol) > 0) print "(a,i2,a,i2,a)", &
318 'column ',ilocerrbars(icol),' contains errors for column ',icol,':'//label(icol)
319 enddo
320 if (any(ilocerrbars(1:ndataplots) > 0)) then
321 call prompt('turn on plotting of error bars? ',iploterrbars)
322 if (.not.iploterrbars) return
323 else
324 iploterrbars = .false.
325 endif
326 icol = 1
327 do while(icol /= 0)
328 icol = 0
329 call prompt('Enter column to set location of error bars for (0=none)',icol,0,ndataplots)
330 if (icol > 0) then
331 call prompt('Enter location of error data for this column in the data',ilocerrbars(icol),0)
332 if (ilocerrbars(icol) <= 0 .or. ilocerrbars(icol) > ndataplots) then
333 print "(a,i2)",' WARNING: currently no data in column ',ilocerrbars(icol)
334 else
335 iploterrbars = .true.
336 endif
337 if (all(ilocerrbars(1:ndataplots) <= 0)) iploterrbars = .false.
338 else
339 if (all(ilocerrbars(1:ndataplots) <= 0)) iploterrbars = .false.
340 endif
341 enddo
342 print "(2(/,a))",' 0) Default style |--|',&
343 ' 1) Semi-transparent shaded region'
344 call prompt('Select error bar style',ErrorBarType,0,1)
345 else
346 print*,'Circles of interaction can also be set interactively'
347 call prompt('Enter number of circles to draw',ncircpart,0,size(icircpart))
348 if (ncircpart > 0) then
349 do n=1,ncircpart
350 if (icircpart(n)==0) then
351 if (n > 1) then
352 icircpart(n) = icircpart(n-1)+1
353 else
354 icircpart(n) = 1
355 endif
356 endif
357 call prompt('Enter particle number to plot circle around', &
358 icircpart(n),1,sum(npartoftype(:,1)))
359 enddo
360 endif
361 endif
362 return
363 !------------------------------------------------------------------------
364 case(7)
365 print "(' 0) reset (=',i2,')')",icoords
366 do i=1,maxcoordsys
367 print "(1x,i1,')',1x,a)",i,labelcoordsys(i)
368 enddo
369 icoordsprev = icoordsnew
370 call prompt(' Enter coordinate system to plot in:', &
371 icoordsnew,0,maxcoordsys)
372 if (icoordsnew==0) icoordsnew = icoords
373 select case(icoordsnew)
374 !case(igeom_rotated)
375 ! call prompt('enter rotation angle a (degrees)',rot_angle_a)
376 ! call prompt('enter rotation angle b (degrees)',rot_angle_b)
377 !call set_rotation_angles(rot_angle_a*pi/180.,rot_angle_b*pi/180.)
378 case(igeom_flaredcyl,igeom_logflared)
379 call prompt('enter reference radius (Rref) in z''=z(R/Rref)**(-beta)',rref)
380 print "(2(/,a),/)",' Use beta = 1.5 - q to give correct flaring index in a disc', &
381 ' where q is sound speed index i.e. cs = cs_0(R/R_0)^-q '
382 call prompt('enter flaring index beta',betaflare)
383 call set_flaring_index(rref,betaflare)
384 case(igeom_planetwake)
385 call prompt('enter radial location of planet (r0)',rplanet)
386 call prompt('enter disc aspect ratio H/R at rp',HonR)
387 call prompt('enter sound speed index q (cs = R^-q)',q_index)
388 call set_planet_wake(rplanet,phase,1.0,q_index,HonR)
389 end select
390
391 if (icoordsnew /= icoordsprev) then
392 itrans(1:ndim) = 0
393 call coord_transform_limits(lim(1:ndim,1),lim(1:ndim,2), &
394 icoordsprev,icoordsnew,ndim)
395 call set_coordlabels(numplot)
396 if (DataIsBuffered) then
397 call calc_quantities(1,nsteps)
398 else
399 call calc_quantities(1,nstepsinfile(ifileopen))
400 endif
401 endif
402 return
403 !------------------------------------------------------------------------
404 case(8)
405 call submenu_exact(iexact)
406 return
407 !------------------------------------------------------------------------
408 case(9)
409 call options_exact(iexact)
410 return
411 !------------------------------------------------------------------------
412 case default
413 return
414
415 end select
416
417 return
418 end subroutine submenu_particleplots
419
420 end module settings_part