UDF program for calculating the pressure

  • 142 Views
  • Last Post 29 August 2019
  • Topic Is Solved
vighnesh posted this 24 July 2019

Hello there,

can anyone help me in writing a UDF program ??

I need to calculate Change in pressure and with change in inlet velocity at given time interval in a pipe.Pipe description is as mention in this link. (https://studentcommunity.ansys.com/thread/calculate-pressure-difference/?order=all#comment-22db4f04-ee3b-48ba-b8bb-aa8800b2b566).

@abenhadj and rwoolhou, as you people suggested, i got expected result. Which was like..

Once done with the geometry and meshing,in setup create the point P1 and P2. in models,materials,cell zone conditions and boundry conditions do the necessary changes.In solution-->report definations for P1 and P2 and then in monitors,generate report files as explained the above link.

In this solution i was manually changing the inlet velocity and calculating P1-P2 everytime after required time step for say 'T' sec.

What I need is how can i write a UDF program so that all the variable parameters are addressed in one program i.e calculate p1-p2 with varieing inlet velocity for regular interval of time say for first 100 sec velocity is v1 next 100 sec velocity is v2 and so on for 2000sec.

any comments or data materials will help..

 

Thanks.

Order By: Standard | Newest | Votes
abenhadj posted this 25 July 2019

You need to use DEFINE_PROFILE to change the boundary value at your inlet. If the profile is only dependent on time you can use profile file. If you are using actual versions you can use Fluent Expression to change the value at the boundary.

The pressure difference is via Report so I guess you do not need to do anything. Only if you want to have that on demand via UDF. But is this really required.

 

All above is documented.

Best regards,

Amine

rwoolhou posted this 25 July 2019

You don't need a UDF to calculate the pressure. If you use the reporting features (as you've done) for the pressure drop you then only need a profile or expression (or simple boundary UDF) to alter the velocity with time.  The latter can be done using a couple of example UDFs in the manual: start with DEFINE_PROFILE

 

vighnesh posted this 25 July 2019

Thank you..will go through both the suggestions.

Please find the attachment below.

Fig 1 is the graph what i am getting now using Ansys fluent. Fig 2 is what i need to get.

Any thoughts??Graph

Thanks.

abenhadj posted this 25 July 2019

See my suggestions above thanks.

Best regards,

Amine

vighnesh posted this 29 July 2019


Hi abenhadj,rwoolhou,

I dont understand where to start with. Im litrally new to programming. Please help. I had gone through the Ansys UDF manual. Should i write a c code or TUI commands and journal files will do the trick?? 

 

regards,

rwoolhou posted this 29 July 2019

Right, start off with what you need to know:

For a given velocity (that changes with time) you want the pressure loss. 

 

So, input is the velocity profile. If you can ignore the higher frequency noise    velocity = coefficient * time     Now read the DEFINE_PROFILE example in the UDF manual, and look for examples where solution time has been used.  If velocity is a stair-step you'll need to use an IF function and figure out the logic. 

The output is the pressure loss or value. For a velocity inlet & pressure outlet, the pressure on the outlet is fixed, and varies on the inlet to force the flow into the domain.  Using a Report you can plot & save this value to a file (read up on monitor points). 

Plot the input you give the UDF and Pressure monitor (remember to add time into the export) to get what you're after. 

 

As an aside: please use one thread per problem. Posting elsewhere won't get you a faster answer and will result in other topics being locked. As I have a finite amount of time it'll also mean I don't answer other threads. 

vighnesh posted this 29 July 2019

Thanks rwoolhou,

Attached a image file of UDF, please comment if anything to be added into that. I am able to compile the program but not able to get the expected graph.

vighnesh posted this 30 July 2019

How to export velocity values (0.03 to 1.95) to the report file??

rwoolhou posted this 30 July 2019

You can set a second report and then combine the files, or add in the data manually: you're setting the velocity. Check you can't add multiple reports to one file (can't remember if they need to have the same units). 

Re the UDF, if time is greater than 1000s it's also greater than 900s (and 800s etc): what value should the solver use? 

vighnesh posted this 05 August 2019

hi rwoolhou,

1. As written in UDF,  as far as my understanding solver uses value in between the timestamp as mention. E.g : After 1000s and till 1100, v=1.5m/s and if >900 and less than 1000,v=1.35.

Please correct me if i am wrong.

2. I get some negative Delta p values,as velocity step increases. Any suggestions??

Velocity is lower at P1 and higher at P2 as expected but Pressure is not stable.

 

abenhadj posted this 05 August 2019

1/yes 2/ Perhaps it requires more iterations and or smaller time steps especially at transition.

Why not using transient profile or Expressions.

Best regards,

Amine

vighnesh posted this 05 August 2019

Hi Amine,

Why not using transient profile or Expressions..

Can you please elaborate..? 

abenhadj posted this 05 August 2019

Transient Profile is another alternative instead of writing UDFs. The same is with Fluent Expressions. But now you are using UDF: that is okay.

Best regards,

Amine

vighnesh posted this 05 August 2019

Thank you. Will try increasing iterations(already done for 20 iterations) and also smaller time steps.

lately i have been doing this for every 100sec,increase v at steps of 0.05m/s.

is that okay?

Regards,

Vighnesh

abenhadj posted this 05 August 2019

That is your application: I don't know if this is okay as I do not know the application. If your application and reality require this ramp-up then you should try to do that.

Best regards,

Amine

vighnesh posted this 05 August 2019

Hi Amine,

smaller time steps especially at transition...

Do u mean..

a. Should I try calculating Delta P for every 0.25 sec rather than 1sec.

b. Should i try this for lesser duration time/change in velocity (lately i have been doing this for every 100sec,increase v at steps of 0.05m/s)

abenhadj posted this 05 August 2019

Just try and report. I was meaning using smaller time steps in general and more iteration during each time step (set it to 20 max and report interval to 5 to enforce 5 iterations every time step).

Best regards,

Amine

vighnesh posted this 29 August 2019

Hi Amine,rwoolhou,

Can I know how Ansys calculates the pressure,velocity etc. (back end code on which equation/formula it uses). I have theoretically calculated Delta P which is not close to the value I got from Ansys. I need to know how does Ansys calculate those values.

regards,

Vighnesh

rwoolhou posted this 29 August 2019

The equations are all in the theory guide: we calculate values at each cell and iterate to a solution.  Differences to theory can be due to limitations in the theory (eg assumptions in the equations), insufficient mesh/resolution, user error etc so there's no one reason for a discrepancy. 

vighnesh posted this 29 August 2019

Thanks rwoolhou!!!

 

Close