


{"id":406941,"date":"2025-01-24T12:55:18","date_gmt":"2025-01-24T12:55:18","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/apdl-script-becomes-very-slow-due-to-fsum-in-loop\/"},"modified":"2025-01-24T13:06:31","modified_gmt":"2025-01-24T13:06:31","slug":"apdl-script-becomes-very-slow-due-to-fsum-in-loop","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/apdl-script-becomes-very-slow-due-to-fsum-in-loop\/","title":{"rendered":"Apdl script becomes very slow due to FSUM in loop"},"content":{"rendered":"<p>&lt;p style=&#8221;text-align: left;&#8221;&gt;&lt;p&gt;Hi,&lt;\/p&gt;&lt;p&gt;Currently I&#8217;m trying to get some nodal data into a CSV format, such that it is immediately proccesable by Matlab or Excel for specific weld calculations. Previously we used NLIST and NFORCE to export the nodal data, but this creates files with a lot of unwanted text. Since the column sizes differ per export, errors occured in the Matlab or VBA script while processing these text files into usable array&#8217;s. So, the idea was to export the data as a table only consisting of numbers directly from Ansys by using apdl. The table should consist of NodeNumber, LocX, LocY, LocZ, Fx, Fy, Fz (nodal forces, no constrained nodes) (or two tables are fine as well: Node,LocX,LocY,LocZ and Node,Fx,Fy,Fz)&lt;\/p&gt;&lt;p&gt;Now comes the issue, I&#8217;ve came up with the apdl code below, but this turns out to be very very slow when adding the FSUM into the DO loop. Is there a way to speed up this proces, or is there a better way to write the NFORCE data into a clean table only containing the nodal force data as separated arrays. Thanks!&lt;\/p&gt;&lt;p&gt;\/Post1&lt;br&gt;set,last&lt;\/p&gt;&lt;p&gt;csys,0&lt;br&gt;clocal,99,1,0,0,0,0,0,0 !creates a cylindrical coordinate system&lt;br&gt;csys,99 ! Make this 0 for XYZ and 99 for Cylindrical frame&lt;\/p&gt;&lt;p&gt;cmsel,s,Named_Selection_of_multiple_edges,NODE !select nodes in Named selection&lt;\/p&gt;&lt;p&gt;*GET,node_nr,NODE,0,count &nbsp; &nbsp; ! get total number of nodes&lt;br&gt;*GET,node_min,NODE,0,num,min &nbsp;! select node with minimum node number in selection&lt;br&gt;*dim,node_vec,,node_nr &nbsp;! create vector with nodes&lt;br&gt;n0=node_min&lt;br&gt;node_vec(1)=n0&lt;\/p&gt;&lt;p&gt;*do,i,2,node_nr&lt;br&gt;n0=ndnext(n0)&lt;br&gt;node_vec(i)=n0&lt;br&gt;*enddo&lt;\/p&gt;&lt;p&gt;*DIM, ANODES, TABLE, Node_nr, 3 !Define table to save coordinates &lt;\/p&gt;&lt;p&gt; *DO, J, 1, Node_nr,1&lt;br&gt;*GET, ANODES(J,1), NODE, node_vec(J), LOC, X ! when using Cylindrical frame X stands for R&lt;br&gt;*GET, ANODES(J,2), NODE, node_vec(J), LOC, Y ! when using Cylindrical frame Y stands for Theta&lt;br&gt;*GET, ANODES(J,3), NODE, node_vec(J), LOC, Z ! when using Cylindrical frame Z stands for Z&lt;\/p&gt;&lt;p&gt;*ENDDO&lt;\/p&gt;&lt;p&gt;csys,0 !reset coordinate frame to XYZ &lt;br&gt;set,,,,,3.525 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ! Set the specific time step in [sec] that needs to evaluated. Use &#8216;set,last&#8217; for 1 step simulation&lt;\/p&gt;&lt;p&gt;!Defining force vectors:&lt;\/p&gt;&lt;p&gt;*DIM, AFORCE, TABLE, Node_nr, 3&lt;\/p&gt;&lt;p&gt;*DO, ii, 1, Node_nr,1&lt;\/p&gt;&lt;p&gt;nsel,s,node,,node_vec(ii),node_vec(ii)&lt;\/p&gt;&lt;p&gt;FSUM&lt;\/p&gt;&lt;p&gt;&lt;br&gt;*GET, AFORCE(ii,1), FSUM,, ITEM, FX &lt;br&gt;*GET, AFORCE(ii,2), FSUM,, ITEM, FY&lt;br&gt;*GET, AFORCE(ii,3), FSUM,, ITEM, FZ&lt;\/p&gt;&lt;p&gt;*ENDDO&lt;\/p&gt;&lt;p&gt;&lt;br&gt;\/OUTPUT, OutputFile,csv&lt;\/p&gt;&lt;p&gt;*VWRITE, node_vec(1,1),ANODES(1,1),ANODES(1,2),ANODES(1,3),AFORCE(1,1),AFORCE(1,2),AFORCE(1,3)&lt;br&gt;%g, %g, %g, %g, %g, %g, %g &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;\/p&gt;&lt;p&gt;\/output&lt;\/p&gt;&lt;p&gt; &lt;\/p&gt;&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-406941","topic","type-topic","status-publish","hentry","topic-tag-apdl","topic-tag-do-loop-1","topic-tag-FSUM-1"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_forum_id":["27791"],"_bbp_topic_id":["406941"],"_bbp_subscription":["506933","20905"],"_bbp_author_ip":["93.240.151.42"],"_bbp_last_reply_id":["408434"],"_bbp_last_active_id":["408434"],"_bbp_last_active_time":["2025-02-05 08:25:13"],"_bbp_reply_count":["14"],"_bbp_reply_count_hidden":["0"],"_bbp_voice_count":["2"],"_bbp_engagement":["506933","20905"],"_btv_view_count":["510"],"_bbp_topic_status":["unanswered"],"_edit_last":["506933"],"_bbp_revision_log":["a:1:{i:406944;a:2:{s:6:\"author\";i:506933;s:6:\"reason\";s:0:\"\";}}"]},"test":"dee93643371db259ad6c06d2251eab763889eb48"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/406941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/406941\/revisions"}],"predecessor-version":[{"id":406944,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/406941\/revisions\/406944"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=406941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}