V3FIT
sxrem_ratio.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 !
14 !*******************************************************************************
15 
16  MODULE sxrem_ratio
17 
18  USE stel_kinds, only: rprec, dp
19  USE model
20  USE signal
21 
22  IMPLICIT NONE
23 
24 !*******************************************************************************
25 ! DERIVED-TYPE DECLARATIONS
26 ! 1) sxrem_ratio base class
27 !
28 !*******************************************************************************
29 !-------------------------------------------------------------------------------
33 !-------------------------------------------------------------------------------
34  TYPE, EXTENDS(signal_class) :: sxrem_ratio_class
36  REAL (rprec), DIMENSION(3) :: x_cart
38  INTEGER, DIMENSION(2) :: indices
39  CONTAINS
40  PROCEDURE :: &
41  & get_modeled_signal_last => sxrem_ratio_get_modeled_signal
42  PROCEDURE :: &
43  & get_observed_signal => sxrem_ratio_get_observed_signal
44  PROCEDURE :: get_type => sxrem_ratio_get_type
45  PROCEDURE :: &
46  & write_auxiliary => sxrem_ratio_write_auxiliary
47  final :: sxrem_ratio_destruct
48  END TYPE sxrem_ratio_class
49 
50 !-------------------------------------------------------------------------------
52 !-------------------------------------------------------------------------------
53  INTERFACE sxrem_ratio_class
54  MODULE PROCEDURE sxrem_ratio_construct
55  END INTERFACE
56 
57  CONTAINS
58 !*******************************************************************************
59 ! CONSTRUCTION SUBROUTINES
60 !*******************************************************************************
61 !-------------------------------------------------------------------------------
69 !-------------------------------------------------------------------------------
70  FUNCTION sxrem_ratio_construct(x_cart, indices)
71 
72  IMPLICIT NONE
73 
74 ! Declare Arguments
75  class(sxrem_ratio_class), POINTER :: sxrem_ratio_construct
76  REAL (rprec), DIMENSION(3), INTENT(in) :: x_cart
77  INTEGER, DIMENSION(2), INTENT(in) :: indices
78 
79 ! local variables
80  REAL (rprec) :: start_time
81 
82 ! Start of executable code
83  start_time = profiler_get_start_time()
84 
85  ALLOCATE(sxrem_ratio_construct)
86 
87  sxrem_ratio_construct%x_cart = x_cart
88  sxrem_ratio_construct%indices = indices
89 
90  CALL profiler_set_stop_time('sxrem_ratio_construct', start_time)
91 
92  END FUNCTION
93 
94 !*******************************************************************************
95 ! DESTRUCTION SUBROUTINES
96 !*******************************************************************************
97 !-------------------------------------------------------------------------------
103 !-------------------------------------------------------------------------------
104  SUBROUTINE sxrem_ratio_destruct(this)
105 
106  IMPLICIT NONE
107 
108 ! Declare Arguments
109  TYPE (sxrem_ratio_class), INTENT(inout) :: this
110 
111 ! Start of executable code
112  this%x_cart = 0.0
113  this%indices = 0
114 
115  END SUBROUTINE
116 
117 !*******************************************************************************
118 ! GETTERS SUBROUTINES
119 !*******************************************************************************
120 !-------------------------------------------------------------------------------
130 !-------------------------------------------------------------------------------
131  FUNCTION sxrem_ratio_get_modeled_signal(this, a_model, sigma, &
132  & last_value)
133 
134  IMPLICIT NONE
135 
136 ! Declare Arguments
137  REAL (rprec), DIMENSION(4) :: sxrem_ratio_get_modeled_signal
138  class(sxrem_ratio_class), INTENT(inout) :: this
139  TYPE (model_class), POINTER :: a_model
140  REAL (rprec), DIMENSION(4), INTENT(out) :: sigma
141  REAL (rprec), DIMENSION(4), INTENT(in) :: last_value
142 
143 ! local variables
144  REAL (rprec) :: emissivity
145  REAL (rprec) :: start_time
146 
147 ! Start of executable code
148  start_time = profiler_get_start_time()
149 
150  sigma = 0.0
151 
152  IF (btest(a_model%state_flags, model_state_vmec_flag) .or. &
153  & btest(a_model%state_flags, model_state_siesta_flag) .or. &
154  & btest(a_model%state_flags, model_state_shift_flag) .or. &
155  & btest(a_model%state_flags, model_state_sxrem_flag + &
156  & (this%indices(1) - 1)) .or. &
157  & btest(a_model%state_flags, model_state_sxrem_flag + &
158  & (this%indices(2) - 1)) .or. &
159  & btest(a_model%state_flags, model_state_signal_flag)) THEN
160 
161  emissivity = model_get_sxrem_cart(a_model, this%x_cart, &
162  & this%indices(2))
163 
164  IF (emissivity .eq. 0.0) THEN
166  ELSE
168  & model_get_sxrem_cart(a_model, this%x_cart, &
169  & this%indices(1))/emissivity
170  END IF
171 
172  CALL this%scale_and_offset(a_model, &
174  ELSE
175  sxrem_ratio_get_modeled_signal = last_value
176  END IF
177 
178  CALL profiler_set_stop_time('sxrem_ratio_get_modeled_signal', &
179  & start_time)
180 
181  END FUNCTION
182 
183 !-------------------------------------------------------------------------------
192 !-------------------------------------------------------------------------------
193  FUNCTION sxrem_ratio_get_observed_signal(this, a_model)
194 
195  IMPLICIT NONE
196 
197 ! Declare Arguments
198  REAL (rprec) :: sxrem_ratio_get_observed_signal
199  class(sxrem_ratio_class), INTENT(in) :: this
200  TYPE (model_class), INTENT(in) :: a_model
201 
202 ! local variables
203  REAL (rprec) :: start_time
204 
205 ! Start of executable code
206  start_time = profiler_get_start_time()
207 
209  & model_get_sxrem_ratio(a_model, model_get_te_cart(a_model, &
210  & this%x_cart))
211 
212  CALL profiler_set_stop_time('sxrem_ratio_get_observed_signal', &
213  & start_time)
214 
215  END FUNCTION
216 
217 !-------------------------------------------------------------------------------
225 !-------------------------------------------------------------------------------
226  FUNCTION sxrem_ratio_get_type(this)
227 
228  IMPLICIT NONE
229 
230 ! Declare Arguments
231  CHARACTER (len=data_name_length) :: sxrem_ratio_get_type
232  class(sxrem_ratio_class), INTENT(in) :: this
233 
234 ! local variables
235  REAL (rprec) :: start_time
236 
237 ! Start of executable code
238  start_time = profiler_get_start_time()
239 
240  sxrem_ratio_get_type = 'sxrem ratio'
241 
242  CALL profiler_set_stop_time('sxrem_ratio_get_type', start_time)
243 
244  END FUNCTION
245 
246 !*******************************************************************************
247 ! UTILITY SUBROUTINES
248 !*******************************************************************************
249 !-------------------------------------------------------------------------------
258 !-------------------------------------------------------------------------------
259  SUBROUTINE sxrem_ratio_write_auxiliary(this, iou, index, a_model)
260 
261  IMPLICIT NONE
262 
263 ! Declare Arguments
264  class(sxrem_ratio_class), INTENT(in) :: this
265  INTEGER, INTENT(in) :: iou
266  INTEGER, INTENT(in) :: index
267  TYPE (model_class), INTENT(in) :: a_model
268 
269 ! local variables
270  REAL (rprec) :: start_time
271 
272 ! Start of executable code
273  start_time = profiler_get_start_time()
274 
275  WRITE (iou,1000) this%indices(1), this%indices(2)
276 
277  CALL profiler_set_stop_time('sxrem_ratio_write_auxiliary', &
278  & start_time)
279 
280 1000 FORMAT('sxrem profile ratio',1x,i2,'/',1x,i2)
281 
282  END SUBROUTINE
283 
284  END MODULE
model::model_get_sxrem_cart
real(rprec) function model_get_sxrem_cart(this, x_cart, index)
Gets the soft x-ray emissivity at a cartesian position.
Definition: model.f:2217
model::model_get_te_cart
real(rprec) function model_get_te_cart(this, x_cart)
Gets the electron temperature at a cartesian position.
Definition: model.f:1602
sxrem_ratio::sxrem_ratio_get_type
character(len=data_name_length) function sxrem_ratio_get_type(this)
Gets a discription of the feedback type.
Definition: sxrem_ratio.f:227
sxrem_ratio
Defines a feedback signal based on the temperature based on the ration of the soft x-ray emissivity p...
Definition: sxrem_ratio.f:16
model
Defines the base class of the type model_class. The model contains information not specific to the eq...
Definition: model.f:59
sxrem_ratio::sxrem_ratio_class
Base class representing a sxrem_ratio signal.
Definition: sxrem_ratio.f:34
sxrem_ratio::sxrem_ratio_construct
class(sxrem_ratio_class) function, pointer sxrem_ratio_construct(x_cart, indices)
Construct a sxrem_ratio_class object.
Definition: sxrem_ratio.f:71
sxrem_ratio::sxrem_ratio_get_modeled_signal
real(rprec) function, dimension(4) sxrem_ratio_get_modeled_signal(this, a_model, sigma, last_value)
Calculates the modeled signal.
Definition: sxrem_ratio.f:133
sxrem_ratio::sxrem_ratio_write_auxiliary
subroutine sxrem_ratio_write_auxiliary(this, iou, index, a_model)
Write out auxiliary signal information to an output file.
Definition: sxrem_ratio.f:260
model::model_class
Base class representing a model.
Definition: model.f:141
model::model_get_sxrem_ratio
real(rprec) function model_get_sxrem_ratio(this, te)
Gets the soft x-ray emissivity ratio.
Definition: model.f:2318
sxrem_ratio::sxrem_ratio_destruct
subroutine sxrem_ratio_destruct(this)
Deconstruct a sxrem_ratio_class object.
Definition: sxrem_ratio.f:105
sxrem_ratio::sxrem_ratio_get_observed_signal
real(rprec) function sxrem_ratio_get_observed_signal(this, a_model)
Calculates the observed signal.
Definition: sxrem_ratio.f:194
signal::signal_class
Base class representing a signal.
Definition: signal.f:33
signal
Defines the base class of the type signal_class.
Definition: signal.f:14