1.7.2.5. HeatExchanger

[1]:
import sys, time
import numpy as np
seed = 1435
np.random.seed(seed)

# import problem classes
import Exeter_CFD_Problems as TestProblems
verbose = False

sys.argv = sys.argv[:1]
print('Demonstration of the HeatExchanger test problem.')
# set up directories.
settings = {
    'source_case': 'Exeter_CFD_Problems/data/HeatExchanger/heat_exchange/',
    'case_path': 'Exeter_CFD_Problems/data/HeatExchanger/case_multi/'
}
# instantiate the problem object
prob = TestProblems.HeatExchanger(settings)
lb, ub = prob.get_decision_boundary()
x = np.random.random((1000, lb.shape[0])) * (ub - lb) + lb
rand_x = []
for i in range(x.shape[0]):
    if prob.constraint(x[i]):
        rand_x.append(x[i])
print('Decision vector: ', rand_x[10])
print('Running simulation ...')
start = time.time()
res = prob.evaluate(rand_x[10], verbose=verbose)
print('Objective function value:', res)
print('Time taken:', time.time()-start, ' seconds.')
Demonstration of the HeatExchanger test problem.
Decision vector:  [-0.89232652  0.03599114  0.7075494  -0.24789502  3.72886442  3.11245792
  8.70912195  8.31955523  0.84670057  0.7638816  -0.49889754  0.32321096
  6.62711066  6.89689518  8.22022831  8.50896155  0.56366081  0.53639077
 -0.53977858 -0.69141556  3.83963371  2.83172664  0.88267636  2.35745137
  0.73458725  0.79221888  0.53419005 -0.217558  ]
Running simulation ...
Objective function value: (17.8506, 3.13576e-08)
Time taken: 45.9740571975708  seconds.
[1]:
! postProcess -case Exeter_CFD_Problems/data/HeatExchanger/case_multi -func sample > log 2>&1
[20]:
import plotHeatExchangerTemperature
import importlib
importlib.reload(plotHeatExchangerTemperature)
%matplotlib inline
filename = \
'Exeter_CFD_Problems/data/HeatExchanger/case_multi/postProcessing/sample/0/T_nearWall.vtk'
plotHeatExchangerTemperature.plot(filename)
../../_images/33_machine_learning_optimiserTestProblemSuite_HeatExchanger_3_0.png
[ ]: