From 241d45ed235324df57179c6fa733db62ee7d9d2c Mon Sep 17 00:00:00 2001 From: ErolBa Date: Tue, 3 Mar 2026 09:00:12 +0100 Subject: [PATCH 1/2] Removed derivatives of the coordinate axis from calculation of the hessian. --- src/hesian.f90 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hesian.f90 b/src/hesian.f90 index ff7cf149..34dde88e 100644 --- a/src/hesian.f90 +++ b/src/hesian.f90 @@ -35,7 +35,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) dFFdRZ,HdFFdRZ, dBBdmp, dmupfdx, hessian, dessian, Lhessianallocated, psifactor, & hessian2D,dessian2D,Lhessian2Dallocated, & Lhessian3Dallocated,denergydrr, denergydrz,denergydzr,denergydzz, & - LocalConstraint + LocalConstraint, dRodR, dRodZ, dZodR, dZodZ, dRadR, dRadZ, dZadR, dZadZ use sphdf5, only : write_stability @@ -241,6 +241,15 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) !endif !This step cleared. + dRodR = 0.0 + dZodR = 0.0 + dRodZ = 0.0 + dZodZ = 0.0 + dRadR = 0.0 + dRadZ = 0.0 + dZadR = 0.0 + dZadZ = 0.0 + LComputeDerivatives = .true. !; position(0) = zero ! this is not used; 11 Aug 14; LComputeAxis = .false. WCALL( hesian, dforce, ( NGdof, position(0:NGdof), force(0:NGdof), LComputeDerivatives, LComputeAxis) ) ! calculate force-imbalance & hessian; From b3c3b9b6fa5eb5750cbb5600ff5ca278dbf585c5 Mon Sep 17 00:00:00 2001 From: ErolBa Date: Tue, 3 Mar 2026 16:46:29 +0100 Subject: [PATCH 2/2] Updated code for saving force and force_gradient. Functionality unchanged --- src/global.f90 | 1 + src/sphdf5.f90 | 4 ++-- src/xspech.f90 | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/global.f90 b/src/global.f90 index 3f359850..5351fec6 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -743,6 +743,7 @@ module allglobal REAL, allocatable :: dessian3D(:,:) !< derivative Hessian 3D REAL, allocatable :: force_final(:) !< Final force on the interfaces [inface*mode] + REAL, allocatable :: force_final_grad(:, :) !< Final force gradient on the interfaces !> @} !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! diff --git a/src/sphdf5.f90 b/src/sphdf5.f90 index 1c54039f..d571f32e 100644 --- a/src/sphdf5.f90 +++ b/src/sphdf5.f90 @@ -1042,7 +1042,7 @@ subroutine hdfint TT, & beltramierror, & IPDt, dlambdaout, lmns, & - force_final, hessian, NGdof + force_final, force_final_grad, NGdof LOCALS @@ -1171,7 +1171,7 @@ subroutine hdfint if( Lcheck.eq.7 ) then HWRITERV(grpOutput, NGdof+1, force_final, force_final(0:NGdof)) - HWRITERA( grpOutput, NGdof, NGdof, force_final_grad, hessian(1:NGdof,1:NGdof) ) + HWRITERA( grpOutput, NGdof, NGdof, force_final_grad, force_final_grad(1:NGdof,1:NGdof) ) end if HCLOSEGRP( grpOutput ) diff --git a/src/xspech.f90 b/src/xspech.f90 index 03b3a9e2..8feefdeb 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -319,7 +319,7 @@ subroutine spec version, & MPI_COMM_SPEC, & force_final, Lhessianallocated, LocalConstraint, hessian, dBBdmp, dFFdRZ, dmupfdx, & - dRodR, dRodZ, dZodR, dZodZ, dRadR, dRadZ, dZadR, dZadZ, dessian, LGdof + dRodR, dRodZ, dZodR, dZodZ, dRadR, dRadZ, dZadR, dZadZ, dessian, LGdof, force_final_grad !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! @@ -514,6 +514,10 @@ subroutine spec WCALL( xspech, dforce, ( NGdof, position(0:NGdof), force_final(0:NGdof), LComputeDerivatives, LComputeAxis) ) Lfindzero = Lfindzero_temp + ! Save force gradient for output to .h5 file + SALLOCATE( force_final_grad, (1:NGdof,1:NGdof), zero ) + force_final_grad(1:NGdof,1:NGdof) = hessian(1:NGdof,1:NGdof) + else SALLOCATE( force_final, (0:NGdof), zero )