Water flow function

The water flow function is defined as: $f(r_w,r,T_u,H_u,T_l,H_l,L,K_w) = \frac{2*\pi*T_u(H_u - H_l)}{\log(\frac{r}{r_w})*[1 + \frac{2LT_u}{\log(\frac{r}{r_w})*r_w^2*K_w}+ \frac{T_u}{T_l} ]}$

It has 8 dimensions, with the bounds below. The response spans roughly an order of magnitude across that box, so the errors reported at the end are worth reading against that scale rather than in absolute terms.

using Surrogates
using PolyChaos
using Plots
using LinearAlgebra

Define the objective function:

function f(x)
    r_w = x[1]
    r = x[2]
    T_u = x[3]
    H_u = x[4]
    T_l = x[5]
    H_l = x[6]
    L = x[7]
    K_w = x[8]
    log_val = log(r / r_w)
    return (2 * pi * T_u * (H_u - H_l)) /
           (log_val * (1 + (2 * L * T_u / (log_val * r_w^2 * K_w)) + T_u / T_l))
end
f (generic function with 1 method)
n = 180
lb = [0.05, 100, 63070, 990, 63.1, 700, 1120, 9855]
ub = [0.15, 50000, 115600, 1110, 116, 820, 1680, 12045]
x = sample(n, lb, ub, SobolSample())
y = f.(x)
n_test = 1000
x_test = sample(n_test, lb, ub, GoldenSample())
y_true = f.(x_test)
1000-element Vector{Float64}:
 145.83997177108955
 147.68674562247347
  76.73659244577273
 119.20504557892866
  96.2095847181461
  62.34950269764311
  50.379843644410585
  47.34739271117506
  55.280691607535104
  33.55030846148717
   ⋮
  38.01440588905075
  27.910712144623076
  24.453585452699688
 154.36204414919325
 154.42425054392385
  82.79950972351598
 127.05250398828431
 154.29009593068545
  68.22648842243387
my_rad = RadialBasis(x, y, lb, ub)
y_rad = my_rad.(x_test)
my_poly = PolynomialChaosSurrogate(x, y, lb, ub)
y_poly = my_poly.(x_test)
rmse_rad = norm(y_true - y_rad, 2) / sqrt(n_test)
rmse_poly = norm(y_true - y_poly, 2) / sqrt(n_test)
println("RMSE Radial:     $rmse_rad")
println("RMSE Polynomial: $rmse_poly")
RMSE Radial:     51.173848060060585
RMSE Polynomial: 1.5134393318842814