General Mechanical

General Mechanical

Topics related to Mechanical Enterprise, Motion, Additive Print and more.

Write the parameter value to a text file

    • mashetty
      Subscriber

      I am working on an transient thermal analysis using ansys workbench. I am using a commands(Apdl) to input some apdl commands in the workbench. I am trying to write an output file, for getting some values timevalues. My code is as follows,

      TIMINT, ON

      DDELE,ALL,TEMP

      *DO,i,1,20,1   !simulation time for 20 seconds

      TIME,i

      *CFOPEN,timeout,txt

      *VWRITE,TIME

      (F9.5)

      *CFCLOSE

      *ENDDO

       

      However, My output file only gives one value.Can you please let me know, how to write all the output vales in the file for each iteration.

    • danielshaw
      Ansys Employee

      You are opening and closing the output file each time through the *DO loop.  You could try opening it before the *DO and closing it after the *DO.  You could also store time solution times in an array (one time stored each loop) and then use *VWRITE to write out that array after the *DO is finished.

       

    • dlooman
      Ansys Employee

      In your commands TIME isn't a parameter, it's a command.  The commands should be something like below:

      TIMINT, ON

      DDELE,ALL,TEMP

      time_val=0

      *DO,i,1,20,1   !simulation time for 20 seconds

      time_val=time_val+0.1

      TIME,time_val

      *CFOPEN,timeout,txt,,APPEND         !!! need to APPEND output to file

      *VWRITE,time_val

      (F9.5)

      *CFCLOSE

      *ENDDO

    • mjmiddle
      Ansys Employee

      I'm sorry, but none of this makes sense to me if you really want to use the TIME command, not the original commands, or Dave Looman's last comments. The TIME command sets the end time of the load step as a solution setting before running the solution:

      https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v241/en/ans_cmd/Hlp_C_TIME.html

      It does not make sense to keep resetting the load step end time, without issuing a SOLVE after each iteration. It's just going to use the last TIME command for the next SOLVE command.

      What are you really trying to do? Do you just want to print out all the load step end times? Or maybe all the result set end times? Do the following in a command snippet under Solution:

      /post1
      *get,nrsets,active,0,set,nset    ! Only works when result file is present. Does not work when results are stored to database
      *cfopen,timeout,txt
      *do,rset,1,nrsets
      set,,,,,,,rset
      *get,Lstep,active,0,set,lstp
      *get,Sbstep,active,0,set,sbst
      *get,time,active,0,set,time
      *vwrite,Lstep
      Loadstep %4I
      *vwrite,Sbstep
      Substep %4I
      *vwrite,rset
      Cumulative Substep %5I
      *vwrite,time
      Time %13.5E
      *enddo
      *cfclos

       

    • mashetty
      Subscriber

      I am sorry for the late reply. Thanks for your suggestion, Dave. I have to write temperature values of a particular node for each time step to a text or csv file. So i was thinking to move forward from writing the time steps in an output file and extend the same code for writing the temperature results too.  

          *CFOPEN,timeout,txt,,APPEND
          *VGET,my_TEMP,NODE,1,BFE,TEMP
          *vwrite,time_val,my_TEMP
          (F9.5,F9.5)
          *CFCLOSE

      I would like to have my output text file as mentioned below excel file. Please let me know, how to create an output text file for a particular node, which consists of time and temp value for each substep using apdl commands, so that i can run the simulation in batch mode and use the output file without opening the ansys.

      1,00E-060
      0,46250
      0,5550
      8,881396,7
      9,3425928,18
      9,435902,65
      9,8975683,47
      9,99651,56
      10,453536,74
    • dlooman
      Ansys Employee

       

      After the thermal transient solution is complete you could use the commands below without any APDL complexity:

      /post26

      nsol,2,node_number,temp

      /out,temp_solution,out

      prvar,2

      /out 

       

    • mashetty
      Subscriber

      I have tried as follows, 

      /post26
      nsol,2,561,temp
      /out,temp_solution,out
      prvar,2
      /out

      However, i am able to create a output file(temp_solution.out),  but i am getting an error.

      I have found online, i should use save MAPDL db file to yes and i have changed it to yes. Please let me know, what else can i do. I have one more question to, i would like to print the element results to an output file using ESOL(average of all the node values of the element, if  only node results exists in the simulation),can you please help me with that too.   

    • mjmiddle
      Ansys Employee

      For the error, I suspect you ran a post solve for a command snippet under the Solution branch after a solution was present. If the solution is cleared, it will run the command snippet as part of the solution and this error does not occur. To run as a post solve, you often need to set "Save MAPDL db" to yes in the Analysis Settings:

      In the command snippet include the RESUME command near the top.

    • mashetty
      Subscriber

      I have already done both of what you mentioned, still getting the same error. I have included RESUME before /post26(and after /post26 resume too ). I have also changed the status of the mapdl db - to yes. still getting the same error file in the output file. 

    • mjmiddle
      Ansys Employee

      When you set the "Save MAPDL db" to yes it requires running the solution again. It's not marking the solution out-of-date when you change this setting and that would help enforce the correct action. Right click to "Clear Generated Data" on the solution after changing this setting and run the soution again.

    • mashetty
      Subscriber

      Thanks for your response. I have started the simulation from the beginning and now its working. I would like to write the result of an element to the output file, i have tried using this command

      esol,2,10,,bfe,temp

      (ansys documentation reference ESOL, NVAR, ELEM, NODE, Item, Comp, Name

      Specifies element data to be stored from the results file.)

      complete code is 

      RESUME

      /post26

      !nsol,2,22,temp

      esol,2,10,,bfe,temp

      /out,temp_solution,out

      prvar,2

      /out

       

      However, this is not working and in the outfile, i can see the warning : PRVAR is ignored.

      Can you please help me in writing the element temperature values w.r.t to the output file. If element values are not available, i would like to write the average of the temperature values of all nodes(for that particular element).

    • mjmiddle
      Ansys Employee

      I don't have much experience with the time history post processor /post26. Temperatures are from the nodal solution, not the element solution. Often when getting element results from nodes, the APDL commands do the averaging to the element centoid. But the documentation does not show anything in the items and comps that would get the temperature nodal solution. The BFE,TEMP is for applied temperature, not result temperatures that you want.

      https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v241/en/ans_cmd/Hlp_C_ESOL.html

      I would normally loop through the result sets using SET command with /post1 and *GET the temperatures on nodes. See my earlier post on looping through results sets. Use the *GET documentation to figure out a command to get temp on node(s). Maybe someone in this post knows how to so it simpler with /post26 processor?

    • dlooman
      Ansys Employee

      BFE,TEMP is a "structural" temperature not a thermal analysis temperature.  Normally the nodal temperatures are of interest so nsol,2,node number,temp is used.  I don't see a way to plot the average element temperature in post26 so you for that you have to use post1 as Matt mentioned:

      /post1 

      set,,,,,time

      etable,e_temp,temp

      pretab,e_temp

       

Viewing 12 reply threads
  • The topic ‘Write the parameter value to a text file’ is closed to new replies.