General Mechanical

General Mechanical

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

Save thermal results in txt file via /post1 snippet

    • John Miller
      Subscriber

      Hello together,

       

      I wrote a small snippet to save temperature results to a text (txt) file:

       

      LoadStep=1
      !
      /post1
      set,LoadStep 
      *get,numnode,node,,count                   !Retrieves a value and stores it as a scalar parameter or part of an array parameter.
      *dim,NodeTemp,array,numnode                !Defines an array parameter and its dimensions.
      *vget,NodeTemp(1),node,,TEMP               !Retrieves values and stores them into an array parameter.
      *cfopen,'myTempfile','txt'
      *vlen,1
      *vwrite,'Nodal','Temperature'
      (A8,X,A8)
      *vwrite,sequ,NodeTemp(1)
      (F8.0,X,E13.6,X,E13.6)
      *cfclos

       

      For the temperature of every node sorted for nodal number, it’s working quite well.

       

      Nodal    Temperat
            1.  0.344929E+02
            2.  0.419993E+02
            3.  0.407717E+02
            4.  0.414503E+02
            5.  0.416919E+02
            6.  0.420074E+02

      ....

      ....

       283051.  0.400000E+02
       283052.  0.400000E+02
       283053.  0.400000E+02
       283054.  0.400000E+02

       

      My question is how can I save not the nodal number but the coordinates (x,y,z position of the node and the node temperature? Can I save the Temperature results of one specific node over the time (known ID or x,y,z position)?

       

      What changes are necessary?

       

      With best regards

      John M.

       

    • Chandra Sekaran
      Ansys Employee

      To get the node coordinates you can do:

      *get,numnode,node,,count                   !Retrieves a value and stores it as a scalar parameter or part of an array parameter.
      *dim,NodeTemp,array,numnode,4               !Defines an array parameter and its dimensions.

      *vget,nodetemp(1,1),node,1,loc,x

      *vget,nodetemp(1,2),node,1,loc,y

      *vget,nodetemp(1,3),node,1,loc,z

      *vget,NodeTemp(1,4),node,1,TEMP               !Retrieves values and stores them into an array parameter.

      To get the temperature time history of a node you can use POST26 like below:

      /post26

      nsol,2,node,nodeid,temp

      prvar,2

      plvar,2

       

      • John Miller
        Subscriber

         

        Hello Chandra,

         

        thanks for fast and helpfull answer.

        Due to you, the issue with the coordinate data disappeared

        I’m struggling a little bit to visualise the time dependant data.

        prvar lists the temperature vs. time and plvar displays the time vs. temp in a graph, but where can I see the graph and how is it possible to save the prescribed time vs temperature data in a txt file

        nodeid=27844

        /post26
        nsol,2,node,nodeid,temp !Specifies nodal data to be stored from the results file
        prvar,2                             !Lists variables vs. time (or frequency).
        plvar,2                             !Displays up to ten variables in the form of a graph.

         

        Do I miss something?

         

        With best regards

        John M.

         

         

    • Chandra Sekaran
      Ansys Employee

      prvar lists the temperature vs. time and plvar displays the time vs. temp in a graph, but where can I see the graph and how is it possible to save the prescribed time vs temperature data in a txt file

      If you are in MAPDL GUI, then prvar will pop us a list of time vs temp and PLVAR will plot on the screeen. If you are in Mechanical (Workbench) then the PRVAR will be in the SOLVE.OUT file or Solution Information. You can get to solve.out by "Solution>right mouse click> Open solver files directory". 

      You can also redirect by doing the below. This will redirect PRVAR to the file myprvar.dat in d: drive. The PLVAR will be in a png file that will also show up in Mechanical under the commands.

      /out,d:\myprvar.dat

      prvar,2

      /out

      /show,png

      plvar,2

      /show,close

       

      • John Miller
        Subscriber

        Hello Chandra,

        thank you for the helpfull answer.

        When I apply the mentioned lines to my code:

         

        nodeid=27844

        /post26
        nsol,2,node,nodeid,temp !Specifies nodal data to be stored from the results file
        prvar,2                              !Lists variables vs. time (or frequency).
        plvar,2                              !Displays up to ten variables in the form of a graph.

        /out,d:\mypvar.dat
        prvar,2
        /out
        /show,png
        plvar,2
        /show,close

         

        this is the outcome in the solve.out file:

         

                  ***** TIME-HISTORY POSTPROCESSOR (POST26) *****

         ALL POST26 SPECIFICATIONS ARE RESET TO INITIAL DEFAULTS

         *** WARNING ***                         CP =     418.125   TIME= 13:48:41
         The data in field 3 is invalid.  The NSOL command is ignored.           

         *** WARNING ***                         CP =     418.125   TIME= 13:48:41
         No data points are saved during this storage step.                      

         /OUTPUT FILE= d:\mypvar.dat

         /SHOW SWITCH PLOTS TO  PNG         - RASTER MODE.

         Set Encoding of XML File to:ISO-8859-1

         Set Output of XML File to:
             PARM,     ,     ,     ,     ,     ,     ,     ,     ,     ,     ,     ,
                 ,     ,     ,     ,     ,     ,     ,

         DATABASE WRITTEN ON FILE  parm.xml                                                                                                                                                                                                                                                            


         ***** ROUTINE COMPLETED *****  CP =       419.062

         

         PRINTOUT RESUMED BY /GOP

         *GET  _WALLDONE  FROM  ACTI  ITEM=TIME WALL  VALUE=  13.8116667    

         PARAMETER _PREPTIME =     1.000000000    

         PARAMETER _SOLVTIME =     150.0000000    

         PARAMETER _POSTTIME =     4.000000000    

         PARAMETER _TOTALTIM =     155.0000000    

         *GET  _DLBRATIO  FROM  ACTI  ITEM=SOLU DLBR  VALUE=  0.00000000    

         *GET  _COMBTIME  FROM  ACTI  ITEM=SOLU COMB  VALUE=  0.00000000    

         *GET  _SSMODE   FROM  ACTI  ITEM=SOLU SSMM  VALUE=  2.00000000    

         *GET  _NDOFS    FROM  ACTI  ITEM=SOLU NDOF  VALUE=  122196.000    
         --- Total number of nodes = 283054
         --- Total number of elements = 84182
         --- Element load balance ratio = 0
         --- Time to combine distributed files = 0
         --- Sparse memory mode = 2
         --- Number of DOF = 122196

         EXIT ANSYS WITHOUT SAVING DATABASE


         NUMBER OF WARNING MESSAGES ENCOUNTERED=         30
         NUMBER OF ERROR   MESSAGES ENCOUNTERED=          0

         

        Obviously, the nodal data isn't stored at all.

         

        With best regards

        John M.

    • Chandra Sekaran
      Ansys Employee

      It is the NSOL command format. just use 'nsol,2,nodeid,temp'

      • John Miller
        Subscriber

         

        Dear Chandra,

         

        I finally debugged my script. Now it’s working as expected.

        There were a few errors regarding the correct syntax.

        Thanks for the support.

         

        With best regards

        John M.

         

    • John Miller
      Subscriber

       

       

      Dear Chandra,

       

      I finally debugged my script. Now it’s working as expected.

      There were a few errors regarding the correct syntax.

      Thanks for the support.

       

      With best regards

      John M.

       

       

Viewing 4 reply threads
  • The topic ‘Save thermal results in txt file via /post1 snippet’ is closed to new replies.