**Feb 2023 Update – Read the revised tutorial for the dapta app here: https://daptadocs.com/Tutorials/Automating%20design%20optimisations.html**

**This is the third post in the parametric model series. In the last two posts, we first automated the creation of a parametric finite element model using Python and CalculiX GraphiX (cgx) and then automated the analysis and results plotting, which allowed us to run parametric design studies. In this post, we will first review and check the results generated by the parametric study, and then move onto the topic of design optimisation using OpenMDAO.**

Note: there is a copy of the example source code on github.com (make sure you use v0.0.3 for this post).

You can also get a quick video run-through of the code updates and optimisation implementation on Youtube, where I explain the inputs/outputs and demo the optimisation execution.

#### Example part 3: Model checking, testing and some additional features

Last time, we concluded that the deflections of the model looked sensible — but stated that more checks and tests would certainly be needed in practice to make sure that our model behaved in the expected way. And in fact there were a couple of problems that could have been spotted already:

- If our design intent was to induce bend-twist coupling, the model from v0.0.2 was not set up correctly. Indeed, the shell normals point into opposite directions on the top and bottom skins, which causes rotations of the main material fibre direction on both skins to be in opposite directions, whereas we wanted rotation in the same direction (see the video below for a more detailed explanation).
- The mean rotation calculation from the nodal displacements at the tip of the wing was not implemented correctly, leading to negative Ry rotations angles being calculated even for visibly positive tip rotations in the analysis output.

The first problem is related to our finite element model definition and the assumptions that we make as engineers. It is worth mentioning that **if the wing that you want to design and analyse is made of a single ply of material wrapped around the airfoil section, then the model from v.0.0.2 is probably set up correctly for your purposes**. However, we want to make the engineering design choice here to model a wing with discontinuous fibre orientations at the leading and trailing edges — we assume there will be joints or ply drops in the laminates at those locations. We can resolve this problem by simply splitting our airfoil surface at the leading edge in CalculiX GraphiX and flipping the top surface normal along with any associated shell elements. This allows us to have consistent shell normals and material orientations on the top and bottom skins, so that we can design a wing with bend-twist coupling (which will be useful for our optimisation in part 4 below).

The second problem is not related to engineering assumptions but is an error in the code implementation. **This type of error is insidious and potentially dangerous, because we were able to run the scripts for different inputs without getting any warnings or errors that told us something was wrong!** To catch this sort of error, we need to implement verification tests that compare the outputs of our mean rotation calculation script against known test cases — which is exactly the type of test that is now implemented in the test module.

The following video runs through the details of both fixes. In addition, I also go through some new features that I implemented to show you how easy it is to create more complex models from the existing code. The new features allow the user to define multiple sections along the span of the wing and also add solid core elements to some or all of these sections.

#### Example part 4: Parametric model design optimisation

So far, we have only looked at the effects of modifying a single design parameter in our model: the main composite material fibre direction. In reality, we are more likely to have tens or even hundreds of design parameters. In addition, we may have many different performance requirements that we want to satisfy at the same time. Using parametric studies to evaluate the individual and combined effects of all these parameters on the different design performance metrics could become very expensive indeed!

This is where design optimization algorithms become useful, as they can help us to find a good design faster. This may be a good time to review our first blog post from last year, where I provided a broad overview of design optimisation in engineering.

In this section, I wanted to provide a practical example of using open source optimisation libraries (OpenMDAO and Scipy.optimize) to design the properties of our wing model.

In the video below, I start by introducing OpenMDAO and implementing a simple constrained optimisation problem from the OpenMDAO documentation. I then define a design optimisation problem around our wing model (e.g. what I want to optimise, what is constrained and what the variables are) and adapt the optimisation implementation from the simple example to our wing model.

The output of the optimisation execution (if it converges) is the optimal design definition and performance of that design in terms of our objective and constraint functions. We now know that the maximum wing wash-out at the tip is 0.038 rads (2.2 degrees) if we constrain the vertical tip deflection magnitude to 6cm maximum, which corresponds to a main fibre direction rotation angle of 22.7 degrees.

#### Recap

We have now completed some basic model checking and we have also implemented an optimisation loop around our simple single discipline wing model example. Clearly, we could not have done this without automating our model creation, analysis and post-processing.

What is next? Well, clearly there are more tests that could be implemented if we wanted to make sure that we don’t break the code in the future. From an engineering point of view, we may also want to add more disciplines or “components” to our optimization problem. For example, we may want to couple the wing FEM to an aerodynamic analysis that generates the loads on the wing. We may also want to analyse the dynamic properties of the wing, as well as its static deflections. More on that next time!

#### From the author

Thanks for reading our blog. Feedback is a great way to learn, so if you have any questions or comments about this post or previous one, please get in touch! Olivia (Linkedin | Email)