V3FIT
intpol.f
Go to the documentation of this file.
1 !*******************************************************************************
4 !
5 ! Note separating the Doxygen comment block here so detailed decription is
6 ! found in the Module not the file.
7 !
12 !*******************************************************************************
13 
14  MODULE intpol
15 
16  USE stel_kinds, only: rprec, dp
19  USE profiler
20  USE model
21  USE signal
22 
23  IMPLICIT NONE
24 !*******************************************************************************
25 ! intpol module parameters
26 !*******************************************************************************
28  REAL(rprec), PARAMETER :: intpol_polar_constant = 2.62e-13_dp
29 
30 !*******************************************************************************
31 ! DERIVED-TYPE DECLARATIONS
32 ! 1) intpol base class
33 !
34 !*******************************************************************************
35 !-------------------------------------------------------------------------------
39 !-------------------------------------------------------------------------------
40  TYPE, EXTENDS(signal_class) :: intpol_class
42  TYPE (vertex), POINTER :: chord_path => null()
43  CONTAINS
44  PROCEDURE :: &
45  & get_modeled_signal_last => intpol_get_modeled_signal
46  PROCEDURE :: &
47  & get_type=> intpol_get_type
48  PROCEDURE :: get_gp_i => intpol_get_gp_i
49  PROCEDURE :: get_gp_s => intpol_get_gp_s
50  PROCEDURE :: get_gp_x => intpol_get_gp_x
51  final :: intpol_destruct
52  END TYPE
53 
54 !-------------------------------------------------------------------------------
58 !-------------------------------------------------------------------------------
59  TYPE, EXTENDS(intpol_class) :: intpol_pol_class
61  REAL (rprec) :: wavelength
63  LOGICAL :: in_degrees
64  CONTAINS
65  PROCEDURE :: &
66  & get_modeled_signal_last => intpol_pol_get_modeled_signal
67  PROCEDURE :: get_gp_i => intpol_pol_get_gp_i
68  PROCEDURE :: get_gp_s => intpol_pol_get_gp_s
69  PROCEDURE :: get_gp_x => intpol_pol_get_gp_x
70  final :: intpol_pol_destruct
71  END TYPE
72 
73 !-------------------------------------------------------------------------------
76 !-------------------------------------------------------------------------------
79  TYPE (model_class), POINTER :: model => null()
81  INTEGER :: i
83  INTEGER :: flags = model_state_all_off
84  END TYPE
85 
86 !-------------------------------------------------------------------------------
89 !-------------------------------------------------------------------------------
92  TYPE (model_class), POINTER :: model => null()
94  class(signal_class), POINTER :: signal => null()
96  INTEGER :: flags = model_state_all_off
97  END TYPE
98 
99 !-------------------------------------------------------------------------------
102 !-------------------------------------------------------------------------------
105  TYPE (model_class), POINTER :: model => null()
107  REAL (rprec), DIMENSION(3) :: xcart
108  END TYPE
109 
110 !*******************************************************************************
111 ! INTERFACE BLOCKS
112 !*******************************************************************************
113 !-------------------------------------------------------------------------------
115 !-------------------------------------------------------------------------------
116  INTERFACE intpol_class
117  MODULE PROCEDURE intpol_construct
118  END INTERFACE
119 
120 !-------------------------------------------------------------------------------
122 !-------------------------------------------------------------------------------
123  INTERFACE intpol_pol_class
124  MODULE PROCEDURE intpol_pol_construct
125  END INTERFACE
126 
127 !-------------------------------------------------------------------------------
129 !-------------------------------------------------------------------------------
130 
131  PRIVATE :: int_function, pol_function, gp_function_i, &
132  & gp_function_x
133 
134  CONTAINS
135 !*******************************************************************************
136 ! CONSTRUCTION SUBROUTINES
137 !*******************************************************************************
138 !-------------------------------------------------------------------------------
146 !-------------------------------------------------------------------------------
147  FUNCTION intpol_construct(chord_paths)
148 
149  IMPLICIT NONE
150 
151 ! Declare Arguments
152  class(intpol_class), POINTER :: intpol_construct
153  REAL (rprec), DIMENSION(:,:) :: chord_paths
154 
155 ! local variables
156  INTEGER :: i
157  REAL (rprec) :: start_time
158 
159 ! Start of executable code
160  start_time = profiler_get_start_time()
161 
162  ALLOCATE(intpol_construct)
163 
164  DO i = 1, SIZE(chord_paths, 1)
165  CALL path_append_vertex(intpol_construct%chord_path, &
166  & chord_paths(i,:))
167  END DO
168 
169  CALL profiler_set_stop_time('intpol_construct', start_time)
170 
171  END FUNCTION
172 
173 !-------------------------------------------------------------------------------
184 !-------------------------------------------------------------------------------
185  FUNCTION intpol_pol_construct(wavelength, in_degrees, chord_paths)
186 
187  IMPLICIT NONE
188 
189 ! Declare Arguments
190  class(intpol_pol_class), POINTER :: intpol_pol_construct
191  REAL (rprec), INTENT(in) :: wavelength
192  LOGICAL, INTENT(in) :: in_degrees
193  REAL (rprec), DIMENSION(:,:) :: chord_paths
194 
195 ! local variables
196  INTEGER :: i
197  REAL (rprec) :: start_time
198 
199 ! Start of executable code
200  start_time = profiler_get_start_time()
201 
202  ALLOCATE(intpol_pol_construct)
203 
204  DO i = 1, SIZE(chord_paths, 1)
205  CALL path_append_vertex(intpol_pol_construct%chord_path, &
206  & chord_paths(i,:))
207  END DO
208 
209  intpol_pol_construct%wavelength = wavelength
210  intpol_pol_construct%in_degrees = in_degrees
211 
212  CALL profiler_set_stop_time('intpol_pol_construct', start_time)
213 
214  END FUNCTION
215 
216 !*******************************************************************************
217 ! DESTRUCTION SUBROUTINES
218 !*******************************************************************************
219 !-------------------------------------------------------------------------------
225 !-------------------------------------------------------------------------------
226  SUBROUTINE intpol_destruct(this)
227 
228  IMPLICIT NONE
229 
230 ! Declare Arguments
231  TYPE (intpol_class), INTENT(inout) :: this
232 
233 ! Start of executable code
234 
235  IF (ASSOCIATED(this%chord_path)) THEN
236  CALL path_destruct(this%chord_path)
237  this%chord_path => null()
238  END IF
239 
240  END SUBROUTINE
241 
242 !-------------------------------------------------------------------------------
248 !-------------------------------------------------------------------------------
249  SUBROUTINE intpol_pol_destruct(this)
250 
251  IMPLICIT NONE
252 
253 ! Declare Arguments
254  TYPE (intpol_pol_class), INTENT(inout) :: this
255 
256 ! Start of executable code
257  this%wavelength = 0
258  this%in_degrees = .false.
259 
260  END SUBROUTINE
261 
262 !*******************************************************************************
263 ! GETTER SUBROUTINES
264 !*******************************************************************************
265 !-------------------------------------------------------------------------------
276 !-------------------------------------------------------------------------------
277  FUNCTION intpol_get_modeled_signal(this, a_model, sigma, &
278  & last_value)
279 
280  IMPLICIT NONE
281 
282 ! Declare Arguments
283  REAL (rprec), DIMENSION(4) :: intpol_get_modeled_signal
284  class(intpol_class), INTENT(inout) :: this
285  TYPE (model_class), POINTER :: a_model
286  REAL (rprec), DIMENSION(4), INTENT(out) :: sigma
287  REAL (rprec), DIMENSION(4), INTENT(in) :: last_value
288 
289 ! local variables
290  CHARACTER(len=1), ALLOCATABLE :: context(:)
291  INTEGER :: context_length
292  REAL (rprec) :: start_time
293 
294 ! Start of executable code
295  start_time = profiler_get_start_time()
296 
297  sigma = 0.0
298 
299  IF (btest(a_model%state_flags, model_state_vmec_flag) .or. &
300  & btest(a_model%state_flags, model_state_siesta_flag) .or. &
301  & btest(a_model%state_flags, model_state_ne_flag) .or. &
302  & btest(a_model%state_flags, model_state_shift_flag) .or. &
303  & btest(a_model%state_flags, model_state_signal_flag)) THEN
304 
305 ! Cast model into a data to a context. This is the equivalent to casting to a
306 ! void pointer in C.
307  context_length = SIZE(transfer(a_model, context))
308  ALLOCATE(context(context_length))
309  context = transfer(a_model, context)
310 
312  & path_integrate(a_model%int_params, this%chord_path, &
313  & int_function, context)
314 
315  DEALLOCATE(context)
316 
317  CALL this%scale_and_offset(a_model, &
319  ELSE
320  intpol_get_modeled_signal = last_value
321  END IF
322 
323  CALL profiler_set_stop_time('intpol_get_modeled_signal', &
324  & start_time)
325 
326  END FUNCTION
327 
328 !-------------------------------------------------------------------------------
339 !-------------------------------------------------------------------------------
340  FUNCTION intpol_pol_get_modeled_signal(this, a_model, sigma, &
341  & last_value)
342 
343  IMPLICIT NONE
344 
345 ! Declare Arguments
346  REAL (rprec), DIMENSION(4) :: intpol_pol_get_modeled_signal
347  CLASS (intpol_pol_class), INTENT(inout) :: this
348  TYPE (model_class), POINTER :: a_model
349  REAL (rprec), DIMENSION(4), INTENT(out) :: sigma
350  REAL (rprec), DIMENSION(4), INTENT(in) :: last_value
351 
352 ! local variables
353  CHARACTER(len=1), ALLOCATABLE :: context(:)
354  INTEGER :: context_length
355  REAL (rprec) :: start_time
356 
357 ! Start of executable code
358  start_time = profiler_get_start_time()
359 
360  sigma = 0.0
361 
362  IF (btest(a_model%state_flags, model_state_vmec_flag) .or. &
363  & btest(a_model%state_flags, model_state_siesta_flag) .or. &
364  & btest(a_model%state_flags, model_state_ne_flag) .or. &
365  & btest(a_model%state_flags, model_state_shift_flag) .or. &
366  & btest(a_model%state_flags, model_state_signal_flag)) THEN
367 
368 ! Cast model into a data to a context. This is the equivalent to casting to a
369 ! void pointer in C.
370  context_length = SIZE(transfer(a_model, context))
371  ALLOCATE(context(context_length))
372  context = transfer(a_model, context)
373 
375  & intpol_polar_constant*(this%wavelength**2.0_dp) * &
376  & path_integrate(a_model%int_params, this%chord_path, &
377  & pol_function, context)
378  IF (this%in_degrees) THEN
381  END IF
382 
383  DEALLOCATE(context)
384 
385  CALL this%scale_and_offset(a_model, &
387  ELSE
388  intpol_pol_get_modeled_signal = last_value
389  END IF
390 
391  CALL profiler_set_stop_time('intpol_pol_get_modeled_signal', &
392  & start_time)
393 
394  END FUNCTION
395 
396 !-------------------------------------------------------------------------------
403 !-------------------------------------------------------------------------------
404  FUNCTION intpol_get_type(this)
406 
407  IMPLICIT NONE
408 
409 ! Declare Arguments
410  CHARACTER (len=data_name_length) :: intpol_get_type
411  CLASS (intpol_class), INTENT(in) :: this
412 
413 ! local variables
414  REAL (rprec) :: start_time
415 
416 ! Start of executable code
417  start_time = profiler_get_start_time()
418 
419  intpol_get_type = 'ipch'
420 
421  CALL profiler_set_stop_time('intpol_get_type', start_time)
422 
423  END FUNCTION
424 
425 !-------------------------------------------------------------------------------
437 !-------------------------------------------------------------------------------
438  FUNCTION intpol_get_gp_i(this, a_model, i, flags)
439 
440  IMPLICIT NONE
441 
442 ! Declare Arguments
443  REAL (rprec) :: intpol_get_gp_i
444  CLASS (intpol_class), INTENT(in) :: this
445  TYPE (model_class), POINTER :: a_model
446  INTEGER, INTENT(in) :: i
447  INTEGER, INTENT(in) :: flags
448 
449 ! local variables
450  CHARACTER(len=1), ALLOCATABLE :: context(:)
451  INTEGER :: context_length
452  TYPE (intpol_gp_context_i) :: gp_context
453  REAL (rprec) :: start_time
454 
455 ! Start of executable code
456  start_time = profiler_get_start_time()
457 
458 ! The relevant data for the guassian process context.
459  gp_context%model => a_model
460  gp_context%i = i
461  gp_context%flags = flags
462 
463 ! Cast model into a data to a context. This is the equivalent to casting to a
464 ! void pointer in C.
465  context_length = SIZE(transfer(gp_context, context))
466  ALLOCATE(context(context_length))
467  context = transfer(gp_context, context)
468 
469  intpol_get_gp_i = path_integrate(a_model%int_params, &
470  & this%chord_path, gp_function_i, &
471  & context)
472 
473  DEALLOCATE(context)
474 
475  CALL this%scale_and_offset(a_model, intpol_get_gp_i)
476 
477  CALL profiler_set_stop_time('intpol_get_gp_i', start_time)
478 
479  END FUNCTION
480 
481 !-------------------------------------------------------------------------------
494 !-------------------------------------------------------------------------------
495  FUNCTION intpol_get_gp_s(this, a_model, signal, flags)
496 
497  IMPLICIT NONE
498 
499 ! Declare Arguments
500  REAL (rprec) :: intpol_get_gp_s
501  CLASS (intpol_class), INTENT(in) :: this
502  TYPE (model_class), POINTER :: a_model
503  class(signal_class), POINTER :: signal
504  INTEGER, INTENT(in) :: flags
505 
506 ! local variables
507  CHARACTER(len=1), ALLOCATABLE :: context(:)
508  INTEGER :: context_length
509  TYPE (intpol_gp_context_s) :: gp_context
510  REAL (rprec) :: start_time
511 
512 ! Start of executable code
513  start_time = profiler_get_start_time()
514 
515  gp_context%model => a_model
516  gp_context%signal => signal
517  gp_context%flags = flags
518 
519 ! Cast model into a data to a context. This is the equivalent to casting to a
520 ! void pointer in C.
521  context_length = SIZE(transfer(gp_context, context))
522  ALLOCATE(context(context_length))
523  context = transfer(gp_context, context)
524 
525  intpol_get_gp_s = path_integrate(a_model%int_params, &
526  & this%chord_path, gp_function_s, &
527  & context)
528 
529  DEALLOCATE(context)
530 
531  CALL this%scale_and_offset(a_model, intpol_get_gp_s)
532 
533  CALL profiler_set_stop_time('intpol_get_gp_s', start_time)
534 
535  END FUNCTION
536 
537 !-------------------------------------------------------------------------------
549 !-------------------------------------------------------------------------------
550  FUNCTION intpol_get_gp_x(this, a_model, x_cart, flags)
551 
552  IMPLICIT NONE
553 
554 ! Declare Arguments
555  REAL (rprec) :: intpol_get_gp_x
556  CLASS (intpol_class), INTENT(in) :: this
557  TYPE (model_class), POINTER :: a_model
558  REAL (rprec), DIMENSION(3), INTENT(in) :: x_cart
559  INTEGER, INTENT(in) :: flags
560 
561 ! local variables
562  REAL (rprec) :: start_time
563  CHARACTER(len=1), ALLOCATABLE :: context(:)
564  INTEGER :: context_length
565  TYPE (intpol_gp_context_x) :: gp_context
566 
567 ! Start of executable code
568  start_time = profiler_get_start_time()
569 
570  gp_context%model => a_model
571  gp_context%xcart = x_cart
572 
573 ! Cast model into a data context. This is the equivalent to casting to a void
574 ! pointer in C.
575  context_length = SIZE(transfer(gp_context, context))
576  ALLOCATE(context(context_length))
577  context = transfer(gp_context, context)
578 
579  intpol_get_gp_x = path_integrate(a_model%int_params, &
580  & this%chord_path, gp_function_x,
581  & context)
582 
583  DEALLOCATE(context)
584 
585  CALL this%scale_and_offset(a_model, intpol_get_gp_x)
586 
587  CALL profiler_set_stop_time('intpol_get_gp_x', start_time)
588 
589  END FUNCTION
590 
591 !-------------------------------------------------------------------------------
603 !-------------------------------------------------------------------------------
604  FUNCTION intpol_pol_get_gp_i(this, a_model, i, flags)
605 
606  IMPLICIT NONE
607 
608 ! Declare Arguments
609  REAL (rprec) :: intpol_pol_get_gp_i
610  CLASS (intpol_pol_class), INTENT(in) :: this
611  TYPE (model_class), POINTER :: a_model
612  INTEGER, INTENT(in) :: i
613  INTEGER, INTENT(in) :: flags
614 
615 ! local variables
616  CHARACTER(len=1), ALLOCATABLE :: context(:)
617  INTEGER :: context_length
618  TYPE (intpol_gp_context_i) :: gp_context
619  REAL (rprec) :: start_time
620 
621 ! Start of executable code
622  start_time = profiler_get_start_time()
623 
624 ! The relevant data for the guassian process context.
625  gp_context%model => a_model
626  gp_context%i = i
627  gp_context%flags = flags
628 
629 ! Cast model into a data to a context. This is the equivalent to casting to a
630 ! void pointer in C.
631  context_length = SIZE(transfer(gp_context, context))
632  ALLOCATE(context(context_length))
633  context = transfer(gp_context, context)
634 
636  & * (this%wavelength**2.0_dp) &
637  & * path_integrate(a_model%int_params, &
638  & this%chord_path, &
639  & gp_pol_function_i, &
640  & context)
641 
642  DEALLOCATE(context)
643 
644  IF (this%in_degrees) THEN
646  END IF
647  CALL this%scale_and_offset(a_model, intpol_pol_get_gp_i)
648 
649  CALL profiler_set_stop_time('intpol_pol_get_gp_i', start_time)
650 
651  END FUNCTION
652 
653 !-------------------------------------------------------------------------------
666 !-------------------------------------------------------------------------------
667  FUNCTION intpol_pol_get_gp_s(this, a_model, signal, flags)
668 
669  IMPLICIT NONE
670 
671 ! Declare Arguments
672  REAL (rprec) :: intpol_pol_get_gp_s
673  CLASS (intpol_pol_class), INTENT(in) :: this
674  TYPE (model_class), POINTER :: a_model
675  class(signal_class), POINTER :: signal
676  INTEGER, INTENT(in) :: flags
677 
678 ! local variables
679  CHARACTER(len=1), ALLOCATABLE :: context(:)
680  INTEGER :: context_length
681  TYPE (intpol_gp_context_s) :: gp_context
682  REAL (rprec) :: start_time
683 
684 ! Start of executable code
685  start_time = profiler_get_start_time()
686 
687 ! The relevant data for the guassian process context.
688  gp_context%model => a_model
689  gp_context%signal => signal
690  gp_context%flags = flags
691 
692 ! Cast model into a data to a context. This is the equivalent to casting to a
693 ! void pointer in C.
694  context_length = SIZE(transfer(gp_context, context))
695  ALLOCATE(context(context_length))
696  context = transfer(gp_context, context)
697 
699  & * (this%wavelength**2.0_dp) &
700  & * path_integrate(a_model%int_params, &
701  & this%chord_path, &
702  & gp_pol_function_s, &
703  & context)
704 
705  DEALLOCATE(context)
706 
707  IF (this%in_degrees) THEN
709  END IF
710  CALL this%scale_and_offset(a_model, intpol_pol_get_gp_s)
711 
712  CALL profiler_set_stop_time('intpol_pol_get_gp_s', start_time)
713 
714  END FUNCTION
715 
716 !-------------------------------------------------------------------------------
728 !-------------------------------------------------------------------------------
729  FUNCTION intpol_pol_get_gp_x(this, a_model, x_cart, flags)
730 
731  IMPLICIT NONE
732 
733 ! Declare Arguments
734  REAL (rprec) :: intpol_pol_get_gp_x
735  CLASS (intpol_pol_class), INTENT(in) :: this
736  TYPE (model_class), POINTER :: a_model
737  REAL (rprec), DIMENSION(3), INTENT(in) :: x_cart
738  INTEGER, INTENT(in) :: flags
739 
740 ! local variables
741  REAL (rprec) :: start_time
742  CHARACTER(len=1), ALLOCATABLE :: context(:)
743  INTEGER :: context_length
744  TYPE (intpol_gp_context_x) :: gp_context
745 
746 ! Start of executable code
747  start_time = profiler_get_start_time()
748 
749  gp_context%model => a_model
750  gp_context%xcart = x_cart
751 
752 ! Cast model into a data context. This is the equivalent to casting to a void
753 ! pointer in C.
754  context_length = SIZE(transfer(gp_context, context))
755  ALLOCATE(context(context_length))
756  context = transfer(gp_context, context)
757 
759  & * (this%wavelength**2.0_dp) &
760  & * path_integrate(a_model%int_params, &
761  & this%chord_path, &
762  & gp_pol_function_x, &
763  & context)
764 
765  DEALLOCATE(context)
766 
767  IF (this%in_degrees) THEN
769  END IF
770  CALL this%scale_and_offset(a_model, intpol_pol_get_gp_x)
771 
772  CALL profiler_set_stop_time('intpol_pol_get_gp_x', start_time)
773 
774  END FUNCTION
775 
776 !*******************************************************************************
777 ! PRIVATE
778 !*******************************************************************************
779 !-------------------------------------------------------------------------------
794 !-------------------------------------------------------------------------------
795  FUNCTION int_function(context, xcart, dxcart, length, dx)
796 
797  IMPLICIT NONE
798 
799 ! Declare Arguments
800  CHARACTER (len=1), INTENT(in) :: context(:)
801  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
802  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
803  REAL (rprec), INTENT(in) :: length
804  REAL (rprec), INTENT(in) :: dx
805  REAL (rprec) :: int_function
806 
807 ! local variables
808  TYPE (model_class) :: a_model
809  REAL (rprec) :: start_time
810 
811 ! Start of executable code
812  start_time = profiler_get_start_time()
813 
814  a_model = transfer(context, a_model)
815  int_function = model_get_ne(a_model, xcart)*dx
816 
817  CALL profiler_set_stop_time('int_function', start_time)
818 
819  END FUNCTION
820 
821 !-------------------------------------------------------------------------------
838 !-------------------------------------------------------------------------------
839  FUNCTION pol_function(context, xcart, dxcart, length, dx)
840 
841  IMPLICIT NONE
842 
843 ! Declare Arguments
844  CHARACTER (len=1), INTENT(in) :: context(:)
845  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
846  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
847  REAL (rprec), INTENT(in) :: length
848  REAL (rprec), INTENT(in) :: dx
849  REAL (rprec) :: pol_function
850 
851 ! local variables
852  TYPE (model_class) :: a_model
853  REAL (rprec), DIMENSION(3) :: bcart
854  REAL (rprec) :: start_time
855 
856 ! Start of executable code
857  start_time = profiler_get_start_time()
858 
859  a_model = transfer(context, a_model)
860 
861  bcart = equilibrium_get_b_vec(a_model%equilibrium, xcart, .false.)
862  pol_function = &
863  & model_get_ne(a_model, xcart)*dot_product(bcart, dxcart)
864 
865  CALL profiler_set_stop_time('pol_function', start_time)
866 
867  END FUNCTION
868 
869 !-------------------------------------------------------------------------------
887 !-------------------------------------------------------------------------------
888  FUNCTION gp_function_i(context, xcart, dxcart, length, dx)
889 
890  IMPLICIT NONE
891 
892 ! Declare Arguments
893  REAL (rprec) :: gp_function_i
894  CHARACTER (len=1), INTENT(in) :: context(:)
895  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
896  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
897  REAL (rprec), INTENT(in) :: length
898  REAL (rprec), INTENT(in) :: dx
899 
900 ! local variables
901  TYPE (intpol_gp_context_i) :: gp_context
902  REAL (rprec) :: start_time
903 
904 ! Start of executable code
905  start_time = profiler_get_start_time()
906 
907  gp_context = transfer(context, gp_context)
908  gp_function_i = model_get_gp_ne(gp_context%model, xcart, &
909  & gp_context%i)*dx
910 
911  CALL profiler_set_stop_time('gp_function_i', start_time)
912 
913  END FUNCTION
914 
915 !-------------------------------------------------------------------------------
933 !-------------------------------------------------------------------------------
934  FUNCTION gp_pol_function_i(context, xcart, dxcart, length, dx)
935 
936  IMPLICIT NONE
937 
938 ! Declare Arguments
939  REAL (rprec) :: gp_pol_function_i
940  CHARACTER (len=1), INTENT(in) :: context(:)
941  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
942  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
943  REAL (rprec), INTENT(in) :: length
944  REAL (rprec), INTENT(in) :: dx
945 
946 ! local variables
947  TYPE (intpol_gp_context_i) :: gp_context
948  REAL (rprec), DIMENSION(3) :: bcart
949  REAL (rprec) :: start_time
950 
951 ! Start of executable code
952  start_time = profiler_get_start_time()
953 
954  gp_context = transfer(context, gp_context)
955  bcart = equilibrium_get_b_vec(gp_context%model%equilibrium, xcart, &
956  & .false.)
957  gp_pol_function_i = model_get_gp_ne(gp_context%model, xcart, &
958  & gp_context%i) *
959  & * dot_product(bcart, dxcart)
960 
961  CALL profiler_set_stop_time('gp_pol_function_i', start_time)
962 
963  END FUNCTION
964 
965 !-------------------------------------------------------------------------------
982 !-------------------------------------------------------------------------------
983  FUNCTION gp_function_s(context, xcart, dxcart, length, dx)
984 
985  IMPLICIT NONE
986 
987 ! Declare Arguments
988  REAL (rprec) :: gp_function_s
989  CHARACTER (len=1), INTENT(in) :: context(:)
990  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
991  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
992  REAL (rprec), INTENT(in) :: length
993  REAL (rprec), INTENT(in) :: dx
994 
995 ! local variables
996  TYPE (intpol_gp_context_s) :: gp_context
997  REAL (rprec) :: start_time
998 
999 ! Start of executable code
1000  start_time = profiler_get_start_time()
1001 
1002  gp_context = transfer(context, gp_context)
1003  gp_function_s = gp_context%signal%get_gp(gp_context%model, xcart, &
1004  & gp_context%flags)*dx
1005 
1006  CALL profiler_set_stop_time('gp_function_s', start_time)
1007 
1008  END FUNCTION
1009 
1010 !-------------------------------------------------------------------------------
1027 !-------------------------------------------------------------------------------
1028  FUNCTION gp_pol_function_s(context, xcart, dxcart, length, dx)
1030  IMPLICIT NONE
1031 
1032 ! Declare Arguments
1033  REAL (rprec) :: gp_pol_function_s
1034  CHARACTER (len=1), INTENT(in) :: context(:)
1035  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
1036  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
1037  REAL (rprec), INTENT(in) :: length
1038  REAL (rprec), INTENT(in) :: dx
1039 
1040 ! local variables
1041  TYPE (intpol_gp_context_s) :: gp_context
1042  REAL (rprec), DIMENSION(3) :: bcart
1043  REAL (rprec) :: start_time
1044 
1045 ! Start of executable code
1046  start_time = profiler_get_start_time()
1047 
1048  gp_context = transfer(context, gp_context)
1049  bcart = equilibrium_get_b_vec(gp_context%model%equilibrium, xcart, &
1050  & .false.)
1051  gp_pol_function_s = gp_context%signal%get_gp(gp_context%model, &
1052  & xcart, &
1053  & gp_context%flags) &
1054  & * dot_product(bcart, dxcart)
1055 
1056  CALL profiler_set_stop_time('gp_pol_function_s', start_time)
1057 
1058  END FUNCTION
1059 
1060 !-------------------------------------------------------------------------------
1074 !-------------------------------------------------------------------------------
1075  FUNCTION gp_function_x(context, xcart, dxcart, length, dx)
1077  IMPLICIT NONE
1078 
1079 ! Declare Arguments
1080  REAL (rprec) :: gp_function_x
1081  CHARACTER (len=1), INTENT(in) :: context(:)
1082  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
1083  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
1084  REAL (rprec), INTENT(in) :: length
1085  REAL (rprec), INTENT(in) :: dx
1086 
1087 ! local variables
1088  TYPE (intpol_gp_context_x) :: gp_context
1089  REAL (rprec) :: start_time
1090 
1091 ! Start of executable code
1092  start_time = profiler_get_start_time()
1093 
1094 ! This is the second signal so put xcart in the second position.
1095  gp_context = transfer(context, gp_context)
1096  gp_function_x = model_get_gp_ne(gp_context%model, &
1097  & xcart, gp_context%xcart)*dx
1098 
1099  CALL profiler_set_stop_time('gp_function_x', start_time)
1100 
1101  END FUNCTION
1102 
1103 !-------------------------------------------------------------------------------
1117 !-------------------------------------------------------------------------------
1118  FUNCTION gp_pol_function_x(context, xcart, dxcart, length, dx)
1120  IMPLICIT NONE
1121 
1122 ! Declare Arguments
1123  REAL (rprec) :: gp_pol_function_x
1124  CHARACTER (len=1), INTENT(in) :: context(:)
1125  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
1126  REAL (rprec), DIMENSION(3), INTENT(in) :: dxcart
1127  REAL (rprec), INTENT(in) :: length
1128  REAL (rprec), INTENT(in) :: dx
1129 
1130 ! local variables
1131  TYPE (intpol_gp_context_x) :: gp_context
1132  REAL (rprec), DIMENSION(3) :: bcart
1133  REAL (rprec) :: start_time
1134 
1135 ! Start of executable code
1136  start_time = profiler_get_start_time()
1137 
1138 ! This is the second signal so put xcart in the second position.
1139  gp_context = transfer(context, gp_context)
1140  bcart = equilibrium_get_b_vec(gp_context%model%equilibrium, xcart, &
1141  & .false.)
1142  gp_pol_function_x = model_get_gp_ne(gp_context%model, &
1143  & xcart, gp_context%xcart) &
1144  & * dot_product(bcart, dxcart)
1145 
1146  CALL profiler_set_stop_time('gp_pol_function_x', start_time)
1147 
1148  END FUNCTION
1149 
1150  END MODULE
intpol::gp_function_s
real(rprec) function gp_function_s(context, xcart, dxcart, length, dx)
Interferometry gaussian process callback function for signal signal kernel evaluation.
Definition: intpol.f:984
intpol
Implements interferometry/polarimetry diagnostic. Defines the base class of the type intpol_class.
Definition: intpol.f:14
intpol::intpol_get_modeled_signal
real(rprec) function, dimension(4) intpol_get_modeled_signal(this, a_model, sigma, last_value)
Calculates the interferometry signal.
Definition: intpol.f:279
profiler
Defines functions for measuring an tabulating performance of function and subroutine calls....
Definition: profiler.f:13
coordinate_utilities
Module is part of the LIBSTELL. This modules containes code to convert from different coordinate syst...
Definition: coordinate_utilities.f:12
intpol::intpol_pol_class
Base class representing a polarimetry signal.
Definition: intpol.f:59
intpol::intpol_pol_get_gp_x
real(rprec) function intpol_pol_get_gp_x(this, a_model, x_cart, flags)
Gets the guassian process kernel for a polarimetry signal and a cartesian position.
Definition: intpol.f:730
intpol::int_function
real(rprec) function, private int_function(context, xcart, dxcart, length, dx)
Interferometer callback function.
Definition: intpol.f:796
model::model_get_ne
Interface for the model density profile values.
Definition: model.f:223
model
Defines the base class of the type model_class. The model contains information not specific to the eq...
Definition: model.f:59
intpol::intpol_get_gp_i
real(rprec) function intpol_get_gp_i(this, a_model, i, flags)
Gets the guassian process kernel for an inteferometry signal and a position.
Definition: intpol.f:439
intpol::intpol_get_type
character(len=data_name_length) function intpol_get_type(this)
Gets a discription of the intpol type.
Definition: intpol.f:405
vertex
A vertex.
Definition: vertex.hpp:21
intpol::pol_function
real(rprec) function, private pol_function(context, xcart, dxcart, length, dx)
Polarmetry callback function.
Definition: intpol.f:840
intpol::gp_pol_function_i
real(rprec) function gp_pol_function_i(context, xcart, dxcart, length, dx)
Electron density gaussian process callback function for signal point kernel evaluation for a polarime...
Definition: intpol.f:935
intpol::intpol_gp_context_x
Structure to hold all memory needed to be sent to the guassian process callback function for position...
Definition: intpol.f:103
intpol::gp_function_x
real(rprec) function, private gp_function_x(context, xcart, dxcart, length, dx)
Interferometry gaussian process callback function for kernel evaluation of two positions.
Definition: intpol.f:1076
integration_path
Module is part of the LIBSTELL. This modules contains code to define and integrate along an arbitray ...
Definition: integration_path.f:12
intpol::intpol_class
Base class representing a interferometer signal.
Definition: intpol.f:40
profiler::profiler_get_start_time
real(rprec) function profiler_get_start_time()
Gets the start time of profiled function.
Definition: profiler.f:194
model::model_class
Base class representing a model.
Definition: model.f:141
intpol::intpol_pol_get_gp_s
real(rprec) function intpol_pol_get_gp_s(this, a_model, signal, flags)
Gets the guassian process kernel for an polarimetry signal and a signal.
Definition: intpol.f:668
intpol::intpol_destruct
subroutine intpol_destruct(this)
Deconstruct a intpol_class object.
Definition: intpol.f:227
intpol::intpol_pol_construct
class(intpol_pol_class) function, pointer intpol_pol_construct(wavelength, in_degrees, chord_paths)
Construct a intpol_class object representing a polarimetry diagnostic.
Definition: intpol.f:186
intpol::gp_pol_function_s
real(rprec) function gp_pol_function_s(context, xcart, dxcart, length, dx)
Polarimetry gaussian process callback function for signal signal kernel evaluation.
Definition: intpol.f:1029
integration_path::path_integrate
recursive real(rprec) function path_integrate(this, path, integration_function, context)
Integrate along the path.
Definition: integration_path.f:293
intpol::intpol_get_gp_s
real(rprec) function intpol_get_gp_s(this, a_model, signal, flags)
Gets the guassian process kernel for an inteferometry signal and a signal.
Definition: intpol.f:496
integration_path::path_append_vertex
recursive subroutine path_append_vertex(this, position)
Append a vertex to a path.
Definition: integration_path.f:253
intpol::intpol_get_gp_x
real(rprec) function intpol_get_gp_x(this, a_model, x_cart, flags)
Gets the guassian process kernel for a inteferometry signal and a cartesian position.
Definition: intpol.f:551
intpol::intpol_gp_context_i
Structure to hold all memory needed to be sent to the guassian process callback function of a point.
Definition: intpol.f:77
model::model_get_gp_ne
Interface for the model guassian process density profile values.
Definition: model.f:231
data_parameters
This modules contains parameters used by equilibrium models.
Definition: data_parameters.f:10
intpol::intpol_gp_context_s
Structure to hold all memory needed to be sent to the guassian process callback function for signal.
Definition: intpol.f:90
intpol::intpol_construct
class(intpol_class) function, pointer intpol_construct(chord_paths)
Interface to get the guassian process kernel values.
Definition: intpol.f:148
intpol::intpol_pol_get_modeled_signal
real(rprec) function, dimension(4) intpol_pol_get_modeled_signal(this, a_model, sigma, last_value)
Calculates the polarimetry signal.
Definition: intpol.f:342
profiler::profiler_set_stop_time
subroutine profiler_set_stop_time(symbol_name, start_time)
Gets the end time of profiled function.
Definition: profiler.f:121
intpol::intpol_polar_constant
real(rprec), parameter intpol_polar_constant
Constant term for the polarimety.
Definition: intpol.f:28
signal::signal_class
Base class representing a signal.
Definition: signal.f:33
intpol::gp_function_i
real(rprec) function, private gp_function_i(context, xcart, dxcart, length, dx)
Electron density gaussian process callback function for signal point kernel evaluation.
Definition: intpol.f:889
intpol::intpol_pol_get_gp_i
real(rprec) function intpol_pol_get_gp_i(this, a_model, i, flags)
Gets the guassian process kernel for an polarimetry signal and a position.
Definition: intpol.f:605
integration_path::path_destruct
Destruct interface using either path_destruct_int or path_destruct_vertex.
Definition: integration_path.f:84
intpol::intpol_pol_destruct
subroutine intpol_pol_destruct(this)
Deconstruct a intpol_class object.
Definition: intpol.f:250
signal
Defines the base class of the type signal_class.
Definition: signal.f:14
intpol::gp_pol_function_x
real(rprec) function gp_pol_function_x(context, xcart, dxcart, length, dx)
Polarimetry gaussian process callback function for kernel evaluation of two positions.
Definition: intpol.f:1119