|
[Sponsors] |
June 17, 2015, 04:04 |
Script Model - Mechanical
|
#1 |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
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 05:58. |
|
June 17, 2015, 19:38 |
|
#2 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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" 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 |
|
June 26, 2015, 05:19 |
|
#3 |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
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"); |
|
June 28, 2015, 19:47 |
|
#4 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Max,
Good Day!! Try this! Code:
DS.Script.doInsertEnvironmentFixedDisplacement(1) Cheers KAPI |
|
June 30, 2015, 07:34 |
|
#5 |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
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 |
|
June 30, 2015, 22:08 |
|
#6 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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 |
|
July 13, 2015, 11:07 |
|
#7 |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
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); Thank you for all your help! Best regards, Max |
|
July 13, 2015, 19:21 |
|
#8 | |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Hi Max,
Quote:
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) Cheers KAPI |
||
July 14, 2015, 01:14 |
|
#9 | |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
Quote:
So it would be nice if you could check this! Best regards Max |
||
July 14, 2015, 03:10 |
|
#10 |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
.. 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? |
|
July 14, 2015, 21:09 |
|
#11 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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 |
|
July 15, 2015, 05:30 |
|
#12 |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
I figured out how to access features (pressure, fiexed support, force, ..) in the tree outline:
Code:
DS.Tree.FirstActiveBranch.Environment.Loads.Item(i); |
|
July 15, 2015, 19:13 |
|
#13 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
Good Job Max,
I have been busy lately, will get back to CFDOnline by tuesday most likely! |
|
July 22, 2015, 04:09 |
|
#14 | |
New Member
Joakim
Join Date: Jul 2015
Posts: 14
Rep Power: 11 |
Quote:
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"; I'm not sure if i should change item to pressure or ad a number instead of i? |
||
July 22, 2015, 04:25 |
|
#15 | |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
Quote:
"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"; Best Regards, Max |
||
July 22, 2015, 05:05 |
|
#16 | |
New Member
Joakim
Join Date: Jul 2015
Posts: 14
Rep Power: 11 |
Quote:
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"; Thanks for your assistance Last edited by joxen; July 23, 2015 at 06:36. |
||
July 24, 2015, 08:51 |
|
#17 | |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
Quote:
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 |
||
July 26, 2015, 19:58 |
|
#18 |
Senior Member
Join Date: Apr 2014
Location: Melbourne
Posts: 584
Rep Power: 14 |
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 |
|
July 27, 2015, 03:55 |
|
#19 | |
Member
Max
Join Date: May 2015
Posts: 48
Rep Power: 11 |
Quote:
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") Best regards, Max Last edited by USER1234; July 27, 2015 at 07:37. |
||
July 27, 2015, 08:36 |
|
#20 | |
New Member
Joakim
Join Date: Jul 2015
Posts: 14
Rep Power: 11 |
Quote:
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"; Code:
var SelCommands = DS.Tree.FirstActiveBranch.AnswerSet.Item(1); DS.Script.changeActiveObject(SelCommands.ID); ListView.ActivateItem("Suppressed"); ListView.ItemValue="Yes"; 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 |
||
Tags |
ansys, mechanical, mesh, model, script |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Atomization and Breakup model | xck1986 | OpenFOAM | 4 | May 31, 2014 05:43 |
manualInjection model in sprayFoam | Mentalo | OpenFOAM Running, Solving & CFD | 1 | April 2, 2014 10:29 |
Mixture model + VOF? | blacksoil2012 | Fluent Multiphase | 2 | February 9, 2014 00:59 |
eddy dissipation model: combustion doesn't occur | roukaia | FLUENT | 0 | December 24, 2011 10:10 |
Problems bout CFD model of biomass gasification, Downdraft gasifier | wanglong | FLUENT | 2 | November 26, 2009 00:27 |