CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Udf for pumped outlet - help please (https://www.cfd-online.com/Forums/fluent/67108-udf-pumped-outlet-help-please.html)

Adammada August 4, 2009 09:01

Udf for pumped outlet - help please
 
I am trying to make a pump to represent a constant volume pump (using a pressure outlet and varying preassure at outlet with read volume flow rate at the face to a chive a pre determined value). I have come up with the following UDF which causes this error when I initilize

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: ()

Udf:
#include "udf.h"
#include "mem.h"
DEFINE_PROFILE(pumpt,thread,position)
{
face_t f;

Thread *t;

real NV_VEC(a);

real area = 0.000506;

real vdotreq = 0.1;

real po = 101325;

real vtemp = 0;

real uf = 1000;

begin_f_loop(f, thread)
{
F_AREA(a,f,t);
vtemp = (F_V(f,t)*NV_MAG(a)) + vtemp;

}
end_f_loop(f, thread)

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = po * 1 - ((vdotreq-vtemp)*uf);
}
end_f_loop(f, thread)
}

I have a feeling it is related to the vtemp = (F_V(f,t) as it does not have the error when it is removed. Thanks in advance for the help. A second version is below without the first loop.

Adam


or

DEFINE_PROFILE(pump,thread,position)
{
face_t f;

Thread *t;

real area = 0.000506;

real vreq = 0.1;

real vdotreq = vreq * area;

real po = 101325;

real uf = 1000;

real vt = F_V(f,t);

real vdot = vt * area;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, position) = po * 1 - ((vdotreq-vdot)*uf);
}
end_f_loop(f, thread)
}

Allan Walsh August 4, 2009 14:51

Usually an access_violation is caused when you try and access a variable that you don't have access to (due to an error in your code).
Why don't you just use the fan (pump) boundary condition and avoid the problems that go along with UDFs.

Micael August 4, 2009 23:07

This loop has a bug:

begin_f_loop(f, thread)
{
F_AREA(a,f,t);
vtemp = (F_V(f,t)*NV_MAG(a)) + vtemp;
}
end_f_loop(f, thread)

You loop on "thread", but then put "t" as argument. What do you expect "t" to be? Another thread zone? Anyway, this argument should be consistent, use one or the other.

What this loop intends to do?

Have a good day.

Micaël

Adammada August 5, 2009 08:35

Thanks Micael it now initializes. This loop is meant to add up the area x y velocity of every thread in the face - to give a total volume flow rate for the face - will it do that?
Allan - the fan boundary allows a constant pressure or pressure drop I can't see how to get it to provide a constant volume in a multi phase situation. It may be the case that a constant negative pressure provides a constant volume but I don't want to find the pressure manually for each case hence the udf.

Adam

Micael August 5, 2009 09:29

The loop calculates volume flow rate if the face is normal to y velocity.


All times are GMT -4. The time now is 22:27.