V3FIT
thomson.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 thomson
15 
16  USE stel_kinds, only: rprec
17  USE mpi_inc
18  USE profiler
19  USE model
20  USE signal
21 
22  IMPLICIT NONE
23 
24 !*******************************************************************************
25 ! thomson module parameters
26 !*******************************************************************************
28  CHARACTER (len=*), PARAMETER :: &
29  & thomson_p_error = 'Guassian processes are not supported ' // &
30  & 'for thomson pressure measurements.'
31 
32 !*******************************************************************************
33 ! DERIVED-TYPE DECLARATIONS
34 ! 1) thomson base class
35 ! 2) thomson te class
36 ! 3) thomson ne class
37 ! 4) thomson p class
38 !
39 !*******************************************************************************
40 !-------------------------------------------------------------------------------
44 !-------------------------------------------------------------------------------
45  TYPE, EXTENDS(signal_class) :: thomson_class
47  REAL (rprec), DIMENSION(3) :: xcart
48  CONTAINS
49  PROCEDURE :: get_type => thomson_get_type
50  final :: thomson_destruct
51  END TYPE
52 
53 !-------------------------------------------------------------------------------
57 !-------------------------------------------------------------------------------
58  TYPE, EXTENDS (thomson_class) :: thomson_te_class
59  CONTAINS
60  PROCEDURE :: &
61  & get_modeled_signal_last => thomson_te_get_modeled_signal
62  PROCEDURE :: get_gp_i => thomson_te_get_gp_i
63  PROCEDURE :: get_gp_x => thomson_te_get_gp_x
64  END TYPE
65 
66 !-------------------------------------------------------------------------------
70 !-------------------------------------------------------------------------------
71  TYPE, EXTENDS (thomson_class) :: thomson_ne_class
72  CONTAINS
73  PROCEDURE :: &
74  & get_modeled_signal_last => thomson_ne_get_modeled_signal
75  PROCEDURE :: get_gp_i => thomson_ne_get_gp_i
76  PROCEDURE :: get_gp_x => thomson_ne_get_gp_x
77  END TYPE
78 
79 !-------------------------------------------------------------------------------
83 !-------------------------------------------------------------------------------
84  TYPE, EXTENDS (thomson_class) :: thomson_p_class
85  CONTAINS
86  PROCEDURE :: &
87  & get_modeled_signal_last => thomson_p_get_modeled_signal
88  END TYPE
89 
90 !*******************************************************************************
91 ! INTERFACE BLOCKS
92 !*******************************************************************************
93 !-------------------------------------------------------------------------------
95 !-------------------------------------------------------------------------------
96  INTERFACE thomson_te_class
97  MODULE PROCEDURE thomson_te_construct
98  END INTERFACE
99 
100 !-------------------------------------------------------------------------------
102 !-------------------------------------------------------------------------------
103  INTERFACE thomson_ne_class
104  MODULE PROCEDURE thomson_ne_construct
105  END INTERFACE
106 
107 !-------------------------------------------------------------------------------
109 !-------------------------------------------------------------------------------
110  INTERFACE thomson_p_class
111  MODULE PROCEDURE thomson_p_construct
112  END INTERFACE
113 
114  CONTAINS
115 !*******************************************************************************
116 ! CONSTRUCTION SUBROUTINES
117 !*******************************************************************************
118 !-------------------------------------------------------------------------------
123 !-------------------------------------------------------------------------------
124  FUNCTION thomson_te_construct(xcart)
125 
126  IMPLICIT NONE
127 
128 ! Declare Arguments
129  class(thomson_te_class), POINTER :: thomson_te_construct
130  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
131 
132 ! local variables
133  REAL (rprec) :: start_time
134 
135 ! Start of executable code
136  start_time = profiler_get_start_time()
137 
138  ALLOCATE(thomson_te_construct)
139  thomson_te_construct%xcart = xcart
140 
141  CALL profiler_set_stop_time('thomson_te_construct', start_time)
142 
143  END FUNCTION
144 
145 !-------------------------------------------------------------------------------
150 !-------------------------------------------------------------------------------
151  FUNCTION thomson_ne_construct(xcart)
152 
153  IMPLICIT NONE
154 
155 ! Declare Arguments
156  class(thomson_ne_class), POINTER :: thomson_ne_construct
157  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
158 
159 ! local variables
160  REAL (rprec) :: start_time
161 
162 ! Start of executable code
163  start_time = profiler_get_start_time()
164 
165  ALLOCATE(thomson_ne_construct)
166  thomson_ne_construct%xcart = xcart
167 
168  CALL profiler_set_stop_time('thomson_ne_construct', start_time)
169 
170  END FUNCTION
171 
172 !-------------------------------------------------------------------------------
177 !-------------------------------------------------------------------------------
178  FUNCTION thomson_p_construct(xcart)
179 
180  IMPLICIT NONE
181 
182 ! Declare Arguments
183  class(thomson_p_class), POINTER :: thomson_p_construct
184  REAL (rprec), DIMENSION(3), INTENT(in) :: xcart
185 
186 ! local variables
187  REAL (rprec) :: start_time
188 
189 ! Start of executable code
190  start_time = profiler_get_start_time()
191 
192  ALLOCATE(thomson_p_construct)
193  thomson_p_construct%xcart = xcart
194 
195  CALL profiler_set_stop_time('thomson_p_construct', start_time)
196 
197  END FUNCTION
198 
199 !*******************************************************************************
200 ! DESTRUCTION SUBROUTINES
201 !*******************************************************************************
202 !-------------------------------------------------------------------------------
208 !-------------------------------------------------------------------------------
209  SUBROUTINE thomson_destruct(this)
210 
211  IMPLICIT NONE
212 
213 ! Declare Arguments
214  TYPE (thomson_class), INTENT(inout) :: this
215 
216 ! Start of executable code
217  this%xcart = 0.0
218 
219  END SUBROUTINE
220 
221 !*******************************************************************************
222 ! GETTER SUBROUTINES
223 !*******************************************************************************
224 !-------------------------------------------------------------------------------
235 !-------------------------------------------------------------------------------
236  FUNCTION thomson_te_get_modeled_signal(this, a_model, sigma, &
237  & last_value)
238  USE model
239 
240  IMPLICIT NONE
241 
242 ! Declare Arguments
243  REAL (rprec), DIMENSION(4) :: thomson_te_get_modeled_signal
244  class(thomson_te_class), INTENT(inout) :: this
245  TYPE (model_class), POINTER :: a_model
246  REAL (rprec), DIMENSION(4), INTENT(out) :: sigma
247  REAL (rprec), DIMENSION(4), INTENT(in) :: last_value
248 
249 ! local variables
250  REAL (rprec) :: start_time
251 
252 ! Start of executable code
253  start_time = profiler_get_start_time()
254 
255  sigma = 0.0
256 
257  IF (btest(a_model%state_flags, model_state_vmec_flag) .or. &
258  & btest(a_model%state_flags, model_state_siesta_flag) .or. &
259  & btest(a_model%state_flags, model_state_te_flag) .or. &
260  & btest(a_model%state_flags, model_state_shift_flag) .or. &
261  & btest(a_model%state_flags, model_state_signal_flag)) THEN
263  & this%xcart)
264 
265  CALL this%scale_and_offset(a_model, &
267  ELSE
268  thomson_te_get_modeled_signal = last_value
269  END IF
270 
271  CALL profiler_set_stop_time('thomson_te_get_modeled_signal', &
272  & start_time)
273 
274  END FUNCTION
275 
276 !-------------------------------------------------------------------------------
287 !-------------------------------------------------------------------------------
288  FUNCTION thomson_ne_get_modeled_signal(this, a_model, sigma, &
289  & last_value)
290  USE model
291 
292  IMPLICIT NONE
293 
294 ! Declare Arguments
295  REAL (rprec), DIMENSION(4) :: thomson_ne_get_modeled_signal
296  CLASS (thomson_ne_class), INTENT(inout) :: this
297  TYPE (model_class), POINTER :: a_model
298  REAL (rprec), DIMENSION(4), INTENT(out) :: sigma
299  REAL (rprec), DIMENSION(4), INTENT(in) :: last_value
300 
301 ! local variables
302  REAL (rprec) :: start_time
303 
304 ! Start of executable code
305  start_time = profiler_get_start_time()
306 
307  sigma = 0.0
308 
309  IF (btest(a_model%state_flags, model_state_vmec_flag) .or. &
310  & btest(a_model%state_flags, model_state_siesta_flag) .or. &
311  & btest(a_model%state_flags, model_state_ne_flag) .or. &
312  & btest(a_model%state_flags, model_state_shift_flag) .or. &
313  & btest(a_model%state_flags, model_state_signal_flag)) THEN
315  & this%xcart)
316 
317  CALL this%scale_and_offset(a_model, &
319  ELSE
320  thomson_ne_get_modeled_signal = last_value
321  END IF
322 
323  CALL profiler_set_stop_time('thomson_ne_get_modeled_signal', &
324  & start_time)
325 
326  END FUNCTION
327 
328 !-------------------------------------------------------------------------------
339 !-------------------------------------------------------------------------------
340  FUNCTION thomson_p_get_modeled_signal(this, a_model, sigma, &
341  & last_value)
342  USE model
343 
344  IMPLICIT NONE
345 
346 ! Declare Arguments
347  REAL (rprec), DIMENSION(4) :: thomson_p_get_modeled_signal
348  CLASS (thomson_p_class), INTENT(inout) :: this
349  TYPE (model_class), POINTER :: a_model
350  REAL (rprec), DIMENSION(4), INTENT(out) :: sigma
351  REAL (rprec), DIMENSION(4), INTENT(in) :: last_value
352 
353 ! local variables
354  REAL (rprec) :: start_time
355 
356 ! Start of executable code
357  start_time = profiler_get_start_time()
358 
359  sigma = 0.0
360 
361  IF (btest(a_model%state_flags, model_state_vmec_flag) .or. &
362  & btest(a_model%state_flags, model_state_siesta_flag) .or. &
363  & btest(a_model%state_flags, model_state_shift_flag) .or. &
364  & btest(a_model%state_flags, model_state_signal_flag)) THEN
366  & equilibrium_get_p(a_model%equilibrium, this%xcart)
367 
368  CALL this%scale_and_offset(a_model, &
370  ELSE
371  thomson_p_get_modeled_signal = last_value
372  END IF
373 
374  CALL profiler_set_stop_time('thomson_p_get_modeled_signal', &
375  & start_time)
376 
377  END FUNCTION
378 
379 !-------------------------------------------------------------------------------
387 !-------------------------------------------------------------------------------
388  FUNCTION thomson_get_type(this)
390 
391  IMPLICIT NONE
392 
393 ! Declare Arguments
394  CHARACTER (len=data_name_length) :: thomson_get_type
395  CLASS (thomson_class), INTENT(in) :: this
396 
397 ! local variables
398  REAL (rprec) :: start_time
399 
400 ! Start of executable code
401  start_time = profiler_get_start_time()
402 
403  thomson_get_type = 'thscte'
404 
405  CALL profiler_set_stop_time('thomson_get_type', start_time)
406 
407  END FUNCTION
408 
409 !-------------------------------------------------------------------------------
420 !-------------------------------------------------------------------------------
421  FUNCTION thomson_get_gp_s(this, a_model, signal, flags)
422 
423  IMPLICIT NONE
424 
425 ! Declare Arguments
426  REAL (rprec) :: thomson_get_gp_s
427  CLASS (thomson_class), INTENT(in) :: this
428  TYPE (model_class), POINTER :: a_model
429  class(signal_class), INTENT(in) :: signal
430  INTEGER, INTENT(in) :: flags
431 
432 ! local variables
433  REAL (rprec) :: start_time
434 
435 ! Start of executable code
436  start_time = profiler_get_start_time()
437 
438  thomson_get_gp_s = signal%get_gp(a_model, this%xcart, flags)
439  CALL this%scale_and_offset(a_model, thomson_get_gp_s)
440 
441  CALL profiler_set_stop_time('thomson_get_gp_s', start_time)
442 
443  END FUNCTION
444 
445 !-------------------------------------------------------------------------------
457 !-------------------------------------------------------------------------------
458  FUNCTION thomson_te_get_gp_i(this, a_model, i, flags)
459 
460  IMPLICIT NONE
461 
462 ! Declare Arguments
463  REAL (rprec) :: thomson_te_get_gp_i
464  CLASS (thomson_te_class), INTENT(in) :: this
465  TYPE (model_class), POINTER :: a_model
466  INTEGER, INTENT(in) :: i
467  INTEGER, INTENT(in) :: flags
468 
469 ! local variables
470  REAL (rprec) :: start_time
471 
472 ! Start of executable code
473  start_time = profiler_get_start_time()
474 
475  thomson_te_get_gp_i = model_get_gp_te(a_model, this%xcart, i)
476 
477  CALL this%scale_and_offset(a_model, thomson_te_get_gp_i)
478 
479  CALL profiler_set_stop_time('thomson_te_get_gp_i', start_time)
480 
481  END FUNCTION
482 
483 !-------------------------------------------------------------------------------
497 !-------------------------------------------------------------------------------
498  FUNCTION thomson_te_get_gp_x(this, a_model, x_cart, flags)
499 
500  IMPLICIT NONE
501 
502 ! Declare Arguments
503  REAL (rprec) :: thomson_te_get_gp_x
504  CLASS (thomson_te_class), INTENT(in) :: this
505  TYPE (model_class), POINTER :: a_model
506  REAL (rprec), DIMENSION(3), INTENT(in) :: x_cart
507  INTEGER, INTENT(in) :: flags
508 
509 ! local variables
510  REAL (rprec) :: start_time
511 
512 ! Start of executable code
513  start_time = profiler_get_start_time()
514 
515  thomson_te_get_gp_x = model_get_gp_te(a_model, this%xcart, x_cart)
516  CALL this%scale_and_offset(a_model, thomson_te_get_gp_x)
517 
518  CALL profiler_set_stop_time('thomson_te_get_gp_x', start_time)
519 
520  END FUNCTION
521 
522 !-------------------------------------------------------------------------------
535 !-------------------------------------------------------------------------------
536  FUNCTION thomson_ne_get_gp_i(this, a_model, i, flags)
537 
538  IMPLICIT NONE
539 
540 ! Declare Arguments
541  REAL (rprec) :: thomson_ne_get_gp_i
542  CLASS (thomson_ne_class), INTENT(in) :: this
543  TYPE (model_class), POINTER :: a_model
544  INTEGER, INTENT(in) :: i
545  INTEGER, INTENT(in) :: flags
546 
547 ! local variables
548  REAL (rprec) :: start_time
549 
550 ! Start of executable code
551  start_time = profiler_get_start_time()
552 
553  thomson_ne_get_gp_i = model_get_gp_ne(a_model, this%xcart, i)
554  CALL this%scale_and_offset(a_model, thomson_ne_get_gp_i)
555 
556  CALL profiler_set_stop_time('thomson_ne_get_gp_i', start_time)
557 
558  END FUNCTION
559 
560 !-------------------------------------------------------------------------------
574 !-------------------------------------------------------------------------------
575  FUNCTION thomson_ne_get_gp_x(this, a_model, x_cart, flags)
576 
577  IMPLICIT NONE
578 
579 ! Declare Arguments
580  REAL (rprec) :: thomson_ne_get_gp_x
581  CLASS (thomson_ne_class), INTENT(in) :: this
582  TYPE (model_class), POINTER :: a_model
583  REAL (rprec), DIMENSION(3), INTENT(in) :: x_cart
584  INTEGER, INTENT(in) :: flags
585 
586 ! local variables
587  REAL (rprec) :: start_time
588 
589 ! Start of executable code
590  start_time = profiler_get_start_time()
591 
592  thomson_ne_get_gp_x = model_get_gp_ne(a_model, this%xcart, x_cart)
593  CALL this%scale_and_offset(a_model, thomson_ne_get_gp_x)
594 
595  CALL profiler_set_stop_time('thomson_ne_get_gp_x', start_time)
596 
597  END FUNCTION
598 
599  END MODULE
thomson::thomson_te_get_gp_i
real(rprec) function thomson_te_get_gp_i(this, a_model, i, flags)
Gets the guassian process kernel for a thomson te signal and a position.
Definition: thomson.f:459
profiler
Defines functions for measuring an tabulating performance of function and subroutine calls....
Definition: profiler.f:13
thomson::thomson_get_gp_s
real(rprec) function thomson_get_gp_s(this, a_model, signal, flags)
Gets the guassian process kernel for a thomson signal and a signal.
Definition: thomson.f:422
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
thomson::thomson_te_class
Base class representing a thomson scattering te signal.
Definition: thomson.f:58
thomson::thomson_p_class
Base class representing a thomson scattering te signal.
Definition: thomson.f:84
thomson::thomson_te_get_gp_x
real(rprec) function thomson_te_get_gp_x(this, a_model, x_cart, flags)
Gets the guassian process kernel for a thomson te signal and a cartesian position.
Definition: thomson.f:499
thomson::thomson_class
Base class representing a thomson scattering signal.
Definition: thomson.f:45
thomson::thomson_p_get_modeled_signal
real(rprec) function, dimension(4) thomson_p_get_modeled_signal(this, a_model, sigma, last_value)
Calculates the modeled pressure signal.
Definition: thomson.f:342
mpi_inc
Umbrella module avoid multiple inlcudes of the mpif.h header.
Definition: mpi_inc.f:11
model::model_get_gp_te
Interface for the model guassian process electron temperature profile values.
Definition: model.f:249
thomson::thomson_ne_get_gp_x
real(rprec) function thomson_ne_get_gp_x(this, a_model, x_cart, flags)
Gets the guassian process kernel for a thomson ne signal and a cartesian position.
Definition: thomson.f:576
thomson::thomson_ne_construct
class(thomson_ne_class) function, pointer thomson_ne_construct(xcart)
Construct a thomson_class object measureing density.
Definition: thomson.f:152
thomson::thomson_destruct
subroutine thomson_destruct(this)
Deconstruct a thomson_class object.
Definition: thomson.f:210
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
model::model_get_te
Interface for the model electron temperature profile values.
Definition: model.f:240
thomson::thomson_ne_get_modeled_signal
real(rprec) function, dimension(4) thomson_ne_get_modeled_signal(this, a_model, sigma, last_value)
Calculates the modeled ne signal.
Definition: thomson.f:290
thomson::thomson_get_type
character(len=data_name_length) function thomson_get_type(this)
Gets a discription of the thomson type.
Definition: thomson.f:389
thomson::thomson_p_construct
class(thomson_p_class) function, pointer thomson_p_construct(xcart)
Construct a thomson_class object measureing pressure.
Definition: thomson.f:179
thomson
Implements thomson scattering diagnostic. Defines the base class of the type thomson_class.
Definition: thomson.f:14
thomson::thomson_te_get_modeled_signal
real(rprec) function, dimension(4) thomson_te_get_modeled_signal(this, a_model, sigma, last_value)
Calculates the modeled te signal.
Definition: thomson.f:238
thomson::thomson_te_construct
class(thomson_te_class) function, pointer thomson_te_construct(xcart)
Construct a thomson_class object measureing temperature.
Definition: thomson.f:125
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
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
thomson::thomson_ne_get_gp_i
real(rprec) function thomson_ne_get_gp_i(this, a_model, i, flags)
Gets the guassian process kernel for a thomson ne signal and a position.
Definition: thomson.f:537
signal::signal_class
Base class representing a signal.
Definition: signal.f:33
thomson::thomson_p_error
character(len= *), parameter thomson_p_error
Assert message for pressure methods.
Definition: thomson.f:28
signal
Defines the base class of the type signal_class.
Definition: signal.f:14
thomson::thomson_ne_class
Base class representing a thomson scattering te signal.
Definition: thomson.f:71