14 USE stel_kinds,
only: rprec
41 INTEGER :: control_flags
89 & force_coil_reponse, &
90 & use_3D_only, svd_cut_off)
98 INTEGER,
INTENT(in) :: mdsig_iou
99 LOGICAL,
INTENT(in) :: use_coil_response
100 LOGICAL,
INTENT(in) :: force_coil_reponse
101 LOGICAL,
INTENT(in) :: use_3d_only
102 REAL (rprec),
INTENT(in) :: svd_cut_off
105 INTEGER,
DIMENSION(3) :: dim_lengths
107 REAL (rprec) :: start_time
119 IF (force_coil_reponse)
THEN
122 &
'Cannot force coil response. Coil responses ' //
123 &
'not found in mdsig file.')
129 IF (use_3d_only)
THEN
137 IF (.not.use_coil_response)
THEN
162 TYPE (magnetic_class),
INTENT(inout) :: this
165 IF (
ASSOCIATED(this%response))
THEN
167 this%response => null()
197 REAL (rprec),
DIMENSION(4),
INTENT(out) :: sigma
198 REAL (rprec),
DIMENSION(4),
INTENT(in) :: last_value
201 REAL (rprec) :: start_time
208 IF (btest(a_model%state_flags, model_state_vmec_flag) .or.
209 & btest(a_model%state_flags, model_state_siesta_flag) .or.
210 & btest(a_model%state_flags, model_state_shift_flag) .or.
211 & btest(a_model%state_flags, model_state_signal_flag))
THEN
221 CALL this%scale_and_offset(a_model,
261 REAL (rprec),
DIMENSION(4),
INTENT(out) :: sigma
264 REAL (rprec),
DIMENSION(3) :: b_field
265 REAL (rprec) :: start_time
272 b_field = equilibrium_get_ext_b_plasma(a_model%equilibrium,
273 & this%response%position,
277 & dot_product(b_field, this%response%direction)
281 b_field = equilibrium_get_ext_b_plasma(a_model%equilibrium,
282 & this%response%position,
286 & dot_product(b_field, this%response%direction)
350 USE v3_utilities,
only: err_warn
358 REAL (rprec),
DIMENSION(4),
INTENT(out) :: sigma
361 INTEGER :: phi, num_phi, r, z
362 INTEGER :: numrvol, numzvol
364 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: rgrid
365 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: zgrid
366 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: rvolgrid
367 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: zvolgrid
368 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: jrvolgrid
369 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: jphivolgrid
370 REAL (rprec),
DIMENSION(:,:,:),
POINTER :: jzvolgrid
371 REAL (rprec),
DIMENSION(:,:),
POINTER :: krgrid
372 REAL (rprec),
DIMENSION(:,:),
POINTER :: kphigrid
373 REAL (rprec),
DIMENSION(:,:),
POINTER :: kzgrid
374 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: response_rvol
375 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: response_phivol
376 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: response_zvol
377 REAL (rprec),
DIMENSION(:,:),
ALLOCATABLE :: sumrz
378 REAL (rprec),
DIMENSION(:),
ALLOCATABLE :: sumphi
379 INTEGER :: num_r, num_z
381 REAL (rprec) :: start_time
393 & equilibrium_get_magnetic_volume_rgrid(a_model%equilibrium)
395 & equilibrium_get_magnetic_volume_zgrid(a_model%equilibrium)
397 & equilibrium_get_magnetic_volume_jrgrid(a_model%equilibrium)
399 & equilibrium_get_magnetic_volume_jphigrid(a_model%equilibrium)
401 & equilibrium_get_magnetic_volume_jzgrid(a_model%equilibrium)
404 IF (
ASSOCIATED(rvolgrid) .and.
ASSOCIATED(zvolgrid) .and.
405 &
ASSOCIATED(jrvolgrid) .and.
ASSOCIATED(jphivolgrid) .and.
406 &
ASSOCIATED(jzvolgrid))
THEN
410 numrvol =
SIZE(rvolgrid, 1)
411 numzvol =
SIZE(rvolgrid, 2)
412 ALLOCATE(response_rvol(numrvol, numzvol))
413 ALLOCATE(response_phivol(numrvol, numzvol))
414 ALLOCATE(response_zvol(numrvol, numzvol))
417 num_phi =
SIZE(this%response%a_r)
418 ALLOCATE(sumrz(numrvol, numzvol))
419 ALLOCATE(sumphi(num_phi))
424 num_r = compression_get_dimension1(this%response%a_r(1)%p)
425 ALLOCATE(rgrid(num_r))
427 rgrid(r) = this%response%rmin
428 & + (r - 1)*(this%response%rmax - this%response%rmin)
432 num_z = compression_get_dimension2(this%response%a_r(1)%p)
433 ALLOCATE(zgrid(num_z))
435 zgrid(z) = this%response%zmin
436 & + (z - 1)*(this%response%zmax - this%response%zmin)
451 CALL compression_decompress(this%response%a_r(phi)%p)
453 & this%response%a_r(phi)%p%data_buffer,
455 CALL compression_cleanup(this%response%a_r(phi)%p)
457 CALL compression_decompress(this%response%a_f(phi)%p)
459 & this%response%a_f(phi)%p%data_buffer,
461 CALL compression_cleanup(this%response%a_f(phi)%p)
463 CALL compression_decompress(this%response%a_z(phi)%p)
465 & this%response%a_z(phi)%p%data_buffer,
467 CALL compression_cleanup(this%response%a_z(phi)%p)
472 sumrz = jrvolgrid(:,:,phi)*response_rvol
473 & + jphivolgrid(:,:,phi)*response_phivol
474 & + jzvolgrid(:,:,phi)*response_zvol
475 sumphi(phi) = sum(sumrz(2:numrvol - 1,:))
476 & + sum(sumrz(1,:) + sumrz(numrvol,:))/2.0
486 & - (sumphi(1) + sumphi(num_phi))/2.0
492 & * equilibrium_get_volume_int_element(a_model%equilibrium)
498 DEALLOCATE(response_rvol, response_phivol, response_zvol)
499 DEALLOCATE(sumrz, sumphi)
500 DEALLOCATE(rgrid, zgrid)
507 num_phi = compression_get_dimension2(this%response%a_s_r)
510 & equilibrium_get_con_surface_krgrid(a_model%equilibrium)
512 & equilibrium_get_con_surface_kphigrid(a_model%equilibrium)
514 & equilibrium_get_con_surface_kzgrid(a_model%equilibrium)
516 IF (
ASSOCIATED(krgrid) .and.
ASSOCIATED(kphigrid) .and.
517 &
ASSOCIATED(kzgrid))
THEN
518 ALLOCATE(sumphi(num_phi))
520 CALL compression_decompress(this%response%a_s_r)
521 CALL compression_decompress(this%response%a_s_f)
522 CALL compression_decompress(this%response%a_s_z)
526 & = sum(krgrid(:,phi)*
527 & this%response%a_s_r%data_buffer(:,phi))
528 & + sum(kphigrid(:,phi)*
529 & this%response%a_s_f%data_buffer(:,phi))
530 & + sum(kzgrid(:,phi)*
531 & this%response%a_s_z%data_buffer(:,phi))
534 CALL compression_cleanup(this%response%a_s_r)
535 CALL compression_cleanup(this%response%a_s_f)
536 CALL compression_cleanup(this%response%a_s_z)
543 & - (sumphi(1) + sumphi(num_phi))/2.0
549 & * equilibrium_get_area_int_element(a_model%equilibrium)
607 LOGICAL :: scale_current
608 INTEGER :: num_currents
609 REAL (rprec),
DIMENSION(:),
POINTER :: extcur
610 REAL (rprec) :: start_time
619 num_currents =
SIZE(this%response%inductance)
625 extcur => equilibrium_get_ext_currents(a_model%equilibrium,
630 IF (
ASSOCIATED(extcur))
THEN
633 num_currents = min(
SIZE(extcur),
634 &
SIZE(this%response%inductance))
635 IF (num_currents .lt. this%response%n_field_cg)
THEN
636 CALL err_warn(
'magnetic_get_modeled_signal_coil: ' //
637 &
'mdsig_file expected more currents')
640 IF (scale_current)
THEN
642 & this%response%inductance(1:num_currents),
643 & extcur(1:num_currents)/this%response%current_scale)
646 & this%response%inductance(1:num_currents),
647 & extcur(1:num_currents))
653 &
'magnetic_get_modeled_signal_coil_pickup', start_time)
676 REAL (rprec) :: start_time
704 CHARACTER (len=data_name_length),
DIMENSION(7),
INTENT(inout) ::
708 REAL (rprec) :: start_time
713 header(1) =
'plasma only'
714 header(2) =
'eq currents'
718 header(3) =
'shell currents'
720 header(3) =
'Axi signal'
723 header(4) =
'model_sig(1)'
724 header(5) =
'model_sig(2)'
725 header(6) =
'model_sig(3)'
726 header(7) =
'model_sig(4)'