CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Problem estimating flow of next timestep in Windkessel UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 31, 2020, 10:09
Talking Problem estimating flow of next timestep in Windkessel UDF
  #1
New Member
 
Judith Fonken
Join Date: Jan 2020
Posts: 6
Rep Power: 6
Juud is on a distinguished road
Hi all,

I'm a Master student working on FSI modeling of abdominal aorta aneurysms including the aortic-iliac bifurcation. I'm facing a problem implementing an algorithm in my fluid part. I'm prescribing a 3-element Windkessel model as boundary condition to my outlets. The pressure (p) of the next time step (n+1) can be calculated from the flow (q) using the following function:

p(n+1) = (R*C)/(R*C+dt)*p(n) + (dt(Z+R)+Z*R*C)/(R*C+dt)*q(n+1) - (Z*R*C)/(R*C+dt)*q(n)

This is easy when you assume q(n+1) = q(n). I implemented this using a define_execute_at_end UDF.

The hard part is to predict q(n+1) if you don't assume that it's equal to q(n). My supervisor proposed an iterative method to find a better estimate for the flow in the next time step:
1 - Use q(n) as first estimate of q(n+1)
2 - Calculate the first estimate of p(n+1) given the equation stated previously
3 - Solve the continuity and momentum equations as if it's the next timestep. This will yield a new flow, which will be a better prediction of q(n+1).
4 - Use the new flow to calculate a new estimate of p(n+1)

Repeat these steps till convergence is reached (q(new) is almost equal to q(n)).

I've not been able to find a way to solve the continuity and momentum equations without continuing to the next timestep. All suggestions are more than welcome!!
Juud is offline   Reply With Quote

Old   January 31, 2020, 10:32
Default Run with 0
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Keep the number of time-steps as 0. Then Fluent does not proceed further in time.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   January 31, 2020, 11:02
Default
  #3
New Member
 
Judith Fonken
Join Date: Jan 2020
Posts: 6
Rep Power: 6
Juud is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Keep the number of time-steps as 0. Then Fluent does not proceed further in time.
Could you please elaborate on this? How do I solve a steady-state problem within a transient problem?

Thanks in advance.
Juud is offline   Reply With Quote

Old   January 31, 2020, 11:11
Default Number of Time Steps
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Fluent requires user to enter number of time steps apart from the time-step itself. As long the number of time steps is 0, Fluent does not proceed further to next time. Since you wish to carry out a transient simulation, however, you also wants to make sure that an internal convergence is achieved. So, keep the number of time steps to 0 until convergence for q is reached and then switch it to 1 to move to next time. Repeat the process.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   January 31, 2020, 11:40
Default
  #5
New Member
 
Judith Fonken
Join Date: Jan 2020
Posts: 6
Rep Power: 6
Juud is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Fluent requires user to enter number of time steps apart from the time-step itself. As long the number of time steps is 0, Fluent does not proceed further to next time. Since you wish to carry out a transient simulation, however, you also wants to make sure that an internal convergence is achieved. So, keep the number of time steps to 0 until convergence for q is reached and then switch it to 1 to move to next time. Repeat the process.
Do you know what the command is to alter the number of time steps?
Juud is offline   Reply With Quote

Old   January 31, 2020, 11:45
Default Command
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
The command used to run a transient simulation is

solve dti <number of time steps> <number of iterations per time step>

The following command will run 100 iterations but without going further in time

solve dti 0 100
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   January 31, 2020, 12:51
Default
  #7
New Member
 
Judith Fonken
Join Date: Jan 2020
Posts: 6
Rep Power: 6
Juud is on a distinguished road
Okay, I'm going to try to implement this in my UDF. Thanks for your help!
Juud is offline   Reply With Quote

Old   January 31, 2020, 13:35
Default Not UDF macros
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
The commands I shared are not UDF commands. These are text user interface commands.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   January 31, 2020, 14:12
Default
  #9
New Member
 
Judith Fonken
Join Date: Jan 2020
Posts: 6
Rep Power: 6
Juud is on a distinguished road
Do you know if there are UDF commands that can solve a steady state problem? I think it would be cumbersome to use a journal for this problem
Juud is offline   Reply With Quote

Old   January 31, 2020, 15:03
Default UDF cannot run the simulation
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
You cannot use C/C++ based UDF to start a simulation, however, you can use Scheme based UDF. But then you will have to learn how to program in Scheme. An alternative could be as follows

1. Use UDF to calculate p(n+1) as you might be doing right now
2. Create a new scheme variable. Look at customization manual of Fluent how to create an rpvar.
3. rpvar can be accessed from scheme, text user interface, as well as C/C++ UDF
4. Set the value of this rpvar to 1 or 0 depending upon whether equation for p(n+1) has converged or not.
5. Run the simulation using command solve dti rpvar 100

This will ensure that Fluent advances to next time only when rpvar is set to 1.

Scheme is not very difficult either. With a little help you can implement your iterative procedure within Scheme and then control whole of the simulation from one function.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   January 31, 2020, 15:04
Default Steady-State or Transient
  #11
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
If your case is steady-state, then there is no question of time step. You can just run the simulation and let the iterative process do its job every iteration. If it is transient, then the process I explained in previous post may be used.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   June 25, 2021, 04:06
Default
  #12
New Member
 
weidong yang
Join Date: Jun 2021
Posts: 3
Rep Power: 5
qazmlp223 is on a distinguished road
Quote:
Originally Posted by Juud View Post
Hi all,

I'm a Master student working on FSI modeling of abdominal aorta aneurysms including the aortic-iliac bifurcation. I'm facing a problem implementing an algorithm in my fluid part. I'm prescribing a 3-element Windkessel model as boundary condition to my outlets. The pressure (p) of the next time step (n+1) can be calculated from the flow (q) using the following function:

p(n+1) = (R*C)/(R*C+dt)*p(n) + (dt(Z+R)+Z*R*C)/(R*C+dt)*q(n+1) - (Z*R*C)/(R*C+dt)*q(n)

This is easy when you assume q(n+1) = q(n). I implemented this using a define_execute_at_end UDF.

The hard part is to predict q(n+1) if you don't assume that it's equal to q(n). My supervisor proposed an iterative method to find a better estimate for the flow in the next time step:
1 - Use q(n) as first estimate of q(n+1)
2 - Calculate the first estimate of p(n+1) given the equation stated previously
3 - Solve the continuity and momentum equations as if it's the next timestep. This will yield a new flow, which will be a better prediction of q(n+1).
4 - Use the new flow to calculate a new estimate of p(n+1)

Repeat these steps till convergence is reached (q(new) is almost equal to q(n)).

I've not been able to find a way to solve the continuity and momentum equations without continuing to the next timestep. All suggestions are more than welcome!!
Hello, I am also working on Windkessel boundary problem now. Have you solved your problem? Could you share the code with me. thanks!
qazmlp223 is offline   Reply With Quote

Reply

Tags
estimate, solver, udf, windkessel


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
Flow over a circular cylinder, Re=8000, Problem with cd david caseiro FLUENT 4 October 10, 2017 11:18
Back flow problem in gas cyclone lakhi FLUENT 0 August 31, 2012 05:27
Convergence problem with target mass flow rate ADL FLUENT 2 May 29, 2012 22:11
transient, impregnating flow problem fgommer FLUENT 0 February 29, 2012 17:10
compatibility problem of UDF on LINUX manu FLUENT 4 December 19, 2007 05:58


All times are GMT -4. The time now is 13:56.