Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

switching boundary conditions in COMSOL while running a time-dependent simulation

Please login with a confirmed email address before reporting spam

I have been trying to simulate reciprocating flow of a convective fluid through a heated channel in COMSOL-Multiphysics. Basically, if there are two boundaries to the channel Left L and right R, the boundary L should act as an inlet for half of the oscillation time-period. During this half, the boundary R should act as an outlet. Similarly, in the next half of the cycle, R should act as the inlet, while L now is the outlet. Obviously, it is a time dependent simulation.

I do understand that I need to define an inlet mass flux or velocity profile at the boundaries. The problem is that I cannot figure out how to change the type of boundary conditions at the cycle halves.


6 Replies Last Post Apr 19, 2022, 2:00 p.m. EDT
Mats Nigam COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 2 years ago Dec 7, 2021, 10:22 a.m. EST

Dear Indrasis, You can drive the flow entirely from one of the boundaries by for example specifying a time periodic mass flow condition. At the other boundary, you simply put a static pressure condition and uncheck the suppress backflow option (and possibly check the normal flow option).

Dear Indrasis, You can drive the flow entirely from one of the boundaries by for example specifying a time periodic mass flow condition. At the other boundary, you simply put a static pressure condition and uncheck the suppress backflow option (and possibly check the normal flow option).

Please login with a confirmed email address before reporting spam

Posted: 2 years ago Dec 7, 2021, 11:25 p.m. EST
Updated: 2 years ago Dec 8, 2021, 6:37 a.m. EST

Hi Mats,

Appreciate the reply. The method you are suggesting will change the type of oscillatory flow,i.e., it will become a pulsating flow. A pulsating flow is unidirectional with mass flow rate being modulated as a sinusoid at one end. However, I want to simulate a reciprocating flow where the flow inlets and exits are cyclic (bi-directional flow). This too falls as a sub-category of oscillating flow. I am especially interested in the resulting temperature gradients. This is why, I wanted to switch the boundary conditions.

I have found a method by the way. Let us assume that the left end is L and the right end is R. If I define a sinusoidal pressure profile at L and a sinusoidal pressure profile at R (but phase shifted by pi radians at the R end), with the suppress backflow option unchecked, I have found that the reciprocation can be achieved. In this way, for a half cycle, the pressure gradient driving the flow is from L to R, while in the next half-cycle it switches from R to L. This could be possible because the COMSOL documentation suggests that with a pressure type boundary condition, the boundaries can act both as an inlet and outlet (depending on the local pressure). When I combine this flow set-up with an open boundary type boundary condition at L and R (in the heat transfer section) with a specified upstream temperature, the heat transfer aspect can also be aptly modeled. Once again becasue the open boundary type boundary condition, can act as both an inlet with upstream temperature if the flow is into the domain and as a zero conductive flux outlet, if the flow is out of the domain. The direction of the flow is obviously being determined when the flow equations are being solved for the particular time-step.

However, my primary objective is to assign a sinusoidal mass flow rate profile at the domain ends. This fails because both the mass and velocity inlet boundary conditions require the flow to be only into the domain or out of the domain. Therefore, I am in need of switching them each half-cycle.

![](http://)Hi Mats, Appreciate the reply. The method you are suggesting will change the type of oscillatory flow,i.e., it will become a pulsating flow. A pulsating flow is unidirectional with mass flow rate being modulated as a sinusoid at one end. However, I want to simulate a reciprocating flow where the flow inlets and exits are cyclic (bi-directional flow). This too falls as a sub-category of oscillating flow. I am especially interested in the resulting temperature gradients. This is why, I wanted to switch the boundary conditions. I have found a method by the way. Let us assume that the left end is L and the right end is R. If I define a sinusoidal pressure profile at L and a sinusoidal pressure profile at R (but phase shifted by pi radians at the R end), with the suppress backflow option unchecked, I have found that the reciprocation can be achieved. In this way, for a half cycle, the pressure gradient driving the flow is from L to R, while in the next half-cycle it switches from R to L. This could be possible because the COMSOL documentation suggests that with a pressure type boundary condition, the boundaries can act both as an inlet and outlet (depending on the local pressure). When I combine this flow set-up with an open boundary type boundary condition at L and R (in the heat transfer section) with a specified upstream temperature, the heat transfer aspect can also be aptly modeled. Once again becasue the open boundary type boundary condition, can act as both an inlet with upstream temperature if the flow is into the domain and as a zero conductive flux outlet, if the flow is out of the domain. The direction of the flow is obviously being determined when the flow equations are being solved for the particular time-step. However, my primary objective is to assign a sinusoidal *mass* flow rate profile at the domain ends. This fails because both the mass and velocity inlet boundary conditions require the flow to be only into the domain or out of the domain. Therefore, I am in need of switching them each half-cycle.


Please login with a confirmed email address before reporting spam

Posted: 2 years ago Dec 8, 2021, 7:22 a.m. EST

OK Mats, reading your comment with some more focus, I can understand it a little more. Do you mean to say that the mass flux profile will have negative parts also and when imposed at one of the boundaries it will act as both inlet and outlet. In this way with a zero gauge pressure at the other end, during the second half cycle the other end will actually work as the inlet. Right ?

And for temperature I can just use the open boundary option on both the boundaries with the upstream temperature set to whatever I need. This temperature will be automatically applied to the boundary which acts as the inlet during a particular half cycle.

I doubt I have been clear enough.

OK Mats, reading your comment with some more focus, I can understand it a little more. Do you mean to say that the mass flux profile will have negative parts also and when imposed at one of the boundaries it will act as both inlet and outlet. In this way with a zero gauge pressure at the other end, during the second half cycle the other end will actually work as the inlet. Right ? And for temperature I can just use the open boundary option on both the boundaries with the upstream temperature set to whatever I need. This temperature will be automatically applied to the boundary which acts as the inlet during a particular half cycle. I doubt I have been clear enough.

Mats Nigam COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 2 years ago Dec 9, 2021, 5:59 a.m. EST

Yes, that's right. Let me know if you run into any other issues.

Yes, that's right. Let me know if you run into any other issues.

Please login with a confirmed email address before reporting spam

Posted: 2 years ago Dec 10, 2021, 12:14 a.m. EST

Hi Mats, Thanks a lot. The setup suggested by you works perfectly.

Hi Mats, Thanks a lot. The setup suggested by you works perfectly.

Please login with a confirmed email address before reporting spam

Posted: 2 years ago Apr 19, 2022, 2:00 p.m. EDT
Updated: 2 years ago Apr 19, 2022, 2:03 p.m. EDT

Dear Mitra Sir and Nigam Sir, I have a same type of query. I am simulating a flow between two parallel plates. During the half time, left side (L) acts as inlet and right side (R) acts as a outlet in my simulation, while during another half cycle, L acts as outlet and R acts as inlet. how can I define an inlet velocity in this type of flow? Note: Velocity in my case is of constant nature which has same value during both cycles. Please help me out. Thank you in advance. Regards Prakash Singh

Dear Mitra Sir and Nigam Sir, I have a same type of query. I am simulating a flow between two parallel plates. During the half time, left side (L) acts as inlet and right side (R) acts as a outlet in my simulation, while during another half cycle, L acts as outlet and R acts as inlet. how can I define an inlet velocity in this type of flow? Note: Velocity in my case is of constant nature which has same value during both cycles. Please help me out. Thank you in advance. Regards Prakash Singh

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.