ACT Extension: How to write APDL code into different loadsteps of ds.dat

  • 33 Views
  • Last Post 05 June 2020
  • Topic Is Solved
Jan123 posted this 03 June 2020

Hi
 
I started to script my own ACT extension for the fused deposition modeling (FDM) process. I need to activate (with EALIVE) many elements, each element at one timestep in a transient thermal simulation. I saw that an Additive Manufacturing Extension exists (similar to FDM but not the same), but only as binary file so i can't learn from it.

The .xml will execute the main Python script on solve. The Python script writes all APDL Commands into the ds.dat by "WriteLine" but I didn't find out which Commands in IronPython allow me to write lines into the different loadsteps in ds.dat. By adding APDL command snippets in the model tree I can select the timesteps, in which the snippet is written - but how can i do this directly?

And how can i select the convection surface elements best? I need to select all surface152 elements of one belonging solid90 element in order to bring everything alive at the same time.
 
Thank you very much for your help!
 
Jan

Order By: Standard | Newest | Votes
Jan123 posted this 03 June 2020

The ds.dat should look like this, with APDL Commands inserted at different loadsteps:
 
/com,****************************************************************************
/com,*************************    SOLUTION       ********************************
/com,****************************************************************************

/com,****************************************************
/com,******************* SOLVE FOR LS 1 OF 2 ****************
...
! ****** Begin Command Snippet ******
!APDL code for Loadstep 1
! ****** End   Command Snippet ******
...
/com,****************************************************
/com,*************** FINISHED SOLVE FOR LS 1 *************
/com,****************************************************
/com,******************* SOLVE FOR LS 2 OF 2 ****************
...
! ****** Begin Command Snippet ******
!APDL code for Loadstep 2
! ****** End   Command Snippet ******
solve
/com,****************************************************
/com,*************** FINISHED SOLVE FOR LS 2 *************
/com,****************************************************

The XML:
...
(interface context="Mechanical"))
      (callbacks)
        (getsolvecommands)writebirthdeath(/getsolvecommands)
      (/callbacks)
(/interface)
 
The .py:
import os
 
def writebirthdeath(analysis,stream):
    stream.WriteLine("nropt, full")
    stream.WriteLine("tintp,,,,1")

    ##########Loadstep1##########
    stream.WriteLine("autots,on")
    stream.WriteLine("nsub,100,1000,10")
    #time 1 already selected
    stream.WriteLine("timint,on")
   
    stream.WriteLine("esel,all")
    stream.WriteLine("EKILL, ALL")
    stream.WriteLine("esel,s,cent,x,0,1")
    stream.WriteLine("esel,r,cent,z,0.5,0.5")
    stream.WriteLine("CM,EL_1,ELEM")
    stream.WriteLine("ealive,all")
    stream.WriteLine("NSLE,S,ALL")
    stream.WriteLine("D,ALL,TEMP,99")
    stream.WriteLine("allsel")
    stream.WriteLine("solve")

    ###########Loadstep2##########
    stream.WriteLine("autots,on")
    stream.WriteLine("nsub,100,1000,10")
    stream.WriteLine("time,2.")
    stream.WriteLine("timint,on")
   
    stream.WriteLine("cmsel,s,el_1")
    #stream.WriteLine("nsle,s,all") #seems not necessary?
    stream.WriteLine("ddele,all,temp")
    stream.WriteLine("allsel")
    stream.WriteLine("esel,s,cent,x,0,1")
    stream.WriteLine("esel,r,cent,z,1.5,1.5")
    stream.WriteLine("cm,el_2,elem")
    stream.WriteLine("ealive,all")
    stream.WriteLine("NSLE,S,ALL")
    stream.WriteLine("D,ALL,TEMP,99")
    stream.WriteLine("ALLSEL")
    stream.WriteLine("solve")

Jan123 posted this 04 June 2020

I tried to run it but ACTLog tells me:

   No module named Utililties

   Import Exception

How can I install this module?

Jan

Aniket posted this 04 June 2020

Which version are you using? Please try the same version that the extension uses, also, it contains the source code as well, so you can check and debug it.

 

BTW why do you need to write an extension to do this? Why can't the standard feature be used for this? (https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v201/en/wb_sim/ds_element_controls.html%23ds_element_controls)

-Aniket

How to access Ansys Online Help Document

How to show full resolution image

Guidelines on the Student Community

How to use Google to search within Ansys Student Community

 

Jan123 posted this 05 June 2020

2020 R1. I don't have an older version.
As I understand it, the .py file from the Extension "Command-Obj-to-ACT" wants to import different modules (import os, import shutil etc) and "import Ansys.Utilities" is not possible because it can not find said module.

You linked me the help site for Element birth and death - that's what I'm using. My extension has more functionality than only the code i wrote above.

By checking the source code I found what I was looking for. From the "GetCommandsCustomObj1(Me, SolverData, Stream):" I can use SolverData.CurrentStep to specify the timestep.

Thanks again for your help.

 

Close