5 #include <PB3D_macros.h>
28 logical :: debug_plot_harmonics = .false.
41 integer,
intent(in) :: last_unstable_id
44 character(len=max_str_ln) :: plot_title
45 character(len=max_str_ln) :: plot_name
46 integer :: n_sol_found
50 n_sol_found =
size(sol%val)
55 plot_title =
'final Eigenvalues omega^2 [log]'
56 plot_name =
'Eigenvalues'
58 &log10(abs(rp(sol%val(1:n_sol_found)))),draw=.false.)
59 call draw_ex([plot_title],plot_name,1,1,.false.,ex_plot_style=1)
62 if (last_unstable_id.gt.0)
then
63 plot_title =
'final unstable Eigenvalues omega^2'
64 plot_name =
'Eigenvalues_unstable'
66 &rp(sol%val(1:last_unstable_id)),&
67 &x=[(id*1._dp,id=1,last_unstable_id)],draw=.false.)
68 call draw_ex([plot_title],plot_name,1,1,.false.,ex_plot_style=1)
72 if (last_unstable_id.lt.n_sol_found)
then
73 plot_title =
'final stable Eigenvalues omega^2'
74 plot_name =
'Eigenvalues_stable'
76 &rp(sol%val(last_unstable_id+1:n_sol_found)),&
77 &x=[(id*1._dp,id=last_unstable_id+1,n_sol_found)],&
79 call draw_ex([plot_title],plot_name,1,1,.false.,ex_plot_style=1)
114 integer function plot_sol_vec(mds_X,mds_sol,grid_eq,grid_X,grid_sol,eq_1,&
115 &eq_2,X,sol,XYZ,X_id,plot_var)
result(ierr)
130 character(*),
parameter :: rout_name =
'plot_sol_vec'
142 real(dp),
intent(in) :: xyz(:,:,:,:)
143 integer,
intent(in) :: x_id
144 logical,
intent(in) :: plot_var(2)
149 integer :: norm_id(2)
150 integer :: id, jd, jd2, kd, td
152 integer :: plot_dim(4)
153 integer :: plot_offset(4)
156 logical :: plot_var_loc(2)
157 logical :: xyz_plot_setup
159 real(dp),
allocatable :: x_0_ser(:)
160 real(dp),
allocatable :: time(:)
161 real(dp),
allocatable :: xyz_plot(:,:,:,:,:)
162 real(dp),
allocatable :: xyz_vec(:,:,:,:,:)
163 real(dp),
allocatable :: h12(:,:,:)
164 real(dp),
allocatable :: h22(:,:,:)
165 real(dp),
allocatable :: h23(:,:,:)
166 real(dp),
allocatable :: g13(:,:,:)
167 real(dp),
allocatable :: g33(:,:,:)
168 real(dp),
allocatable :: jac_fd_int(:,:,:)
169 real(dp),
allocatable :: f_plot_phase(:,:,:,:)
170 real(dp),
allocatable :: ccomp(:,:,:,:,:)
172 complex(dp),
allocatable :: f_plot(:,:,:,:,:)
173 character(len=max_str_ln) :: err_msg
174 character(len=max_str_ln) :: var_name(2)
175 character(len=max_str_ln) :: file_name(2)
176 character(len=max_str_ln) :: description(2)
177 character(len=2) :: sol_name
181 real(dp),
allocatable :: dq_saf(:)
182 real(dp),
allocatable :: drot_t(:)
183 complex(dp),
allocatable :: u_inf(:,:,:,:)
184 complex(dp),
allocatable :: u_inf_prop(:,:,:)
194 if (count(plot_var).eq.0)
return
195 plot_var_loc = plot_var
196 if (abs(pert_mult_factor_post).ge.tol_zero)
then
199 do kd = 1,grid_sol%loc_n_r
200 x_0 = max(x_0,abs(sum(sol%vec(:,kd,x_id))))
204 x_0 = maxval(x_0_ser)
207 call writo(
'Perturbing the position vector (X,Y,Z) with &
208 &multiplicative factor '//trim(
r2strt(pert_mult_factor_post)))
209 if (.not.plot_var(1))
then
210 call writo(
'For nonzero "pert_mult_factor_POST", need to also &
211 &plot xi',warning=.true.)
212 plot_var_loc(1) = .true.
217 call writo(
'Plot the solution vector')
222 if (
size(xyz,4).ne.3)
then
224 err_msg =
'X, Y and Z needed'
227 if (grid_eq%n(1).ne.
size(xyz,1) .or. &
228 &grid_eq%n(2).ne.
size(xyz,2) .or. &
229 &grid_sol%loc_n_r.ne.
size(xyz,3))
then
231 err_msg =
'XYZ needs to have the correct dimensions'
240 if (rp(sol%val(x_id)).lt.0)
then
249 if (product(n_t).gt.1)
then
256 ierr = grid_out%init([grid_eq%n(1:2),grid_sol%n(3)],&
257 &i_lim=[grid_sol%i_min,grid_sol%i_max],divided=grid_sol%divided)
259 grid_out%r_F = grid_sol%r_F
260 grid_out%r_E = grid_sol%r_E
261 grid_out%loc_r_F = grid_sol%loc_r_F
262 grid_out%loc_r_E = grid_sol%loc_r_E
263 if (eq_style.eq.1)
allocate(grid_out%trigon_factors(&
264 &
size(grid_x%trigon_factors,1),
size(grid_x%trigon_factors,2),&
265 &
size(grid_x%trigon_factors,3),grid_out%loc_n_r,&
266 &
size(grid_x%trigon_factors,5)))
267 select case (x_grid_style)
270 do jd = 1,grid_x%n(2)
271 do id = 1,grid_x%n(1)
272 ierr =
spline(grid_x%loc_r_F,grid_x%theta_F(id,jd,:),&
273 &grid_sol%loc_r_F,grid_out%theta_F(id,jd,:),&
274 &ord=norm_disc_prec_x)
276 ierr =
spline(grid_x%loc_r_F,grid_x%theta_E(id,jd,:),&
277 &grid_sol%loc_r_F,grid_out%theta_E(id,jd,:),&
278 &ord=norm_disc_prec_x)
280 ierr =
spline(grid_x%loc_r_F,grid_x%zeta_F(id,jd,:),&
281 &grid_sol%loc_r_F,grid_out%zeta_F(id,jd,:),&
282 &ord=norm_disc_prec_x)
284 ierr =
spline(grid_x%loc_r_F,grid_x%zeta_E(id,jd,:),&
285 &grid_sol%loc_r_F,grid_out%zeta_E(id,jd,:),&
286 &ord=norm_disc_prec_x)
288 if (eq_style.eq.1)
then
289 do td = 1,
size(grid_x%trigon_factors,5)
290 do kd = 1,
size(grid_x%trigon_factors,1)
291 ierr =
spline(grid_x%loc_r_F,&
292 &grid_x%trigon_factors(kd,id,jd,:,td),&
294 &grid_out%trigon_factors&
295 &(kd,id,jd,:,td),ord=norm_disc_prec_x)
304 grid_out%theta_F = grid_x%theta_F
305 grid_out%theta_E = grid_x%theta_E
306 grid_out%zeta_F = grid_x%zeta_F
307 grid_out%zeta_E = grid_x%zeta_E
311 ierr =
trim_grid(grid_out,grid_out_trim,norm_id)
315 plot_dim = [grid_out_trim%n,product(n_t)]
316 plot_offset = [0,0,grid_out_trim%i_min-1,0]
319 if (
size(eq_jobs_lims,2).gt.1)
then
320 plot_dim(1) = eq_jobs_lims(2,
size(eq_jobs_lims,2)) - &
321 &eq_jobs_lims(1,1) + 1
322 plot_offset(1) = eq_jobs_lims(1,eq_job_nr) - 1
326 cont_plot = eq_job_nr.gt.1
329 allocate(time(product(n_t)))
330 do td = 1,product(n_t)
331 if (n_t(1).eq.1)
then
332 time(td) = (td-1) * 0.25
334 time(td) = (mod(td-1,n_t(1))*1._dp/n_t(1) + &
335 &(td-1)/n_t(1)) * 0.25
340 allocate(h12(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r))
341 allocate(h22(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r))
342 allocate(h23(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r))
343 allocate(g13(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r))
344 allocate(g33(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r))
345 allocate(jac_fd_int(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r))
347 allocate(dq_saf(grid_out%loc_n_r))
348 allocate(drot_t(grid_out%loc_n_r))
352 do jd = 1,grid_eq%n(2)
353 do id = 1,grid_eq%n(1)
354 ierr =
spline(grid_eq%loc_r_F,&
355 &eq_2%h_FD(id,jd,:,
c([1,2],.true.),0,0,0),grid_sol%loc_r_F,&
356 &h12(id,jd,:),ord=norm_disc_prec_eq)
358 ierr =
spline(grid_eq%loc_r_F,&
359 &eq_2%h_FD(id,jd,:,
c([2,2],.true.),0,0,0),grid_sol%loc_r_F,&
360 &h22(id,jd,:),ord=norm_disc_prec_eq)
362 ierr =
spline(grid_eq%loc_r_F,&
363 &eq_2%h_FD(id,jd,:,
c([2,3],.true.),0,0,0),grid_sol%loc_r_F,&
364 &h23(id,jd,:),ord=norm_disc_prec_eq)
366 ierr =
spline(grid_eq%loc_r_F,&
367 &eq_2%g_FD(id,jd,:,
c([1,3],.true.),0,0,0),grid_sol%loc_r_F,&
368 &g13(id,jd,:),ord=norm_disc_prec_eq)
370 ierr =
spline(grid_eq%loc_r_F,&
371 &eq_2%g_FD(id,jd,:,
c([3,3],.true.),0,0,0),grid_sol%loc_r_F,&
372 &g33(id,jd,:),ord=norm_disc_prec_eq)
374 ierr =
spline(grid_eq%loc_r_F,&
375 &eq_2%jac_FD(id,jd,:,0,0,0),grid_sol%loc_r_F,&
376 &jac_fd_int(id,jd,:),ord=norm_disc_prec_eq)
381 ierr =
spline(grid_eq%loc_r_F,eq_1%q_saf_FD(:,1),grid_sol%loc_r_F,&
382 &dq_saf,ord=norm_disc_prec_eq)
384 ierr =
spline(grid_eq%loc_r_F,eq_1%rot_t_FD(:,1),grid_sol%loc_r_F,&
385 &drot_t,ord=norm_disc_prec_eq)
391 omega = sqrt(sol%val(x_id))
392 if (ip(omega).gt.0) omega = - omega
400 allocate(f_plot(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r,&
402 allocate(ccomp(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r,3,2))
403 allocate(xyz_plot(grid_out%n(1),grid_out%n(2),grid_out_trim%loc_n_r,&
405 allocate(xyz_vec(grid_out%n(1),grid_out%n(2),grid_out_trim%loc_n_r,3,&
407 xyz_plot_setup = .false.
411 if (.not.plot_var_loc(jd)) cycle
417 ierr =
calc_xuq(mds_x,mds_sol,grid_eq,grid_x,grid_sol,eq_1,&
418 &eq_2,x,sol,x_id,1,time,f_plot(:,:,:,:,1))
420 ierr =
calc_xuq(mds_x,mds_sol,grid_eq,grid_x,grid_sol,eq_1,&
421 &eq_2,x,sol,x_id,2,time,f_plot(:,:,:,:,2))
424 file_name(1) = trim(
i2str(x_id))//
'_sol_X'
425 file_name(2) = trim(
i2str(x_id))//
'_sol_U'
427 ierr =
calc_xuq(mds_x,mds_sol,grid_eq,grid_x,grid_sol,eq_1,&
428 &eq_2,x,sol,x_id,3,time,f_plot(:,:,:,:,1))
430 ierr =
calc_xuq(mds_x,mds_sol,grid_eq,grid_x,grid_sol,eq_1,&
431 &eq_2,x,sol,x_id,4,time,f_plot(:,:,:,:,2))
434 file_name(1) = trim(
i2str(x_id))//
'_sol_Qn'
435 file_name(2) = trim(
i2str(x_id))//
'_sol_Qg'
437 var_name(1) =
'Normal comp. of '//trim(sol_name)
438 var_name(2) =
'Geodesic comp. of '//trim(sol_name)
439 description(1) =
'Normal component of vector '//trim(sol_name)//&
440 &
' for Eigenvalue '//trim(
i2str(x_id))//
' with omega = '//&
441 &trim(
r2str(rp(omega)))
442 description(2) =
'Geodesic component of vector '//trim(sol_name)//&
443 &
' for Eigenvalue '//trim(
i2str(x_id))//
' with omega = '//&
444 &trim(
r2str(rp(omega)))
447 do td = 1,product(n_t)
453 ccomp(:,:,:,1,1) = rp(f_plot(:,:,:,td,2)) * &
454 &jac_fd_int**2*h22/g33
455 ccomp(:,:,:,2,1) = rp(f_plot(:,:,:,td,1)) * &
457 &rp(f_plot(:,:,:,td,2)) * &
458 &jac_fd_int**2*h12/g33
459 ccomp(:,:,:,3,1) = 0._dp
466 ccomp(:,:,:,1,2) = rp(f_plot(:,:,:,td,1)) * &
467 &h12/h22 + rp(f_plot(:,:,:,td,2))
468 ccomp(:,:,:,2,2) = rp(f_plot(:,:,:,td,1))
469 ccomp(:,:,:,3,2) = rp(f_plot(:,:,:,td,1)) * &
470 &h23/h22 - rp(f_plot(:,:,:,td,2)) * g13/g33
473 if (abs(pert_mult_factor_post).ge.tol_zero .and. jd.eq.1) &
474 &ccomp = ccomp*pert_mult_factor_post/x_0
477 if (use_normalization)
then
482 ccomp = ccomp / (
r_0**2)
493 xyz_vec(:,:,:,id,:) = xyz(:,:,norm_id(1):norm_id(2),:)
495 call plot_hdf5([trim(sol_name)],trim(sol_name)//
'_T_'//&
496 &trim(
i2str(td)),ccomp(:,:,norm_id(1):norm_id(2),:,1),&
497 &tot_dim=[plot_dim(1:3),3],&
498 &loc_offset=[plot_offset(1:3),0],&
499 &x=xyz_vec(:,:,:,:,1),y=xyz_vec(:,:,:,:,2),&
500 &z=xyz_vec(:,:,:,:,3),col=4,cont_plot=cont_plot,&
501 &descr=
'perturbation for time t = '//&
506 if (.not.xyz_plot_setup)
then
507 xyz_plot(:,:,:,td,:) = xyz(:,:,norm_id(1):norm_id(2),:)
508 if (abs(pert_mult_factor_post).ge.tol_zero .and. jd.eq.1) &
509 &xyz_plot(:,:,:,td,:) = xyz_plot(:,:,:,td,:) + &
510 &ccomp(:,:,norm_id(1):norm_id(2),:,1)
515 xyz_plot_setup = .true.
519 call writo(
'Checking how well U approximates the pure &
524 allocate(u_inf(grid_out%n(1),grid_out%n(2),grid_out%loc_n_r,&
528 do ld = 1,product(n_t)
529 do jd2 = 1,grid_out%n(2)
530 do id = 1,grid_out%n(1)
531 ierr =
spline(grid_out%loc_r_F,&
532 &f_plot(id,jd2,:,ld,1),grid_out%loc_r_F,&
533 &u_inf(id,jd2,:,ld),ord=norm_disc_prec_eq,&
541 allocate(u_inf_prop(grid_out%n(1),grid_out%n(2),&
544 do kd = 1,grid_out%loc_n_r
545 u_inf_prop(:,:,kd) = h12(:,:,kd)/h22(:,:,kd) + &
546 &dq_saf(kd)*grid_out%theta_F(:,:,kd)
550 do kd = 1,grid_out%loc_n_r
551 u_inf_prop(:,:,kd) = h12(:,:,kd)/h22(:,:,kd) - &
552 &drot_t(kd)*grid_out%zeta_F(:,:,kd)
558 do ld = 1,product(n_t)
559 u_inf(:,:,:,ld) = iu/nm * u_inf(:,:,:,ld) - &
560 &f_plot(:,:,:,ld,1) * u_inf_prop
562 deallocate(u_inf_prop)
566 &rp(f_plot(:,:,norm_id(1):norm_id(2),1,1)),&
567 &tot_dim=plot_dim(1:3),loc_offset=plot_offset(1:3))
569 &rp(u_inf(:,:,norm_id(1):norm_id(2),1)),&
570 &
'TEST_RE_U_inf_'//trim(
i2str(x_id)),tot_dim=plot_dim(1:3),&
571 &loc_offset=plot_offset(1:3),descr=
'To test whether U &
572 &approximates the ideal ballooning result',&
573 &output_message=.true.)
577 &ip(f_plot(:,:,norm_id(1):norm_id(2),1,1)),&
578 &tot_dim=plot_dim(1:3),loc_offset=plot_offset(1:3))
580 &ip(u_inf(:,:,norm_id(1):norm_id(2),1)),&
581 &
'TEST_IM_U_inf_'//trim(
i2str(x_id)),tot_dim=plot_dim(1:3),&
582 &loc_offset=plot_offset(1:3),descr=
'To test whether U &
583 &approximates the ideal ballooning result',&
584 &output_message=.true.)
586 call writo(
'Checking done')
592 allocate(f_plot_phase(grid_out%n(1),grid_out%n(2),&
593 &grid_out_trim%loc_n_r,product(n_t)))
596 if (use_normalization)
then
600 f_plot(:,:,:,:,2) = f_plot(:,:,:,:,2) / (
r_0**2*
b_0)
602 f_plot(:,:,:,:,1) = f_plot(:,:,:,:,1) *
b_0/
r_0
603 f_plot(:,:,:,:,2) = f_plot(:,:,:,:,2) / (
r_0**3)
608 call plot_hdf5([var_name(kd)],trim(file_name(kd))//
'_RE',&
609 &rp(f_plot(:,:,norm_id(1):norm_id(2),:,kd)),&
610 &tot_dim=plot_dim,loc_offset=plot_offset,&
611 &x=xyz_plot(:,:,:,:,1),y=xyz_plot(:,:,:,:,2),&
612 &z=xyz_plot(:,:,:,:,3),col=col,cont_plot=cont_plot,&
613 &descr=description(kd))
614 call plot_hdf5([var_name(kd)],trim(file_name(kd))//
'_IM',&
615 &ip(f_plot(:,:,norm_id(1):norm_id(2),:,kd)),&
616 &tot_dim=plot_dim,loc_offset=plot_offset,&
617 &x=xyz_plot(:,:,:,:,1),y=xyz_plot(:,:,:,:,2),&
618 &z=xyz_plot(:,:,:,:,3),col=col,cont_plot=cont_plot,&
619 &descr=description(kd))
620 f_plot_phase = atan2(&
621 &ip(f_plot(:,:,norm_id(1):norm_id(2),:,kd)),&
622 &rp(f_plot(:,:,norm_id(1):norm_id(2),:,kd)))
623 where (f_plot_phase.lt.0) f_plot_phase = f_plot_phase + 2*pi
624 call plot_hdf5([var_name(kd)],trim(file_name(kd))//
'_PH',&
625 &f_plot_phase,tot_dim=plot_dim,loc_offset=plot_offset,&
626 &x=xyz_plot(:,:,:,:,1),y=xyz_plot(:,:,:,:,2),&
627 &z=xyz_plot(:,:,:,:,3),col=col,cont_plot=cont_plot,&
628 &descr=description(kd))
632 deallocate(f_plot_phase)
636 call grid_out%dealloc()
637 call grid_out_trim%dealloc()
645 integer function plot_harmonics(mds,grid_sol,sol,X_id,res_surf)
result(ierr)
655 character(*),
parameter :: rout_name =
'plot_harmonics'
661 integer,
intent(in) :: x_id
662 real(dp),
intent(in) :: res_surf(:,:)
666 integer :: norm_id(2)
673 character(len=max_str_ln) :: file_name
674 character(len=max_str_ln),
allocatable :: plot_title(:)
675 real(dp) :: norm_factor
676 real(dp),
allocatable :: x_plot(:,:)
677 real(dp),
allocatable :: y_plot(:,:)
678 complex(dp),
allocatable :: sol_vec_ser(:,:)
679 complex(dp),
allocatable :: sol_vec_dum(:,:)
680 complex(dp),
allocatable :: sol_vec_ser_tot(:,:,:)
681 complex(dp),
allocatable :: sol_vec_ser_loc(:)
682 real(dp),
allocatable :: sol_vec_phase(:,:)
684 character(len=max_str_ln) :: err_msg
686 real(dp),
allocatable :: sol_vec_sum(:,:)
696 ierr =
trim_grid(grid_sol,grid_sol_trim,norm_id)
701 n_mod_loc = sol%n_mod
702 n_mod_tot =
size(mds%sec,1)
703 min_nm_x = minval(mds%sec(:,1),1)
707 &
allocate(sol_vec_ser(1:n_mod_loc,1:grid_sol_trim%n(3)))
709 ierr =
get_ser_var(sol%vec(ld,norm_id(1):norm_id(2),x_id),&
710 &sol_vec_ser_loc,scatter=.true.)
712 if (rank.eq.0) sol_vec_ser(ld,:) = sol_vec_ser_loc
713 deallocate(sol_vec_ser_loc)
728 allocate(sol_vec_ser_tot(1:n_mod_tot,1:grid_sol_trim%n(3),&
732 &sol_vec_dum,deriv=id)
734 sol_vec_ser_tot(:,:,id) = sol_vec_dum
736 deallocate(sol_vec_dum)
741 allocate(x_plot(grid_sol_trim%n(3),n_mod_tot))
742 allocate(y_plot(grid_sol_trim%n(3),n_mod_tot))
743 allocate(sol_vec_phase(grid_sol_trim%n(3),n_mod_tot))
744 if (use_pol_flux_f)
then
750 x_plot(:,ld) = grid_sol_trim%r_F
751 y_plot(:,ld) = min_nm_x+ld-1
755 x_plot = x_plot/norm_factor
759 allocate(plot_title(n_mod_tot))
761 plot_title(ld) =
'EV - midplane ('//nm_x//
' = '//&
762 &trim(
i2str(min_nm_x+ld-1))//
')'
768 file_name = trim(
i2str(x_id))//
'_EV_midplane_RE'
769 if (id.gt.0) file_name = trim(file_name)//
'_D'//trim(
i2str(id))
773 &rp(transpose(sol_vec_ser_tot(:,:,id))),x=x_plot,&
775 call draw_ex(plot_title,file_name,n_mod_tot,1,&
776 &.false.,draw_ops=[
'with lines'],ex_plot_style=1)
777 call draw_ex(plot_title,file_name,n_mod_tot,1,&
778 &.false.,ex_plot_style=2)
781 if (n_mod_tot*grid_sol_trim%n(3).le.ex_max_size)
then
782 call draw_ex(plot_title,trim(file_name)//
'_3D',&
783 &n_mod_tot,3,.false.,draw_ops=[
'with lines'],&
784 &data_name=file_name,ex_plot_style=1)
790 file_name = trim(
i2str(x_id))//
'_EV_midplane_IM'
791 if (id.gt.0) file_name = trim(file_name)//
'_D'//trim(
i2str(id))
795 &ip(transpose(sol_vec_ser_tot(:,:,id))),x=x_plot,&
799 call draw_ex(plot_title,file_name,n_mod_tot,1,.false.,&
800 &draw_ops=[
'with lines'],ex_plot_style=1)
803 if (n_mod_tot*grid_sol_trim%n(3).le.ex_max_size)
then
804 call draw_ex(plot_title,trim(file_name)//
'_3D',&
805 &n_mod_tot,3,.false.,draw_ops=[
'with lines'],&
806 &data_name=file_name,ex_plot_style=1)
811 file_name = trim(
i2str(x_id))//
'_EV_midplane_PH'
812 if (id.gt.0) file_name = trim(file_name)//
'_D'//trim(
i2str(id))
815 sol_vec_phase = atan2(ip(transpose(sol_vec_ser_tot(:,:,id))),&
816 &rp(transpose(sol_vec_ser_tot(:,:,id))))
817 where (sol_vec_phase.lt.0) sol_vec_phase = sol_vec_phase + 2*pi
820 call print_ex_2d(plot_title,file_name,sol_vec_phase,&
821 &x=x_plot,draw=.false.)
824 call draw_ex(plot_title,file_name,n_mod_tot,1,&
825 &.false.,draw_ops=[
'with lines'],ex_plot_style=1)
828 if (n_mod_tot*grid_sol_trim%n(3).le.ex_max_size)
then
829 call draw_ex(plot_title,trim(file_name)//
'_3D',&
830 &n_mod_tot,3,.false.,draw_ops=[
'with lines'],&
831 &data_name=file_name,ex_plot_style=1)
835 deallocate(plot_title)
838 allocate(plot_title(3))
839 plot_title(1) =
'real part'
840 plot_title(2) =
'imaginary part'
841 plot_title(3) =
'phase'
842 file_name = trim(
i2str(x_id))//
'_EV_midplane'
843 if (id.gt.0) file_name = trim(file_name)//
'_D'//trim(
i2str(id))
848 call plot_hdf5(plot_title,trim(file_name),&
849 &reshape([rp(transpose(sol_vec_ser_tot(:,:,id))),&
850 &ip(transpose(sol_vec_ser_tot(:,:,id))),&
851 &sol_vec_phase],[grid_sol_trim%n(3),n_mod_tot,1,3]),&
852 &x=reshape(x_plot,[grid_sol_trim%n(3),n_mod_tot,1,1]),&
853 &y=reshape(y_plot,[grid_sol_trim%n(3),n_mod_tot,1,1]))
856 deallocate(plot_title)
860 if (debug_plot_harmonics)
then
861 allocate(plot_title(4))
862 allocate(sol_vec_sum(1:grid_sol_trim%n(3),4))
863 plot_title(1) =
'EV - outboard midplane - REAL'
864 plot_title(2) =
'EV - outboard midplane - IMAG'
865 plot_title(3) =
'EV - inboard midplane - REAL'
866 plot_title(4) =
'EV - inboard midplane - IMAG'
868 file_name =
'TEST_harmonics'
869 if (id.gt.0) file_name = trim(file_name)//
'_D'//&
871 sol_vec_sum(:,1) = rp(sum(sol_vec_ser_tot(:,:,id),1))
872 sol_vec_sum(:,2) = ip(sum(sol_vec_ser_tot(:,:,id),1))
873 sol_vec_sum(:,3) = rp(&
874 &sum(sol_vec_ser_tot(1:n_mod_tot:2,:,id),1) - &
875 &sum(sol_vec_ser_tot(2:n_mod_tot:2,:,id),1))
876 sol_vec_sum(:,4) = ip(&
877 &sum(sol_vec_ser_tot(1:n_mod_tot:2,:,id),1) - &
878 &sum(sol_vec_ser_tot(2:n_mod_tot:2,:,id),1))
879 call print_ex_2d(plot_title,file_name,sol_vec_sum,&
880 &x=x_plot(:,1:1),draw=.false.)
881 call draw_ex(plot_title,file_name,4,1,&
882 &.false.,draw_ops=[
'with lines'],ex_plot_style=1)
883 call draw_ex(plot_title,file_name,4,1,&
884 &.false.,ex_plot_style=2)
886 deallocate(plot_title)
887 deallocate(sol_vec_sum)
894 deallocate(sol_vec_phase)
897 if (
size(res_surf,1).gt.0)
then
899 file_name = trim(
i2str(x_id))//
'_EV_max'
900 allocate(plot_title(2))
901 plot_title(1) =
'mode maximum'
902 plot_title(2) =
'resonating surface'
905 allocate(x_plot(n_mod_tot,2))
906 allocate(y_plot(n_mod_tot,2))
911 if (maxval(abs(rp(sol_vec_ser_tot(ld,:,0)))).gt.0)
then
913 x_plot(ld_loc,1) = grid_sol_trim%r_F(&
914 &maxloc(abs(rp(sol_vec_ser_tot(ld,:,0))),1))
915 y_plot(ld_loc,1) = min_nm_x+ld-1
918 if (ld_loc.eq.0)
then
920 err_msg =
'None of the modes resonates'
923 x_plot(ld_loc+1:n_mod_tot,1) = x_plot(ld_loc,1)
924 y_plot(ld_loc+1:n_mod_tot,1) = y_plot(ld_loc,1)
927 x_plot(1:
size(res_surf,1),2) = res_surf(:,2)
928 x_plot(
size(res_surf,1)+1:n_mod_tot,2) = &
929 &res_surf(
size(res_surf,1),2)
930 y_plot(1:
size(res_surf,1),2) = res_surf(:,1)
931 y_plot(
size(res_surf,1)+1:n_mod_tot,2) = &
932 &res_surf(
size(res_surf,1),1)
935 x_plot = x_plot/norm_factor
938 call print_ex_2d(plot_title,file_name,y_plot,x=x_plot,&
942 call draw_ex(plot_title,file_name,2,1,.false.,extra_ops=&
944 &trim(
r2str(grid_sol_trim%r_F(1)/norm_factor))//
':'//&
945 &trim(
r2str(grid_sol_trim%r_F(grid_sol_trim%n(3))/&
946 &norm_factor))//
']',ex_plot_style=1)
951 call grid_sol_trim%dealloc()
989 &eq_1,eq_2,X,sol,vac,X_id,B_aligned,XYZ,E_pot_int,E_kin_int) &
995 character(*),
parameter :: rout_name =
'decompose_energy'
1008 integer,
intent(in) :: x_id
1009 logical,
intent(in) :: b_aligned
1010 real(dp),
intent(in),
optional :: xyz(:,:,:,:)
1011 complex(dp),
intent(inout),
optional :: e_pot_int(7)
1012 complex(dp),
intent(inout),
optional :: e_kin_int(2)
1016 integer :: norm_id(2)
1018 integer :: loc_dim(3)
1019 integer :: plot_dim(3)
1020 integer :: plot_offset(3)
1021 logical :: cont_plot
1022 complex(dp),
allocatable,
target :: e_pot(:,:,:,:)
1023 complex(dp),
allocatable,
target :: e_kin(:,:,:,:)
1024 complex(dp) :: e_pot_int_loc(7)
1025 complex(dp) :: e_kin_int_loc(2)
1026 complex(dp),
pointer :: e_pot_trim(:,:,:,:) => null()
1027 complex(dp),
pointer :: e_kin_trim(:,:,:,:) => null()
1028 real(dp),
allocatable,
target :: x_tot(:,:,:,:), y_tot(:,:,:,:), &
1030 real(dp),
pointer :: x_tot_trim(:,:,:,:) => null()
1031 real(dp),
pointer :: y_tot_trim(:,:,:,:) => null()
1032 real(dp),
pointer :: z_tot_trim(:,:,:,:) => null()
1033 character(len=max_str_ln),
allocatable :: var_names_pot(:)
1034 character(len=max_str_ln),
allocatable :: var_names_kin(:)
1035 character(len=max_str_ln),
allocatable :: var_names(:)
1036 character(len=max_str_ln) :: file_name
1037 character(len=max_str_ln) :: description
1043 call writo(
'Calculate energy terms')
1047 ierr =
calc_e(mds_x,mds_sol,grid_eq,grid_x,grid_sol,eq_1,eq_2,x,sol,&
1048 &vac,b_aligned,x_id,e_pot,e_kin,e_pot_int_loc,e_kin_int_loc)
1052 if (
present(e_pot_int)) e_pot_int = e_pot_int + e_pot_int_loc
1053 if (
present(e_kin_int)) e_kin_int = e_kin_int + e_kin_int_loc
1058 if (
present(xyz))
then
1063 call writo(
'Preparing plots')
1070 allocate(var_names_pot(6))
1071 var_names_pot(1) =
'1. normal line bending term ~ Q_n^2'
1072 var_names_pot(2) =
'2. geodesic line bending term ~ Q_g^2'
1073 var_names_pot(3) =
'3. normal ballooning term ~ -p'' X^2 kappa_n'
1074 var_names_pot(4) =
'4. geodesic ballooning term ~ -p'' X U* kappa_g'
1075 var_names_pot(5) =
'5. normal kink term ~ -sigma X*Q_g'
1076 var_names_pot(6) =
'6. geodesic kink term ~ sigma U*Q_n'
1079 allocate(var_names_kin(2))
1080 var_names_kin(1) =
'1. normal kinetic term ~ rho X^2'
1081 var_names_kin(2) =
'2. geodesic kinetic term ~ rho U^2'
1084 ierr =
trim_grid(grid_sol,grid_sol_trim,norm_id)
1088 loc_dim = [grid_eq%n(1),grid_eq%n(2),grid_sol_trim%loc_n_r]
1089 plot_dim = [grid_eq%n(1),grid_eq%n(2),grid_sol_trim%n(3)]
1090 plot_offset = [0,0,grid_sol_trim%i_min-1]
1091 allocate(x_tot(loc_dim(1),loc_dim(2),loc_dim(3),6))
1092 allocate(y_tot(loc_dim(1),loc_dim(2),loc_dim(3),6))
1093 allocate(z_tot(loc_dim(1),loc_dim(2),loc_dim(3),6))
1095 x_tot(:,:,:,kd) = xyz(:,:,norm_id(1):norm_id(2),1)
1096 y_tot(:,:,:,kd) = xyz(:,:,norm_id(1):norm_id(2),2)
1097 z_tot(:,:,:,kd) = xyz(:,:,norm_id(1):norm_id(2),3)
1099 allocate(var_names(2))
1109 e_pot_trim => e_pot(:,:,norm_id(1):norm_id(2),:)
1110 e_kin_trim => e_kin(:,:,norm_id(1):norm_id(2),:)
1115 call writo(
'Plot energy terms')
1119 file_name = trim(
i2str(x_id))//
'_E_kin'
1120 description =
'Kinetic energy constituents'
1121 x_tot_trim => x_tot(:,:,:,1:2)
1122 y_tot_trim => y_tot(:,:,:,1:2)
1123 z_tot_trim => z_tot(:,:,:,1:2)
1124 call plot_hdf5(var_names_kin,trim(file_name)//
'_RE',rp(e_kin_trim),&
1125 &tot_dim=[plot_dim,2],loc_offset=[plot_offset,0],&
1126 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,cont_plot=cont_plot,&
1128 call plot_hdf5(var_names_kin,trim(file_name)//
'_IM',ip(e_kin_trim),&
1129 &tot_dim=[plot_dim,2],loc_offset=[plot_offset,0],&
1130 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,cont_plot=cont_plot,&
1132 nullify(x_tot_trim,y_tot_trim,z_tot_trim)
1135 file_name = trim(
i2str(x_id))//
'_E_pot'
1136 description =
'Potential energy constituents'
1137 x_tot_trim => x_tot(:,:,:,1:6)
1138 y_tot_trim => y_tot(:,:,:,1:6)
1139 z_tot_trim => z_tot(:,:,:,1:6)
1140 call plot_hdf5(var_names_pot,trim(file_name)//
'_RE',rp(e_pot_trim),&
1141 &tot_dim=[plot_dim,6],loc_offset=[plot_offset,0],&
1142 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,cont_plot=cont_plot,&
1144 call plot_hdf5(var_names_pot,trim(file_name)//
'_IM',ip(e_pot_trim),&
1145 &tot_dim=[plot_dim,6],loc_offset=[plot_offset,0],&
1146 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,cont_plot=cont_plot,&
1148 nullify(x_tot_trim,y_tot_trim,z_tot_trim)
1151 var_names(1) =
'1. stabilizing term'
1152 var_names(2) =
'2. destabilizing term'
1153 file_name = trim(
i2str(x_id))//
'_E_stab'
1154 description =
'(de)stabilizing energy'
1155 x_tot_trim => x_tot(:,:,:,1:2)
1156 y_tot_trim => y_tot(:,:,:,1:2)
1157 z_tot_trim => z_tot(:,:,:,1:2)
1158 call plot_hdf5(var_names,trim(file_name)//
'_RE',rp(reshape(&
1159 &[sum(e_pot_trim(:,:,:,1:2),4),sum(e_pot_trim(:,:,:,3:6),4)],&
1160 &[loc_dim(1),loc_dim(2),loc_dim(3),2])),&
1161 &tot_dim=[plot_dim,2],loc_offset=[plot_offset,0],&
1162 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,&
1163 &cont_plot=cont_plot,descr=description)
1164 call plot_hdf5(var_names,trim(file_name)//
'_IM',ip(reshape(&
1165 &[sum(e_pot_trim(:,:,:,1:2),4),sum(e_pot_trim(:,:,:,3:6),4)],&
1166 &[loc_dim(1),loc_dim(2),loc_dim(3),2])),&
1167 &tot_dim=[plot_dim,2],loc_offset=[plot_offset,0],&
1168 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,&
1169 &cont_plot=cont_plot,descr=description)
1172 var_names(1) =
'1. potential energy'
1173 var_names(2) =
'2. kinetic energy'
1174 file_name = trim(
i2str(x_id))//
'_E'
1175 description =
'total potential and kinetic energy'
1176 call plot_hdf5(var_names,trim(file_name)//
'_RE',rp(reshape(&
1177 &[sum(e_pot_trim,4),sum(e_kin_trim,4)],&
1178 &[loc_dim(1),loc_dim(2),loc_dim(3),2])),&
1179 &tot_dim=[plot_dim,2],loc_offset=[plot_offset,0],&
1180 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,cont_plot=cont_plot,&
1182 call plot_hdf5(var_names,trim(file_name)//
'_IM',ip(reshape(&
1183 &[sum(e_pot_trim,4),sum(e_kin_trim,4)],&
1184 &[loc_dim(1),loc_dim(2),loc_dim(3),2])),&
1185 &tot_dim=[plot_dim,2],loc_offset=[plot_offset,0],&
1186 &x=x_tot_trim,y=y_tot_trim,z=z_tot_trim,cont_plot=cont_plot,&
1192 nullify(e_kin_trim,e_pot_trim)
1193 nullify(x_tot_trim,y_tot_trim,z_tot_trim)
1194 call grid_sol_trim%dealloc()
1203 integer function calc_e(mds_X,mds_sol,grid_eq,grid_X,grid_sol,eq_1,eq_2,X,&
1204 &sol,vac,B_aligned,X_id,E_pot,E_kin,E_pot_int,E_kin_int)
result(ierr)
1216 character(*),
parameter :: rout_name =
'calc_E'
1229 logical,
intent(in) :: b_aligned
1230 integer,
intent(in) :: x_id
1231 complex(dp),
intent(inout),
allocatable :: e_pot(:,:,:,:)
1232 complex(dp),
intent(inout),
allocatable :: e_kin(:,:,:,:)
1233 complex(dp),
intent(inout) :: e_pot_int(7)
1234 complex(dp),
intent(inout) :: e_kin_int(2)
1237 integer :: norm_id(2)
1238 integer :: id, jd, kd
1239 integer :: loc_dim(3)
1241 real(dp),
allocatable :: h22(:,:,:), g33(:,:,:), j(:,:,:)
1242 real(dp),
allocatable :: kappa_n(:,:,:), kappa_g(:,:,:)
1243 real(dp),
allocatable :: sigma(:,:,:)
1244 real(dp),
allocatable :: d2p(:,:,:), rho(:,:,:)
1245 real(dp),
allocatable :: ang_1(:,:,:), ang_2(:,:,:), norm(:)
1246 complex(dp),
allocatable :: xuq(:,:,:,:)
1247 complex(dp),
allocatable :: e_int_tot(:)
1248 character(len=max_str_ln) :: err_msg
1250 integer :: plot_dim(3)
1251 integer :: plot_offset(3)
1252 real(dp),
allocatable :: s(:,:,:)
1253 complex(dp),
allocatable :: du(:,:,:)
1254 complex(dp),
allocatable :: du_alt(:,:,:)
1258 loc_dim = [grid_eq%n(1:2),grid_sol%loc_n_r]
1262 plot_dim = [grid_eq%n(1:2),grid_sol%n(3)]
1263 plot_offset = [0,0,grid_sol%i_min-1]
1267 allocate(h22(loc_dim(1),loc_dim(2),loc_dim(3)))
1268 allocate(g33(loc_dim(1),loc_dim(2),loc_dim(3)))
1269 allocate(j(loc_dim(1),loc_dim(2),loc_dim(3)))
1270 allocate(kappa_n(loc_dim(1),loc_dim(2),loc_dim(3)))
1271 allocate(kappa_g(loc_dim(1),loc_dim(2),loc_dim(3)))
1272 allocate(sigma(loc_dim(1),loc_dim(2),loc_dim(3)))
1273 allocate(d2p(loc_dim(1),loc_dim(2),loc_dim(3)))
1274 allocate(rho(loc_dim(1),loc_dim(2),loc_dim(3)))
1275 allocate(ang_1(loc_dim(1),loc_dim(2),loc_dim(3)))
1276 allocate(ang_2(loc_dim(1),loc_dim(2),loc_dim(3)))
1277 allocate(norm(loc_dim(3)))
1278 allocate(xuq(loc_dim(1),loc_dim(2),loc_dim(3),4))
1279 allocate(e_pot(loc_dim(1),loc_dim(2),loc_dim(3),6))
1280 allocate(e_kin(loc_dim(1),loc_dim(2),loc_dim(3),2))
1283 allocate(du(loc_dim(1),loc_dim(2),loc_dim(3)))
1284 allocate(s(loc_dim(1),loc_dim(2),loc_dim(3)))
1287 ierr =
calc_xuq(mds_x,mds_sol,grid_eq,grid_x,grid_sol,eq_1,eq_2,x,&
1288 &sol,x_id,2,0._dp,du,deriv=.true.)
1299 do jd = 1,grid_eq%n(2)
1300 do id = 1,grid_eq%n(1)
1301 ierr =
spline(grid_eq%loc_r_F,&
1302 &eq_2%h_FD(id,jd,:,
c([2,2],.true.),0,0,0),grid_sol%loc_r_F,&
1305 ierr =
spline(grid_eq%loc_r_F,&
1306 &eq_2%g_FD(id,jd,:,
c([3,3],.true.),0,0,0),grid_sol%loc_r_F,&
1309 ierr =
spline(grid_eq%loc_r_F,&
1310 &eq_2%jac_FD(id,jd,:,0,0,0),grid_sol%loc_r_F,&
1313 ierr =
spline(grid_eq%loc_r_F,&
1314 &eq_2%kappa_n(id,jd,:),grid_sol%loc_r_F,&
1317 ierr =
spline(grid_eq%loc_r_F,&
1318 &eq_2%kappa_g(id,jd,:),grid_sol%loc_r_F,&
1321 ierr =
spline(grid_eq%loc_r_F,&
1322 &eq_2%sigma(id,jd,:),grid_sol%loc_r_F,&
1327 ierr =
spline(grid_eq%loc_r_F,&
1328 &eq_2%S(id,jd,:),grid_sol%loc_r_F,&
1335 ierr =
spline(grid_eq%loc_r_F,eq_1%pres_FD(:,1),grid_sol%loc_r_F,&
1338 ierr =
spline(grid_eq%loc_r_F,eq_1%rho,grid_sol%loc_r_F,&
1341 do kd = 1,loc_dim(3)
1342 d2p(:,:,kd) = d2p(1,1,kd)
1343 rho(:,:,kd) = rho(1,1,kd)
1352 do jd = 1,grid_eq%n(2)
1353 do id = 1,grid_eq%n(1)
1354 ierr =
spline(grid_x%loc_r_F,&
1355 &grid_x%theta_F(id,jd,:),grid_sol%loc_r_F,&
1361 do jd = 1,grid_eq%n(2)
1362 do id = 1,grid_eq%n(1)
1363 ierr =
spline(grid_x%loc_r_F,&
1364 &grid_x%zeta_F(id,jd,:),grid_sol%loc_r_F,&
1371 ang_2(:,jd,:) =
alpha(jd)
1374 do jd = 1,grid_eq%n(2)
1375 do id = 1,grid_eq%n(1)
1376 ierr =
spline(grid_x%loc_r_F,&
1377 &grid_x%theta_F(id,jd,:),grid_sol%loc_r_F,&
1380 ierr =
spline(grid_x%loc_r_F,&
1381 &grid_x%zeta_F(id,jd,:),grid_sol%loc_r_F,&
1391 ang_1 = grid_x%theta_F
1393 ang_1 = grid_x%zeta_F
1396 ang_2(:,jd,:) =
alpha(jd)
1399 ang_1 = grid_x%theta_F
1400 ang_2 = grid_x%zeta_F
1403 norm = grid_sol%loc_r_F
1407 ierr =
calc_xuq(mds_x,mds_sol,grid_eq,grid_x,grid_sol,eq_1,eq_2,x,&
1408 &sol,x_id,kd,0._dp,xuq(:,:,:,kd))
1413 e_kin(:,:,:,1) = rho/h22*xuq(:,:,:,1)*conjg(xuq(:,:,:,1))
1417 &rho*h22*j**2/g33*xuq(:,:,:,2)*conjg(xuq(:,:,:,2))
1419 e_kin(:,:,:,2) = 0._dp
1421 err_msg =
'No normalization style associated with '//&
1428 e_pot(:,:,:,1) = 1._dp/
vac_perm*1._dp/h22*xuq(:,:,:,3)*&
1429 &conjg(xuq(:,:,:,3))
1430 e_pot(:,:,:,2) = 1._dp/
vac_perm*h22*j**2/g33*xuq(:,:,:,4)*&
1431 &conjg(xuq(:,:,:,4))
1432 e_pot(:,:,:,3) = -2*d2p*kappa_n*xuq(:,:,:,1)*conjg(xuq(:,:,:,1))
1433 e_pot(:,:,:,4) = -2*d2p*kappa_g*xuq(:,:,:,1)*conjg(xuq(:,:,:,2))
1434 e_pot(:,:,:,5) = -sigma*xuq(:,:,:,4)*conjg(xuq(:,:,:,1))
1435 e_pot(:,:,:,6) = sigma*xuq(:,:,:,3)*conjg(xuq(:,:,:,2))
1439 call writo(
'Testing whether the total potential energy is &
1440 &equal to the alternative form given in [ADD REF]')
1444 e_pot(:,:,:,3) = (-2*d2p*kappa_n+sigma*s)*&
1445 &xuq(:,:,:,1)*conjg(xuq(:,:,:,1))
1446 e_pot(:,:,:,4) = -sigma/j*2*rp(xuq(:,:,:,1)*conjg(du))
1447 e_pot(:,:,:,5:6) = 0._dp
1453 call writo(
'Plotting the squared amplitude of the normal &
1457 call plot_hdf5(
'X_norm',
'TEST_X_norm_POST_'//trim(
i2str(x_id)),&
1458 &rp(xuq(:,:,:,1)*conjg(xuq(:,:,:,1))),&
1459 &tot_dim=plot_dim,loc_offset=plot_offset)
1465 call writo(
'Testing whether DU is indeed the parallel &
1469 allocate(du_alt(loc_dim(1),loc_dim(2),loc_dim(3)))
1472 do kd = 1,loc_dim(3)
1473 do jd = 1,loc_dim(2)
1474 ierr =
spline(ang_1(:,jd,kd),xuq(:,jd,kd,2),ang_1(:,jd,kd),&
1482 &trim(
i2str(x_id)),rp(xuq(:,:,:,2)),tot_dim=plot_dim,&
1483 &loc_offset=plot_offset)
1485 &
'TEST_RE_DU_'//trim(
i2str(x_id)),plot_dim,&
1486 &plot_offset,descr=
'To test whether DU is &
1487 ¶llel derivative of U',output_message=.true.)
1491 &trim(
i2str(x_id)),ip(xuq(:,:,:,2)),tot_dim=plot_dim,&
1492 &loc_offset=plot_offset)
1494 &
'TEST_IM_DU_'//trim(
i2str(x_id)),plot_dim,&
1495 &plot_offset,descr=
'To test whether DU is &
1496 ¶llel derivative of U',output_message=.true.)
1505 ierr =
trim_grid(grid_sol,grid_sol_trim,norm_id)
1513 &ang_2(:,:,norm_id(1):norm_id(2)),norm(norm_id(1):norm_id(2)),&
1514 &j(:,:,norm_id(1):norm_id(2)),&
1515 &e_kin(:,:,norm_id(1):norm_id(2),:),e_kin_int)
1518 &ang_2(:,:,norm_id(1):norm_id(2)),norm(norm_id(1):norm_id(2)),&
1519 &j(:,:,norm_id(1):norm_id(2)),&
1520 &e_pot(:,:,norm_id(1):norm_id(2),:),e_pot_int(1:6))
1524 e_pot_int(7) = 0._dp
1525 write(*,*)
'¡¡¡¡¡ NO VACUUM !!!!!'
1529 e_pot_int(7) = e_pot_int(7) + &
1530 &conjg(sol%vec(kd,grid_sol%loc_n_r,x_id)) * &
1531 &vac%res(kd,jd) * sol%vec(jd,grid_sol%loc_n_r,x_id)
1538 ierr =
get_ser_var([e_kin_int(kd)],e_int_tot,scatter=.true.)
1540 e_kin_int(kd) = sum(e_int_tot)
1541 deallocate(e_int_tot)
1544 ierr =
get_ser_var([e_pot_int(kd)],e_int_tot,scatter=.true.)
1546 e_pot_int(kd) = sum(e_int_tot)
1547 deallocate(e_int_tot)
1551 call grid_sol_trim%dealloc()
1565 &remove_previous_arrs)
result(ierr)
1573 character(*),
parameter :: rout_name =
'print_output_sol'
1578 character(len=*),
intent(in) :: data_name
1579 integer,
intent(in),
optional :: rich_lvl
1580 logical,
intent(in),
optional :: remove_previous_arrs
1583 type(
var_1d_type),
allocatable,
target :: sol_1d(:)
1584 type(
var_1d_type),
pointer :: sol_1d_loc => null()
1592 if (
size(sol%val).gt.0)
then
1594 call writo(
'Write solution variables to output file')
1607 sol_1d_loc => sol_1d(id); id = id+1
1608 sol_1d_loc%var_name =
'RE_sol_val'
1609 allocate(sol_1d_loc%tot_i_min(1),sol_1d_loc%tot_i_max(1))
1610 allocate(sol_1d_loc%loc_i_min(1),sol_1d_loc%loc_i_max(1))
1611 sol_1d_loc%tot_i_min = [1]
1612 sol_1d_loc%tot_i_max = [
size(sol%val)]
1613 sol_1d_loc%loc_i_min = [1]
1614 sol_1d_loc%loc_i_max = [
size(sol%val)]
1615 allocate(sol_1d_loc%p(
size(sol%val)))
1616 sol_1d_loc%p = rp(sol%val)
1619 sol_1d_loc => sol_1d(id); id = id+1
1620 sol_1d_loc%var_name =
'IM_sol_val'
1621 allocate(sol_1d_loc%tot_i_min(1),sol_1d_loc%tot_i_max(1))
1622 allocate(sol_1d_loc%loc_i_min(1),sol_1d_loc%loc_i_max(1))
1623 sol_1d_loc%tot_i_min = [1]
1624 sol_1d_loc%tot_i_max = [
size(sol%val)]
1625 sol_1d_loc%loc_i_min = [1]
1626 sol_1d_loc%loc_i_max = [
size(sol%val)]
1627 allocate(sol_1d_loc%p(
size(sol%val)))
1628 sol_1d_loc%p = ip(sol%val)
1631 sol_1d_loc => sol_1d(id); id = id+1
1632 sol_1d_loc%var_name =
'RE_sol_vec'
1633 allocate(sol_1d_loc%tot_i_min(3),sol_1d_loc%tot_i_max(3))
1634 allocate(sol_1d_loc%loc_i_min(3),sol_1d_loc%loc_i_max(3))
1635 sol_1d_loc%loc_i_min = [1,grid_trim%i_min,1]
1636 sol_1d_loc%loc_i_max = [sol%n_mod,grid_trim%i_max,
size(sol%vec,3)]
1637 sol_1d_loc%tot_i_min = [1,1,1]
1638 sol_1d_loc%tot_i_max = [sol%n_mod,grid_trim%n(3),
size(sol%vec,3)]
1639 allocate(sol_1d_loc%p(
size(sol%vec)))
1640 sol_1d_loc%p = reshape(rp(sol%vec),[
size(sol%vec)])
1643 sol_1d_loc => sol_1d(id); id = id+1
1644 sol_1d_loc%var_name =
'IM_sol_vec'
1645 allocate(sol_1d_loc%tot_i_min(3),sol_1d_loc%tot_i_max(3))
1646 allocate(sol_1d_loc%loc_i_min(3),sol_1d_loc%loc_i_max(3))
1647 sol_1d_loc%loc_i_min = [1,grid_trim%i_min,1]
1648 sol_1d_loc%loc_i_max = [sol%n_mod,grid_trim%i_max,
size(sol%vec,3)]
1649 sol_1d_loc%tot_i_min = [1,1,1]
1650 sol_1d_loc%tot_i_max = [sol%n_mod,grid_trim%n(3),
size(sol%vec,3)]
1651 allocate(sol_1d_loc%p(
size(sol%vec)))
1652 sol_1d_loc%p = reshape(ip(sol%vec),[
size(sol%vec)])
1660 &trim(data_name),rich_lvl=rich_lvl,&
1661 &remove_previous_arrs=remove_previous_arrs)
1666 call grid_trim%dealloc()
1674 call writo(
'No solutions to write')