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.

Time dependent alternating temperature/thermal insulation boundary conditions

Please login with a confirmed email address before reporting spam

Hi all,

I am trying to setup alternating boundary conditions for a certain boundary based on the hours of each day. My model will run for about 2 months, and I would like to set the boundary condition such that:

- 0-6 hours: Temperature BC
- 6-24 hours: Thermal insulation BC

The boundary condition would switch from Temperature to Insulation and vice versa each day until the end of running. I am wondering if this is possible, or if there is a more practical approach.

I would be grateful if you could help me. Thanks,

--
Tolga

7 Replies Last Post 05.01.2017, 01:35 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 18.06.2013, 21:56 GMT-4
I managed to solve this problem using Matlab. However, now I have another problem with respect to extracting result data.

Imagine that you have tens of transient solvers each corresponding to a different time period of the problem. In COMSOL, is it possible to combine these results and get continuous data?

My solver configuration looks like:
Solver 1: range(0, 15[min], 6[h])
Solver 2: range(6[h], 15[min], 24[h])
Solver 3: range(24[h], 15[min], 30[h])
Solver 4: range(30[h], 15[min], 48[h])
....


Can I extract the data, i.e. integration of heat flux over a certain boundary for the total period (0 to 48 hours)? Right now I can only do it per solution within COMSOL. I think this is also doable by writing a script in Matlab, but I was wondering if there is a practical way to do it within COMSOL.

Thanks,

--
Tolga
I managed to solve this problem using Matlab. However, now I have another problem with respect to extracting result data. Imagine that you have tens of transient solvers each corresponding to a different time period of the problem. In COMSOL, is it possible to combine these results and get continuous data? My solver configuration looks like: [quote]Solver 1: range(0, 15[min], 6[h]) Solver 2: range(6[h], 15[min], 24[h]) Solver 3: range(24[h], 15[min], 30[h]) Solver 4: range(30[h], 15[min], 48[h]) ....[/quote] Can I extract the data, i.e. integration of heat flux over a certain boundary for the total period (0 to 48 hours)? Right now I can only do it per solution within COMSOL. I think this is also doable by writing a script in Matlab, but I was wondering if there is a practical way to do it within COMSOL. Thanks, -- Tolga

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19.06.2013, 02:59 GMT-4
Hi,

There is a simple trick to do this. For the first day write your prescribed temperature as

if(t<6[h],T0,T)

where T0 is your prescribed temperature, and T is the name of the temperature degree of freedom. The 'if' condition has to be generalized to cover more days of course.

This reason that this works is that the constraint applied is T-T_prescribed = 0. So if we set the prescribed temperature to T itself, no constraint is generated since T-T cancels.

Now you can run all in one study, and can avoid the problems with merging results.

Regards,
Henrik
Hi, There is a simple trick to do this. For the first day write your prescribed temperature as if(t

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19.06.2013, 03:05 GMT-4
Hi Henrik,

Thank you so much for the trick. I couldn't imagine that this would work.

I was struggling with writing code in Matlab to generate the needed study steps and extract result data. I've been successful so far, but the trick you provided will make things way easier and faster.

--
Tolga
Hi Henrik, Thank you so much for the trick. I couldn't imagine that this would work. I was struggling with writing code in Matlab to generate the needed study steps and extract result data. I've been successful so far, but the trick you provided will make things way easier and faster. -- Tolga

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 19.06.2013, 03:50 GMT-4
Here is my solution as per Henrik's suggestion:

I set the prescribed temperature as follows: (Works perfectly, thanks again!)
if(mod(t/3600, 24) <= 6, T0, T)


For the Matlab solution, the trick is to conditionally toggle the Temperature BC node:
model.physics('ht').feature('temp1').active(true);
model.physics('ht').feature('temp1').active(false);


and in order to extract data from the model:
% get the heat flux magnitude for current solver step
totalHeatFluxMagnitudeOfPipeInnerBoundaryForCurrentStep = mphint2(model, {'ht.tfluxMag'}, 'line', 'dataset', solutionSet, 'selection', 'sel5');

% Merge the data: Only for the first step, directly assign it to current data
totalHeatFluxMagnitudeOfPipeInnerBoundary = totalHeatFluxMagnitudeOfPipeInnerBoundaryForCurrentStep;

% Merge the data: For other steps, add current data and obtain cumulative data
totalHeatFluxMagnitudeOfPipeInnerBoundary = [totalHeatFluxMagnitudeOfPipeInnerBoundary totalHeatFluxMagnitudeOfPipeInnerBoundaryForCurrentStep];


Here solutionSet is the name of the solution set, which you will need to iterate in your loop, i.e. 'dset1', 'dset2', ...

--
Tolga
Here is my solution as per Henrik's suggestion: I set the prescribed temperature as follows: (Works perfectly, thanks again!) [quote]if(mod(t/3600, 24)

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 22.12.2014, 15:31 GMT-5
Understanding that set u=u means to switch off the constraint

another way to do this is

T-T*(t<0.6[h])+T0*(t<0.6[h])

this is useful when the switch is based on randomly-changing variables (say you want to switch to insulation when temperature(x,y,z) reaches 90 [degC])
Understanding that set u=u means to switch off the constraint another way to do this is T-T*(t

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 02.01.2015, 19:21 GMT-5
I found this switching BC worked fine when switch from temperature to insulation. However, when switch from insulation to temperature, it does not converge. Is there any solution to this?
I found this switching BC worked fine when switch from temperature to insulation. However, when switch from insulation to temperature, it does not converge. Is there any solution to this?

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 05.01.2017, 01:35 GMT-5
Can someone explain me how does exactly work "mod(t,24)"?
Can someone explain me how does exactly work "mod(t,24)"?

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.