This article presents a procedure to generate a plane wing using Ansys Design Modeller 15.0 and Ansys Workbench 15.0.
(but it should also work without significant changes on the prior versions).
The basic idea is:
- Use a Python script to generate an in-memory JScript file with the commands to construct the wing. The JScript is responsible for:
- Generate one or more planes, distant from each other in the Z direction;
- Generate the wing profiles, using the NACA algorithm, one for each plane created;
- Generate the solid from the profiles by using the Skin tool.
- Use this same Python script to "inject" the JScript file on a previously created Design Modeller system on Ansys Workbench.
All you have to do is create a Design Modeller in the Workbench Project Schematic, as below:
In general, most of the ANSYS tools are "scriptable". ANSYS Workbench uses Python as script language, whereas Ansys Design Modeler uses JScript. But how could we use these two languages to generate the plane wing ?
The answer relies on the Workbench ability to "inject" commands in the Systems in the Project Schematic.
This can be done by using these Python commands:
geomSystem = GetSystem(Name="Geom")
geometryComponent = geomSystem.GetContainer(ComponentName="Geometry")
The command SendCommand injects the contents of the variable jscript in the system geomSystem (which is a DesignModeler system).
So, in theory, all you need to do is generate this JScript, correct? Yes, and you'll realize that such script is not so hard to write (but also is not a simple one).
The full explanation of the Naca is beyond the scope of this article. You can find a very good explanation on this wikipedia link:
Here I'm using the 4-digit series. But the code could be easily adapted to a more complex series (5-digit, 6-digit, ...).
The formula for the shape of a NACA 4-digit is:
An excerpt for the respective Python code is:
_x = 1 - math.cos(math.radians(n) * (90.0 / (self._numberOfPoints - 1)))
_yt = (_t / 0.2) * (0.2969 * math.sqrt(_x) - 0.126 * _x - 0.3516 * _x ** 2 + 0.2843 * _x ** 3 - 0.1015 * _x ** 4)
if _x < _p:
_yc = (_m / _p ** 2) * (2 * _p * _x - _x ** 2)
_yc = (_m / (1 - _p) ** 2) * ((1 - 2 * _p) + 2 * _p * _x - _x ** 2)
You can find the full source code in a ZIP file attached in this article.
Once we have all the coordinates calculaded by the Python code, it's possible to generate the JScript code that effectively builds the profile. In fact, such code is a sequence of the following command:
p.Ln7 = Line( 0.00000, 0.00000, 0.00064, 0.00172);
In summary, this command instructs Design Modeler script engine to draw a line from a x1,y1 coordinate to a x2,y2 coordinate. There are as many commands like above as the points defined to generate the each profile.
By running the full code, you get a set of profiles like is shown in the figure below:
Important: Please notice that we've got a profile for each plane created. This is important, because in this case all the points of a given profile are coplanar.
Once we have all the profiles created, we can use the Skin command to generates the solid which in turn is the plane wing.
The JScript code that does this solid is shown below:
var Skin1 = agb.Skin(agc.Add, agc.No, 0.0, 0.0);
Skin1.Name = "Skin";
The Wing Definition
Below is the python code that does all the magic. It creates a WingGenerator object, and also defines 4 profiles:
- NACA 0412, factor scale 1.0, at the 0 position
- NACA 2412, factor scale 0.7, at the 2 position
- NACA 4412, factor scale 0.5, at the 4 position
- NACA 4606, factor scale 0.4, at the 6 position
ng = WingGenerator()
ng.addProfile("P01", 0, 4, 12, 1.0, 0)
ng.addProfile("P02", 2, 4, 12, 0.7, 2)
ng.addProfile("P03", 4, 4, 12, 0.5, 4)
ng.addProfile("P04", 4, 6, 06, 0.4, 6)
jscript = ng.writeScript()
The jscript variable contains the commands which will later injected in the DesignModeler system, as previously mentioned in this article.
The final result can be seen below:
As you can see, the result is very good.
The procedure to use this script is at follows:
- Edit the final part of the script to add as many profiles you want. Obviously, you need to know beforehand the NACA profiles you want to use and their respective position and scale
- In the Workbench GUI,
- Creates a blank project with a Geometry system on it;
- Selects File->Scripting ->Run Script File ..., and selects the edited python script
- (The wing building process occurs in the background)
- Open Design Modeller
- Please notice that the required Python script is attached to this article
- The code can be improved in many ways:
- You can use different plane orientations for each profile
- You can adapt the code to use profiles not generated by the NACA algorithm (e.g:, to generate a wind turbine blade);
- You can use splines to join the points, instead of straight lines;
- You can adapt the code to generate the farfield, if your intention is a CFD analysis.