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 Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread 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: 9
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
Member
 
Join Date: May 2013
Posts: 61
Rep Power: 13
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: 9
Krishnamurthy is on a distinguished road
Thank you for your help.
Krishnamurthy is offline   Reply With Quote

Old   May 8, 2024, 17:16
Question Command to find value of "Y" for a particular "X" value in Tecplot
  #4
New Member
 
Hi
Join Date: Mar 2022
Posts: 2
Rep Power: 0
CMHR is on a distinguished road
Hi Guys,

New here.

Could someone please assist me regarding this:

I have a parameter on the X-axis (it is either X velocity or velocity magnitude) with the Y-axis being the perpendicular height above the surface and I would like to extract the value of Y (delta=boundary layer thickness) for a particular X value (at U_e).

Q) Do you guys know what function I could apply to get the value of Y at a particular X value? I think the IF statement can work but it would require me to write a return value for try or false sections. I don't think I could get BL thickness value by giving a true or false value (1 or 0 respectively).

I have a MATLAB script that can extract the boundary layer thickness for a given U_e but I would like to reproduce this in Tecplot. it essentially finds Y when the U_e matches the Velocity magnitude data.

Thank you.

CMHR is offline   Reply With Quote

Reply


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 Off
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 08:35.