CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent Multiphase

Help with writing a macro/UDF_file/script to change BC at regular time step intervals

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   April 24, 2014, 10:07
Default Help with writing a macro/UDF_file/script to change BC at regular time step intervals
New Member
Join Date: Apr 2014
Posts: 2
Rep Power: 0
Codophobia is on a distinguished road
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 ?
Codophobia is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine time step size and Max. iterations per time step. pratik c FLUENT 45 February 26, 2019 22:50
Help for the small implementation in turbulence model shipman OpenFOAM Programming & Development 25 March 19, 2014 10:08
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 13:12
AMI interDyMFoam for mixer nu problem danny123 OpenFOAM Programming & Development 8 September 6, 2013 02:34
calculation diverge after continue to run zhajingjing OpenFOAM 0 April 28, 2010 04:35

All times are GMT -4. The time now is 14:18.