Initialization method for a minimizer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(t_minimizer_mhd3d), | intent(inout), | ALLOCATABLE | :: | sf |
allocatable minimizer object |
|
| integer, | intent(in) | :: | varsize_in(:) |
size of the dofs |
||
| real(kind=wp), | intent(in) | :: | dt_initial |
initial stepsize for the minimization |
||
| integer, | intent(in) | :: | MinType_in |
gradient descent = 0, accelerated gradient descent = 10 |
||
| real(kind=wp), | intent(in) | :: | dW_allowed_in |
for minimizer, accept step if dW<dW_allowed*W_MHD(iter=0) |
||
| logical, | intent(in) | :: | DoCheckDistance |
TRUE: check distance between solutions of two log output states |
||
| logical, | intent(in) | :: | DoCheckAxis |
TRUE: check axis position |
||
| integer, | intent(in) | :: | outputIter |
number of iterations after which output files are written |
||
| integer, | intent(in) | :: | nlogScreen |
number of log outputs after a screen output is written |
||
| integer, | intent(in) | :: | logIter |
number of iterations after which a screen log is written |
SUBROUTINE new_minimizer(& sf, varsize_in, dt_initial, MinType_in, dW_allowed_in,& ! Minimizer DoCheckDistance, DoCheckAxis,& !what to log outputIter, nlogScreen, logIter& !when to log ) !----------------------------------------------------------------------------------------------------------------------------------- ! MODULES USE MODgvec_MHD3D_evalFunc, ONLY: EvalForce !----------------------------------------------------------------------------------------------------------------------------------- ! INPUT VARIABLES INTEGER , INTENT(IN) :: varsize_in(:) !! size of the dofs REAL(wp), INTENT(IN) :: dt_initial !! initial stepsize for the minimization REAL(wp), INTENT(IN) :: dW_allowed_in !! for minimizer, accept step if dW<dW_allowed*W_MHD(iter=0) INTEGER, INTENT(IN) :: MinType_in !! gradient descent = 0, accelerated gradient descent = 10 LOGICAL, INTENT(IN) :: DoCheckDistance !! TRUE: check distance between solutions of two log output states LOGICAL, INTENT(IN) :: DoCheckAxis !! TRUE: check axis position INTEGER, INTENT(IN) :: outputIter !! number of iterations after which output files are written INTEGER, INTENT(IN) :: nlogScreen !! number of log outputs after a screen output is written INTEGER, INTENT(IN) :: logIter !! number of iterations after which a screen log is written !----------------------------------------------------------------------------------------------------------------------------------- ! OUTPUT VARIABLES TYPE(t_minimizer_mhd3d),ALLOCATABLE, INTENT(INOUT) :: sf !! allocatable minimizer object !----------------------------------------------------------------------------------------------------------------------------------- ! LOCAL VARIABLES INTEGER :: i !! iteration variable !=================================================================================================================================== ALLOCATE(sf) sf%MinType = MinType_in IF(MinType_in.EQ.0)THEN ALLOCATE(t_gradient_descent_vars :: sf%vars) sf%vars%MinimizerType="Gradient-Descent" ELSEIF(MinType_in.EQ.10)THEN ALLOCATE(t_accelerated_gradient_descent_vars :: sf%vars) sf%vars%MinimizerType="Accelerated Gradient-Descent" ELSE CALL abort(__STAMP__,& "requested MinimizeType does not exist, expecting 0 or 10",intinfo=MinType_in,& TypeInfo="InvalidParameterError") END IF ASSOCIATE(vars=>sf%vars) vars%dt = dt_initial vars%dW_allowed = dW_allowed_in ALLOCATE(vars%dofs(-3:1)) CALL vars%dofs(1)%init(varsize_in) DO i=-3,0 CALL vars%dofs(i)%copy(vars%dofs(1)) END DO ALLOCATE(vars%force(-1:0)) DO i=-1,0 CALL vars%force(i)%copy(vars%dofs(1)) END DO ALLOCATE(vars%temp_dofs(-1:1)) DO i=-1,1 CALL vars%temp_dofs(i)%copy(vars%dofs(1)) END DO ! variables for the accelerated Gradient descent SELECT TYPE(vars) TYPE IS(t_accelerated_gradient_descent_vars) ALLOCATE(vars%velocity(-1:1)) DO i=-1,1 CALL vars%velocity(i)%copy(vars%dofs(1)) END DO vars%tau_bar = 0.075_wp vars%ndamp = 10 ALLOCATE(vars%tau(vars%ndamp)) vars%tau=0.0_wp vars%Vnorm = 0.0_wp END SELECT !Type vars%JacCheck = 1 vars%nstepDecreased = 0 vars%nSkip_Jac = 0 vars%t_pseudo = 0 vars%lastOutputIter = 0 vars%iter = 0 vars%logiter_ramp = 1 vars%logscreen = 1 vars%nSkip_dw = 0 vars%JacCheck = 1 vars%restart_iter = .TRUE. vars%logger_is_initialized = .FALSE. vars%DoCheckDistance = DoCheckDistance vars%DoCheckAxis = DoCheckAxis vars%outputIter = outputIter vars%nlogScreen = nlogScreen vars%logIter = logIter vars%Fnorm = 10.0_wp vars%Fnorm0 = 10.0_wp vars%W_MHD3D_0 = 0.0_wp vars%deltaW = 0.0_wp END ASSOCIATE !vars sf%initialized = .TRUE. END SUBROUTINE new_minimizer