CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > ANSYS Meshing & Geometry

[ANSYS Meshing] Script Model - Mechanical

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 17, 2015, 03:04
Default Script Model - Mechanical
  #1
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Hello everyone,

I have to script a complete ANSYS analysis and allready managed to write a script with MATLAB which generates the engineering data and the geometry of a tooth from a gear-wheel (by importing points and create Skin's out of these).
Now I have to script all the meshing and external loads, fixed supports, ... by using the ANSYS Mechanical Feature (Model).

My question: Does anybody know where I can find information how to script the Mechanical feature of ANSYS? I couldn't find any helpful information in the "ANSYS Scripting Guide" or in the "Mechanical Application" directory (ANSYS HELP). Or does anybody has done some scripting on ANSYS Mechanical in the past?

Edit: Maybe I can solve the problem by using Icem CFD and do it manually and record all of my steps - does anybody tried this before?

Best Regards
Max

Last edited by USER1234; June 17, 2015 at 04:58.
USER1234 is offline   Reply With Quote

Old   June 17, 2015, 18:38
Default
  #2
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Max,

By quick search thru JS files in Ansys folder, I found this!
Code:
//Accesing the boundary conditions properties
var Env = DS.Tree.FirstActiveBranch.Environment;DS.Script.SelectItems(""+Env.ID);
//Creating force at the top of the structure
DS.Script.doInsertEnvironmentForce(1)
ListView.ActivateItem("Scoping Method");
ListView.ItemValue = "Named Selection" ;
ListView.ActivateItem("Named Selection");
ListView.ItemValue = "T1" ;
ListView.ActivateItem("Define By");
ListView.ItemValue = "Components" ;
ListView.ActivateItem("X Component");
ListView.ItemValue = "-10000"
ListView.SelectedItem.IsChecked="true"
ListView.ActivateItem("Y Component");
ListView.ItemValue = "0"
ListView.SelectedItem.IsChecked="true"
ListView.ActivateItem("Z Component");
ListView.ItemValue = "-810.42"
ListView.SelectedItem.IsChecked="true"
It looks like most of the function used in Mechanical has prefix of "doInsertEnvironment..." but I could be wrong.
Similar to this you can create, fixed support

You need to create Named Selection for the faces where you are applying force and support so that you can call them when you are running your script.

Hope it helps

Cheers
KAPI
USER1234 likes this.
Kapi is offline   Reply With Quote

Old   June 26, 2015, 04:19
Default
  #3
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by Kapi View Post
fixed support
Hi Kapi,

I managed to script MeshSizing and some other things but at the moment I have problems to find the "DS.Script.doInsert.." for FixedSupport in the .xml and .js files in Ansys directory. This here doesn't work .. it says that "DS.Script.doInsertEnvironmentFixedSupport();" doesn't exist:


Code:
var SelStatStruc=DS.Tree.FirstActiveBranch.Environment;
DS.Script.changeActiveObject(SelStatStruc.ID);
DS.Script.doInsertEnvironmentFixedSupport();

Best Regards,Max


EDIT: this one doesn't work ether:

Code:
 DS.Script.localString("ID_EnvironmentInsertDisplacementFixedSupport");
USER1234 is offline   Reply With Quote

Old   June 28, 2015, 18:47
Default
  #4
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Max,

Good Day!!
Try this!

Code:
DS.Script.doInsertEnvironmentFixedDisplacement(1)
It should help you solve your problem!


Cheers
KAPI
USER1234 likes this.
Kapi is offline   Reply With Quote

Old   June 30, 2015, 06:34
Default
  #5
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by Kapi View Post
Code:
DS.Script.doInsertEnvironmentFixedDisplacement(1)
Thanks - this one worked!

I have another problem in Mechanical when it comes to mesh my geometry:

I don't have problems to change the value of "Physics Preference" for example but I don't know how to access the parameters for "Sizing" (it is closed and has to be opened with the "+" infront)

When I want to change the "Sizing" -> "Min Size" an error says, that "Min Size" doesn't exist. I hope you understand what I mean - I have attached an example.

Best regards,
Max
Attached Images
File Type: png Access_Details_of_Mesh.png (8.9 KB, 22 views)
USER1234 is offline   Reply With Quote

Old   June 30, 2015, 21:08
Default
  #6
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Max,

You need to find particular functions just like you found physics preference, just search more!

Anyways this will help!

Code:
meshGroup.MinSizeSF = 0.0001;

Cheers
KAPI
USER1234 likes this.
Kapi is offline   Reply With Quote

Old   July 13, 2015, 10:07
Default
  #7
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by Kapi View Post
You need to find particular functions...
Hi KAPI,

I have another question: I couldn't find anything for selecting a force in my mechanical tree outline and activate this one.
I tried several codes like this ones:

Code:
var SelForce=DS.Tree.FirstActiveBranch.Environment.Load(1);
or
var SelForce=DS.Tree.FirstActiveBranch.Environment.Force(1);
or
var SelForce=DS.Tree.FirstActiveBranch.Environment.Force;
or
var SelForce=DS.Tree.FirstActiveBranch.Load(1);
or
var SelForce=DS.Tree.FirstActiveBranch.Force(1);
or
var SelForce=DS.Tree.FirstActiveBranch.Environment.Item(1);
...

DS.Script.changeActiveObject(SelForce.ID);
Maybe you know how to acces this force.

Thank you for all your help!


Best regards,
Max
USER1234 is offline   Reply With Quote

Old   July 13, 2015, 18:21
Default
  #8
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Max,

Quote:
I couldn't find anything for selecting a force in my mechanical tree outline
How did you get your force in your tree outline?
What I mean is you can give values of force when you first created the force by the below code (for ex: force at top of the strcuture)
Code:
DS.Script.doInsertEnvironmentForce(1)
so you dont have access it again but if you need then I will check how to do it and get back to ya!

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   July 14, 2015, 00:14
Default
  #9
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by Kapi View Post
so you dont have access it again but if you need then I will check how to do it and get back to ya!
I want to run the analysis and after getting the result I want to change the force which I have created (change the position where the force is pointing at my surface) and want tu run the analysis again and again and again ..

So it would be nice if you could check this!

Best regards
Max
USER1234 is offline   Reply With Quote

Old   July 14, 2015, 02:10
Default
  #10
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
.. I will try to delete this force and create a new force .. maybe this works

.. have you used "commands" in the tree outline of Mechanical Ansys? Can I change the material by overwrite the material properties in APDL code?
USER1234 is offline   Reply With Quote

Old   July 14, 2015, 20:09
Default
  #11
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Max,

Yea you can try to delete force and add new one. You can try to make it parametric as well so that you can run the same simulation by only changing force.
I have not done much on Ansys mechanical Tree outline so I have limited knowledge.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   July 15, 2015, 04:30
Default
  #12
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
I figured out how to access features (pressure, fiexed support, force, ..) in the tree outline:

Code:
DS.Tree.FirstActiveBranch.Environment.Loads.Item(i);
USER1234 is offline   Reply With Quote

Old   July 15, 2015, 18:13
Default
  #13
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Good Job Max,

I have been busy lately, will get back to CFDOnline by tuesday most likely!
Kapi is offline   Reply With Quote

Old   July 22, 2015, 03:09
Default
  #14
New Member
 
Joakim
Join Date: Jul 2015
Posts: 14
Rep Power: 10
joxen is on a distinguished road
Quote:
Originally Posted by USER1234 View Post
I figured out how to access features (pressure, fiexed support, force, ..) in the tree outline:

Code:
DS.Tree.FirstActiveBranch.Environment.Loads.Item(i);

Hi, I'm working with a similar project and have the same problem as you have. I'd like to select an already existing load in the tree and make changes. Lets say that we have a pressure load and we like to supress it. Would the code be like:


Code:
DS.Tree.FirstActiveBranch.Environment.Loads.Pressure(i);
ListView.ActivateItem("Suppressed");
ListView.ItemValue="No";
[/QUOTE]

I'm not sure if i should change item to pressure or ad a number instead of i?
joxen is offline   Reply With Quote

Old   July 22, 2015, 03:25
Default
  #15
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by joxen View Post
I'm not sure if i should change item to pressure or ad a number instead of i?
hi,

"item" is for all of the different external inputs like pressure, force, .. the same. You get access to the different loads by replace the "i" with the position in your tree of the item which you want to select.

So for example you have in your "loads" a fixed support at first position and a pressure on second position.
to select the pressure and set it to "unsuppressed" the code should be the following:

Code:
var SelPressure = DS.Tree.FirstActiveBranch.Environment.Loads.Item(2);
DS.Script.changeActiveObject(SelPressure.ID);
ListView.ActivateItem("Suppressed");
ListView.ItemValue="No";
If it is not working - just let me know!

Best Regards,
Max
USER1234 is offline   Reply With Quote

Old   July 22, 2015, 04:05
Default
  #16
New Member
 
Joakim
Join Date: Jul 2015
Posts: 14
Rep Power: 10
joxen is on a distinguished road
Quote:
Originally Posted by USER1234 View Post
hi,

"item" is for all of the different external inputs like pressure, force, .. the same. You get access to the different loads by replace the "i" with the position in your tree of the item which you want to select.

So for example you have in your "loads" a fixed support at first position and a pressure on second position.
to select the pressure and set it to "unsuppressed" the code should be the following:

Code:
var SelPressure = DS.Tree.FirstActiveBranch.Environment.Loads.Item(1);
DS.Script.changeActiveObject(SelPressure.ID);
ListView.ActivateItem("Suppressed");
ListView.ItemValue="No";
If it is not working - just let me know!

Best Regards,
Max

Thank you so much, it work, but i also have a question regarding how to change the analysis settings, for example NumberOfSetps?


Code:
var SelAnslysis = DS.Tree.FirstActiveBranch.Environment.Loads.Item(2);
DS.Script.changeActiveObject(SelAnalysis.ID);
ListView.ActivateItem("NumberOfSteps");
ListView.ItemValue="2";
I
Thanks for your assistance

Last edited by joxen; July 23, 2015 at 05:36.
joxen is offline   Reply With Quote

Old   July 24, 2015, 07:51
Default
  #17
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by joxen View Post
i also have a question regarding how to change the analysis settings, for example NumberOfSetps?
I will look at this on monday .. I don't have acces to ANSYS at the moment.


I also have another question:
in Mechanical you have the option to export a file with the result of the displacement. Does anybody know the code to do this export?

Best regards
Max
USER1234 is offline   Reply With Quote

Old   July 26, 2015, 18:58
Default
  #18
Senior Member
 
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14
Kapi is on a distinguished road
Hi Max,

I think you have to use "Send Command" in .wbjn file to export your result with Displacement. I have never used export command in mechanical but I used once for CFX result file.

Cheers
KAPI
Kapi is offline   Reply With Quote

Old   July 27, 2015, 02:55
Default
  #19
Member
 
Max
Join Date: May 2015
Posts: 48
Rep Power: 10
USER1234 is on a distinguished road
Quote:
Originally Posted by Kapi View Post
Hi Max,

I think you have to use "Send Command" in .wbjn file to export your result with Displacement. I have never used export command in mechanical but I used once for CFX result file.

Cheers
KAPI
Hi,

can you share the code for export CFX result file? Maybe it will be quite similar to export the Mechanical result file?!

Best regards,
Max

EDIT: I figured out how to export a specific solution (in my case: Displacement on a node) into a txt-file or in a Excel-file.
here is the code (to write in txt-file use:"DS.Script.doExportToTextFile(FilePath="XXX")" ):

Code:
var SelDis=DS.Tree.FirstActiveBranch.AnswerSet.Results.Item(1);
DS.Script.changeActiveObject(SelDis.ID);
DS.Script.doExportToTextFile(FilePath="XXX.xls")
now I have the problem that I want to change my force after output the displacement result in Excel and will output the new result in the same excel file .. it will overwrite it in excel -> so I have to tell excel in which cell it should write the new displacement result - does anybody know how to do that?

Best regards,
Max

Last edited by USER1234; July 27, 2015 at 06:37.
USER1234 is offline   Reply With Quote

Old   July 27, 2015, 07:36
Default
  #20
New Member
 
Joakim
Join Date: Jul 2015
Posts: 14
Rep Power: 10
joxen is on a distinguished road
Quote:
Originally Posted by Kapi View Post
Hi Max,

I think you have to use "Send Command" in .wbjn file to export your result with Displacement. I have never used export command in mechanical but I used once for CFX result file.

Cheers
KAPI

Hi Kapi,

Do you know how to handle the command snippet with the journal script?`
I can access all loads and results with the codes:

Code:
var SelExtMoment = DS.Tree.FirstActiveBranch.Environment.Loads.Item(2);
DS.Script.changeActiveObject(SelExtMoment.ID);
ListView.ActivateItem("Suppressed");
ListView.ItemValue="No";
and

Code:
var SelCommands = DS.Tree.FirstActiveBranch.AnswerSet.Item(1);
DS.Script.changeActiveObject(SelCommands.ID);
ListView.ActivateItem("Suppressed");
ListView.ItemValue="Yes";
to suppress and unsuppress each item. I have some command snippets in the Environment section that I want to suppress and unsuppress and also in the solution/AnswerSet but I can't control them.

If the snippet is in place 3 and I choose Item(3) it skips the snippet and suppress the next item. Do you know how to handle this?

Thanks
// Joakim
joxen is offline   Reply With Quote

Reply

Tags
ansys, mechanical, mesh, model, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Atomization and Breakup model xck1986 OpenFOAM 4 May 31, 2014 04:43
manualInjection model in sprayFoam Mentalo OpenFOAM Running, Solving & CFD 1 April 2, 2014 09:29
Mixture model + VOF? blacksoil2012 Fluent Multiphase 2 February 8, 2014 23:59
eddy dissipation model: combustion doesn't occur roukaia FLUENT 0 December 24, 2011 09:10
Problems bout CFD model of biomass gasification, Downdraft gasifier wanglong FLUENT 2 November 25, 2009 23:27


All times are GMT -4. The time now is 19:13.