INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Using Python to define ANSYS Workbench Parameters

Using Python to define ANSYS Workbench Parameters

(OP)
Hello everybody,

I am creating a python script to run ANSYS Mechanical files for numerous load cases. So far I have managed to set the python script up to create a input journal within ANSYS which creates and changes certain loads and geometries associated with that load case. At present all of my variables are defined by Parameters and read through the python file from ANSYS.

Part of that study looks at varying the preload in a bolt, obtaining an average stress from a path, then applying a force and obtaining the average stress again. The difference between average stresses will be used as part of a study. I know I can create a CSV file to extract the results that I require, however what I am stuck on is how to use python (or ANSYS commands) to vary the initial preload in the study and then apply a load after this. Unfortunately I cannot define bolt preload using the parameters or specify a load to be applied after this.

Can anyone point me in the direction of the coding or method to use to alter the preload on the bolt and then apply a load on the load step after this.

Thanks

RE: Using Python to define ANSYS Workbench Parameters

Hi Andy,

Hopefully this is what you're after:

CODE --> Python

ExtAPI.DataModel.Project.Model.Analyses[0].AnalysisSettings.NumberOfSteps = 2

bolt =  ExtAPI.DataModel.Project.Model.Analyses[0].AddBoltPretension()
bolt.Location = ExtAPI.DataModel.Project.Model.NamedSelections.Children[2]

bolt.SetDefineBy(1,Ansys.ACT.Automation.Mechanical.Enums.BoltLoadDefineBy.Load)
bolt.SetDefineBy(2,Ansys.ACT.Automation.Mechanical.Enums.BoltLoadDefineBy.Lock)
bolt.Preload.Output.DiscreteValues = [Quantity('10[N]'), Quantity('20[N]')] # second value useless

myf = ExtAPI.DataModel.Project.Model.Analyses[0].AddForce()
myf.Magnitude.Inputs[0].DiscreteValues= [Quantity('0[sec]'), Quantity('1[sec]'),Quantity('2[sec]')]
myf.Magnitude.Output.DiscreteValues=[Quantity('0[N]'), Quantity('0[N]'), Quantity('10[N]')]
myf.Location = ExtAPI.DataModel.Project.Model.NamedSelections.Children[0] 

I'm a beginner at using Python in Mechanical. Here's a blog post on it: http://www.ansystips.com/2017/06/act-console.html.


Best Regards,
Jason

RE: Using Python to define ANSYS Workbench Parameters

(OP)
Hi Jason,

Thanks for your reply. Te code looks relatively simple and straight forward, however I am having difficulties with the ExtAPI - is there a specific module I should install in python?

I am pretty new to python so everything is a little.... slow

Andy

RE: Using Python to define ANSYS Workbench Parameters

Hi Andy,

I know it can be accessed through ACT console and ACT inside Mechanical (previous reply). I'm not aware of how to access it from outside of Ansys. Sorry, I'm no help here.


Best regards,
Jason

RE: Using Python to define ANSYS Workbench Parameters

(OP)
No problem Jason,

Thanks for your help!

Andy

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close