CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent Multiphase (https://www.cfd-online.com/Forums/fluent-multiphase/)
-   -   Help with writing a macro/UDF_file/script to change BC at regular time step intervals (https://www.cfd-online.com/Forums/fluent-multiphase/134105-help-writing-macro-udf_file-script-change-bc-regular-time-step-intervals.html)

Codophobia April 24, 2014 10:07

Help with writing a macro/UDF_file/script to change BC at regular time step intervals
 
First of all, Hello to everyone !

This is my first post on this forum so I do apologise for any rude-ness, inconsiderations, transgressions I may have unknowingly committed. Also, please keep in mind I am relatively new to the world of CFD so bear with any 'amatuer' questions.

So here goes.

I am modeling a 2D multi-phase VOF simulation. I have 2 pressure inlets, one for Air and one for Water.

These inlets are never open at the same time and follow a regular time step interval.

The strategy I am adopting for this is changing the BC for the inlets so they are converted from a pressure inlet to a wall and vice-versa to represent their closing and opening respectively.

To illustrate what I mean, as an example,

Initial condition as I start the run from the GUI: Air Inlet Open (Pressure Inlet), Water Inlet Close (Wall)

What I want to automate:
After w no. of timesteps, change Air Inlet from pressure inlet to wall
After x no. of timesteps, change Water Inlet from wall to pressure inlet
After y no. of timesteps, change Water inlet from pressure inlet to wall
After z no. of timesteps, change Air inlet from wall to pressure inlet

where w,x,y,z are timesteps in sequence

Assuming that is 1 cycle, and the last step is the end of cycle 1 and start of cycle 2, I want to run 5 cycles maintaining the same variation in timesteps between each macro.

Now, I managed to use the 'define macro' function in the 'Calculation Activities' tab to define the 4 steps described above as 4 macros. FLUENT allows me to run each of the 4 macros at regular timestep intervals (this setting found in the same window where I defined the macros), but that method only works for the first cycle.

To ensure the cycle maintains its timestep interval between each macro in all cycles, not just the first one, My idea is to create a series of IF statements and incorporate it into the macros so that I can define how many timesteps after the 1st macro is executed the next macro will run and so on and so forth.

In other words, I want to use IF statements to tell FLUENT that when it runs each macro, after a certain no. of time steps I want it to run the next macro, so by writing out statements for each macro, it will flow onto the next macro.

i.e. IF macro 1 is run, after X no. of time steps, run macro 2.


Question 1: Assuming the strategy above is sound, how would I go about executing it ? I have no coding background/experience and have no idea how to construct logical statements using the coorect syntax which FLUENT can recognise. Could you please give me a few lines as example to show what sort of code would give me the timestep variation between each macro that I am looking for ?

Question 2: Is this strategy which I have described so far a good strategy ? If not, are there any alternate methods I could look into, such as writing a UDF file from scratch ?


All times are GMT -4. The time now is 06:46.