A WIP demonstration (PoC) repository on how to use foamBO to run
Multi-objective Bayesian Optimization algorithms on OpenFOAM cases.
- Requirements for reproducing the optimization
- Q&As
- Necessary changes to the OpenFOAM case
- Optimization insights
- Lessons learned
./prepare.sh # Makes sure you have required toolsTake a look at MOO.yaml for the parameter set and objective functions, which should be self-explanatory.
To poke around the published state of the optimization:
uvx foamBO visualize --config MOO.yaml ++store.read_from=jsonTo run an optimization study from scratch:
uvx [email protected] --config MOO.yaml ++store.read_from=nowhereNote
Since the optimization is seeded with random trials, this will not be an exact
reproduction. If you want exact reproducibility, you can seed the random trial
generator with a fixed number. For more information on this, run:
uvx foamBO --docs
and look for "seed"
If one considers some increments to represent the minimal change in a parameter value that might result in a considerable effect on the objective functions, we get 14784 total brute-force cases:
angularVelocity: range (10, 40), increment 5 -> 7 valuesnRotorBlades: range (3, 6) -> 4 valuesrotorBladeRadius: range (0.01, 0.02), increment 0.002 -> 6 valuesrotorBladeHeight: range (0.03, 0.05), increment 0.002 -> 11 valuesrotorBladeTiltAngle: range (0, 14), increment 2 -> 8 values
That's 2464 hours (100 days) of simulating the (very) coarse annularThermalMixer case.
With 70 max trials (4 max parallel trials), the BOTorch algorithm converges in ~60 trials.
One nice feature of Bayesian Algorithms is that the stopping strategy can be shifted from objective values over to the probability of improving on current best optima estimations.
# These are pretty relaxed settings
orchestration_settings:
global_stopping_strategy:
min_trials: 20
window_size: 10
improvement_bar: 0.3By adding a choice parameter with 6 possible values - which extends the search space to 88.7k
brute-force cases - the optimization algorithm takes only few more trials to converge under the
same conditions. It should be noted that the added parameter was not more significant to any
of the objectives than the existing ones:
nStatorBlades:
type: choice
value_type: int
values: [3, 4, 5, 6, 7, 8]
is_ordered: TrueFor this optimization case, adding a range parameter of some significance to at least one
the objectives can be expected to increase time-to-convergence by 10-15 trials.
Tip
Git shows more accurate changes:
treecommit=$(git log --format='%H' --author=Elwardi --reverse -- annularThermalMixer/ | head -1)
git diff $treecommit..HEAD -M -- annularThermalMixer ':(exclude)*.stl'But this section will motivate the important ones.
- All original OBJ geometries are converted to (non-compressed) STL format.
shaft.stl,statorBlades.stlandrotorBlades.stlare now dynamically generated byscripts/generate.pyPython script, based onconstant/cadDictsettings.Allrunis modified to rungeometry/generate.pyinstead of copying original surfaces.
I still have some concerns:
snappyHexMeshis kept as the mesh generator, and it doesn't keep a constant max cell size if the dimensions of the domain change (eg. How far the AMI patch is from the shaft). So, any optimization study may be biased towards specific sets of dimensions.cfMeshwould do better.
- A single serial run of the case takes around 20 mins to simulate 1 sec. Overall mesh resolution has been lowered from the base case.
- The case is decomposed for 4 processors, where the execution time becomes 10 mins.
The following objective functions are computed using scripts/obj*.sh shell scripts for convenience.
Scalar values to represent the following objectives are chosen so their minimization of the scalar values results in better objectives.
- Blade durability is estimated through erosion prediction which is represented by wall shear stress, raised to some power (2, or 3); Total surface area of patch faces with more than 70% of the value-range of "the shear stress squared" is used as an indication of possible erosion regions.
- Mixing quality is estimated through Coefficient of variation (CoV) of component concentrations (alpha fields).
- This is a two-phase computation, so there is only one alpha field
- Power consumption is computed through pressure and shear stress fields on the impeller.
- Torque Coefficient is computed through
propellerInfofunction object. - Power consumption = torque x blade rotational speed
- Torque Coefficient is computed through
Let's start by looking at the surrogate model's cross-validation plots after around 60 trials, which:
- suggest that the model is trained to predict blade durability the most.
- suggest that the model will predict power consumption with the most uncertainty.
But, it seems the model has picked up significant signal on all metrics.
A quick look at the Hyper-Volume trace suggests that the model would benefit from tighter improvement bar as it's still taking an increasing trend:
Now that we know what to expect from the surrogate model, we may investigate how much of the search space was explored:
Observe that:
- The Bayesian algorithm preferred maximum range value of
angularVelocityandrotorBladeRadiuswhich indicates a desire to explore past the parameter range, suggesting the optimal points are further up the specified range - The algorithm also preferred lower
rotorBladeHeightandrotorBladeTiltAnglevalues.
The next question would be: which parameter are most important to which objectives?
These insights should be understood only at and around the Pareto frontier computed using the given baseline parameter set:
In order to understand more how exactly changing some choice-type parameters affect an objective, we can look at marginal effects plots:
Warning
bladeDurability is just an evaluation of "stress on blade patches". It was not named properly as
"blade brittleness" is a better name. We would want to maximize the "actual durability" of the blades.
As confirmation for earlier analysis, one can look at the trial's objectives plotted against each other;
we can clearly see that the model has much more confidence in bladeDurability:
Loading the visualizer UI on this optimization allows to
- Pick an objective to focus the analysis on
- Explore how much the objectives would be affected by changing various parameter values.
It's important to understand that this analysis is only valid around the Pareto frontier points, hence the display of confidence intervals:
Important
You can access past lessons from past README commits
I did some minor changes to the parameter ranges so no failed trials are tried, and relaxed the stopping strategy a little bit.
Overall, the optimization process went smoother than with v0.1.2 and the reports are much better. Within 60 trials, the optimization meets the stopping criteria and the SEM values on the Pareto frontier are all less than 3%.
With v1.1.0 optimization visualizer, we can easily make well-informed decisions on what parameters to tweak, in which direction, in order to trade efficiently between objectives.







