Customization d S i ti and Scripting
Within the Within the Workbench
E i tEnvironment
© 2012 CAE Associates
Understanding the Workbench Framework
Native applications Native applications— Built entirely on WB2 Framework— Embedded within the “Workbench”
windowwindow— Project Schematic, Design
Exploration, Engineering Data— Fully support by Workbench scriptingy pp y p g— Scripting Language: Python
Data-integrated applications Data integrated applications— Share data and parameters with
Workbench, native applications, and other data-integrated applications
— Independent GUI (WB1 Framework)• E.g., Mechanical, Mechanical APDL,
CFX, FLUENT, DeisgnModelerS i ti L J i t APDL
2
— Scripting Language: Jscript, APDL…
Workbench Customization Options
1 Workbench journaling and scripting for native applications1. Workbench journaling and scripting for native applications— Fully documented and supported— Python-based scripting language
2 Presently (v14 0) customization in ANSYS Mechanical2. Presently (v14.0) customization in ANSYS Mechanical1. Command Blocks2. Custom Scripting
F d t ti f i ti f t th h JS i t ( bj t i— Focused on automation of existing features through JScript (e.g.: objects in outline tree, wizards, etc…)
— Not possible to create new “features”Not documented— Not documented
3. The Application Customization Toolkit (ACT) at v14.5 enables— Ability to create new features
Id ti l b h i d i t ti t d d W kb h f t— Identical behavior and integration as standard Workbench features• Persistent and parametric approach
— Documented Application Programming Interface (API) Reference and Developer’s Guide sample templates etc
3
Developer s Guide, sample templates, etc..
Workbench ACT Customization
The “Application Customization Toolkit” will be The Application Customization Toolkit will be— A lasting solution— Maintainable and supportable
Integrated into standard Workbench— Integrated into standard Workbench— Open to other disciplines (Mechanical as of today)
• Next step: CFD, Fluent, LS-DYNAFlexible and customizable by third party (compiler not mandatory)— Flexible and customizable by third party (compiler not mandatory)
ACT-based Extensions library : Customization forum enabling customers to upload/share their own Extensionsto upload/share their own Extensions
— Planned ACT-based extensions to be posted:• Acoustics• FE InfoFE Info• Morphing• Advanced post-processing• Post-processing for beams
4
• Workbench/LS-DYNA
Workbench ACT Customization
A homogeneous API providing access to the main components of A homogeneous API providing access to the main components of Workbench (Mechanical)
— GUI components, Mesh, Geometry, simulation data, graphs, charts…Accessible by Python or C++ / C#— Accessible by Python or C++ / C#
— Ability to integrate new BCs, loads, results, etc…— Ability to access additional information/properties during the simulation process
5
Workbench ACT Overview
ACT Infrastructure ACT Infrastructure
6
Examples of the Customization Options
Workbench Scripting Examples: Workbench Scripting Examples:— Project Page Customization
• Record Journal / Python— MAPDL Material Importp
— Mechanical GUI Customization• Command Blocks• Jscript:
— Named Selection Creation— Set Mechanical session defaults— Force based submodeling
• ACTACT— MAPDL macro reuse— Demo: Interact with the Mechanical GUI
7
Project Page C t i tiCustomization
Material Import GUI
© 2012 CAE Associates
Workbench Customization
Users that have ANSYS APDL formatted material properties may want to Users that have ANSYS APDL formatted material properties may want to be able to import them into Workbench in an automated way.
A python script was used to convert the data from APDL into a XML formatted file The XML file is then imported into WBformatted file. The XML file is then imported into WB.
9
Workbench Customization
The material import script is called from a Project Page button The material import script is called from a Project Page button. APDL material libraries are read in from a directory and listed.
10
Workbench Customization
Data will be added to the Engineering Data of the currently highlighted Data will be added to the Engineering Data of the currently highlighted system.
— If an Engineering Data item does not exist for the System or no System is currently selected, a new Engineering Data Standalone system will be created.currently selected, a new Engineering Data Standalone system will be created.
11
Workbench Customization
Material names and properties imported into Engineering Data Material names and properties imported into Engineering Data
12
Mechanical C t i tiCustomization
Command Blocks
© 2012 CAE Associates
Command Block Example
Apply a convective boundary condition to the blade surface in a 2D axi- Apply a convective boundary condition to the blade surface in a 2D axi-symmetric analysis— Since the model is 2D, a convective boundary condition is allowed only on edges
Using a command snippet we can apply the convection load to the surface!— Using a command snippet we can apply the convection load to the surface!
14
Mechanical C t i tiCustomization
Add Icons to GUI for Commonly Used ScriptsCommonly Used Scripts
© 2012 CAE Associates
Mechanical Customization
Custom scripts can be assigned to buttons and added into the Mechanical Custom scripts can be assigned to buttons and added into the Mechanical GUI Tool bars and Menu Bars.
— The buttons are created through a XML add-in that runs a JScript upon loading the Mechanical GUI.the Mechanical GUI.
— Clicking on a button calls a user created JScript.
16
Mechanical Customization
Example: A Tool bar button is used to call script that creates named Example: A Tool bar button is used to call script that creates named selections of all surfaces in the model.
Used to improve geometry creation within FE Modeler.FE Modeler can build geometry from nodal components— FE Modeler can build geometry from nodal components.
— A deformed mesh from a Mechanical simulation can be turned into CAD geometry through this process.
17
Mechanical C t i tiCustomization
Setting User Defaults
© 2012 CAE Associates
Mechanical Customization
The Mechanical GUI provides the user input to set various defaults The Mechanical GUI provides the user input to set various defaults, however not all settings within the GUI can be set.
19
Mechanical Customization
Using scripting any setting within the Mechanical GUI can become a user Using scripting, any setting within the Mechanical GUI can become a user default.
For example, the following global mesh controls are always set to:Shape Checking = Standard Mechanical— Shape Checking = Standard Mechanical
— Automatic Mesh Based Defeaturing = ON
20
Mechanical Customization
As a best practice it might be preferred to always use custom settings As a best practice, it might be preferred to always use custom settings.— A customer can always start an analysis with company approved defaults.
This can be accomplished with an add-in that calls a JScript upon the first time Mechanical is openedtime Mechanical is opened.
— This example script keys off the geometry attach action to track the first time Mechanical is opened.A session variable is saved in the project afterwards which ensures the script— A session variable is saved in the project afterwards, which ensures the script is not called again due to a geometry update.
21
Mechanical Customization
The Jscript is attached to an action call back in Mechanical that prompts The Jscript is attached to an action call back in Mechanical that prompts the user if they’d like to accept the custom default settings.
22
SubmodelingA t ti i Automation in
Ansys Workbench Mechanical
© 2012 CAE Associates
Submodeling - Background
Submodeling is an analysis technique that allows for a more refined Submodeling is an analysis technique that allows for a more refined solution to be calculated from a previous analysis.
— This analysis technique uses two separate models (one coarse and one more refined).refined).
— The results from the coarse model are mapped onto the refined model as an analysis input.
The results that are typically mapped between the two different models are yp y ppdisplacements.
— i.e. the calculated displacement results from the coarse model are mapped as input displacements onto the refined model.
Displacements or forces could however be used with this technique.
24
Submodeling - Background
Force-based submodeling: Force-based submodeling:— Useful when the refined model does not match up well with the global model’s
stiffness.— Using forces allows for both models to share the same loadingUsing forces allows for both models to share the same loading.
An example of using forces is shown below:
Fixed Support
Fixed Support Same load transferred between the
two models when mapping forces
Load
two models when mapping forces.
Load= 1200
Load = 1200
25
Mapped forces
Submodeling - Background
Displacement-based submodeling: Displacement-based submodeling:— This procedure is already built within MAPDL.— This type of submodeling can be done within Workbench; however it would
require a series of command blocks at v14 0require a series of command blocks at v14.0.
Force-based submodeling:This is not directly available within either the MAPDL or Workbench GUIs— This is not directly available within either the MAPDL or Workbench GUIs.
— Workbench scripting can be used to implement this analysis technique.
26
Workbench Submodel Automation
Procedure Summary Procedure Summary— Run global model, possibly many load cases.— Apply global model cut boundary loads on submodel.
Workbench Mechanical automation procedure for detailed analysis:
Gl b l d l ith l d t S bmodel ith applied freebodGlobal model with loads to… Submodel with applied freebodyloads from the Global model
27
Workbench Submodel Automation
What does the user have to do? What does the user have to do?— Create the global model loads file, formatted as shown:
Node Number Node X – Coord Node Y - Coord Node Z – Coord X – Force Y – Force Z – Force X - Moment Y – Moment Z - Moment0.34600000E+03 0.22869699E+01 0.39693382E+01 0.10000000E+01 -0.43632647E+03 0.00000000E+00 -0.10134672E+03 0.00000000E+00 0.00000000E+00 0.00000000E+000.34700000E+03 0.20547679E+01 0.41314414E+01 0.10000000E+01 0.44097543E+02 0.00000000E+00 -0.24463717E+02 0.00000000E+00 0.00000000E+00 0.00000000E+00
• Note: Exclude the header line shown for format purposes only
0.34700000E+03 0.20547679E+01 0.41314414E+01 0.10000000E+01 0.44097543E+02 0.00000000E+00 0.24463717E+02 0.00000000E+00 0.00000000E+00 0.00000000E+000.34800000E+03 0.18225660E+01 0.42935446E+01 0.10000000E+01 -0.67849514E+02 0.00000000E+00 0.11068292E+02 0.00000000E+00 0.00000000E+00 0.00000000E+000.34900000E+03 0.15903641E+01 0.44556478E+01 0.10000000E+01 -0.41197611E+03 0.00000000E+00 0.14319679E+02 0.00000000E+00 0.00000000E+00 0.00000000E+000.35000000E+03 0.13581622E+01 0.46177510E+01 0.10000000E+01 -0.32768655E+03 0.00000000E+00 0.47461539E+02 0.00000000E+00 0.00000000E+00 0.00000000E+000.36200000E+03 -0.11653908E+01 0.41971589E+01 0.10000000E+01 -0.25396659E+03 0.24740064E+03 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+000.36300000E+03 -0.13489603E+01 0.40477800E+01 0.10000000E+01 -0.41577343E+03 0.57856992E+03 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+000.36400000E+03 -0.15325299E+01 0.38984010E+01 0.10000000E+01 -0.27608402E+03 0.40337368E+03 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00
• Note: Exclude the header line, shown for format purposes only.
— The following MAPDL script can be used as an example to generate this file:set,last
l fnsel,,,,Cut_Surfesel,,,,Cut_Body*dim,rxns,,ndinqr(0,13),7ndcur=0*do,i,1,ndinqr(0,13)ndcur=ndnext(ndcur)nsel,,,,ndcurFsum
(i 1) drxns(i,1)=ndcur*get,rxns(i,2),node,ndcur,loc,x*get,rxns(i,3),node,ndcur,loc,y*get,rxns(i,4),node,ndcur,loc,z*get,rxns(i,5),fsum,,ITEM,fx*get,rxns(i,6),fsum,,ITEM,fy*get,rxns(i,7),fsum,,ITEM,fznsel,,,,cut_Surf* dd
28
*enddo*mwrite,rxns,ANSYS_RXNs,csv,,jik(7E16.8)
Workbench Submodel Automation
Automated loads generation example: Automated loads generation example:
29
Mechanical C t i tiCustomization
Application Customization Toolkit (ACT)Toolkit (ACT)
© 2012 CAE Associates
ACT Customization
User scenarios User scenarios— Scenario A:
• Need to only create new features (not existing in Mechanical already)Scenario B:— Scenario B:
• Need to automate existing and new features in Mechanical
New GUI features
Interact with GUI real time
User specific Result
31
Apply a convective boundary condition to the blade surface in a 2D axi-
ACT Example
Apply a convective boundary condition to the blade surface in a 2D axi-symmetric analysis
Create an ACT extension to apply this loadEasy to use— Easy to use
— Reduce potential errors
32
APDLWB Mechanical
Reuse of an APDL Macro
! APDL_script_for_convection.inp
/prep7cmsel,s,componentthickness = 0 001thickness = 0.001film_coefficient = 200temperature = 120
*GET,n_el,ELEM,0,num,max*GET,mat1, ELEM,n_el,ATTR,MAT
et,100,152keyop,100,8,2.et,1001,131keyo,1001,3,2sectype,1001,shell
d t thi k t1secdata,thickness,mat1secoff,mid
emodif,all,type,1001emodif,all,secnum,1001type,100esurffinialls/soluesel,s,type,,100nsle
33
sf,all,conv,film_coefficient,temperatureallsel, all
ACT Demo
Query FE information from the Mechanical GUI Query FE information from the Mechanical GUI
34
Thank You!
© 2012 CAE Associates
Top Related