1 / 31

Taking Advantage of Patran Session/Journal Files

Taking Advantage of Patran Session/Journal Files. John Parady – June 2009. Session File Topics. Contents of a session file Syntax of a session file Using Variables in a session file Getting User Input Adding Comments Limitations Other uses. Contents of a Session/Journal File.

sheena
Download Presentation

Taking Advantage of Patran Session/Journal Files

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Taking Advantage of Patran Session/Journal Files John Parady – June 2009

  2. Session File Topics • Contents of a session file • Syntax of a session file • Using Variables in a session file • Getting User Input • Adding Comments • Limitations • Other uses

  3. Contents of a Session/Journal File • The session file is essentially a textual copy of your .db. • It contains a record of everything you did. • Can be played back to recover your .db (.jou file is expected for recover) • Journal file (.jou) and a Session file (.ses) have almost the same contents and the names are often use interchangeably. • Session file contains data on all actions performed on any database during that Patran session. • Journal file contains just the data on all actions performed on a particular database. • Journal file starts with the function: uil_file_rebuild.start("C:\MSC\Patran\2007_r1b/template.db","test.db")

  4. Contents of a Session/Journal File • Contents include all analysis submittals (Playback gives option to wait for analysis to finish) • All view change commands (can be turned off so they are not recorded) • All post processing commands. • Open and Close of databases (session file only) • Date and time stamps each time the session/journal file is closed or appended to. • Undo – removes the previous command from the session file.

  5. Prevent Patran.ses.* Files from Piling up • Most of the time, the Patran.ses files are not used. • To prevent continued over population of these files, they can be turned off (neutered). • Preferences-Global

  6. Session File Stability • Session files are reliable without any editing if no changes are made to the input before replaying. • Sources of problems are: • Missing data. Missing imported files. • Imported files were modified from when it was initially used. • Changed paths (paths must be manually updated) • Updated installation (paths may need updating) • Missing PCL tools that were used when creating the model. • PCL tools used were not properly recorded to the session file.

  7. Journal (*.jou) File Maintenance • Journal files can become extremely bloated over a long period of time. • The complete Journal file could also become useless since earlier data used to create the model is no longer available. • Analysis and post processing steps could also further slow down potential rebuild steps. • The Journal file may have been deleted or you inherited a database without one.

  8. Journal File Maintenance 1. 2. .jou file A Work Work Work Work Work Work backup Work Work Work Work Work backup Work Work Work Work Work ERROR! The purpose is to create or maintain a session file safety net, while addressing many of the problems outlined on the previous slide. • Make a backup of your current database. Include the date in the name. • Create a new blank .jou file: databasename.db.jou • Begin using the database, along with this blank .jou file, and the .jou file will be appended to from that time forward. Each use of the database will be date and time stamped in the .jou file. gu_fit_view( ) ga_view_aa_set( -76.179268, 0.952826, -102.196404 ) $# Journal file stopped recording at 14-Sep-07 12:15:36 $# Appending to existing journal file $# C:\leedom_home\sol_600_bushing_tet.db.jou at 14-Sep-07 15:01:08 ga_view_aa_set( -63.794102, 0.076274, 14.840541 ) ga_view_aa_set( -86.548615, 0.155425, -0.719787 ) • If there is a problem, create a session file from the segment of the .jou file at the date stamp that is after your last backup .db • Open a copy of your latest backup, then play this session file and it will bring you up to date. C B .ses file 4. + B

  9. Syntax of a Session File(Input form / Session file Association) • A session file is a list of PCL function calls (Patran Command Language). • In most cases, each function call in the session file matches up with an apply on a form in the GUI. • Arguments can usually be figured out with a small amount of trial and error, or look in the on-line doc. STRING fem_create_nodes__nodes_created[VIRTUAL] fem_create_nodes_1( "Coord 0", "Coord 0", 3, "#", @ "Point 2414", fem_create_nodes__nodes_created ) $# === 1 node created. ID = 1.

  10. Syntax of a Session File(View Commands) • View commands like the ones below will be written to the session file. The are usually desirable, but at times fill space and slow down execution. They can be turned off using following steps. ga_view_center_set( -2.092421, -0.591265 ) ga_view_zoom_set( 0.482866 ) ga_view_aa_set( 9.500656, -21.879219, 2.266462 )

  11. What is PCL • PCL stands for Patran Command Language • Comprehensive, fully functional computer programming language • Looping (for loops, while loops, repeat) • Branching (If-Then, switch) • Variables (string, real, integer, logical, arrays) • Functions/subroutines • Complete GUI creation • Can call external programs • Can read and write data to the Patran database • Specifically and uniquely suited for CAE applications • Delivered as a part of Patran • Not case sensitive

  12. All You Need to Know about PCL • How to Recognize argument data types in the session file. (strings, reals, integers, arrays, logicals). • How to declare variables. • How to use variables in forms when creating the model. • How to put variables in the session file. • How to add comments to a session file. • Simple debug statement to check the value of a variable.

  13. Understand Data Types in the Session File • String constants: Function parameters delimited with “” asm_const_line_xyz( "1", "<5 0 0>", "[0 0 0]", "Coord 0", created_ids ) • String variables: Variables that are strings. Usually the last variables in a function. Give the list of created ids in “pick list” syntax. asm_const_line_xyz( "1", "<5 0 0>", "[0 0 0]", "Coord 0", created_ids ) • Numerical constants: REALS or INTEGERS sgm_const_curve_2d_circle_v2( "3", 1, 1., "Coord 0.3", "", "[0 0 0]", FALSE,…) • Logical constants: TRUE or FALSE sgm_const_curve_2d_circle_v2( "3", 1, 1., "Coord 0.3", "", "[0 0 0]", FALSE,…) • Array constants: Numerical or strings material.create( …, ["", "", "", "", ""], [0, 0, 0, 0, 0], …, ["10e6", ".33", ""] )

  14. How to Declare Variables(Direct PCL Method) • Definition of a variable has up to 3 parts. Keyword defining the variable type, variable name, and optional initial value. • Defining a string: STRING my_property_name[20]=“Engine_mount_prop” STRING input_points[25], x_coord[10] STRING created_ids[VIRTUAL] • Defining a number: REAL x=2.3, y, z=0.1 INTEGER number_of_ribs, count=0 • Defining a Logical: LOGICAL flag=TRUE, finished=FALSE • Variable definitions are not remembered between sessions. • Variable definitions are recorded in the session file if entered in the command window. Variable name rules: • Cannot start with a number • Cannot not be greater than 32 characters • Cannot be a reserved word (for, while, if, …) • Cannot contain spaces

  15. How to Declare Variables(Parameter Method) • Variables can also be defined using Tools/Pre-Release/Parametric Modeling. • The same information is given as before. Variable type, Variable name, and initial value. • Descriptions can also be added. • Variables are re-initialized when the database is re-opened.

  16. How to Declare Variables(Parameter Method) • Variables can be updated from a configuration file during session file playback. • Configuration file can be defined by an environment variable or a PCL command. • Environment variable: PARAMETRIC_MODELING_CONFIG_FILE • PCL command: parametric_modeling_util.define_user_config_file(“file_name”) • Configuration file Format (! is a comment prefix): maximum = 1000 ! this is an integer three = 1, 2, 3 ! this is a 3 word integer array data = 37.655 ! this is a real moredata = 1.0, 2.0, 3.0, 4.0 ! this is a 4 word real array name = mat1 ! this is a string variable, note no quotes names = one, two, three ! this is a string array, again no quotes • The configuration file data is read as the variable definitions are found in the session file. • Variable can be forced to be read by using this PCL command: parametric_modeling_util.reset_variable( “variable_name" )

  17. How to Declare Variables(Parameter Method) • Special result variables can be defined using the Parameter method. • This variable will store useful results quantities so they can be easily used in automated processes. • To create a result variable: • Attach results and make a plot of the type of result you want. • Open the Parametric Modeling form and change the object to Outputs. • Select the desired results parameters similar to post processing steps, then hit Apply. • The result variable will update if the xdb updates.

  18. How to use variables(when creating the model) • Variable can be used any place a value or string name is used. • Begin and end variable with “`”. (single quote over the Tab Key)

  19. How to use variables(Editing a Session File) • Use a sample session file with inserted variables for an example. • Method of use in a session file is the same as use in forms. sgm_const_curve_2d_circle_v2("6",1, `radius`,"Coord 0.3","",@ "[`x_coord` 0 0]",FALSE, sgm_create_curve_2d_created_ids )

  20. How to Add Comments to a Session File • If you plan to edit a session file and use it more than once, adding comments may be a good idea. • Comments can be added by beginning a line with “$”. Similar to a Nastran .bdf file. • A comment can also begin with /* and end with */, but do not extend it beyond one line in a session file. Note: Syntax highlighting using a Textpad syntax file

  21. Simple Debug Statement • IF variables are being used and the session file is not acting as you expected, verify the variable values. • Use the Dump statement to see the contents of any variable. • Type the dump statement in a session file to see the values during playback. • Type the dump statement in the command window at any time to see the value of a variable.

  22. Controlling the Flow of Data • Session file functions that create entities usually have starting ids and output ids lists. • To make a session file more flexible, some editing may be needed to adapt changes in model dimensions or mesh densities. sgm_const_surface_2curve( "3", "Surface 1.2", "Surface 2.1", created_ids ) dump created_ids $#STRING created_ids[VIRTUAL] = "Surface 3” fem_create_mesh_surf_4( "Paver", 49664, "Surface 3", 4, ["`mesh_density`","0.1",… • Make simple change so starting surface id no longer matters. sgm_const_surface_2curve( “#", "Surface 1.2", "Surface 2.1", created_ids ) fem_create_mesh_surf_4( "Paver", 49664, created_ids, 4, ["`mesh_density`","0.1",… • The starting id of “#” means, use the next highest free id.

  23. Limitations • You cannot play a session file in a loop. (session files can be made into functions with some editing to avoid this) For (I = 1 to 10) sf_play(“my_cool_process.ses”) End for • PCL loop constructs and some conditional statements are not fully supported for all situations. • Multi-line comments are not supported( /* */ ).

  24. Case Study • The following example will provide a simple scenario to show how a process with many variable changes can be automated painlessly. • In this example, the parameters are: width, height, radius, dx, dy, mesh density and hole mesh density. • The variables were created using the Tools menu so they can be controlled form an external parameter file. Sample Parameter File Sample Model !Iteration #6 !22-Jan-08 17:59:53 width = 4.0 height = 2.0 dx = 2 dy = 1 rad = .45 thickness = .04 mesh_density = .14 hole_size_factor = 4.

  25. Case Study • The tricky part is making changes to the parameter file, re-running the session file, and then capturing the desired data. • The desired results in this case are the max Von Mises stress for the full model including top and bottom stresses. • An additional parameter was created to capture this information • A small amount of PCL was used to then write this max stress to a Patran XYplot file for each iteration so a stress convergence plot could be made. XYDATA,Stress Vs Mesh 3 2084.6411 7 3549.7471 11 4371.4541 20 4466.9731 40 4809.1738 80 4924.437 226 4979.7329

  26. Case Study • Components needed for the automation: • Session file with Parameter variables. This session file was created with variables, then tested stand alone. • Master parameter file. A simple text file with the first column being the variable name and the remaining columns the desired variable changes. ! this is a sample master parameter file. ! only the variables that change must be repeated. ! The last value of a variable is assumed to be repeated as needed width 4.0 height 2.0 dx 2.0 dy 1.0 rad 0.45 thickness 0.04 mesh_density 0.8 0.4 0.25 0.1 0.14 0.14 0.1 hole_size_factor 1.0 1.0 1.0 1.0 2.0 4.0 8.0 • A copy of the parameter PCL tool. This is the tool that expands the above master parameter file into valid parameter files and creates a complete session file so all the iterations are run.

  27. width =4.0 height =2.0 dx =2.0 dy =1.0 rad =0.45 thickness =0.04 mesh_density =0.8 hole_size_factor=1.0 width 4.0 height 2.0 dx 2.0 dy 1.0 rad 0.45 thickness 0.04 mesh_density 0.8 0.4 0.25 hole_size_factor 1.0 1.0 1.0 Case Study • The complexity of the Master Parameter File controls how many times the session file will be expanded. Session File Session File Session File Session File Parameter File Parameter File Parameter File Master Parameter File + Only User Inputs

  28. Case Study • Simple session file drives it all…. $ input the PCL tool to automate loop !!input expand_session_file_wth_params.pcl $ Call function to build the expanded session file and paramater files expand_session_file_wth_params("param_file.master","session_file.ses","expanded_session_file.ses") $ Delete the xyplot file to start from a fresh one if it already exists IF (file_exists("convergence.xyd","")) then file_delete("convergence.xyd") $ Play the new session file sf_play("expanded_session_file.ses") • This session file calls out the Session File and Master Parameter File, then runs the expanded session file.

  29. Other Uses of a Session file • Session files can be executed in batch by command line statement. Patran –sfp my_cool_process.ses • Session files can be used to initialize a database to include common data like materials, groups, custom fringe ranges, … • It is also possible to have a specific session file played each time a new database is opened. (simple PCL function required)

  30. Additional sources of Documentation • On-line Documentation has over 99% of session file content covered. • PCL Workshop Notes for diving in deeper with PCL. PCLWorkshopNotes.11-18-05.doc

  31. Questions?

More Related