Felix Laasch



So in case anybody is looking for this: this is how it worked for me. (Not the cleanest code, for example propably not all of the allsels are needed.) Postprocessing by the way was the most complex for me to get right as a first time user of apdl snippets. In my case I needed to add multiple resistors, each between a surface I defined beforehand as a named selection or component (not sure how it’s called in english) and a defined voltage. The snippet takes the named selection, couples all nodes together, adds another node somewhere else, inserts a circu124 between them and adds the voltage on the new node.

First snippet (added below the “steady-state thermal-electric conduction” branch of the tree)

!   Commands inserted into this file will be executed just prior to the ANSYS SOLVE command.
!   These commands may supersede command settings set by Workbench.
!   Active UNIT system in Workbench when this object was created:  Metric (mm, kg, N, s, V, A)
!   NOTE:  Any data that requires units (such as mass) is assumed to be in the consistent solver unit system.
!                See Solving Units in the help system for more information.
u1=0 ! Input voltage in Volt
r1= 1e-3  ! Resistor, Ohm, in this example 1 mOhm
cmsel,s,NS_Plus_2,node ! select all nodes of the named component NS_Plus_2
CP,NEXT,VOLT,ALL ! Nodal coupling to connect them all
*GET,NCMaster2,NODE,,NUM,MIN, , , , ! get the master node of the modal coupling
N,1000002,1,1,2,0,0,0 ! Insert another node somewhere
cmsel,s,NS_Plus_3,node ! repeat for each resistor
CP,NEXT,VOLT,ALL ! Nodal coupling
*GET,NCMaster3,NODE,,NUM,MIN, , , , !
N,1000003,1,1,3,0,0,0 ! 
et,100,circu124,0 ! define element type
r,100,r1 !definiert real constant 100 for the resistors value
type,100 ! activate element type
real,100 ! activate real constant
EN,2000002,1000002,NCMaster2 ! add element
EN,2000003,1000003,NCMaster3 ! repeat for every resistor
d,1000002,volt,u1 ! bring the voltage to the other side of the resistor
ALLSEL ! maybe not needed
d,1000003,volt,u1 ! repeat for every resistor
! *GET,my_units,ACTIVE,,UNITS 
! Warning, Workbench units must be set to Volt and Ampere to be able to work in Ohm here.
Second snippet for postprocessing (added under the “solution” branch of the tree)
set, last
allsel ! propably not needed…
*Get,my_NodalCurrent2,NODE,1000002,RF,AMPS ! use the default output search prefix function _my to get this into the results area under details of the snippet.
*Get,my_NodalCurrent3,NODE,1000003,RF,AMPS ! repeat for every resistor base node
allsel ! propably not needed…