31
MSC.Software Corporation Taking Advantage of Patran Session/Journal Files John Parady – June 2009

Taking Advantage of Patran Session/Journal Files

  • Upload
    sheena

  • View
    135

  • Download
    2

Embed Size (px)

DESCRIPTION

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. - PowerPoint PPT Presentation

Citation preview

Page 1: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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

Page 2: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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

Page 3: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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")

Page 4: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

Page 5: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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

Page 6: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

Page 7: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

Page 8: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

Journal File Maintenance

The purpose is to create or maintain a session file safety net, while addressing many of the problems outlined on the previous slide.

1. Make a backup of your current database. Include the date in the name.

2. Create a new blank .jou file: databasename.db.jou

3. 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 )

4. 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

5. Open a copy of your latest backup, then play this session file and it will bring you up to date.

Work

Work

Work

Work

Work

Work

backup

Work

Work

Work

Work

Work

backup

Work

Work

Work

Work

Work

ERROR!

.jou file1. 2.

.ses file

4.

A

C

B

B +

Page 9: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

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.

Page 10: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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 )

Page 11: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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

Page 12: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

Page 13: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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 INTEGERSsgm_const_curve_2d_circle_v2( "3", 1, 1., "Coord 0.3", "", "[0 0 0]", FALSE,…)

• Logical constants: TRUE or FALSEsgm_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", ""] )

Page 14: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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:

1. Cannot start with a number

2. Cannot not be greater than 32 characters

3. Cannot be a reserved word (for, while, if, …)

4. Cannot contain spaces

Variable name rules:

1. Cannot start with a number

2. Cannot not be greater than 32 characters

3. Cannot be a reserved word (for, while, if, …)

4. Cannot contain spaces

Page 15: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

Page 16: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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" )

Page 17: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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:1. Attach results and make a plot of the type of result you

want.

2. Open the Parametric Modeling form and change the object to Outputs.

3. Select the desired results parameters similar to post processing steps, then hit Apply.

• The result variable will update if the xdb updates.

Page 18: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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)

Page 19: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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 )

Page 20: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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

Note: Syntax highlighting using a Textpad syntax file

Page 21: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

Page 22: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

Page 23: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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( /* */ ).

Page 24: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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.

!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.

!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.

Sample Model Sample Parameter File

Page 25: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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 Mesh3 2084.64117 3549.747111 4371.454120 4466.973140 4809.173880 4924.437226 4979.7329

XYDATA,Stress Vs Mesh3 2084.64117 3549.747111 4371.454120 4466.973140 4809.173880 4924.437226 4979.7329

Page 26: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

Case Study

• Components needed for the automation:1. Session file with Parameter variables. This session file was created with variables,

then tested stand alone.

2. 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 neededwidth 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.1hole_size_factor 1.0 1.0 1.0 1.0 2.0 4.0 8.0

3. 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.

Page 27: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

Parameter File

ParameterFile

Case Study

• The complexity of the Master Parameter File controls how many times the session file will be expanded.

ParameterFileSession FileSession FileSession File

MasterParameter

FileSession File

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.25hole_size_factor 1.0 1.0 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.25hole_size_factor 1.0 1.0 1.0

width =4.0height =2.0dx =2.0dy =1.0 rad =0.45thickness =0.04mesh_density =0.8hole_size_factor=1.0

width =4.0height =2.0dx =2.0dy =1.0 rad =0.45thickness =0.04mesh_density =0.8hole_size_factor=1.0

+

Only User Inputs

Page 28: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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 filesexpand_session_file_wth_params("param_file.master","session_file.ses","expand

ed_session_file.ses")

$ Delete the xyplot file to start from a fresh one if it already existsIF (file_exists("convergence.xyd","")) then file_delete("convergence.xyd")

$ Play the new session filesf_play("expanded_session_file.ses")

• This session file calls out the Session File and Master Parameter File, then runs the expanded session file.

Page 29: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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)

Page 30: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

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

Page 31: Taking Advantage of Patran Session/Journal Files

•MSC.Software Corporation

Questions?