|
[Sponsors] |
July 9, 2009, 12:39 |
UDF Addidtional Force to momentum equation
|
#1 |
New Member
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 17 |
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. |
|
July 10, 2009, 06:57 |
UDF for momentum source
|
#2 |
New Member
Dr. Dipankar Chatterjee
Join Date: Jul 2009
Posts: 2
Rep Power: 0 |
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; } |
|
July 13, 2009, 19:09 |
|
#3 |
New Member
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 17 |
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 |
|
July 14, 2009, 03:32 |
|
#4 |
New Member
songok
Join Date: Jul 2009
Posts: 4
Rep Power: 17 |
Does that occur just after initialization?
|
|
July 14, 2009, 06:49 |
|
#5 |
Member
Akour
Join Date: May 2009
Posts: 79
Rep Power: 17 |
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 |
|
July 14, 2009, 09:37 |
|
#6 |
New Member
Join Date: Jun 2009
Location: Belgium
Posts: 11
Rep Power: 17 |
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 |
|
July 14, 2009, 16:36 |
|
#7 |
New Member
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 17 |
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 |
|
July 14, 2009, 16:37 |
|
#8 |
New Member
Sara
Join Date: Jul 2009
Posts: 4
Rep Power: 17 |
Oh I forgot one more thing.....The simulation runs without the UDF but not with it.
Sara |
|
July 15, 2009, 06:31 |
|
#9 |
Member
Akour
Join Date: May 2009
Posts: 79
Rep Power: 17 |
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 |
|
July 15, 2009, 06:34 |
|
#10 |
Member
Akour
Join Date: May 2009
Posts: 79
Rep Power: 17 |
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 |
|
July 15, 2009, 10:29 |
|
#11 |
New Member
Join Date: Jun 2009
Location: Belgium
Posts: 11
Rep Power: 17 |
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 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
DEFINE_CG_MOTION and pressure force | Teo Fumagalli | FLUENT | 0 | April 11, 2008 11:25 |
Coupling between momentum and energy equation | Mattia | FLUENT | 0 | October 26, 2007 09:02 |
UDF to switch on energy equation each time step | galary | FLUENT | 1 | January 5, 2006 20:24 |
Problem with momentum equation | Francisco | Main CFD Forum | 4 | August 5, 2004 21:04 |
Force on cylinders through momentum balance | Mauro Oliveira | Main CFD Forum | 0 | April 14, 2000 09:27 |