CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

CFX if and statement

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ghorrocks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 20, 2023, 11:47
Default CFX if and statement
  #1
New Member
 
Join Date: Apr 2022
Posts: 26
Rep Power: 4
3nhu1 is on a distinguished road
Hi I am trying to write a nested IF statement as an expression in CFX.
Particularly I am getting errors as I would like to include the && (AND) portion - sorry I have already read the reference guide section on expressions
This is the equation that I would wish to include, thank you.

Thank you.

T_vc = 0.34[s]
T_vr = 0.15[s]
T = 1[s]
Attached Images
File Type: jpg E_t.jpg (19.6 KB, 23 views)
3nhu1 is offline   Reply With Quote

Old   November 20, 2023, 17:45
Default
  #2
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,872
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
if(t<=T_vc,[Top function],if(t<=T_vc+T_vr,[Middle function],if(y<=T,0[units?],[undefined!])))

Easy.
3nhu1 likes this.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   November 20, 2023, 20:41
Default
  #3
New Member
 
Join Date: Apr 2022
Posts: 26
Rep Power: 4
3nhu1 is on a distinguished road
Thank you! This was a massive help and I am really very grateful.

if(t<=tvc,0.5 - 0.5*cos(pi*t/tvc),if(t<=tvc+tvr,0.5 + 0.5*cos(pi*(t-tvc)/tvr),if(t<=te,0[ ] ,0)))

I realised that this needs to be periodic e.g. 5s, could I ask how would a mod function be initialised?
Attached Images
File Type: jpg elas.jpg (42.7 KB, 10 views)
3nhu1 is offline   Reply With Quote

Old   November 20, 2023, 20:56
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,872
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
t_cycle = mod(t,5[s]))

Then change the equation to check t_cycle rather than t.

Also note your last nested if() statement is not required, both cases evaluate to 0 so you might as well remove it.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   November 21, 2023, 05:38
Default
  #5
New Member
 
Join Date: Apr 2022
Posts: 26
Rep Power: 4
3nhu1 is on a distinguished road
Thank you, sorry a last question I hope!

I tried using the above and also this simple example for another post

Cycletime = mod(t,11[s])
HeaterPower = if(Cycletime<1[s],100[W],0[W])

When I go to the variable in expressions either Cycletime and HeaterPower and plot for t > 1s e.g. 4s would I see the period function repeated in the plot?
I don't seem to obtain that.
3nhu1 is offline   Reply With Quote

Old   November 21, 2023, 06:13
Default
  #6
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,872
Rep Power: 144
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Please post what you do obtain then. Make sure you have enough resolution in the plot to resolve the transients - 0.1[s] resolution would be suitable.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
ghorrocks is offline   Reply With Quote

Old   November 21, 2023, 06:38
Default
  #7
New Member
 
Join Date: Apr 2022
Posts: 26
Rep Power: 4
3nhu1 is on a distinguished road
Actually I managed to find out what was going on, you were right and had to zoom out to see it was repeating every 5 seconds instead, so I needed to set the time period to 1sec!

mod(t,1[s])

This works a treat and was really a massive help, so sincerely my thanks
Attached Images
File Type: jpg elas.jpg (77.1 KB, 11 views)
3nhu1 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



All times are GMT -4. The time now is 22:28.