CFD Online Logo CFD Online URL
Home > Forums > Visualization & Post-Processing Software > Tecplot

Error in "IF ELSEIF" in Tecplot Macro

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   December 6, 2017, 09:37
Smile Error in "IF ELSEIF" in Tecplot Macro
New Member
Join Date: Dec 2017
Posts: 4
Rep Power: 3
Krishnamurthy is on a distinguished road
Hello all.

I have been trying to write a Tecplot macro. I have the required dataset in the active frame. The dataset consists of 9 variables and each variable contains cell-centered values of several zones. With ALTERDATA command, I calculated a new variable (epsilon) which is calculated for all the zones.

EQUATION = "{epsilon} = SQRT(x**2 + y**2)"

Now I need to find a new variable called "H" for all zones by doing the following IF statement. I tried the below expression and I get an error stating "phi" and "epsilon" are invalid and undefined variable in View/Debug Macro panel. But phi is a defined variable in Tecplot dataset and epsilon is a newly found variable. How can I rectify the error and find the "H" for all zones?

$!IF |phi| < -|epsilon|
$!VARSET |H| = 0

$!ELSEIF (|phi| >= (-|epsilon|)) && ((|phi|) <= (|epsilon|))
$!VARSET |H| = (0.5+(|phi|/(2*|epsilon|))+ ((1/(2*3.14159))*SIN((3.14159*|phi|)/|epsilon|)))

$!VARSET |H| = 1

I am new to Tecplot. Any help would be appreciated.

Best Regards,
Krishnamurthy is offline   Reply With Quote

Old   December 6, 2017, 20:30
New Member
Join Date: May 2013
Posts: 26
Rep Power: 7
novedevon is on a distinguished road
First to define a thing or two.

$!VARSET sets macro variables which accessible only from the currently running macro and are only a single value. These are different from zone or data variables which are values at every point in your dataset.

Similarly $!IF $!ELSEIF and $!ELSE are vary basic flow control options and only can be conditioned by macro variables as defined by the || (not dataset variables as in H or Epislon)

What you want here is what we call data alter if conditions which in the macro language looks something like (it matches the same logic as if conditions in Excel)

EQUATION = "{H} = 0"
EQUATION = "{H} = if({phi}=>-{epsilon} && {phi}<={epsilon}, (0.5+({phi}/(2*{epsilon}))+ ((1/(2*3.14159))*SIN((3.14159*{phi})/{epsilon}))),{H})"
EQUATION = "{H} = if({phi}<{epsilon},1,{H})"

*note the use of {} to define variable names in your example above the variables are using the x and y variables assigned to the axes vs the variables by the x and y name although these are almost always the same.

You can also do all of this in the Data > Alter > Specify Equation dialog.

More details on how the if conditions in equations works look up section 20-1.1 in the users manual which should cover how to use the data alter if conditions.

if you have any further questions feel free to contact tecplot support.

Tecplot Technical Product Manager
novedevon is offline   Reply With Quote

Old   December 9, 2017, 09:09
New Member
Join Date: Dec 2017
Posts: 4
Rep Power: 3
Krishnamurthy is on a distinguished road
Thank you for your help.
Krishnamurthy is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tecplot 360 2017 Release 2 manohar1487 Main CFD Forum 0 August 28, 2017 03:08
Movie Macro in Tecplot TedBrogan Tecplot 2 February 4, 2011 11:59
Tecplot Macro - conditional - array variable pchidamb Tecplot 2 July 29, 2009 10:48
Extract Data from Polyline in a Macro (Tecplot) Joe Main CFD Forum 0 September 5, 2008 04:46
TECPLOT 10 macro problem Matthew Morse Tecplot 5 July 5, 2004 02:31

All times are GMT -4. The time now is 20:26.