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

UDF Addidtional Force to momentum equation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 9, 2009, 11:39
Default UDF Addidtional Force to momentum equation
  #1
New Member
 
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 16
sfawal is on a distinguished road
Hello my name is Sara. I am new to fluent and programming. I createda a UDF code in order to add a "Force" to the Navier-Stokes momentum equation to simulate the event of a Blunt Thoracic Aortic Rupture (BTAR). Upon compiling the code in Fluent I get an error that says: line 12: parse error. This is the code that I have written:

/* Adding BTAR Source Term*/
#include "udf.h"
DEFINE_SOURCE(cell_x_source, cell, thread)
{
real source;
real dist = C_T(cell,thread);
if (dist >= 0.1.)
source = 10
else if (dist <= 0.12.)
source = 10
else
source = 0.;
return source;
}


Can some one please help me.
sfawal is offline   Reply With Quote

Old   July 10, 2009, 05:57
Default UDF for momentum source
  #2
New Member
 
Dr. Dipankar Chatterjee
Join Date: Jul 2009
Posts: 2
Rep Power: 0
rsdchat is on a distinguished road
Dear sara,
Try this, dont forget to save the udf file with a .c extension,
Wishes,
Dipankar

/* Adding BTAR Source Term*/
#include "udf.h"
DEFINE_SOURCE(cell_x_source, cell, thread, dS, eqn)
{
real source;
real dist = C_T(cell,thread);
if (dist >= 0.1)
source = 10.0;
else if (dist <= 0.12)
source = 10.0;
else
source = 0.0;
return source;
}
rsdchat is offline   Reply With Quote

Old   July 13, 2009, 18:09
Default
  #3
New Member
 
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 16
sfawal is on a distinguished road
Dear Dr. Dipankar,

Thank you for your help the suggestion you gave me really helped. I was successfully able to complie the UDF code. However, when I wanted to itterate for the solution I got the following Error from Fluent:

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()

Any Suggestions?

Thank you

Sara
sfawal is offline   Reply With Quote

Old   July 14, 2009, 02:32
Default
  #4
New Member
 
songok
Join Date: Jul 2009
Posts: 4
Rep Power: 16
mmoja is on a distinguished road
Does that occur just after initialization?
mmoja is offline   Reply With Quote

Old   July 14, 2009, 05:49
Default
  #5
Member
 
Akour
Join Date: May 2009
Posts: 79
Rep Power: 16
ak6g08 is on a distinguished road
hi,

I think you need to specify the derivative of the source term with respect to the variable that you are solving (in your case x-direction velocity), tghe reason for this is because fluent needs to know whether or not to treat the source term fully explicitly or treat it as two separate terms, one implicit and one explicit, have a look at the UDF manual, it explains this.

however your source term is a constant the derivative is equal to zero, you need to put this somewhere, add a line before the 'return source' line that reads:

dS[eqn]=0;

hope that helps
__________________
akour
ak6g08 is offline   Reply With Quote

Old   July 14, 2009, 08:37
Default
  #6
New Member
 
Join Date: Jun 2009
Location: Belgium
Posts: 11
Rep Power: 16
Laika is on a distinguished road
Hi Sara,

can you list us the exact steps before you encountered the error message? Did your simulation ran fine without the UDF?
Were did you hooked up the UDF source term in your model?

good luck,
Laika,
still orbiting
Laika is offline   Reply With Quote

Old   July 14, 2009, 15:36
Default
  #7
New Member
 
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 16
sfawal is on a distinguished road
Hello,

This is Sara with you all. Below are the exact steps that I have taken to implement the UDF.

1. Read case (mesh file)

2. Define, Models, Solver: I picked Density based and Unsteady conditions

3. Define, Materials: Changed Density to 1060 and viscocity to 0.004 to simulated for Blood.

4. Kept Operation condition as 101325 pascals.

5. Define, User defined, Functions, Interpreted: Loaded my UDF as a .c format and selected display assembly listings (No error message)

6. Define, Boundary Conditions, Fluid: Selected source Terms and changed X Momentum to 1 using udf cell_x_source.

7. Uder boundary conditions, Inlet: I set the inlet velocity to 1 m/s

8. Solve, Controls, Solution: Kept the default settings: Second order Upwind and Courant number = 5

9. Solve, Monitors, Residual set the absolute criteria to 1E-06 and selected Plot under options.

10. Solve, Initialize: Selected for inlet and clicked initialize (No error message).

11. Solve, Itterate: Time step size 0.1 and Number of time steps 500 and clicked on Itterate (Error Message).

12. I get the Error message:

Updating solution at time level N... done.
iter continuity x-velocity y-velocity time/iter
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()

These are the exact steps I followed. I also added the ds[eqn]=0; in the 'C' Code file but I still get the error message.

I would really appreciate your input on this situation.

Sara
sfawal is offline   Reply With Quote

Old   July 14, 2009, 15:37
Default
  #8
New Member
 
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 16
sfawal is on a distinguished road
Oh I forgot one more thing.....The simulation runs without the UDF but not with it.

Sara
sfawal is offline   Reply With Quote

Old   July 15, 2009, 05:31
Default
  #9
Member
 
Akour
Join Date: May 2009
Posts: 79
Rep Power: 16
ak6g08 is on a distinguished road
hi,

Im not sure if this will work, but have a go and see what happens,

1. try declaring 'dist' separately and then giving it a value so have a line that reads

real source,dist;

and then

dist=C_T(cell,thread)

2. try running the simulation for one timestep (choose a small timestep) without the source term on, after the first timestep is complete, cancel the simulation, hook the source term, and continue the simulation, do this WITHOUT re-initializing, normally i dont think you would need to do this, usually only need it for gradients but see what happens...this will make sure fluent is not looking for a variable that doesnt exist yet (which would explain why its an access_violation and not something else)

hope that helps
__________________
akour
ak6g08 is offline   Reply With Quote

Old   July 15, 2009, 05:34
Default
  #10
Member
 
Akour
Join Date: May 2009
Posts: 79
Rep Power: 16
ak6g08 is on a distinguished road
hi again,

C_T is a temperature, i dont see anywehere in your list you having turned on the energy equation in the solver, have you forgotten to do this perhaps??
__________________
akour
ak6g08 is offline   Reply With Quote

Old   July 15, 2009, 09:29
Default
  #11
New Member
 
Join Date: Jun 2009
Location: Belgium
Posts: 11
Rep Power: 16
Laika is on a distinguished road
That's a good remark. Indeed C_T is a temperature. But knowing that you called it dist, and seeing the values 0.1 and 0.12, you probably want to have a location-dependent source. 0.1K and 0.12K is probably not what you are looking for.

Another thing is that you undoubtedly have made a mistake here:
if (dist >= 0.1)
source = 10.0;
else if (dist <= 0.12)
source = 10.0;
else
source = 0.0;

Your source will be uniform 10.0 everywhere!

good luck,

Laika,
still orbiting
Laika 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
DEFINE_CG_MOTION and pressure force Teo Fumagalli FLUENT 0 April 11, 2008 10:25
Coupling between momentum and energy equation Mattia FLUENT 0 October 26, 2007 08:02
UDF to switch on energy equation each time step galary FLUENT 1 January 5, 2006 19:24
Problem with momentum equation Francisco Main CFD Forum 4 August 5, 2004 20:04
Force on cylinders through momentum balance Mauro Oliveira Main CFD Forum 0 April 14, 2000 08:27


All times are GMT -4. The time now is 14:53.