0% found this document useful (0 votes)
7 views10 pages

Python External Connection in ANSYS

Uploaded by

Abdul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views10 pages

Python External Connection in ANSYS

Uploaded by

Abdul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Workshop-1

External Connection with a Python code

1 © 2011 ANSYS, Inc. November 29,


2012
Objectives
This workshop demonstrates
• How to use External connection system in Workbench with
third-party software
– How to update WB input parameters using output
parameters from other software

2 © 2011 ANSYS, Inc. November 29,


2012
Prerequisites

This workshop assumes that you have reviewed


• Introduction to External [Link]

Start with “[Link]” file


• This Python file is our “External Application”
– Reads the input parameters from a file
• For display purpose only (not used in WB)
– Performs some calculation
• Could also invoke an external code
– Read a output parameter file
Use
– [Link]  The input parameters for the external
application
– [Link]  The output from the external application…
to be used in WB for updating the geometry length
– [Link] project
• Length already defined as an input parameter

3 © 2011 ANSYS, Inc. November 29,


2012
Information

“[Link]” performs following functions


• Reads area and width from “[Link]” and creates input parameters in WB
– For display purpose only (not used in WB)
• Execute a external code ([Link])
• Reads length from “[Link]” and creates an output parameter in WB
– For use in WB to update the geometry length

“[Link]” needs to performs the following actions


• Read area and width from “[Link]”
• Calculate length and writes to “[Link]”

4 © 2011 ANSYS, Inc. November 29,


2012
The external (Python) code

A similar function has been


explained in the Workshop-2
in WB Python Scripting

Instead of doing the computation here,


one could invoke an external
application and wait for that to
generate the [Link] file

5 © 2011 ANSYS, Inc. November 29,


2012
Steps
• Create an “[Link]” file
– Explained in next few slides

• Keep the “[Link]” and “[Link]”


in the working directory

• Open “[Link]” file

• Create External Connection System


– Read “[Link]” file using Read
configuration

• Update the External Connection System

• Link the External Connection parameter “Length” to


“[Link]”

6 © 2011 ANSYS, Inc. November 29,


2012
Creating the XML file

Refer to documentation // External Connection Add-in // External


Connection Add-in :: 0 // Process Configuration XML File Details

The <Configuration> node contains the


<Instructions> and other attributes such as:
• SystemName - This is the user-visible string that is
assigned to the system
• CellName - This is the user-visible string that is
assigned to the cell

The information related to initialization (including


parameters definition) and update is provided
inside the global <Instructions> node. A
WorkingDirectory is defined inside the Instructions
node
Refer to next slide on ‘format’

7 © 2011 ANSYS, Inc. November 29,


2012
Creating the XML file (2)

[ Instruction Type ] - The type determines where the


instruction will be executed.
• Init - The parameter will be executed when the
configuration is read
• Update - The parameter will be executed when the project
is updated

8 © 2011 ANSYS, Inc. November 29,


2012
Creating the XML file (3)

[ Parameter Name ] - A unique name that represents a single


parameter in the Workbench environment.
[ Type ] - The general type of the parameter. It must be one of two
possible values:
• Input
• Output
[ Rule Name ] - A name given to the XML node that represents a single
parsing rule for the parameter defined by the rule's parent node.
Multiple rules can be defined for each parameter.
[ Rule Type ] - The type of the rule defined. This can be one of the
following values.
• File - The file rule defines the text file that contains the parameter
value.
• PreString - The text that immediately precedes the actual parameter
value in the file.
• DataType - Describes the type of data that represents the parameter.
9 © 2011 ANSYS, Inc. November 29,
2012
Linking output from ExternalConnection to Box length

P1 is constant

P1 is linked to P5
External Connection system and
the Parameters

10 © 2011 ANSYS, Inc. November 29, Need to solve as input parameter value changed
2012

You might also like