FeResPost Web Site                     FeResPost Online User Manual

IV.2.5.2 Definition of temperature fields

This example is similar to the previous one, but instead of generating “FORCE” fields, one generates temperature fields with “TEMP” Nastran cards. Also, the example differs by the fact that no Results are read from an “op2” file.

One writes two functions devoted to the printing of “TEMP” cards in a Bulk Data File. The first function writes a constant temperature field on a Group:

   def Therm.writeConstTempCards(fileName,lcId,target,constT)  
      print "creating file "  
      puts fileName  
 
      nodes = target.getEntitiesByType("Node")  
      index = 0  
      cards=[]  
      while index < nodes.size  
         if (nodes.size-index>=3) then  
            values = []  
            values << lcId  
            for i in 0..2  
               values << nodes[index]  
               values << constT  
               index+=1  
            end  
         else  
            values = []  
            values << lcId  
            for i in 0...(nodes.size-index)  
               values << nodes[index]  
               values << constT  
               index+=1  
            end  
         end  
         cards << values  
      end  
      NastranDb.writeNastranCards(fileName,"w+","left","short",  
         "TEMP",cards);  
   end

The principle of the function is that one recovers the list of nodes contained in the Group. Then for each node, one writes a “TEMP” entry. The second printing function prints a temperature field corresponding to a scalar Result object:

   def Therm.writeFieldTempCards(fileName,lcId,tempField)  
      print "creating file "  
      puts fileName  
 
      tempData = tempField.getData  
      index = 0  
      size = tempData.size  
      cards=[]  
      while index < size  
         if (size-index>=3) then  
            values = []  
            values << lcId  
            for i in 0..2  
               values << tempData[index][1]  
               values << tempData[index][5]  
               index+=1  
            end  
         else  
            values = []  
            values << lcId  
            for i in 0...(size-index)  
               values << tempData[index][1]  
               values << tempData[index][5]  
               index+=1  
            end  
         end  
         cards << values  
      end  
      NastranDb.writeNastranCards(fileName,"w+","left","short",  
         "TEMP",cards);  
   end

The principle of the function is very similar to the principle of function “FORCE” field printing function described in section IV.2.5.1.

The main function begins with an initialization of the DataBase:

      db=NastranDb.new()  
      db.Name="tmpDB"  
      db.readBdf("../../MODEL/MAINS/orbit_unit_xyz.bdf")  
      db.readGroupsFromPatranSession("../../MODEL/PATRAN/groups.ses")

Then one defines constant temperature fields on parts of the structure. One defines four cases obtained by a combination of cold or hot temperatures, and application to two Groups. The second Group is build by assembling the lateral panels. This part of the main functions looks like:

      # Generation of temperature fields on panel +Z :  
 
      tmpGrp = db.getGroupCopy("pan_PZ")  
      Therm.writeConstTempCards("temp_P120_PAN_PZ.bdf",621001,tmpGrp, 120.0)  
      Therm.writeConstTempCards("temp_M100_PAN_PZ.bdf",621001,tmpGrp,-100.0)  
 
      # Generation of temperature fields on lateral panels :  
 
      tmpGrp = db.getGroupCopy("pan_PX")  
      tmpGrp += db.getGroupCopy("pan_PY")  
      tmpGrp += db.getGroupCopy("pan_MX")  
      tmpGrp += db.getGroupCopy("pan_MY")  
      Therm.writeConstTempCards("temp_P120_PAN_LAT.bdf",622001,tmpGrp, 120.0)  
      Therm.writeConstTempCards("temp_M100_PAN_LAT.bdf",622002,tmpGrp,-100.0)

One also defines temperature fields by production of a corresponding Result object. In this case, the Result is build from the coordinates:

      # Generation of a temperature gradient field :  
 
      tmpGrp = Group.new  
      tmpGrp.setEntities("Node 1:99999")  
      tmpGrp.matchWithDbEntities(db)  
      db.generateCoordResults  
 
      coords=db.getResultCopy("","","Coordinates","NodesOnly",tmpGrp,[])  
      coords.modifyPositionRefCoordSys(db,1001)  
      tGradX=coords*[100.0,   0.0,   0.0]  
      Therm.writeFieldTempCards("temp_GRAD_X.bdf",623001,tGradX)  
      tGradY=coords*[  0.0, 100.0,   0.0]  
      Therm.writeFieldTempCards("temp_GRAD_Y.bdf",623002,tGradY)  
      tGradZ=coords*[  0.0,   0.0, 100.0]  
      Therm.writeFieldTempCards("temp_GRAD_Z.bdf",623003,tGradZ)

Note that the previous ruby lines illustrate the use of several capabilities of FeResPost:

Note that the temperature fields printed in BDF files are used in the definition of loads for Nastran calculations in Chapter IV.1.

The example is provided in file "RUBY/EX07/makeTempFields.rb".