1
NURBS-based and Parametric-based Shape Optimisation with Dierentiated CAD Kernel
Orest Mykhaskiv1, Mladen Banovic2, Salvatore Auriemma3, Pavanakumar Mohanamuraly1, Andrea Walther2, Herve Legrand3 and Jens-Dominik Müller1
1Queen Mary University of London, [email protected] 2University of Paderborn, [email protected] 3OpenCASCADE, [email protected]
Corresponding author: Orest Mykhaskiv, [email protected]
ABSTRACT
Numerical optimisation is becoming an essential industrial method in engineering design for shapes immersed in uids. High-delity optimisation requires ne design spaces with many design variables, which can only be tackled with gradient-based optimisation methods. CAD packages that are open-source or commercially available do not provide shape derivatives, but impose to compute them with expensive, inaccurate and non- robust nite-dierences. The present work is the rst demonstration of obtaining exact shape derivatives with respect to CAD design parametrisation by applying algorithmic dierentiation to a com- plete CAD system, in this case the Open Cascade Technology (OCCT) CAD-kernel. The extension of OCCT to perform shape optimisation is shown by using parametric models based on explicit parametrisations of the CAD model and on implicit parametrisations based on the BRep (NURBS). In addition, we demonstrate the imposition of geomet- ric constraints for both approaches, a salient part of industrial design, and an intuitive method of storing them in standard CAD format. The proposed method is applied to redesign TU Berlin Stator Testcase.
Keywords: aerodynamic shape optimisation, CAD-based sensitivities, gradient method
1 INTRODUCTION In engineering workows it is common practice to maintain master CAD models, which then serve as a foundation for further design and development. In complex system designs these base geometries enable cross-department collaboration and therefore minimise the time needed to bring an industrial component to the production. However, preserving a CAD model description during a gradient-based aerodynamic
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 2
shape optimisation does not work to the full extent due to missing or inexact gradient information from a CAD system. High-delity shape optimisation of immersed bodies subject to uid dynamics, such as aeroplanes, turbines, vehicles or ducts, requires very rich design spaces with many design variables. Tackling these rich design spaces is not computationally feasible with stochastic optimisation methods such as Evolutionary Algorithms. Gradient-based optimisation has been shown to be feasible, and has widely been adopted for these problems. The optimisation community has put a lot of eort into developing methods that compute gradients of objective functions with respect to mesh point perturbation for Computational Fluid Dynamics (CFD) solvers. In particular, the adjoint method [12,8,5, 15, 10] allows to compute these gradients accurately, consistently and with low computational cost. The next step is to dene a parametrisation of the shape. A simple approach is the node-based approach where the design variables are the displacement of the grid nodes on the shape. Although the mesh nodes positions present the richest design space that computational tools can expose, the approach allows surfaces with oscillatory high-frequency noise. This could be tackled with regularisation (smooth- ing) [9]. Alternative approaches are Free Form Deformation [14] or radial basis function [3]. Afterwards, the optimised mesh is imported back to CAD, but this usually inquires signicant approximations and inaccuracies degrading the quality of the optimum. On the contrary, CAD-based methods always keep the CAD representation during the optimisation, while obtaining the necessary CAD sensitivity infor- mation is more challenging. Robinson et al. [13] apply nite dierences to the parametric CAD models created in commercial 'black-box' CAD system. The CAD sensitivity is computed as the dierence be- tween the original CAD model and the one with the perturbed design parameters. Similar approach is followed in [4], where nite dierences are applied to the open-source CAD-kernel Open CASCADE Technology (OCCT). Additionally, several often used CAD primitives and shapes (cube, sphere, etc.) are complemented with analytical derivatives. In [19] a small in-house CAD kernel was automatically dier- entiated and provides analytical derivatives for NURBS. In this paper we exploit recently dierentiated version of the OCCT kernel [1], [2]. Although dierentiation of a complete CAD-kernel is a non-trivial and time-consuming task, it allows us to get exact derivatives without numerical noise in any of CAD modelling algorithms. This makes the dierentiated OCCT practical for wide range of parametrisa- tions and geometrical manipulations. Moreover, the eciency of the sensitivities computation is in most cases superior than with previously mentioned nite dierences, which encourages shape exploration in large-dimensional CAD spaces. The design space set-up is crucial for aerodynamic shape optimisation in CAD-based methods, since it allows to eectively tweak the corresponding ow physics. Therefore, widely used parametric CAD models require from the designer a proper engineering judgement during initial design. To respond to these challenges, several application-specic parametrisation tools were developed [6], [17]. Taking to account extensive engineering experience, these tools allow to parametrise the shapes with conventional and intuitive design parameters (trailing/leading edge radius, blade thickness, wing span, etc.). These parameters are then varied during the design optimisation loop. Furthermore, an explicit control over design variables also allows to incorporate geometrical constraints directly in the parametrisation. Alternatively to the previous approach, instead of changing the parameters of the model's construc- tion algorithm, one can directly modify the geometry of the resulting shape, so-called BRep (Boundary Representation) [19], [21]. Changes to this BRep data (control points positions and weights of corre- sponding NURBS) eliminate the initial parametrisation, but propose rich design spaces, which could be easily rened even further by inserting additional control points. Hence, this method serves better the ultimate goal of optimisation, potentially exploring non-conventional designs. The method is CAD- vendor independent, and requires only a generic CAD-le (STEP, IGES, etc.), eluding problems with parametrisation tree and making the optimisation more automatic.
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 3
Therefore we address two major elements that prevent integration of CAD into the design loop: a) Absence of necessary CAD sensitivity functionality (gradients of CAD surfaces with respect to the constructing design parameters), usually not available in the CAD systems. To overcome this problem, we use our algorithmically dierentiated OCCT kernel. b) Poor parametrisations that cannot capture shape variations originating from adjoint CFD. We consider two distinct approaches to control the shape changes: the rst updates the explicit design parameters of a CAD model; the second modies positions of NURBS control points and ensures resulting shape remains watertight (continuity and smoothness of the model). In this paper the dierentiated OCCT is used to optimise TU Berlin Stator Case [23] and to compute necessary CAD derivatives. A brief introduction to the OCCT dierentiation can be found in Sec.2. Parametrisation of the stator blade with conventional turbomachinery parameters is described in Sec.4. Section5 describes the necessary ingredients for NURBS-based optimisation including corresponding constraint impositions, followed by results for both approaches in Sec.6.
2 AUTOMATIC DIFFERENTIATION OF OCCT CAD-KERNEL Geometrical sensitivities of CAD model w.r.t. its parametrisation are necessary to perform CAD-based shape optimisation. The exact derivatives are obtained by algorithmic dierentiation (AD) of the open- source CAD-kernel Open CASCADE Technology (OCCT) using the AD software tool ADOL-C (Auto- matic Dierentiation by OverLoading in C++)[2]. The ADOL-C tool requires all variables that may be considered as dierentiable quantities to be declared as an adouble type to denote an active variable. This requires one to replace the type declaration of almost all oating point variables in the source code to the adouble type. The idea although straightforward to implement requires signicant man-hours to x compile and run-time errors. ADOL-C [18] provides two kinds of dierentiation options: (i) trace-based and (ii) traceless. Each one implements a dierent version of the adouble class leading to two distinct computational algorithms. In the trace-based option, operator-overloading is used to generate an internal representation (trace) of the function to be dierentiated. Then the ADOL-C driver routines are executed on the generated trace to compute the necessary gradients. In the traceless mode, the gradient computation is propagated directly during the function evaluation, along with the function values. This mode is simpler to use as every overloaded operator embeds both primal and gradient code in its denition. On the contrary, it is not as powerful as the trace-based option since only the forward/tangent mode of AD is possible. In the trace-based option both the forward/tangent and reverse/adjoint mode of AD are possible, where reverse mode of AD can dramatically reduce the temporal complexity of the gradient computation. The theory behind the forward and reverse mode can be found in reference [7]. We successfully dierentiated OCCT using both trace-based and traceless modes provided by ADOL- C. Hence it is possible to compute the CAD sensitivities (i.e., gradients of CAD surface points w.r.t. design parameters of the model) both in the forward and reverse mode of AD. We veried the correctness of the dierentiated CAD kernel against (central dierence) nite dierence results. The geometric algorithms involved in the TU Berlin Stator blade parametrisation in OCCT were also individually veried for correctness against nite dierence. A qualitative comparison of AD and FD surface sensitivities w.r.t. one design parameter is shown in Fig.2. In order to validate the reverse mode dierentiation of OCCT against the forward mode of AD, we developed an optimisation test-case within the CAD system. It is organised as follows:
1. Construct two blades: original and perturbed one, see Fig.1.
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 4
(a) Original stator blade shape (b) Perturbed stator blade shape
Fig. 1: CAD optimisation with two stator blades
2. Sample nal NURBS surfaces with 20K pairs of (u, v) parametric coordinates. These parametric coordinates are later used in NURBS algorithms to evaluate the corresponding three-dimensional points (x, y, z). 3. Dene an objective function as the sum of squared distances of all (x, y, z) point pairs. 4. Declare the original design parameters as independent variables of the system. 5. Minimise the objective function by using the limited-memory BFGS optimisation algorithm with boundary constraints (L-BFGS-B) [22].
The primary objective of this test case is to match the surfaces of two blades by modifying the design parameters of the original blade. Since we have two versions of dierentiated OCCT kernel, one compiled with traceless and another one with trace-based ADOL-C headers, the optimisation was performed twice. We observed small dierences between the gradients obtained from the two modes of AD, as shown in Fig.3. Similar dierences (same order of magnitude) were present in the primal results. We attribute the dierence to oating-point round-o errors, since the oating point operations (and order) dier between traceless and trace-based ADOL-C headers. The dierences relative to the objective function value, which is O(·105) are quite insignicant. The high peaks in dierences occur, for example near gradient index 100 (Fig.3), in the regions of low sensitivity values where round-o errors dominate. The run-time ratios of the optimisation test-case for both forward and reverse mode AD are shown in Table1. Note that the run-time ratio is dened as the ratio between the original and dierentiated OCCT sources. The trace-based reverse mode AD is quite ecient and it is overall 47% faster than the traceless forward mode for the optimisation test-case.
Original sources AD Forward mode (traceless) AD Reverse mode (trace-based) Avg. time (seconds) 0.09 13.27 6.99 Run-time ratio 147.44 77.67
Table 1: Timings for initial blade optimisation iteration done with original and dierentiated (AD) sources
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 5
Fig. 2: Blade sensitivities evaluated by AD (left) and Finite Dierences (right)
5 10− 1.0 × Iteration: 0 0.8 0.6 0.4 0.2
Difference 0.0 0.2 − 0.4 − 0.6 − 0 50 100 150 200 Gradient index
Fig. 3: Gradient dierences between two modes of AD for initial blade optimisation iteration
3 DIFFERENTIATED OCCT AND ADJOINT CFD COUPLING In a typical aerodynamic shape optimisation process one minimises a cost function J (usually scalar like lift, drag, etc.) with respect to the CAD geometry with design parameters α and subject to geometry and ow constraints R [8]: min J(U(X(α)),X(α), α) (1) α R(U(X(α)),X(α)) = 0 . (2) Equation (2) describes the ow eld within the domain of interest by system of Reynolds-Averaged Navier-Stokes equations, with the state variable U and a computational mesh coordinates X, which depend on design parameters α. In case of large amount of design parameters (usually the case in industrial applications) the adjoint method proves to be computationally ecient and could be derived by application of a chain rule to the system (1)-(2) yielding:
dJ h dJ i∂X = + νT f , (3) dα dX ∂α where ∂R f = − . (4) ∂X
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 6
Here ν represents the solution of adjoint equations: ∂R T ∂J ν = . (5) ∂U ∂U After computing the solution of primal and adjoint equations (2),(5), one can rewrite cost function gradient in terms of surface grid points derivatives:
dJ dJ dX = S . (6) dα dXS dα Here, the relation (spring analogy, inverse distance weighting) between volume and surface grid points
displacement is used X = X(XS). The rst term in (6), usually called CFD sensitivity, corresponds to the ow sensitivity in the surface grid points XS. These derivatives could be calculated by several available CFD solvers that have implemented the adjoint method. In this work we use our in-house discrete adjoint solver STAMPS (previously mgopt)[20].
The second term (CAD sensitivity) represents the derivative of the surface grid points XS with respect to the CAD model design parameters. This part is calculated in the automatically dierentiated version of OCCT [1]. The dierentiated OCCT provides the derivatives for almost every possible CAD parametrisation and geometrical manipulation. Equipped with these derivatives, we compose them in the total gradient, which is then used in iterative gradient-based optimisation loop:
dJ α(n+1) = A α(n), (α(n)) , (7) dα with A as an optimisation algorithm. Next sections describe two cases of the above mentioned method, depending on the nature of CAD design parameter α: as design variable in parametric CAD model or BRep/NURBS parametrisation.
4 PARAMETRIC CAD-MODEL FOR TU BERLIN STATOR AND CONSTRAINTS The TUB TurboLab Stator Blade [23] is a typical turbomachinery optimisation testcase, where geo- metrical constraints strongly inuence the nal optimised shape. The test case prescribes the following geometrical constraints on the blade: (i) minimum radius of the leading and the trailing edge, (ii) mini- mum thickness of the blade (iii) minimum thickness near the hub and the shroud to accommodate the four mounting bolts and (iv) constant axial chord length. In the present work, we re-parametrised the blade in OCCT such that all constraints except the thickness constrains for the mounting bolts are explicitly embedded in the parametrisation. These constrains can readily be provided to any optimiser workow.
4.1 2D Prole Parametrisation The blade parametrisation starts by dening a 2d prole. We used B-spline curves to represent the 2d blade proles, since they provide a rich and exible space for the parametrisation [17]. The 2d blade prole is generated using a camber-line (shown in Fig.4) represented by a B-spline curve and characterised by seven control points. We distribute eight reference points (P 1, ..., P 8), as shown in Fig.4, along the camber line using a cosine function. The cosine function is used to cluster points near the leading and trailing edge (LE and TE) of the camber-line. The control points for the suction and pressure side B-splines curves are generated as equidistant osets of the reference points normal to the camber-line (Fig.4). Finally, the suction and pressure side curves are smoothly joined using the specied radius of curvature satisfying G2 continuity.
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 7
LE C LE A H d1 C B d2 Camber-line
d3 A
d4 d4
d5 d5
d6 d6
d7 d7 d8 d8 TE TE TE Fig. 4: Left: Camber-line (blue) with corresponding control polygon (red) and uniform point distribution; Right: Construction of pressure/suction control points; Imposition of curvature (G2 continuity) at the LE
The AB length (Fig.4) in a B-spline curve of degree n is:
r n − 1 AB = curvature · CH · (8) n where AB is the distance between control point A and B and CH is the distance of control point C from the AB line. Therefore, it is possible to impose the curvature in the point A. This approach is applied to suction and pressure B-splines. In particular, the two curves have the same radius of curvature at the LE. This radius is controlled as design parameter of the optimisation. The same approach is also used for the TE radius. Thus the G2 continuity is kept along all the section. In summary, the 2d prole consists of 23 parameters of which, (i) 10 parameters control thickness (2 of them are the radii of TE and LE) and (ii) 13 parameters control the camber-line movement and, therefore, its angle, as shown in Fig.5.
4.2 3D Parametrisation The 3d blade parametrisation is based on a cross-sectional design approach - the lofting. This approach takes n-slices (2d proles) as input and constructs nal B-spline surface using an OCCT approximation tool. The slices are generated along a blade span dened as a B-spline curve, the path-line. Each 2d prole parameter is characterised by a law of evolution along the path-line. The laws are dened as B-spline curves, consisting of 8 control points each. These control points are the design parameters of the optimisation. Their total number is 184 (23 · 8). An example of the blade construction using seven slices is shown in Fig.6.
4.3 Optimisation Constraints The limited memory BFGS algorithm with boundary constraints (L-BFGS-B) is used as optimiser. The constraints specied in the L-BFGS-B are as follows:
G2 continuity: imposed along all the section based on the geometrical construction. Axial chord: the axial-coordinate of the last camber-line control point is set equal to the axial- coordinate of the rst control point plus the constant axial chord value.
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 8
LE Radius
Camber-line control points Path-line
Blade thickness
TE Law of Evolution TE Radius
Fig. 5: Section parameters Fig. 6: Blade skeleton and TE law of evolution in the 3D domain
Thickness distribution: the thickness between the suction and pressure surface is approximated using the corresponding B-Spline control point distances. Therefore this constraint has to be veried a posteriori. LE and TE radii: The lower bound values are specied.
5 NURBS-BASED OPTIMISATIONS AND CONSTRAINTS The NURBS-based optimisation technique with continuity and geometrical constraints (so-called NSPCC approach) was initially proposed in [19] and [21]. In this paper, we extend and automate the NSPCC method further. The authors in [19] use a modest in-house CAD kernel, but we substitute it with a comprehensive OCCT CAD kernel and benet from the extensive CAD functionality. The major updates and novelties are related to the renement of the CAD-space, new constraints capabilities (curvature), recovery of the violated geometrical constraints and the storage of the constraints in standard CAD formats. In the current NSPCC version the role of the CAD tool is more profound, while the amount of manual constraint set-up is reduced. This brings NURBS-based optimisation closer to the industrial workows and creates an alternative to parametric CAD-models optimisation.
5.1 NURBS-based Design The advantage of NURBS-based approach is that in most cases no preprocessing (understanding of initial parametrisation tree, re-parametrisation in another tool, aerodynamic intuition to dene proper CAD space, etc.) is needed. CAD-vendor neutral boundary representation could be retrieved directly from the standard CAD les (STEP, IGES, etc.), which usually contain collection of NURBS patches. Since OCCT is already equipped with an ecient reader of standard CAD formats, its dierentiated version allows to compute the sensitivity information in any point of the surface with respect to control points position of governing NURBS. Therefore the CAD sensitivity dened in Eq.6 is obtained for every surface:
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 9
Fig. 7: Left: Initial (9x22) and rened(18x22) Control Point Net of TUB Stator; Right: Corresponding changes in CAD Surface Sensitivity with respect to movement of the single control point
−−−−−−−−−−−−−−−−−−−−−−−−→3 × N ∂XS1 ∂XS1 ··· ∂XS1 ∂P1 ∂P2 ∂PN ∂XS ∂XS . . .. . = = 3 × M . . . . . (9) ∂α ∂P ∂XSM ∂XSM ··· ∂XSM y ∂P1 ∂P2 ∂PN
Here M and N are the total number of surface mesh points XS and control points P respectively. Moreover, with OCCT one can easily and intuitively rene design space by adding extra control points with knot insertion algorithm [11]. This operation does not change the shape or degree of the surface, but establishes more local control due to local support properties of the splines. This is clearly visible in the changing pattern of the CAD sensitivities shown in Fig.7. These very narrow sensitivities potentially could cope better with small ow features not 'visible' for more global parametric sensitivity (Fig.2). At the moment, the renement is performed manually prior to the optimisation, but this process can be automated with the CFD sensitivity eld as a sensor for renement. It is important to note that in some cases the NURBS surfaces extracted from standard les are not suitable for direct NURBS-based optimisation due to enormous clustering of control points (sometimes as ne as the computational mesh). The root of this problem lies in the creation of the initial shape (morphed from STL, extensive surface trimming, etc.). In these cases reverse engineering and re-approximation of the surfaces might be required.
5.2 Constraints CAD models are usually constructed from multiple adjacent patches. Therefore, modications of control points individually on patches can violate (i) patch-continuity (holes between the CAD faces, non-smooth shapes) or (ii) other geometrical constraints. We alleviate this problem by ltering out the shape modes
Computer-Aided Design & Applications, 15(1), 2018, bbb-ccc © 2018 CAD Solutions, LLC, http://www.cadconferences.com 10
Face1 Face1 PCurve2 Face1 Face2 PCurve3 PCurve1 (u2,v2)
PCurve4
Edge1
Face2 (u1,v1) Edge1 Face2 Edge2
Fig. 8: Left: TUB Stator Topology; Middle: Test-points distribution along PCurves of the common edge; Right: Test-points on generic PCurves of surfaces
with undesired constraints violations using discrete spaces constructed using test-points [19]. Conceptu- ally, the approach requires that the constraints are satised on the particular set of points dened on the surface (test-points). We avoid distinguishing the continuity and the geometrical constraints by bringing them under one framework. In the TUB stator test-case, several geometrical constraints are present and were introduced in the previous section. Several methods were devised to accelerate and automate the process of test-point distribution. Firstly, we identify topological entities (e.g. edges, parts of surfaces, etc.) necessary for constraint imposition. For instance, to distribute test-points along the leading edge (curvature and continuity constraints), we use OCCT to nd two parametric curves (PCurves) of the edge on two adjacent faces (Fig.8). Then we use OCCT to uniformly distributes points (in 1d parametric space) along each PCurve. As a result two pairs of test-points are generated each belonging to the respective PCurves. The test-point pairs along the edge1 (LE) and edge2 (TE) are then used to impose continuity and curvature constraints. It is also possible to generate test-point pairs on PCurves at arbitrary location on a given patch face (connect the predened endpoints (u1, v1) and (u2, v2) in the parametric space of the face). The generated test-points pairs are then used to impose thickness constraints between the two patches of the Stator. The treatment of constraints on a topological level allows to store these PCurves in a standard CAD le. This enables visualisation and inspection of the constraints during optimisation. For example in Fig.9 the pairs of PCurves are shown, where PCurves pairs are identically coloured. In addition, the PCurves can be stored and visualised as wire-frame objects with vertices as test-points. Once all necessary test-points are distributed, standard OCCT geometric algorithms (distance, cur- vature, normal, etc.) can be used to compute the following constraints: Distance constraints
To x the distance dr between two test-points (Xt1,Xt2), the following function is constructed:
Cd = distance(Xt1,Xt2) − dr = 0 . (10)
This constraint is used to ensure G0 continuity (dr = 0 is then used) and the constant axial chord length. Similarly, the minimum thickness (Tmin) constraint, which is required in the middle of the blade and for the bolts, corresponds to inequality constraint and is represented with: