We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
LS Dyna

LS Dyna

Topics related to LS-DYNA, Autodyn, Explicit STR and more.

Export a variable value at a specific node set at the end of the simulation

    • Jesus Alierta
      Subscriber

      I want to include the results of my simulation within an iterative optimization scheme within a Python framework. For that, I need to export the values of a variable (say y-velocity) at a specific set of nodes (say my_set_of_nodes) in a txt format at the end of the simulation. I've been messing with the output options but cannot find the good one. Is this even possible? Thanks

    • mjmiddle
      Ansys Employee

       

       

    • Alex Rycman
      Ansys Employee

      Hello, 

      1. Open the d3plot in LSPP 
      2. Filter elements/parts so that only desired nodes are visible. 
      3. Output to file a nodal resultant velocity at the end of the simulation (Post-Output-Active Parts -> Nodal Velocities).

       

      Please let me know if that helps. 

      Thanks,
      Alex 

    • Jesus Alierta
      Subscriber

      Hi Alex,

      No, unfortunatelly that does not solve my problem. I want to do it automatically (i.e. setting an option to export it within the .k file), as I'm running the simulation within a loop (in a python program) and I need to read those results from a txt (or other format) (depending on those results, I want to change the input .k file for the next iteration). Another option would be to read the results in python via the d3plot binary file, but I would need to know the exact format of the stored data in that file. Hope it is clearer now

    • Alex Rycman
      Ansys Employee

       

      Hi,

      1. You can put extraction of the nodal quantities in one command file (cfile). https://lsdyna.ansys.com/command/ . 
      2. Inside your optimization loop use the subprocess library to call LSPP  with the cfile as an argument, and post-process the d3plots. 
      3. Read the output files 

      I think that would be the easiest way to extract the data without looking inside D3PLOTS. However, if you are interested in the structure of the d3plot file please look at the https://ftp.lstc.com/user/manuals/ls-dyna_database.pdf

      Username: user 
      Password: computer

      Thanks,
      Alex 

       

    • Alex Rycman
      Ansys Employee

      Hi, 

      Here is extra information how to execute LSPP command file. /knowledge/forums/topic/how-execute-an-ls-prepost-command-file/

      Thanks,

      Alex 

       

    • Jesus Alierta
      Subscriber

      Hi Alex, that is really helpful and I follow the idea, but I'm not grasping some specific actions. If I'm understanding you correctly, I should follow the steps of your first reply to manually export the velocities to a file. That should generate a lspost.cfile, is that right? Then I should call LS-PrePost c=commandfile -nographics to automatically do what I did manually. I'm very new to LS-dyna so I'm not familiar with the commands, could you please help me narrowing down the correct command I would need to use? I wrote this pseudocode

      for i in range(N):
          ansys_inc/v241/ansys/bin/lsdyna -b i=my_file_i.k   # 1) run simulation ls-dyna
          ansys_inc/v241/ansys/bin/lsdyna -b c=lspost.cfile -nographics                                   # 2) post-process outputs, is this correct?
          prepare_next_k_file(args)                                       # 3) do stuff depending on previous results

      Thanks in advance

    • Jesus Alierta
      Subscriber

      Hi Alex, 
      I've been trying to export the nodal velocities using the ls-prepost interface as you told me, but it is not working as I expected. It actually works with the shell parts of the model, but not with the Fluid (ALE) parts (it creates a file with the headers but empty values). How do I export the velocity values of the Fluid (ALE) part in which I'm interested? (see attached image). Thankw

    • Ian Do
      Ansys Employee

      Hello Jesus,

      There is not a way to output "nodal vel" for an AMMG, if that is what you are asking. 

      I do not understand your ultimate and precise objective. If you can describe that in details, maybe I can suggest an approach(?).

      By definition, an AMMG or ALE mat/part flows through an ALE computational domain. The nodes are eulerian nodes (fixed ref. frame). As the ALE mat passes through a node, its vel is record at that node as an instantaneous vel. As the AMMG passes by and away from that node, it no longer belong to the AMMG. For LAG part it is very easy to follow the mat because the node is fixed to the mat. For ALE/Eulerian mat, the concept is different. We may not be able to always have the node collection that belongs to an AMMG. So we cannot output that nodeset's nodal vel at every time step.

      Ian Do 

    • Jesus Alierta
      Subscriber

      Hi Ian, 
      I'm sorry I was not clearer before, english is not my main language. I understand the concepts of the fixed eulerian nodes and the ALE part that flows over them, but I was hoping that somehow the software could still output the velocities of eulerian nodes that are "overlapping" with the ALE part at any specific time step. In fact, the software lets you visualize what I want when you hide everything but the ALE part and plot the nodal velocities. 
      Let me explain what I am trying to do so you may suggest me a different approach:

      1- I'm simulating an explosively formed penetrator (EFP). One of the ALE parts is the formed projectile (the blue mesh in my previous screenshot), and I'm interested in its peak velocity because I have measured experimentaly the value that it should achieve. 
      2- I'm trying to optimize the parameters of one of the involved EOS equations to achieve the experimental velocity.

      3- I have heard about Optislang, but have never used it (and I'm not familiar with Workbench either), so I was trying to use my own optimization approach using specialized Python libraries. To calculate the "error" or how far from the objective the results are, I need to know the peak velocity of the projectile. This is the reason I was trying to extract the velocities of that specific part programatically.

      Hope everything is clear now and thank you very much for your help.

Viewing 9 reply threads
  • The topic ‘Export a variable value at a specific node set at the end of the simulation’ is closed to new replies.