Changing boundary condition

  • 213 Views
  • Last Post 26 April 2019
  • Topic Is Solved
Max4 posted this 23 April 2019

Hi,

I have a transient simulation and I want to change the boundary condition from Mass Flow Outlet to Pressure Outlet when a limit value of pressure in a cell zone is reached.

I have already written a Scheme-File for changing a boundary condition as function of time but not as function of a value.

I have read this in order to change the BC.

  - You need a RP Variable

  -  You need an UDF to set that variable to True or False / 1 or 0 depending of the condition

  - You need then a calculation activity which checks for that variable and change the boundary condition

  - You need another UDF to adjust the boundary if RP Varriable is true or 1..

 

I have created the following Scheme for defining a RP Variable named "reached", which defines if the pressure at the outlet is reached or not.

 In a UDF i have to set the variable to True or False depending on the condition. In a UDF I can access the value of the RP Variable by using RP_Get_Integer. I have seen that I can change the value of the variable by using rpsetvar in the Text Interface. For the UDF, can I use RP_Set_Variable("...", int)?

Moreoever how can I access the pressure at the outlet for defining the UDF? I think that I have to use the ID number of the face and the face macro F_P(f, t). Is it right?

 

Regards,

Maxime

Order By: Standard | Newest | Votes
abenhadj posted this 23 April 2019

Pressure variable is available on boundary so just use the face macro to access it. For setting the Rampant variable use what you mentioned. Whenever you want to get the variable on scheme side add % to the rpgetvar (%rpgetvar...)

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 24 April 2019

Thank you for the answer. I have yet the following questions:

1. What kind of macro should I use for the UDF? How can I set in the UDF that I want the pressure at this boundary (i.e. outlet)?

2. "You need then a calculation activity which checks for that variable and change the boundary condition" -> Is it mandatory to use this if I can acess the pressure at outlet directly?

3. "You need another UDF to adjust the boundary if RP Varriable is true or 1"  -> I thought it was only possible to adjust the boundary conditions with by using Scheme?

4. Where can I hook both UDF?

 

Regards,

Maxime

rwoolhou posted this 24 April 2019

You'll need the UDF to trigger the scheme when the face pressure hits your criterion. You'll also need scheme to set the boundary once you've changed it's type. There may also be a pure scheme approach, but not something I've seen done. 

  • Liked by
  • Max4
abenhadj posted this 24 April 2019

1/DEFINE_PROFILE to set the the total pressure at inlet

2/No but is another way

3/That could be an ADJUST which sets the flag or even the DEFINE_PROFILE. 

 

 

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 24 April 2019

Thanks for the answers.

1/ At the outlet I want to know the static pressure, so why I have to use a DEFINE_PROFILE to set the total pressure at the inlet?

2/ Then it will be easier to access directly the static pressure at the boundary using the face macro F_P(f, t). But how can I define that the F_P(f, t) is for the face outlet?

abenhadj posted this 24 April 2019

Because you confused me Max..

 

1/Just using DEFINE_ADJUST / ON_DEMAND or any to get access into it

2/You need to access the correct thread corresponding to the outlet. All that stuff is in the documentation

 

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 24 April 2019

I have then to use the DEFINE_ADJUST or ON_DEMAND Macro in a UDF to access it and use this for having the pressure at the outlet (knowing the ID number).

abenhadj posted this 24 April 2019

Yes.

Best regards,

Amine

  • Liked by
  • Max4
abenhadj posted this 25 April 2019

Please mark this as Is Solved.

Best regards,

Amine

Max4 posted this 25 April 2019

I have wrote the following UDF and Scheme.

1. I have define a RP variable named "reached" which defines when the pressure at the outlet is reached: Where do I hook this Scheme?

2. I have write a UDF to access the pressure on the face and change the value of the RP variable by using RP_Set_Integer("..") if the criterion is reached. Where do I hook this UDF?

3. I wrote a Scheme in order to change the BC according to the value of the RP variable (1 or 0). This Scheme will be load in the Calculations Activities.

Is the method the right one and the functions correct from your point of view?

 

Regards,

Maxime

abenhadj posted this 25 April 2019

Max: This is an open communtiy and i think I need to remind you that we from ANSYS do not debug or comment on any UDF or Schemes. If we are provindin hints than this is pure goodwill.

 

1/You can add it into you .fluent file (on Windows platform under C:\Users\yourname)

2/Function Hooks: Check the Manual for that

3/I won't comment on the commands but the workflow seems consistent

 

Try using the most actual release

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 25 April 2019

Ok thank you. Last question about the RP_Get_*. Is the using of the "RP_Set_Integer("...") = r" in the if_loop correct?

 

Regards,

Maxime

 

rwoolhou posted this 25 April 2019

Add some comments into the UDF and see what's reported on the screen: it's the best way to test logic loops. 

  • Liked by
  • Max4
abenhadj posted this 25 April 2019

Now it is wrong.

RP_Get_Integer (No capital letters)

RP_Set_Integer is correct but the " = r" is wrong. And now start debugging as highlighted by my colleague

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 25 April 2019

Thank you.

With RP_Set_Integer("..") I change the value of the integer. But how should I then affect the change of the variable into the Scheme?

abenhadj posted this 25 April 2019

It set the rp value from C-Side. The changes are committed as soon as you iterate and you are using the % thing.

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 25 April 2019

So I have just to write: RP_Set_Integer("reached", 0) to directly affect the value from C-Side?  In the Scheme I use the %rpgetvar.. so it may be ok.

Is it then mandatory to write "RP_Get_Integer ("reached")" at the beginning of the UDF or it's useless.

 

abenhadj posted this 25 April 2019

You need to decide that..

I will recommend checking the existence of a rp-variable in C-Side: Again check the documentation for that.

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 25 April 2019

Decide if it´s usefull? For me the UDF has to access the value of the RP variable so using RP_Get_Integer(..), but I don´t know how to define it in the UDF.

What kind of rp-variable have I to check? In the Scheme I check if a rp-variable named "reached" already exists.

Regards,

Maxime

abenhadj posted this 25 April 2019

You are already getting and setting values. So can check for the existence of the variable by using a boolean which is documented . Check 3.6 there.

Best regards,

Amine

  • Liked by
  • Max4
Max4 posted this 26 April 2019

The values are changed and assigned during the simulation. By check the existence of the variable, do you mean the " r " if I use " r = RP_Get_Integer("..")"?

In my UDF, can I just write "RP_Get_Integer("..")" so that the if loop can affect the change on this variable if the condition is met?

Regards,

Maxime

abenhadj posted this 26 April 2019

I mean what is documented in the Customization manual Chapter 3.6

Best regards,

Amine

Close