V3FIT
add_resistivity.f90
1 
2  SUBROUTINE add_resistive_e
3  USE stel_kinds
7  USE shared_functions, ONLY: funct_island
9  USE descriptor_mod, ONLY: iam
10  USE siesta_bfield, ONLY: update_bfield
11  USE siesta_displacement, ONLY: update_upperv
12  USE siesta_init, ONLY: init_state
13  USE siesta_state, ONLY: update_state
14  IMPLICIT NONE
15 !-----------------------------------------------
16 ! L o c a l P a r a m e t e r s
17 !-----------------------------------------------
18  INTEGER, PARAMETER :: nits = 10
19  REAL(dp), PARAMETER :: zero = 0
20  REAL(dp) :: save_eta, fmhd, eps
21  INTEGER :: itime, j
22  LOGICAL, PARAMETER :: lcurrent_only=.true.
23  LOGICAL :: lverb_save
24 
25  INTEGER, SAVE :: nCheck = 0
26 !-----------------------------------------------
27  IF (fsq_total1 .LE. ftol) RETURN
28 
29  lverb_save = lverbose
30  lverbose = .false.
31 
32  fmhd = fsq_total1
33 
34  l_update_state = .false.
35 
36 ! No perturbation, vsupX = 0
37  xc = 0
38  CALL init_state(.false.)
39  CALL update_upperv
40 
41  save_eta = eta_factor
42  eta_factor = eta_factor/max(1,nits)
43 
44 ! Diffuse B-field (eta*j) from last update_state call
45  DO itime=1,nits
46 
47  CALL init_state (lcurrent_only) !Use new B-field to get KsubXij currents
48  CALL update_bfield (.true.) !Resistive update to B-field
49  CALL update_state (.false., zero, zero) !Updates B-field with resistive piece
50 
51  END DO
52 
53  ncheck = ncheck+1
54  IF (ncheck .EQ. 0) CALL checkforces(xc, gc) !set iteration value > 0 at which force check is done
55 
56  l_getfsq = .true.
57  l_init_state = .true.
58  CALL funct_island
59 
60 
61  eta_factor = save_eta
62  lverbose = lverb_save
63 
64  IF (iam .EQ. 0) THEN
65  DO j = 6, unit_out, unit_out-6
66  IF (.NOT.lverbose .AND. j.EQ.6) cycle
67  WRITE (j,'(/,a,i3)') ' UPDATING RESISTIVE E-FIELD: ITERATIONS=',nits
68  WRITE (j, '(a,1p2e12.3)') &
69  ' JUMP IN FSQ DUE TO RESISTIVE DIFFUSION: ', fmhd, fsq_total1
70  END DO
71  END IF
72 
73 !SPH101116: limit jump next time
74  IF (fsq_total1 .GT. 4*fmhd) THEN
76  ELSE IF (fsq_total1 .LT. 1.1_dp*fmhd) THEN
77  eta_factor = eta_factor*(1.1_dp*fmhd/fsq_total1)
78  END IF
79 
80  END SUBROUTINE add_resistive_e
shared_data::nprecon
integer nprecon
Preconditioner flag.
Definition: shared_data.f90:68
shared_data::lverbose
logical lverbose
Use verbose screen output.
Definition: shared_data.f90:234
shared_data::l_getfsq
logical l_getfsq
Compute |F|^2.
Definition: shared_data.f90:216
shared_functions
Module contained subroutines and functions updating MHD forces and Wmhd.
Definition: shared_functions.f90:4
shared_data::xc
real(dp), dimension(:), allocatable xc
1D array of Fourier mode displacement components.
Definition: shared_data.f90:97
siesta_state
This file contains subroutines for aupdating from t to t + delta_t the magnetic field and pressure as...
Definition: siesta_state.f90:12
shared_data::l_init_state
logical l_init_state
Store initial field/pressure state.
Definition: shared_data.f90:222
siesta_bfield
This file contains subroutines for updating half-grid magnetic fields.
Definition: siesta_bfield.f90:10
siesta_bfield::update_bfield
subroutine update_bfield(l_add_res)
Update contravariant componets of the magnetic field.
Definition: siesta_bfield.f90:37
siesta_init::init_state
subroutine, public init_state(lcurrent_only, lpar_in)
Initialize equilibrium state.
Definition: siesta_init.f90:45
siesta_namelist::eta_factor
real(dp) eta_factor
Resistivity value.
Definition: siesta_namelist.f90:148
shared_data::unit_out
integer, parameter unit_out
File output io unit.
Definition: shared_data.f90:39
siesta_namelist::ftol
real(dp) ftol
Force tolarance.
Definition: siesta_namelist.f90:146
shared_data::gc
real(dp), dimension(:), allocatable, target gc
1D Array of Fourier mode MHD force components
Definition: shared_data.f90:99
shared_data::l_update_state
logical l_update_state
Update the ste array.
Definition: shared_data.f90:224
shared_data::fsq_total1
real(dp) fsq_total1
|F|^2 WITHOUT column scaling.
Definition: shared_data.f90:93
siesta_namelist
This file contains all the variables and maximum sizes of the inputs for a SIESTA namelist input file...
Definition: siesta_namelist.f90:103
siesta_init
Initializes unperturbed siesta fields and pressure in real space.
Definition: siesta_init.f90:10
shared_data
This file contains variables and parameters used by many modules in SIESTA.
Definition: shared_data.f90:10