


{"id":408930,"date":"2025-02-08T20:13:25","date_gmt":"2025-02-08T20:13:25","guid":{"rendered":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/imported-load-using-pymechanical\/"},"modified":"2025-02-10T11:35:55","modified_gmt":"2025-02-10T11:35:55","slug":"imported-load-using-pymechanical","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/imported-load-using-pymechanical\/","title":{"rendered":"Imported Load using PyMechanical"},"content":{"rendered":"<p>&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;Hello everyone,&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;For my PhD work, I am attempting to run a whole &ldquo;Static Structural&rdquo; simulation on Ansys mechanical using only the scripting feature, utilizing PyMechanical to run the simulation through VS Code. So far, I have been using the &ldquo;Recording&rdquo; feature in Mechanical Scripting for help with the code needed to run the simulation.&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;I have csv files that have displacement and temperature data for multiple timesteps for the model on which I am running the simulation. I have so far been able to implement displacements and velocities in every timestep without the need to use &ldquo;Imported Load&rdquo; since these boundary conditions only apply to certain edges\/bodies. However, my temperature data consists of x and y coordinates (2-D Geometry) and the temperature at that point for every timestep. Doing this while utilizing GUI, I am easily able to utilize &lt;span style=&#8221;mso-spacerun: yes;&#8221;&gt;&nbsp;&lt;\/span&gt;&ldquo;Imported Load&rdquo; &lt;span style=&#8221;mso-spacerun: yes;&#8221;&gt;&nbsp;&lt;\/span&gt;to set each column to a timestep and everything is imported without issue. However, with scripting, I get stuck at filling up the table to assign timesteps to specific rows:&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US; mso-no-proof: yes;&#8221;&gt;&lt;!&#8211; [if gte vml 1]&gt;&lt;v:shapetype id=&#8221;_x0000_t75&#8243; coordsize=&#8221;21600,21600&#8243;<br \/>\n o:spt=&#8221;75&#8243; o:preferrelative=&#8221;t&#8221; path=&#8221;m@4@5l@4@11@9@11@9@5xe&#8221; filled=&#8221;f&#8221;<br \/>\n stroked=&#8221;f&#8221;&gt;<br \/>\n &lt;v:stroke joinstyle=&#8221;miter&#8221;\/&gt;<br \/>\n &lt;v:formulas&gt;<br \/>\n  &lt;v:f eqn=&#8221;if lineDrawn pixelLineWidth 0&#8243;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;sum @0 1 0&#8243;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;sum 0 0 @1&#8243;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;prod @2 1 2&#8243;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;prod @3 21600 pixelWidth&#8221;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;prod @3 21600 pixelHeight&#8221;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;sum @0 0 1&#8243;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;prod @6 1 2&#8243;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;prod @7 21600 pixelWidth&#8221;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;sum @8 21600 0&#8243;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;prod @7 21600 pixelHeight&#8221;\/&gt;<br \/>\n  &lt;v:f eqn=&#8221;sum @10 21600 0&#8243;\/&gt;<br \/>\n &lt;\/v:formulas&gt;<br \/>\n &lt;v:path o:extrusionok=&#8221;f&#8221; gradientshapeok=&#8221;t&#8221; o:connecttype=&#8221;rect&#8221;\/&gt;<br \/>\n &lt;o:lock v:ext=&#8221;edit&#8221; aspectratio=&#8221;t&#8221;\/&gt;<br \/>\n&lt;\/v:shapetype&gt;&lt;v:shape id=&#8221;Picture_x0020_1&#8243; o:spid=&#8221;_x0000_i1025&#8243; type=&#8221;#_x0000_t75&#8243;<br \/>\n style=&#8217;width:450.75pt;height:194.25pt;visibility:visible;mso-wrap-style:square&#8217;&gt;<br \/>\n &lt;v:imagedata src=&#8221;file:\/\/\/C:\/Users\/abdud\/AppData\/Local\/Temp\/msohtmlclip1\/01\/clip_image001.png&#8221;<br \/>\n  o:title=&#8221;&#8221;\/&gt;<br \/>\n&lt;\/v:shape&gt;&lt;![endif]&#8211;&gt;&lt;!&#8211; [if !vml]&#8211;&gt;<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/innovationspace.ansys.com\/forum\/wp-content\/uploads\/sites\/2\/2025\/02\/08-02-2025-1739045528-blobid0.png\" width=\"601\" height=\"259\" \/>&lt;!&#8211;[endif]&#8211;&gt;&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;The &rdquo;Recording&rdquo; feature has unfortunately not been of much help, as when I assign a column of my imported data to an analysis time to fill up the table, no code is being recorded, which leads me to believe that this task is not automatable.&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;I am using the following code to initialize the imported load:&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;analysis = Model.AddStaticStructuralAnalysis()&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;Temp = analysis.AddImportedLoadExternalData()&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;TempLoad = Temp.AddImportedBodyTemperature()&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;Of course, this is just to initialize, and I use other commands to import my csv file. But my question is: is there any function that is able to input data into the table such that I can fill it up with the appropriate columns for each timestep? If not, is there any other way to use the temperature data in the csv file to automatically run the simulations?&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;Thanks in advance&lt;\/span&gt;&lt;\/p&gt;&lt;p class=&#8221;MsoNormal&#8221;&gt;&lt;span lang=&#8221;EN-US&#8221; style=&#8221;mso-ansi-language: EN-US;&#8221;&gt;&nbsp;&lt;\/span&gt;&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-408930","topic","type-topic","status-closed","hentry","topic-tag-python-ironpython-1","topic-tag-imported-load","topic-tag-python","topic-tag-python-scripting"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_forum_id":["27791"],"_bbp_topic_id":["408930"],"_bbp_subscription":["483415","58821"],"_bbp_author_ip":["141.43.177.228"],"_bbp_last_reply_id":["409042"],"_bbp_last_active_id":["409042"],"_bbp_last_active_time":["2025-02-10 11:33:32"],"_bbp_reply_count":["3"],"_bbp_reply_count_hidden":["0"],"_bbp_voice_count":["2"],"_bbp_engagement":["483415","58821"],"_btv_view_count":["1019"],"_bbp_topic_status":["answered"],"_edit_lock":["1739053679:483415"],"_bbp_status":["answered"]},"test":"fathallab-tu-de"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/408930","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\/408930\/revisions"}],"predecessor-version":[{"id":409041,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/408930\/revisions\/409041"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=408930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}