
[Sponsors] 
December 8, 2021, 16:02 
Userdefined function

#1 
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
Hello to all
I am working on a simulation of a blood pump. In my study, I want to calculate the shear stress in the fluid so I can calculate the hemolysis index. I have all the equations I need but I don't know how to use them in a userdefined function. Can anyone help me? please 

December 8, 2021, 17:22 

#2 
Senior Member
GertJan
Join Date: Oct 2012
Location: Europe
Posts: 1,908
Rep Power: 28 
What makes you think you need a user defined function?


December 8, 2021, 17:46 

#3 
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
because I can't find a way to plot either the contours or the plots of the shear stress in the variable list in CFX.
And I have read articles where the authors used UDF to calculate shear stress and hemolysis. I thought that was the only way to do it. 

December 8, 2021, 17:53 

#4 
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,850
Rep Power: 144 
How you apply this depends on the equations you are trying to apply. Note UDFs are Fluent and CFX is different to Fluent.
Depending on what you are trying to do, you might be able to do this in post processing or you might need to put it in the solver to get your new variable. It all depends on what you are trying to do.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum. 

December 8, 2021, 18:50 

#5  
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
Quote:
"The parameter 'Expression Value' in object '/FLOW:Flow Analysis 1/OUTPUT CONTROL/MONITOR OBJECTS/MONITOR POINT:HII' is defined to be "Single Valued" but it depends on the following field valued variables: , Velocity u.Gradient X, Velocity u.Gradient Y, Velocity u.Gradient Z, Velocity v.Gradient X, Velocity v.Gradient Y, Velocity v.Gradient Z, Velocity w.Gradient X, Velocity w.Gradient Y, Velocity w.Gradient Z." 

December 8, 2021, 18:53 

#6 
Senior Member
GertJan
Join Date: Oct 2012
Location: Europe
Posts: 1,908
Rep Power: 28 
CFX makes the shear strain rate available by default in CFDPost. Can't you derive the shear stress from that?


December 8, 2021, 18:59 

#7  
Senior Member
GertJan
Join Date: Oct 2012
Location: Europe
Posts: 1,908
Rep Power: 28 
Quote:


December 8, 2021, 22:43 

#8 
New Member
WEI Liangchuan
Join Date: Nov 2021
Posts: 9
Rep Power: 4 
You should figure out the derivation of the formula for shear stress, starting from the variables known to cfdpost


December 9, 2021, 06:32 

#9 
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
I found the solution for the shear stress. But I still have a problem concerning hemolysis because it is a variable that varies in time


December 9, 2021, 06:38 

#10 
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,850
Rep Power: 144 
Are you going to tell us what hemolysis function you are trying to apply or should we start guessing?
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum. 

December 9, 2021, 06:48 

#11 
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
sorry
HI = C * T^a * SS^b HI: Hemolysis Index c : constant (=3.620*10^5) T : time (= ti  t(i1)) a : constant (= 0.7850) b: constant (= 2.416) SS: Shear Stress 

December 9, 2021, 06:52 

#12 
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,850
Rep Power: 144 
Does this accumulate on the flow as it passes through regions of different shear stress?
Or is this implemented at a specific time point over the domain? Or how do you want to implement it?
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum. 

December 9, 2021, 06:58 

#13 
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
since I am tracking the movement of red blood cells. I think the best option is to use the hemolysis index function on the streamlines. It would be possible to follow the variation of the hemolysis index when the red cell is present in the simulation field.


December 9, 2021, 18:43 

#14 
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,850
Rep Power: 144 
Do not confuse what you can do with what you actually want to do.
Please explain what you want to do. Does the hemolysis index accumulate on the blood cells as it progresses through to domain? (ie: is it integrated over the flow path?) Or is it just an instantaneous value (ie: is it a scalar field?) Or a scalar field which is only meaningful in some locations (eg along the streamlines?) Please describe mathematically what you want to do, otherwise we are going to have to guess that as well.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum. 

December 18, 2021, 12:14 

#15  
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
Quote:
Normally, we calculate the hemolysis index for a defined number of red blood cells. to make the calculation easier, we assume that the streamlines are trajectories for the red blood cells. using this strategy, we can calculate the variation of the shear stress as well as the hemolysis index along the streamlines. for the variable (t), we can use the time on the streamlines. I have already done this with a C code I developed. but to do all this work, I have to do the simulations, extract the streamline data (1000 streamlines), and then import the data into my code. but, this process takes time and I cannot get contours for the hemolysis index. Ps: Sorry for the delai 

December 18, 2021, 17:53 

#16 
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,850
Rep Power: 144 
You have not defined what your equation means. I assume C, alpha and beta are constants, but what are tau_i and Delta tau_i? Also, what is the sum over? Is it along a streamline? If so, why isn't it a line integral rather than a sum?
If these guesses are correct and you make the assumption that the streamlines are trajectories for the red blood cells then by far the easiest way to do this is to model the flow as single phase (so no particles) but with an additional variable set to convection only (diffusion=0). Define a source term to increment the additional variable according to your equation and rerun the simulation. This approach does not require calculation along streamlines, it does that automatically, and produces an answer in the solver which is easily viewed in the post processor.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum. 

December 23, 2021, 08:04 

#17 
Member
Join Date: Dec 2019
Posts: 31
Rep Power: 6 
yes. C, alpha, and beta are constants. tau_i is the scalar heart stress exerted on the red blood cell in the instant t_i. since the mathematical model is a time_depending model. the only way I could find is to use the time on streamlines. but, as I mentioned previously, I couldn't implement it in CFDpost, since I don't know how to add a timevarying variable.
as for the second, I didn't understand it. however, now I'm trying to redo the simulations using a twophase flow (with particles). I'll see if I can track the particles 

December 23, 2021, 12:41 

#18 
Senior Member
GertJan
Join Date: Oct 2012
Location: Europe
Posts: 1,908
Rep Power: 28 
You can calculate time as scalar variable, starting with zero on the inlet, while increasing in the flow domain. Similar like the time on streamlines, but then as continuous variable.
This time can be used in expressions to couple it with your other variables. How can you do this? Follow this link: Residence Time Distribution 

December 24, 2021, 06:27 

#19 
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,850
Rep Power: 144 
The approach I suggested is much easier and better for your case than particle tracking I suspect. You should give it a try. If you don't understand it then ask questions about what you don't understand.
GertJan's link uses a similar approach and explains it a bit more. Make sure you read that as well.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum. 

Tags 
hemolysis, shear stress, udf 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
[Other] mesh airfoil NACA0012  anand_30  OpenFOAM Meshing & Mesh Conversion  13  March 7, 2022 18:22 
[blockMesh] Errors during blockMesh meshing  Madeleine P. Vincent  OpenFOAM Meshing & Mesh Conversion  51  May 30, 2016 11:51 
How to use date from previous time step in user defined field function?  samantkumarnagraj  STARCCM+  2  December 12, 2014 07:08 
ParaView for OF1.6ext  Chrisi1984  OpenFOAM Installation  0  December 31, 2010 07:42 
Help: user defined function  alice  FLUENT  3  December 13, 2000 01:10 