Sailing yachts R&D with PythonOCC

Traditionaly, yacht design softwares have been ranging from expensive to very expensive (think thousands to tens of thousands). florentsailing, the company I run, took another approach to sailing yacht optimization: the open source approach for the freedom, independence and depth of knowledge it provides. Geometry creation, manipulation and analysis are central to the yacht design process and a robust and industrial grade CAD kernel was required. That’s how I found PythonOCC, which added Python ease of development on top of the Open Cascade strenghts.

The holy grail of yacht design is the automatic generation of the design based on the problem definition (e.g. increase the odds of winning a given race for a given set of wind/sea conditions) while respecting a set of constraints (mostly provided by the rules and structural limitations). Reaching the holy grail is obviously a long endeavour, and we are not there yet, but some building blocks now exist and some use PythonOCC. PythonOCC is used at the geometry definition and hydrostatic analysis stage to feed a performance analysis (Velocity Prediction and Race Simulation) of the various designs that meet the constraints. A closed loop optimization is yet to be implemented for the whole process, but tests on a smaller problem (foil sections optimization) are promising.

Parametrics

Any optimization procedure handles a list of numbers and cannot directly manipulate geometry (even though I have seen some attemps to do just that by making geometry differentiable in some advanced scientific papers). parametrics is a Python project that generates a yacht geometry described by a set of numbers, making the geometry ready for optimization. The geometry generation uses the splines and lofting features of PythonOCC. Parametrics also has a wxpython based GUI that uses an embedded PythonOCC viewer. The parameters controls are auto generated from the parametric object (that inherits Atom), using a thin Atom wrapper called Gluon that handles the wx controls autogeneration in a recursive way (the hull is a parametric object that is composed with other parametric objects (i.e. parametric splines)). The generated geometry can be exported to one of PythonOCC supported CAD formats for further processing.

parametrics GUI showing a parametrically defined yacht hull. The PythonOCC viewer has been enriched with topology visualization capabilities and view definition (top, front ..) GUI controls.

parametrics GUI showing a parametrically defined yacht hull. The PythonOCC viewer has been enriched with topology visualization capabilities and view definition (top, front ..) GUI controls.

Interestingly enough, I found the pygem project that is mentionned on the pythonocc.org blog, which is another great way to feed an optimization loop with modified geometry while maintaining design features. The Alinghi team used Free Form Deformation (what pygem is about) to optimize its yachts to successfully defend the 2007 America’s Cup. It is just great to have this capability in the PythonOCC ecosystem.

 

Waterline

Waterline is an hydrostatics analysis project aimed at yacht hulls and underwater geometry. The analysis can be defined for different attitudes (heel, trim). In GUI mode, it is possible to compare multiple geometries. The hydrostatic analysis results can be exported to the next design stage (Velocity Prediction) in batch mode or in GUI mode. The hydrostatic analysis is performed using PythonOCC and a scipy solver to make sure the underwater volume is kept constant when the yacht attitude is changed. Here again, the GUI uses the PythonOCC viewer embedded in a wx application.

waterline GUI used to compare the hydrostatics characteristics (here at a 20° heel angle) of two candidate designs.

waterline GUI used to compare the hydrostatics characteristics (here at a 20° heel angle) of two candidate designs.

 

fAActory

While not being directly related to anything that floats, I would like to mention an experiment I made by integrating Django, three.js and PythonOCC to generate json from a PythonOCC shape. The goal here was to let a user specify geometry via a web interface and simple controls (sliders, drop-downs …), while PythonOCC was used to generate the web 3D viewing data and associated characteristics, taking the http request parameters as an input.

fAActory web interface. The 3D view uses three.js and PythonOCC generated json.

fAActory web interface. The 3D view uses three.js and PythonOCC generated json.

The idea behind this experiment was to bring the design of complex geometry within reach of non-CAD experts, for a limited set of customizable parts. The path from user specification to manufacturing was greatly reduced and, while promising on paper, the experiment did not seem to raise enough interest in real life. Maybe a good idea with a wrong timing, maybe not a good idea, but when there is demand for geometry customization by the end user, we are ready.