CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Additional variable at a previous timestep for use in CEL (https://www.cfd-online.com/Forums/cfx/254650-additional-variable-previous-timestep-use-cel.html)

3nhu1 February 22, 2024 11:36

Additional variable at a previous timestep for use in CEL
 
2 Attachment(s)
Hello,

Please could I ask for some assistance, and thank you especially for all the help previously in the last few months

I have a previous boundary condition implemented that had a 2 element windkessel (see picture).
It required me to create an additional variable for pressure at the previous timestep i.e. P(t-1)
What we had done for this was create an additional variable called pprev. Set it to scalar. In the default domain Modified field, pprev was activated as an Algebraic Equation and set to Pressure.
This additional variable in the expression could then be used in the expression for the pout boundary condition using the final equation for P(t) in the picture by calling for P(t-1) as areaAve(pprev)@out1 (the model has multiple outlets that does similar)

I now need to implement a 3 element windkessel (see 2nd picture). The methodology is fairly similar, but I'm having some difficulty as it requires creating an additional variable for flow rate Q at the previous timestep i.e. Q(t-1).
Mainly as there is no global variable for flow. (Although density is constant in the model).
A colleague suggested using velocity. First I have checked and tried the 2 inbuilt functions, and by using a normal velocity at outlet give a reasonable answer.

Additional variable
NormalVelocity = VelDotn
and
CEL
VelDotn = (Velocity u*Normal X + Velocity v*Normal Y + Velocity w*Normal Z)

Then option 1 for q -
areaInt(NormalVelocity)@OutAorta
and option 2 for q -
Qout_option5=areaAve(NormalVelocity)@OutAorta * area()@OutAorta

Option and Option 2 are equal and very similar to the massflow()@OutAorta / Density when post processed.

Knowing this - What would be a reasonable way to implement Q(t-1)?


Ref 2017 Acedo- Optimisation of a windkessel system for arterial simulation (thesis)

ghorrocks February 22, 2024 18:06

This thread may be interesting: https://www.cfd-online.com/Forums/cf...essions-4.html

As you have got an expression which gives you the flow rate from the velocity, haven't you got an approach which will work for getting Q(last time step)?

3nhu1 February 23, 2024 05:54

Thank you! That thread looks very helpful and has some ccl I can look at

3nhu1 February 24, 2024 08:18

1 Attachment(s)
Think I've managed to make it work

[Option 1]

q(t-1) = areaInt(NormalVelocity)@OutAorta

where
Additional variable: NormalVelocity = VelDotn
&
CEL: VelDotn = (Velocity u*Normal X + Velocity v*Normal Y + Velocity w*Normal Z)


[Option 2]
q(t-1) = qprev
where
Additional variable: qprev = qout0
&
CEL: qout0 = -massFlow()@OutAorta/1060 [kg/m^3]


Also I didn't realise - but after reading the threads I need to put the unsupported setting
"update Loop = TRANS_LOOP"
The results look very wrong otherwise.

The results for option 1 and 2 are slightly different with different sys/dias 126/65 vs 117/54 (not sure why?, although do still need to run it for more cycles as not fully stabilised yet) but both produce realistic looking pressure curves for a 3EWK at the aorta. Which is right - not sure. For now I will use option 1 as I need to use this variable for multiple outlets and I think it saves me creating multiple additional variables which 2 requires.

Also from the thread referenced above:
A value at a previous timestep can also be obtained in this manner, which I think is the more supported way to do this https://forum.ansys.com/forums/topic...-a-cel-in-cfx/
E.g. Previous Pressure = (areaAve(Pressure )@OUTLET-(Pressure.Time Derivative*dtstep))

Yanlu February 29, 2024 05:58

Quote:

Originally Posted by 3nhu1 (Post 865143)
Hello,

Please could I ask for some assistance, and thank you especially for all the help previously in the last few months

I have a previous boundary condition implemented that had a 2 element windkessel (see picture).
It required me to create an additional variable for pressure at the previous timestep i.e. P(t-1)
What we had done for this was create an additional variable called pprev. Set it to scalar. In the default domain Modified field, pprev was activated as an Algebraic Equation and set to Pressure.
This additional variable in the expression could then be used in the expression for the pout boundary condition using the final equation for P(t) in the picture by calling for P(t-1) as areaAve(pprev)@out1 (the model has multiple outlets that does similar)

I now need to implement a 3 element windkessel (see 2nd picture). The methodology is fairly similar, but I'm having some difficulty as it requires creating an additional variable for flow rate Q at the previous timestep i.e. Q(t-1).
Mainly as there is no global variable for flow. (Although density is constant in the model).
A colleague suggested using velocity. First I have checked and tried the 2 inbuilt functions, and by using a normal velocity at outlet give a reasonable answer.

Additional variable
NormalVelocity = VelDotn
and
CEL
VelDotn = (Velocity u*Normal X + Velocity v*Normal Y + Velocity w*Normal Z)

Then option 1 for q -
areaInt(NormalVelocity)@OutAorta
and option 2 for q -
Qout_option5=areaAve(NormalVelocity)@OutAorta * area()@OutAorta

Option and Option 2 are equal and very similar to the massflow()@OutAorta / Density when post processed.

Knowing this - What would be a reasonable way to implement Q(t-1)?


Ref 2017 Acedo- Optimisation of a windkessel system for arterial simulation (thesis)

https://www.researchgate.net/publica...l_in_ANSYS-CFX

Yanlu February 29, 2024 06:03

Quote:

Originally Posted by singer1812 (Post 285482)
Actuallly you can get the derivative from last time step to current time step via use of additional variables settings. If you create an additional variable of the velocity, and add the term using ccl in the ADDITIONAL VARIABLE term:

Update Loop = TRANS_LOOP


This will cause that variable to take the old value of the velocity. You can use it to create your derivative.

You can refer to this answer.


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