CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
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

Reply
 
LinkBack Thread Tools Display Modes
Old   December 6, 2017, 09:37
Smile Error in "IF ELSEIF" in Tecplot Macro
  #1
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.

$!ALTERDATA
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|)))

$!ELSE
$!VARSET |H| = 1
$!ENDIF

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

Best Regards,
Krishnamurthy
Krishnamurthy is offline   Reply With Quote

Old   December 6, 2017, 20:30
Default
  #2
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)

$!ALTERDATA
EQUATION = "{H} = 0"
$!ALTERDATA
EQUATION = "{H} = if({phi}=>-{epsilon} && {phi}<={epsilon}, (0.5+({phi}/(2*{epsilon}))+ ((1/(2*3.14159))*SIN((3.14159*{phi})/{epsilon}))),{H})"
$!ALTERDATA
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.

Devon
Tecplot Technical Product Manager
novedevon is offline   Reply With Quote

Old   December 9, 2017, 09:09
Default
  #3
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

Reply

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.