From 34bfb7233a08f42e7af4dbb764d62024784a1106 Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Mon, 17 Feb 2025 13:28:06 +0000 Subject: [PATCH 1/2] Add description for scaled bounds and scales --- source/fortran/numerics.f90 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/fortran/numerics.f90 b/source/fortran/numerics.f90 index 051868d370..6c3ad7fe3f 100755 --- a/source/fortran/numerics.f90 +++ b/source/fortran/numerics.f90 @@ -407,11 +407,21 @@ module numerics ! !! boundu(ipnvars) /../ : upper bounds used on ixc variables real(dp), dimension(ipnvars) :: bondl + !! Upper bound of the ixc variables scaled to (divided by) + !! the initial value of the corresponding ixc + real(dp), dimension(ipnvars) :: bondu + !! Lower bound of the ixc variables scaled to (divided by) + !! the initial value of the corresponding ixc + real(dp), dimension(ipnvars) :: rcm real(dp), dimension(ipnvars) :: resdl real(dp), dimension(ipnvars) :: scafc + !! The initial value of each ixc variable + real(dp), dimension(ipnvars) :: scale + !! The reciprocal of the initial value of each ixc variable + real(dp), dimension(ipnvars) :: xcm real(dp), dimension(ipnvars) :: xcs real(dp), dimension(ipvlam) :: vlam From 9d6cccca75f6eab83786228739e940508d5d9f0b Mon Sep 17 00:00:00 2001 From: Timothy Nunn Date: Fri, 21 Feb 2025 10:00:09 +0000 Subject: [PATCH 2/2] Rename bondl and bondu to be more descriptive --- process/optimiser.py | 4 ++-- process/scan.py | 13 ++++++++----- source/fortran/iteration_variables.f90 | 6 +++--- source/fortran/numerics.f90 | 12 ++++++------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/process/optimiser.py b/process/optimiser.py index 1c69690539..9cafbf7b18 100644 --- a/process/optimiser.py +++ b/process/optimiser.py @@ -33,8 +33,8 @@ def run(self): # Trim maximum size arrays down to actually used size n = numerics.nvar x = numerics.xcm[:n] - bndl = numerics.bondl[:n] - bndu = numerics.bondu[:n] + bndl = numerics.itv_scaled_lower_bounds[:n] + bndu = numerics.itv_scaled_upper_bounds[:n] # Define total number of constraints and equality constraints m = numerics.neqns + numerics.nineqns diff --git a/process/scan.py b/process/scan.py index 553079b505..bea6c6efc6 100644 --- a/process/scan.py +++ b/process/scan.py @@ -335,8 +335,8 @@ def post_optimise(self, ifail: int): name = f2py_compatible_to_string(numerics.lablxc[numerics.ixc[i] - 1]) solution_vector_table.append([name, numerics.xcs[i], numerics.xcm[i]]) - xminn = 1.01 * numerics.bondl[i] - xmaxx = 0.99 * numerics.bondu[i] + xminn = 1.01 * numerics.itv_scaled_lower_bounds[i] + xmaxx = 0.99 * numerics.itv_scaled_upper_bounds[i] if numerics.xcm[i] < xminn or numerics.xcm[i] > xmaxx: if not written_warning: @@ -359,7 +359,7 @@ def post_optimise(self, ifail: int): process_output.write( constants.nout, f" {name:<30}= {xcval} is at or {location} its {bound} bound:" - f" {numerics.bondu[i] * numerics.scafc[i]}", + f" {numerics.itv_scaled_upper_bounds[i] * numerics.scafc[i]}", ) process_output.ovarre( @@ -374,8 +374,11 @@ def post_optimise(self, ifail: int): else: xnorm = min( max( - (numerics.xcm[i] - numerics.bondl[i]) - / (numerics.bondu[i] - numerics.bondl[i]), + (numerics.xcm[i] - numerics.itv_scaled_lower_bounds[i]) + / ( + numerics.itv_scaled_upper_bounds[i] + - numerics.itv_scaled_lower_bounds[i] + ), 0.0, ), 1.0, diff --git a/source/fortran/iteration_variables.f90 b/source/fortran/iteration_variables.f90 index 26efdcd508..5ed451636c 100755 --- a/source/fortran/iteration_variables.f90 +++ b/source/fortran/iteration_variables.f90 @@ -4424,7 +4424,7 @@ subroutine boundxc !! ! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - use numerics, only: nvar, bondl, bondu, scale, ixc, boundl, boundu + use numerics, only: nvar, itv_scaled_lower_bounds, itv_scaled_upper_bounds, scale, ixc, boundl, boundu implicit none @@ -4435,8 +4435,8 @@ subroutine boundxc ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! do i = 1,nvar - bondl(i) = boundl(ixc(i))*scale(i) - bondu(i) = boundu(ixc(i))*scale(i) + itv_scaled_lower_bounds(i) = boundl(ixc(i))*scale(i) + itv_scaled_upper_bounds(i) = boundu(ixc(i))*scale(i) end do end subroutine boundxc diff --git a/source/fortran/numerics.f90 b/source/fortran/numerics.f90 index 6c3ad7fe3f..e534bc6bf5 100755 --- a/source/fortran/numerics.f90 +++ b/source/fortran/numerics.f90 @@ -406,12 +406,12 @@ module numerics real(dp), dimension(ipnvars) :: boundu ! !! boundu(ipnvars) /../ : upper bounds used on ixc variables - real(dp), dimension(ipnvars) :: bondl - !! Upper bound of the ixc variables scaled to (divided by) + real(dp), dimension(ipnvars) :: itv_scaled_lower_bounds + !! Lower bound of the ixc variables scaled to (divided by) !! the initial value of the corresponding ixc - real(dp), dimension(ipnvars) :: bondu - !! Lower bound of the ixc variables scaled to (divided by) + real(dp), dimension(ipnvars) :: itv_scaled_upper_bounds + !! Upper bound of the ixc variables scaled to (divided by) !! the initial value of the corresponding ixc real(dp), dimension(ipnvars) :: rcm @@ -585,8 +585,8 @@ subroutine init_numerics() ! Issue #287 These bounds now defined in initial.f90 boundu = 9.d99 - bondl = 0.0D0 - bondu = 0.0D0 + itv_scaled_lower_bounds = 0.0D0 + itv_scaled_upper_bounds = 0.0D0 rcm = 0.0D0 resdl = 0.0D0 scafc = 0.0D0