innovation intelligence ® 1 chapter 6: the plotting client

20
Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Upload: bethany-mathews

Post on 05-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Innovation Intelligence®

1

Chapter 6: The Plotting Client

Page 2: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

22

The Plotting Client – Overview

• Plotting Window

• Defining Curves from Data File

• Defining Curves from Math Expressions

• Adding Notes to a Plot

• Introduction to Templex Functions

Page 3: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

33

The Plotting Client – Plotting Window

• Use SetClientType on the window handle to create the plot objectpage1 GetWindowHandle win1 1win1 SetClientType plot

• After setting the client type you can access the plotting client and get full access to its functionality using the GetClientHandle command

page1 GetWindowHandle win1 1win1 GetClientHandle plot1

• Object Hierarchy for pltIPlot (or plotting client)• The prefix “pltI” is used internally for naming the classes within the plotting

client and it stands for “plot Interface”.

Page 4: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

44

Defining Curves from Data Files

• Add empty curve to plotting window• Need a valid curve id

• Get the vector handles for the curve

• Set the type of curve to file

• Define the datatype, request, and component for the x and y vector

• Draw the curve in the plot window

Page 5: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

55

Defining Curves from Data Files

• Add empty curve to plotting window using AddCurve command on the plot object

• This command adds an empty curve and returns the curve index

• Get the curve handle using GetCurveHandle on the plot object

• GetCurveHandle requires two arguments• Handle name which can be any name the user desires• Valid curve id which can be specified by either the AddCurve command or

hard coding an index

• You can use these two commands together to add the empty curve to a session:

set curve_index [plot1 AddCurve]plot1 GetCurveHandle curve1 $curve_index

Page 6: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

66

• Next step is to get the vector handle using GetVectorHandle command on the curve handle

• GetVectorHandle requires two arguments• Handle name which can be any name the user desires• A string indicating which vector to get – x, y, or time

• The vector handle is where the curve data is actually storedcurve1 GetVectorHandle xvector1 xcurve1 GetVectorHandle yvector1 y

Defining Curves from Data Files

Page 7: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

77

Defining Curves from Data Files

• Next we need to set the type of vectors to file using the SetType command on the vector handle

• SetType can be set to file, math, or values

• Also, we need to reference the data file using SetFilename• We will do this by setting a variable which points to the file and then use this

variable in the SetFilename command.

xvector1 SetType fileyvector1 SetType fileset filename nodoutxvector1 SetFilename $filenameyvector1 SetFilename $filename

Page 8: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

88

Defining Curves from Data Files

• Need to define the data type, request, and component, just like we do in the Build Plots panel within HyperGraph.

• Done by using the SetDataType, SetRequest, and SetComponent commands on the vector handle

xvector1 SetDataType "Time"xvector1 SetRequest "Time"xvector1 SetComponent "Time“

yvector1 SetDataType "Node Data"yvector1 SetRequest "Nodal Point 26742"yvector1 SetComponent "X Displacement"

Page 9: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

99

Defining Curves from Data Files

• Final step is to tell the window to calculate the curve and draw it

• The Recalculate command forces the plot to regenerate all calculated data and reread all file data

• The Autoscale command forces the plot to recompute the minimum and maximum values for its axes

• May be necessary to call Recalculate first for recent data changes to be considered

• The Draw command actually draws the plot with the curves on the window • Changes made by other methods may not be displayed properly until Draw is

called• A common practice is to make multiple changes and then call Draw only once,

limiting the number of redraws

plot1 Recalculateplot1 Autoscale

plot1 Draw

Page 10: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1010

Defining Curves from Math Expressions

• First need to understand how curves are referenced

• x and y vector expressions are used to reference any curve vector in a session

• A curve vector reference defines the x or y vector by page, window, and curve number

• An example of a curve vector reference is p2w3c4.x, where:

p2 is page 2w3 is window 3c4 is curve 4x is the vector

• Similarly you have p2w3c4.y for the y vector

Page 11: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1111

Defining Curves from Math Expressions

• Once you have the curve and vector handles, the SetType command can be set to math

xvector1 SetType mathyvector1 SetType math

• Need to define the expressions to be used on x and y vectors using the SetExpression command

• Our example we are adding curves with id 1 and 2

• X vector expression is simply defined as one of the x vectors from the two we are summing

• Y vector expression is the summation of the two y vectors

xvector1 SetExpression p1w1c1.xyvector1 SetExpression p1w1c1.y+p1w1c2.y

Page 12: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1212

Adding Notes to a Plot

• Add a note to the plotting window with AddNote command on plotting client handle

• You also need to get the note handle using GetNoteHandle

• The GetNoteHandle requires two arguments• The first is the handle name• The second is a valid note id

• We can use the GetNoteHandle and AddNote commands together:

win1 GetClientHandle plot1plot1 GetNoteHandle note1 [plot1 AddNote]

Page 13: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1313

Adding Notes to a Plot

• Now that we have adding a note and have the note handle, we can set the name of the note and add text to the node

• Setting the name is done with SetName command on note handle

• Adding text is done with the SetText command on the note handle

note1 SetName “My Note”note1 SetText “This is my note”

• If you wish to find the name or text of a note, you can use the GetName and GetText commands on the note handle

note1 GetName returns: My Note

note1 GetText returns: This is my note

Page 14: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1414

Adding Notes to a Plot

• Notes can be attached to a curve, window, view, or point

• Done with the SetAttachment command on the note handle

note1 SetAttachment curve

• If curve is selected, we also have to set which curve the note is attached to using the SetAttachToCurveIndex command on the note handle

• Below is an example where we are attaching to a curve with index of 2

note1 SetAttachToCurveIndex 2

• We also need to supply the index of the point that the note is attached to using the SetAttachToPointIndex command on the note handle

• Setting the Point Index to 0 attaches the note at the first point of the curve

note1 SetAttachToPointIndex 0

Page 15: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1515

Introduction to Templex Statements

• What is Templex?• Templex is a general purpose text and numeric processor• Can be used to create fully annotated notes and labels capable of performing

data analysis and curve statistics within a plot window

• How do we attach a note to the last point of a curve• Use the index number of the point –you need to know what this number is• Use a Templex statement to tell you the number of points in a curve and

calculate the index

• numpts Templex statement reports the number of element in an expression

• The result is always a scalar

• We can use statement to calculate the index

Page 16: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1616

Introduction to Templex Statements

• Using numpts statement to get the number of elements in a curve

numpts(p1w1c2.y)

• SetAttachToPointIndex requires the final index be specified which is different than the number of elements

• Indexing starts with 0• Counting starts with 1

note1 SetAttachment curvenote1 SetAttachToCurveIndex 2note1 SetAttachToPointIndex “numpts(p1w1c2.y)-

1”

Page 17: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1717

Introduction to Templex Statements

• Using Templex Statements in the text of a note

• Need to use { } around Templex statement when it is used inside a text field

• Templex statement(s) that are inside the { } are automatically evaluated so that in the note you see the numerical value

• For example, let’s report the maximum value of a curve inside a note:

note1 SetText "maximum value is {max(p1w1c2.y)}"

Page 18: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1818

Exercise 6.1

Creating Plots and Notes with Templex inside the Notes

Page 19: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

1919

The Plotting Client - Exercise

Exercise 6aDescription:

Load in the data file demo.dat and create a curve using the following YType, Y Request, and Y Component vs Time:

Y Type:ForceY Request: REQ/13 Curve 13Y Component: Z

Then in the same window, create a second curve using the following vs. Time:Y Type:ForceY Request: REQ/18 Curve 18Y Component: Z

Update the X axis so that the label is “Time (seconds)” and the Y axis label is “Force (Newtons)”.

Handles usedsession, project, page, window, client, curve, vector

TCL/TK commands usedAddCurve, SetFilename, SetType, SetDataType, SetRequest, SetComponent

HintsTry loading the demo.dat file into HyperGraph to see how the Y Type, Y Request, or Y Component are defined.

Page 20: Innovation Intelligence ® 1 Chapter 6: The Plotting Client

Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

2020

The Plotting Client - Exercise

Exercise 6b

Description:

Using the 2 curves created in Exercise 5a, add those two curves together. Update the title of the curve to be “Sum Fz Request 13 and 18”. Add a note which reports the minimum of the new curve. Attach the note to the minimum as well.

Handles used

session, project, page, window, client, curve, vector, note

TCL/TK commands used

SetType, SetExpression, AddNote, SetAttachment

Hints

To attach a note to the curve at the same point as the minimum, try using the Templex command indexofmin.