Real Time CFD Prediction
Cape Horn Engineering have undertaken a cutting-edge research project in collaboration with the companies SumToZero, Sail GP Technologies and NAVASTO to build a Machine Learning model for real time CFD predictions. With this initial project we have managed to predict new sailing conditions in less than a second. This is an average 1666x speedup compared to running a full simulation, which opens the doors to new paradigms in optimisation and flow visualisation endeavours.
CFD Simulations
Cape Horn Engineering are not only experts in Free Surface flows and have been providing aerodynamic simulations through the AeroSim Portal for years. The automated workflow of the AeroSim Portal provides on-demand CFD simulations that are simple and quick to run, so the system is ideal to be used for exploring a wide range of designs.
SumToZero used the AeroSim Portal to run a comprehensive matrix for the SailGP F50 foiling catamarans, in which they varied many sailing parameters, including the ride height, trim and heel, and sail shapes like the sheeting angle, flap angle and flap twist, as well as the jib shape. These sailing changes were all tested in varying boat speed, wind speeds and directions, amounting in 400 simulations. We made some custom modifications to some settings within the AeroSim portal to increase the fidelity of the simulations (at a computational cost). Resulting in an average simulation time of just under half an hour.
With this large matrix of conditions, we had run all the simulations necessary to begin the next step, and simply extended our automatic workflow to export the flow field data for each cell of each simulation.
Matching Learning Model
As we already had the large dataset from our CFD run, these F50 simulations became the perfect foundation to start pushing into the world of machine learning. We had been contacted by NAVASTO who has great experience in the field, but was yet to apply it to the marine industry, thus the collaboration began.
NAVASTO is a German company based in Berlin, who specialises in building software and ML models for engineering applications.
The major benefit of a Machine Learning Model is the computation time, which can be reduced from hours to less than a second, with only a minimal loss of accuracy. However, this magnitude of simulation speed gain does not come without compromise. The models must be trained from data which itself must come from running full CFD simulations. But once the model is trained on a finite set of data, an infinite number of parameter combinations can be simulated in real time.
There are two stages to building machine learning models, which are commonly referred to as the offline-phase, during which the data is generated and the model is trained, and the online-phase, during which the model is used. Since the individual datasets needed for training do not depend on each other, simulations can be run fully parallelized, as was done in this case utilising the AeroSim
Portal.
The Machine Learning Model computed for this project combines two aspects of machine learning. First, proper orthogonal decomposition (POD) is employed to transform all simulation results that are available for training into an equal number of modes and coefficients. Then, a regression model is trained to correlate the parameters of the simulation with said coefficients and additionally the scalar performance values of interest. The result is the model of a complex process that has been transformed by applying mathematical methods in such a way that it is much easier to handle, while preserving the features of the training data. Once the model is available, it can be queried to predict the results – in terms of flow field information, scalar values, and geometries – for unseen parameter combinations.
One of the main advantages of a POD-based model is that they can process large input data (tens of millions of cells) and can be commonly trained within less than an hour even on hundreds of simulations on a standard workstation CPU. The model for the results shown here, for example, was computed with 150 simulations as input on a common PC in just below 50 minutes. The number of required samples for training strongly depends on the specific use case (i.e. the non-linearity of the underlying physical phenomena) and the distribution of the samples in the parameter space. As a general rule, between five and fifteen samples are required per parameter of the problem of interest. This number can be reduced significantly, if data-informed sampling strategies, i.e. adaptive sampling, are used to select the parameter combinations to be simulated. For this use case, the simulations had already been computed before the training of a Machine Learning Model was considered. The sampling points were randomly drawn from a normal distribution, thus, the samples are dense at the centre of the parametric hypercube and sparse at the borders.
This sampling is suboptimal for ML modelling, where for unknown process topology a space filling design is preferable. In consequence we find ourselves closer to the upper bound of the given range for the ten-dimensional parameter space of this project. The figure below plots the quality of predictions versus the number of training samples used to train the model, measured in terms of the R^2 score (R^2 = 1 indicates a perfect model). This plot was produced by training a Kriging model and a neural network model using a varying number of samples as specified on the horizontal axis. Then, using those models to predict the results for the remainder of the 400 samples that were available in total, it is possible to compare the prediction to the simulated result to get the R^2 score.
The following figures show some comparisons of prediction vs ground truth. The left image in each figure shows the results from the test CFD simulations, and the right shows the prediction from the Machine Learning model. The test point was not used in the training of the Machine Learning model.
Results
The movie shows the ParaView plug-in created by NAVASTO which is used to interface with the Machine Learning model. It is possible to change the input parameters and see the results in real-time. The predictions not only include the force results, but the full flow field, thus you can see the pressures on the hull and sails and the streamline around them which show the flow velocity. ParaView is a powerful and widely used open-source data analysis and visualization application, so when used with the machine learning plug-in from Navasto, any and all exploration of the flow field is possible.
As well as the ParaView interface, NAVASTO provide a direct python API (Application Programming Interface). Using this it is possible to load the model and interrogate it in any way necessary, for example to give real forces for a simulator, or to optimise for a set of conditions. It is then possible to save the result from this optimised set of parameters to open graphically and investigate. For example, we could optimise inputs to give the maximum driving force, with a constrain on the maximum side force, that can be produced and for a given wind speed.
Final Remarks
Our long-term vision has always been to supersede the wind tunnel once and for all for racing teams, replacing the need to book tunnel sessions to learn sail trim using scaled down sail models. The power of the tools used in this project make it possible to trim sails in real time and directly see how the flow is affected. This could be extended to Virtual Reality, to form a man-in-the-loop simulator that is both faster and cheaper than wind tunnels, as well as providing a more controlled environment for systematic testing. We are one step closer to our vision with these latest tools.
This project is a stepping-stone to develop the tools necessary for optimising many engineering problems, with our initial focus on the improvement of Wind Assisted Ship Propulsion (WASP) technologies. The tools can help optimise the design, based on high fidelity CFD results that also include the interaction of the WASP and the ship, or act as an autopilot to trim the sails. Now that we have proven this new technology to integrate seamlessly with our methodologies, we can apply the methods to new and exciting projects.
For more details: please see: https://www.cape-horn-eng.com/wind-assisted-propulsion-simulation/