You are on page 1of 5

5/5/2016

HowtousescriptstogenerateaplanewingusingANSYSDesignModeler15.0CustomerPortal
My activities

Submit a request

Sign in

Search

Customer Portal > ANSYS > Tips & Tricks

How To Use Scripts To Generate A Plane Wing Using


ANSYS Design Modeler 15.0

RELATED ARTICLES

Vinicius Strugata Ambrosio


Created: June 22, 2014 04:58 - Updated: August 01, 2014 19:02

How To Run Mechanical Benchmark


Cases
About ESSS

INTRODUCTION
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:

How to Run Fluent Benchmark Cases


Comparao entre modelos com
comportamentos elasto-plsticos
(Encruamento Isotrpico /
Encruamento Cinemtico).
Procedimento Para Instalar ANSYS Inc
License Manager 17.0 (Windows E
Linux)

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

PROMOTED ARTICLES
Non-drag Forces Implemented In
Rocky DEM-CFD Coupling Module
Procedimiento de Instalacin ANSYS
License Manager 16.0 (Windows y
Linux)
Procedimiento de Instalacin ANSYS
16.0 (Windows y Linux)
How to Create and Submit your First
Ticket
First Access to the ESSS Customer
Portal

Schematic, as below:

https://esss.zendesk.com/hc/enus/articles/205250985HowtousescriptstogenerateaplanewingusingANSYSDesignModeler150

1/5

5/5/2016

HowtousescriptstogenerateaplanewingusingANSYSDesignModeler15.0CustomerPortal

THE SOLUTION
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")
geometryComponent.Edit(Interactive=False)
geometryComponent.SendCommand(Command=jscript)
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).

NACA PROFILE
The full explanation of the Naca is beyond the scope of this article. You can find
a very good explanation on this wikipedia link:
http://en.wikipedia.org/wiki/NACA_airfoil
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)))
x.append(_x)

_yt = (_t / 0.2) * (0.2969 * math.sqrt(_x) - 0.126 * _x - 0.3516 * _x ** 2 +


0.2843 * _x ** 3 - 0.1015 * _x ** 4)
yt.append(_yt)

if _x < _p:

https://esss.zendesk.com/hc/enus/articles/205250985HowtousescriptstogenerateaplanewingusingANSYSDesignModeler150

2/5

5/5/2016

HowtousescriptstogenerateaplanewingusingANSYSDesignModeler15.0CustomerPortal
_yc = (_m / _p ** 2) * (2 * _p * _x - _x ** 2)
else:
_yc = (_m / (1 - _p) ** 2) * ((1 - 2 * _p) + 2 * _p * _x - _x ** 2)
yc.append(_yc)
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.

SOLID CREATION
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";
Skin1.AddBaseObject(skPlaneP01.Sk1);
Skin1.AddBaseObject(skPlaneP02.Sk1);
Skin1.AddBaseObject(skPlaneP03.Sk1);
Skin1.AddBaseObject(skPlaneP04.Sk1);
agb.Regen()

THE WING DEFINITION


Below is the python code that does all the magic. It creates a WingGenerator

https://esss.zendesk.com/hc/enus/articles/205250985HowtousescriptstogenerateaplanewingusingANSYSDesignModeler150

3/5

5/5/2016

HowtousescriptstogenerateaplanewingusingANSYSDesignModeler15.0CustomerPortal
object, and also defines 4 profiles:
1. NACA 0412, factor scale 1.0, at the 0 position
2. NACA 2412, factor scale 0.7, at the 2 position
3. NACA 4412, factor scale 0.5, at the 4 position
4. 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.

FINAL RESULT
The final result can be seen below:

As you can see, the result is very good.

USAGE
The procedure to use this script is at follows:
1. 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
2. In the Workbench GUI,
1. Creates a blank project with a Geometry system on it;
2. Selects File->Scripting ->Run Script File ..., and selects the
edited python script
3. (The wing building process occurs in the background)
3. Open Design Modeller
4. Enjoy!

https://esss.zendesk.com/hc/enus/articles/205250985HowtousescriptstogenerateaplanewingusingANSYSDesignModeler150

4/5

5/5/2016

HowtousescriptstogenerateaplanewingusingANSYSDesignModeler15.0CustomerPortal

FINAL REMARKS
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 ofstraight lines;
You can adapt the code to generate the farfield, if your
intention is a CFD analysis.

LINKS
About ESSS
www.python.org
wing_generator.zip (3 KB)

Facebook
Twitter
LinkedIn
Google+

Was this article helpful?

2 out of 2 found this helpful

Have more questions? Submit a request

Comments

Florianpolis +55 (48) 3953-0000 | So Paulo +55 (11) 3046-5744 | Rio de Janeiro +55 (21) 3293-1300 | Caxias do Sul +55 (54) 3419-1257
Home| Services| Software| Education| Company| Contact Us

2015 ESSS - All rights reserved


PoweredbyZendesk

https://esss.zendesk.com/hc/enus/articles/205250985HowtousescriptstogenerateaplanewingusingANSYSDesignModeler150

5/5

You might also like