25 #include "sll_assert.h"
26 #include "sll_working_precision.h"
80 x, v, xmin, xmax, vmin, vmax, iplot, time)
82 character(len=*),
intent(in) :: plot_name
83 sll_real64,
dimension(:),
intent(in) :: x
84 sll_real64,
dimension(:),
intent(in) :: v
85 sll_real64,
intent(in) :: xmin
86 sll_real64,
intent(in) :: xmax
87 sll_real64,
intent(in) :: vmin
88 sll_real64,
intent(in) :: vmax
89 sll_int32,
intent(in) :: iplot
90 sll_real64,
optional :: time
92 character(len=4) :: fin
99 open (newunit=file_id, file=plot_name//
'.gnu', position=
"append")
102 write (file_id,
"('set xr[',g15.3,':',g15.3,']')") xmin, xmax
103 write (file_id,
"('set yr[',g15.3,':',g15.3,']')") vmin, vmax
105 if (
present(time))
then
106 write (file_id,
"(A18,G10.3,A1)")
"set title 'Time = ", time,
"'"
108 write (file_id,
"(a)")
"plot '"//plot_name//
"_"//fin//
".dat' w d "
112 sll_assert(nbpart ==
size(v))
113 open (newunit=file_id, file=plot_name//
"_"//fin//
'.dat')
115 write (file_id, *) sngl(x(k)), sngl(v(k))
122 subroutine compute_df(df, x, v, xmin, xmax, nx, vmin, vmax, nv)
123 sll_real64,
dimension(:),
intent(in) :: x, v
124 sll_real64 :: delta_x, delta_v, xmin, xmax, vmin, vmax
125 sll_int32,
intent(in) :: nx
126 sll_int32,
intent(in) :: nv
127 sll_real64,
dimension(nx, nv) :: df
131 delta_x = (xmax - xmin)/(nx - 1)
132 delta_v = (vmax - vmin)/(nv - 1)
138 i = floor((x(k) - xmin)/delta_x) + 1
139 j = floor((v(k) - vmin)/delta_v) + 1
140 df(i, j) = df(i, j) + weight
146 vmin, vmax, nv, iplot, time)
148 character(len=*),
intent(in) :: plot_name
149 sll_int32,
intent(in) :: nx
150 sll_int32,
intent(in) :: nv
151 sll_real64,
dimension(:),
intent(in) :: x, v
153 sll_real64,
dimension(nx, nv) :: df
155 sll_real64 :: delta_x, delta_v, xmin, xmax, vmin, vmax
156 character(len=4) :: fin
160 delta_x = (xmax - xmin)/nx
161 delta_v = (vmax - vmin)/nv
164 sll_assert(
size(x) ==
size(v))
166 write (*,
"(A7,G10.3)")
"Time = ", time
167 call compute_df(df, x, v, xmin, xmax, nx, vmin, vmax, nv)
176 call sll_o_gnuplot_2d(xmin, xmax, nx, vmin, vmax, nv, df, plot_name, iplot, error)
184 sll_real64,
dimension(:),
intent(in) :: x, v
185 sll_real64,
intent(in) :: time
186 sll_real64 :: xmin, xmax, ymin, ymax
190 print *,
'set term x11 2'
191 print *,
"set title 'time=", time,
"'"
192 print *,
"unset logscale"
194 sll_assert(nbpart ==
size(v))
196 100
format(
'plot [', f7.3,
':', f7.3,
'][', f7.3,
':', f7.3,
'] ''-'' w d')
198 write (*, 100) xmin, xmax, ymin, ymax
211 character(len=*),
intent(in) :: plot_name
212 sll_real64,
dimension(:),
intent(in) :: x, v
213 sll_int32,
intent(in) :: iplot
214 character(len=4) :: fin
215 sll_int32 :: file_id, error
223 sll_assert(
size(v) == nbpart)
224 write (file_id,
"(a)")
'x v zero zero'
226 write (file_id,
"(4e15.3)") x(k), v(k), 0., 0.
236 character(len=*),
intent(in) :: plot_name
237 sll_real64,
dimension(:),
intent(in) :: x, y, z
238 sll_int32,
intent(in) :: iplot
239 character(len=4) :: fin
240 sll_int32 :: file_id, error
248 sll_assert(
size(y) == nbpart)
249 sll_assert(
size(z) == nbpart)
250 write (file_id,
"(a)")
'x y z zero'
252 write (file_id,
"(4e15.3)") x(k), y(k), z(k), 0.
263 character(len=*),
intent(in) :: plot_name
264 sll_real64,
dimension(:),
intent(in) :: p, q, r, s
265 sll_int32,
intent(in) :: iplot
266 character(len=4) :: fin
267 sll_int32 :: file_id, error
275 sll_assert(
size(q) == nbpart)
276 sll_assert(
size(r) == nbpart)
277 sll_assert(
size(s) == nbpart)
278 write (file_id,
"(a)")
'x y z val'
280 write (file_id,
"(4e15.3)") p(k), q(k), r(k), s(k)
293 character(len=*),
intent(in) :: plot_name
294 sll_real64,
dimension(:),
intent(in) :: x
295 sll_real64,
dimension(:),
intent(in) :: v
296 sll_int32,
intent(in) :: iplot
297 character(len=4) :: fin
298 sll_int32 :: file_id, error
299 sll_real64 :: xmin, xmax, vmin, vmax
305 sll_assert(
size(v) == nbpart)
310 write (file_id,
"(2i7)") 2, nbpart, 1
311 write (file_id,
"(a)")
'x'
312 write (file_id,
"(a)")
'v'
313 write (file_id,
"(2f8.3,1x,i7)") xmin, xmax, 1
314 write (file_id,
"(2f8.3,1x,i7)") vmin, vmax, 1
316 write (file_id,
"(2e15.3)") x(k), v(k)
328 vmin, vmax, nv, iplot)
329 character(len=*),
intent(in) :: plot_name
330 sll_real64,
dimension(:),
intent(in) :: x
331 sll_real64,
dimension(:),
intent(in) :: v
332 sll_real64,
dimension(:),
intent(in) :: w
333 sll_int32,
intent(in) :: nx
334 sll_int32,
intent(in) :: nv
336 sll_real64,
dimension(nx, nv) :: df
337 sll_real64 :: delta_x, delta_v, xmin, xmax, vmin, vmax
338 character(len=4) :: fin
343 delta_x = (xmax - xmin)/(nx - 1)
344 delta_v = (vmax - vmin)/(nv - 1)
352 sll_real64,
dimension(:),
intent(in) :: xp, yp, wp
353 sll_real64,
intent(in) :: xmin, xmax, ymin, ymax
354 sll_int32 :: ip, jp, kp
357 sll_real64,
dimension(nx, ny),
intent(out) :: df
361 sll_assert(nbpart ==
size(yp))
362 sll_assert(nbpart ==
size(wp))
367 xt = (xp(kp) - xmin)/(xmax - xmin)*nx
368 yt = (yp(kp) - ymin)/(ymax - ymin)*ny
373 sll_assert(ip >= 1 .and. ip <= nx .and. jp >= 1 .and. jp <= ny)
375 df(ip, jp) = df(ip, jp) + wp(kp)
384 sll_real64,
dimension(:),
intent(in) :: xp, yp, wp
385 sll_real64,
intent(in) :: xmin, xmax, ymin, ymax
386 sll_int32 :: ip, jp, kp
387 sll_real64 :: a1, a2, a3, a4, xt, yt
389 sll_real64,
dimension(nx, ny),
intent(out) :: df
393 sll_assert(nbpart ==
size(yp))
394 sll_assert(nbpart ==
size(wp))
399 xt = (xp(kp) - xmin)/(xmax - xmin)*nx
400 yt = (yp(kp) - ymin)/(ymax - ymin)*ny
405 a1 = (ip + 1 - xt)*(jp + 1 - yt)
406 a2 = (xt - ip)*(jp + 1 - yt)
407 a3 = (ip + 1 - xt)*(yt - jp)
408 a4 = (xt - ip)*(yt - jp)
412 if (ip == nx + 1) ip = nx
413 if (jp == ny + 1) jp = ny
415 sll_assert(ip > 0 .and. ip <= nx .and. jp > 0 .and. jp <= ny)
422 if (jp > 0 .and. jp <= ny)
then
423 if (ip > 0 .and. ip <= nx) df(ip, jp) = df(ip, jp) + a1*wp(kp)
424 if (ip + 1 > 0 .and. ip + 1 <= nx) df(ip + 1, jp) = df(ip + 1, jp) + a2*wp(kp)
426 if (jp + 1 > 0 .and. jp + 1 <= ny)
then
427 if (ip > 0 .and. ip <= nx) df(ip, jp + 1) = df(ip, jp + 1) + a3*wp(kp)
428 if (ip + 1 > 0 .and. ip + 1 <= nx) df(ip + 1, jp + 1) = df(ip + 1, jp + 1) + a4*wp(kp)
435 sll_real64,
intent(in) :: xp(:)
436 sll_real64,
intent(in) :: yp(:)
437 sll_real64,
intent(in) :: wp(:)
438 sll_real64,
intent(in) :: xmin
439 sll_real64,
intent(in) :: xmax
440 sll_int32,
intent(in) :: nx
441 sll_real64,
intent(in) :: ymin
442 sll_real64,
intent(in) :: ymax
443 sll_int32,
intent(in) :: ny
444 sll_real64,
intent(out) :: df(nx, ny)
446 sll_int32 :: ip, jp, kp
447 sll_real64 :: xt, x, cx, cm1x, cm2x, cp1x, cp2x
448 sll_real64 :: yt, y, cy, cm1y, cm2y, cp1y, cp2y
455 xt = (xp(kp) - xmin)/(xmax - xmin)*nx
456 yt = (yp(kp) - ymin)/(ymax - ymin)*ny
475 if (ip > 2 .and. jp > 2 .and. ip < nx - 1 .and. jp < ny - 1)
then
477 df(ip - 2, jp - 2) = df(ip - 2, jp - 2) + cm2x*cm2y*wp(kp)
478 df(ip - 2, jp - 1) = df(ip - 2, jp - 1) + cm2x*cm1y*wp(kp)
479 df(ip - 2, jp) = df(ip - 2, jp) + cm2x*cy*wp(kp)
480 df(ip - 2, jp + 1) = df(ip - 2, jp + 1) + cm2x*cp1y*wp(kp)
481 df(ip - 2, jp + 2) = df(ip - 2, jp + 2) + cm2x*cp2y*wp(kp)
483 df(ip - 1, jp - 2) = df(ip - 1, jp - 2) + cm1x*cm2y*wp(kp)
484 df(ip - 1, jp - 1) = df(ip - 1, jp - 1) + cm1x*cm1y*wp(kp)
485 df(ip - 1, jp) = df(ip - 1, jp) + cm1x*cy*wp(kp)
486 df(ip - 1, jp + 1) = df(ip - 1, jp + 1) + cm1x*cp1y*wp(kp)
487 df(ip - 1, jp + 2) = df(ip - 1, jp + 2) + cm1x*cp2y*wp(kp)
489 df(ip, jp - 2) = df(ip, jp - 2) + cx*cm2y*wp(kp)
490 df(ip, jp - 1) = df(ip, jp - 1) + cx*cm1y*wp(kp)
491 df(ip, jp) = df(ip, jp) + cx*cy*wp(kp)
492 df(ip, jp + 1) = df(ip, jp + 1) + cx*cp1y*wp(kp)
493 df(ip, jp + 2) = df(ip, jp + 2) + cx*cp2y*wp(kp)
495 df(ip + 1, jp - 2) = df(ip + 1, jp - 2) + cp1x*cm2y*wp(kp)
496 df(ip + 1, jp - 1) = df(ip + 1, jp - 1) + cp1x*cm1y*wp(kp)
497 df(ip + 1, jp) = df(ip + 1, jp) + cp1x*cy*wp(kp)
498 df(ip + 1, jp + 1) = df(ip + 1, jp + 1) + cp1x*cp1y*wp(kp)
499 df(ip + 1, jp + 2) = df(ip + 1, jp + 2) + cp1x*cp2y*wp(kp)
501 df(ip + 2, jp - 2) = df(ip + 2, jp - 2) + cp2x*cm2y*wp(kp)
502 df(ip + 2, jp - 1) = df(ip + 2, jp - 1) + cp2x*cm1y*wp(kp)
503 df(ip + 2, jp) = df(ip + 2, jp) + cp2x*cy*wp(kp)
504 df(ip + 2, jp + 1) = df(ip + 2, jp + 1) + cp2x*cp1y*wp(kp)
505 df(ip + 2, jp + 2) = df(ip + 2, jp + 2) + cp2x*cp2y*wp(kp)
515 sll_real64,
intent(in) :: x
518 else if (x .ge. 1. .and. x .le. 2.)
then
519 f_m4 = 0.5*(2.-x)**2*(1.-x)
520 else if (x .le. 1.)
then
521 f_m4 = 1.-2.5*x**2 + 1.5*(abs(x))**3
530 vmin, vmax, nv, iplot)
531 character(len=*),
intent(in) :: plot_name
532 sll_real64,
intent(in) :: x(:)
533 sll_real64,
intent(in) :: v(:)
534 sll_real64,
intent(in) :: w(:)
535 sll_real64,
intent(in) :: xmin
536 sll_real64,
intent(in) :: xmax
537 sll_int32,
intent(in) :: nx
538 sll_real64,
intent(in) :: vmin
539 sll_real64,
intent(in) :: vmax
540 sll_int32,
intent(in) :: nv
541 sll_int32,
intent(in) :: iplot
544 sll_real64 :: df(nx, nv)
545 character(len=4) :: fin
549 call compute_df_m4(x, v, w, xmin, xmax, nx, vmin, vmax, nv, df)
551 call sll_o_gnuplot_2d(xmin, xmax, nx, vmin, vmax, nv, df, plot_name, iplot, error)
555 #define FONCTION1( X ) (0.75_f64-(X)*(X))
557 #define FONCTION2( X ) (0.5_f64 * ( 1.5_f64 - (X) )**2)
559 #define BSPLINES(X,Y) \
560 c_1x = fonction2(1 + x); \
561 c1x = fonction1(x); \
562 c2x = fonction2(1 - x); \
563 c_1y = fonction2(1 + y); \
564 c1y = fonction1(y); \
565 c2y = fonction2(1 - y)
568 sll_real64,
dimension(:),
intent(in) :: xp, yp, wp
569 sll_real64,
intent(in) :: xmin, xmax, ymin, ymax
570 sll_int32 :: ip, jp, kp
573 sll_real64,
dimension(nx, ny),
intent(out) :: df
574 sll_real64 :: x, c1x, c_1x, c2x
575 sll_real64 :: y, c1y, c_1y, c2y
581 xt = (xp(kp) - xmin)/(xmax - xmin)*nx
582 yt = (yp(kp) - ymin)/(ymax - ymin)*ny
592 if (ip > 1 .and. ip < nx .and. jp > 1 .and. jp < ny)
then
594 df(ip, jp) = df(ip, jp) + c1x*c1y*wp(kp)
595 df(ip, jp - 1) = df(ip, jp - 1) + c1x*c_1y*wp(kp)
596 df(ip, jp + 1) = df(ip, jp + 1) + c1x*c2y*wp(kp)
597 df(ip - 1, jp) = df(ip - 1, jp) + c_1x*c1y*wp(kp)
598 df(ip - 1, jp - 1) = df(ip - 1, jp - 1) + c_1x*c_1y*wp(kp)
599 df(ip - 1, jp + 1) = df(ip - 1, jp + 1) + c_1x*c2y*wp(kp)
600 df(ip + 1, jp) = df(ip + 1, jp) + c2x*c1y*wp(kp)
601 df(ip + 1, jp - 1) = df(ip + 1, jp - 1) + c2x*c_1y*wp(kp)
602 df(ip + 1, jp + 1) = df(ip + 1, jp + 1) + c2x*c2y*wp(kp)
613 vmin, vmax, nv, iplot)
614 character(len=*),
intent(in) :: plot_name
615 sll_real64,
dimension(:),
intent(in) :: x
616 sll_real64,
dimension(:),
intent(in) :: v
617 sll_real64,
dimension(:),
intent(in) :: w
618 sll_int32,
intent(in) :: nx
619 sll_int32,
intent(in) :: nv
620 sll_int32 :: iplot, error
621 sll_real64,
dimension(nx, nv) :: df
622 sll_real64 :: xmin, xmax, vmin, vmax
623 character(len=4) :: fin
629 call sll_o_gnuplot_2d(xmin, xmax, nx, vmin, vmax, nv, df, plot_name, iplot, error)
639 electrostatic_energy, impulse, timestepwidth)
640 sll_real64,
dimension(:),
intent(in) :: kinetic_energy, electrostatic_energy, impulse
641 sll_int32 :: timesteps, k
642 sll_real64,
dimension(size(kinetic_energy)) :: total_energy
643 sll_real64,
intent(in) :: timestepwidth
645 timesteps =
size(kinetic_energy)
646 sll_assert(timesteps ==
size(electrostatic_energy))
647 sll_assert(timesteps ==
size(total_energy))
649 total_energy = electrostatic_energy + kinetic_energy
651 if (timesteps > 2)
then
654 print *,
"set term x11 3"
655 print *,
"set logscale y"
656 print *,
"set title 'Relative Energies'"
657 print *,
"plot '-' title 'kinetic' with lines,\ "
658 if (maxval(electrostatic_energy) /= 0.0_f64) print *,
"'-' title 'electrostatic' with lines,\ "
659 print *,
"'-' title 'total' with lines;"
661 print *, (k - 1)*timestepwidth, kinetic_energy(k)/maxval(kinetic_energy)
664 if (maxval(electrostatic_energy) /= 0.0_f64)
then
666 print *, (k - 1)*timestepwidth, electrostatic_energy(k)/maxval(electrostatic_energy)
671 print *, (k - 1)*timestepwidth, total_energy(k)/maxval(total_energy)
677 print *,
"set term x11 4"
678 print *,
"set autoscale y"
679 print *,
"set title 'Total Energy Error'"
680 print *,
"set logscale y"
682 print *,
"plot '-' using 1:2 title 'Relative Error' with lines"
684 print *, (k - 1)*timestepwidth, abs(((total_energy(k) - total_energy(1))/total_energy(1)))
690 print *,
"set term x11 6"
691 print *,
"set autoscale y"
692 print *,
"set title 'Relative Impulse Error'"
693 print *,
"set logscale y"
694 print *,
"plot '-' using 1:2 title 'Relative Impulse Error' with lines"
696 if (impulse(1) /= 0)
then
697 print *, (k - 1)*timestepwidth, abs(impulse(k) - impulse(1))/abs(impulse(1))
698 else if (maxval(abs(impulse)) /= 0.0_f64)
then
699 print *, (k - 1)*timestepwidth, abs(impulse(k) - impulse(1))/maxval(abs(impulse))
701 print *, (k - 1)*timestepwidth, abs(impulse(k) - impulse(1))
724 sll_real64,
dimension(:),
intent(in) :: values, eval_knots
725 sll_int32 :: nknots, k
727 nknots =
size(eval_knots)
728 sll_assert(nknots ==
size(eval_knots))
731 print *,
"set term x11 7"
732 print *,
"set autoscale y"
733 print *,
"set title 'Electric Potential'"
734 print *,
"unset logscale y"
735 print *,
"plot '-' using 1:2 title 'Potential' with lines"
737 print *, eval_knots(k), values(k)
Write file for gnuplot to display 2d field.
plot particles distribution with gnuplot
plot particles centers with gnuplot
Module that contains routines to write data in ASCII format file.
subroutine, public sll_s_ascii_file_create(file_name, file_id, error)
Create ASCII file.
Implements the functions to write data file plotable by GNUplot.
This module provides some routines for plotting during PIC simulations.
subroutine xv_particles_center_gnuplot(plot_name, x, v, xmin, xmax, vmin, vmax, iplot, time)
To plot particles run : gnuplot -persitant plot_name.gnu.
subroutine pqrs_plot_format_points3d(plot_name, p, q, r, s, iplot)
point3D format http://www.visitusers.org/index.php?title=Reading_point_data This format is designed t...
subroutine, public sll_s_distribution_m4_gnuplot(plot_name, x, v, w, xmin, xmax, nx, vmin, vmax, nv, iplot)
GNUplot readable output for particles density.
subroutine, public sll_s_energies_electrostatic_gnuplot_inline(kinetic_energy, electrostatic_energy, impulse, timestepwidth)
Call this function inline with | gnuplot Plots different energies for Electrostatic Particle-in-Cell ...
subroutine, public sll_s_distribution_xdmf(plot_name, x, v, w, xmin, xmax, nx, vmin, vmax, nv, iplot)
VisIt readable output for particles density Data file format could be XML, HDF5 or Binary (not fully ...
subroutine distribution_xv_gnuplot(plot_name, x, v, xmin, xmax, nx, vmin, vmax, nv, iplot, time)
subroutine, public sll_s_particles_center_gnuplot_inline(x, v, xmin, xmax, ymin, ymax, time)
Call this function inline with | gnuplot.
subroutine compute_df_m4(xp, yp, wp, xmin, xmax, nx, ymin, ymax, ny, df)
subroutine, public sll_s_plot_format_xmdv(plot_name, x, v, iplot, xmin, xmax, vmin, vmax)
xmdv format http://davis.wpi.edu/xmdv/fileformats.html This format is designed for particles with a l...
subroutine pqr_plot_format_points3d(plot_name, x, y, z, iplot)
point3D format http://www.visitusers.org/index.php?title=Reading_point_data This format is designed t...
subroutine compute_df_ngp(xp, yp, wp, xmin, xmax, nx, ymin, ymax, ny, df)
Compute grid field from particles distribution with the NGP scheme (Nearest Grid Point)
subroutine, public sll_s_distribution_tsc_gnuplot(plot_name, x, v, w, xmin, xmax, nx, vmin, vmax, nv, iplot)
GNUplot readable output for particles density.
subroutine, public sll_s_electricpotential_gnuplot_inline(values, eval_knots)
Call this function inline with | gnuplot Plots different energies for Electrostatic Particle-in-Cell ...
subroutine compute_df(df, x, v, xmin, xmax, nx, vmin, vmax, nv)
subroutine pq_plot_format_points3d(plot_name, x, v, iplot)
point3D format http://www.visitusers.org/index.php?title=Reading_point_data This format is designed t...
real(kind=f64) function f_m4(x)
M4 function from Monhagan (SPH method)
subroutine, public sll_s_compute_df_cic(xp, yp, wp, xmin, xmax, nx, ymin, ymax, ny, df)
Compute grid field from particles distribution with the CIC scheme (Cloud In.
subroutine compute_df_tsc(xp, yp, wp, xmin, xmax, nx, ymin, ymax, ny, df)
Some common numerical utilities.
subroutine, public sll_s_int2string(istep, cstep)
Convert an integer < 9999 to a 4 characters string.
subroutine, public sll_s_new_file_id(file_id, error)
Get a file unit number free before creating a file.
Implements the functions to write xdmf file plotable by VisIt.
subroutine, public sll_s_xdmf_corect2d_nodes(file_name, array, array_name, eta1_min, delta_eta1, eta2_min, delta_eta2, file_format, iplot, time)
Subroutine to write a 2D array in xdmf format The field is describe on a cartesian mesh Axis are perp...