Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

Boundary conditions vary with time

Please login with a confirmed email address before reporting spam

Hello,

I am new to this forum and starting on Comsol. I checked the history of the forum on the issue of boundary conditions varying with time, but I am not satisfied with the answers and I still raised it.

I have two phenomena in a porous medium, the diffusion of chloride ions accelerated by heat transfer. The concentration of chloride ions on boundary conditions take two values ??that commute every 15 days, such as the transfer of heat.

I tried to use the piecewise function with smoothing but the solver can not evaluate this feature, or maybe I have not handled well.
If somebody has successfully used this function piecewise or if there is another way to solve this problem, I really need your help.
Med Regards.

9 Replies Last Post May 1, 2014, 11:16 p.m. EDT
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 29, 2011, 1:50 a.m. EDT
Hi

you you want a periodic rectangle, of amplitude "amp", period "Dt" , rise time "dt" and pulse length "0n" of "Pt"
you can achieve this in V4 by

1) adding a function "rect1(t) lower limit = "0", upper limit "Pt", transition zone "dt" and then
2) add an analytical function "an1(t)" stating Expression "Amp*mod1.rect1(mod(t,Dt))"

use the "plot" icon to check the shape.

There is also the "make periodic" to remove the mod(t,DT) you will have to play a little with that to understand how it behaves


--
Good luck
Ivar
Hi you you want a periodic rectangle, of amplitude "amp", period "Dt" , rise time "dt" and pulse length "0n" of "Pt" you can achieve this in V4 by 1) adding a function "rect1(t) lower limit = "0", upper limit "Pt", transition zone "dt" and then 2) add an analytical function "an1(t)" stating Expression "Amp*mod1.rect1(mod(t,Dt))" use the "plot" icon to check the shape. There is also the "make periodic" to remove the mod(t,DT) you will have to play a little with that to understand how it behaves -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 30, 2011, 4:02 p.m. EDT
Good evening
Thank you for your help Mr. Ivar. I tried but since I 'm stuck on the analytic function is not quite clear to my level. I do not understand the components of the term " mod1.rect1 ( mod (t, Dt ) ).

I recalled that I have two values ??" C1 " and " C2 " as boundary conditions, the first 15 days I have " C1 ", the second 15 days I have " C2 " and again the value " C1 "to the next 15 days and so on.

a periodic rectangle is a best solution, but I did not understand the expression and the argument too.
Thank you Mr. Ivar.

Regards Med
Good evening Thank you for your help Mr. Ivar. I tried but since I 'm stuck on the analytic function is not quite clear to my level. I do not understand the components of the term " mod1.rect1 ( mod (t, Dt ) ). I recalled that I have two values ??" C1 " and " C2 " as boundary conditions, the first 15 days I have " C1 ", the second 15 days I have " C2 " and again the value " C1 "to the next 15 days and so on. a periodic rectangle is a best solution, but I did not understand the expression and the argument too. Thank you Mr. Ivar. Regards Med

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 30, 2011, 4:07 p.m. EDT
Hi

the mod1.rect1 is another rectangular function defined in COMSOL side by side with the analytical one (note: for an analytical function to work properly when referring to another function, you must add the full name path mod1.rect1(), where mod1 stands for the "tag" (you might turn on and off tags and identifiers with the node names) of the model 1

the the mod(t,Dt) is the modulo built-in math function, it generates a sawtooth with slope 1 and periodicity Dt. Try it yout: make a new analytical function of t and write only "mod(t,1.5)" then plot from -4 to +4

The analytical function and it's plot functionality is ideal to debug complex BC functions

--
Good luck
Ivar
Hi the mod1.rect1 is another rectangular function defined in COMSOL side by side with the analytical one (note: for an analytical function to work properly when referring to another function, you must add the full name path mod1.rect1(), where mod1 stands for the "tag" (you might turn on and off tags and identifiers with the node names) of the model 1 the the mod(t,Dt) is the modulo built-in math function, it generates a sawtooth with slope 1 and periodicity Dt. Try it yout: make a new analytical function of t and write only "mod(t,1.5)" then plot from -4 to +4 The analytical function and it's plot functionality is ideal to debug complex BC functions -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 30, 2011, 11:08 p.m. EDT
Hello Mr. Ivar
Now I understand, I tested the function periodic rectangle and it works:
the " rect1 " with " lower bound = 0 " and " Upper Limit = 15 * 86400 "
and the analytic function " an1 " = " Amp*mod1.rect1 * ( mod (t, 30 * 86400 ) ).

Now to apply the value of the boundary conditions " C1 [mol/m^3] ", I chose to give " Amp " = 1 and therefore the value in the boundary conditions is " C1 * an1". Or I give directly " Amp " = " C1 " and I apply " an1 " as boundary conditions.

In both cases an error is displayed as shown:
The following feature has encountered a problem:
-Feature : Time dependent solver 1 (sol2/t1)
-Error : Failled to evaluate variable Jacobian.

Anyway thank you Mr. Ivar, and i'm trying to correct.
cordially Med.
Hello Mr. Ivar Now I understand, I tested the function periodic rectangle and it works: the " rect1 " with " lower bound = 0 " and " Upper Limit = 15 * 86400 " and the analytic function " an1 " = " Amp*mod1.rect1 * ( mod (t, 30 * 86400 ) ). Now to apply the value of the boundary conditions " C1 [mol/m^3] ", I chose to give " Amp " = 1 and therefore the value in the boundary conditions is " C1 * an1". Or I give directly " Amp " = " C1 " and I apply " an1 " as boundary conditions. In both cases an error is displayed as shown: The following feature has encountered a problem: -Feature : Time dependent solver 1 (sol2/t1) -Error : Failled to evaluate variable Jacobian. Anyway thank you Mr. Ivar, and i'm trying to correct. cordially Med.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 2, 2011, 5:29 a.m. EDT
Hello
I ask for help on the call of analytic functions. Whether it is an analytic function continuous or not continuous, I try to use as boundary conditions, an error appears like this:

- Feature: Time - Dependent Solver 1 ( sol/t1 )
- Error: Failed to Evaluate Jacobian.

Failed to Evaluate variable Jacobian.
- Variable: an1
- Geometry: 1
- Boundary: 2 4 5

I tested several analytical functions and continuous, but I can not understand where is the error. I work with 4.0a.

Regards Med.
Hello I ask for help on the call of analytic functions. Whether it is an analytic function continuous or not continuous, I try to use as boundary conditions, an error appears like this: - Feature: Time - Dependent Solver 1 ( sol/t1 ) - Error: Failed to Evaluate Jacobian. Failed to Evaluate variable Jacobian. - Variable: an1 - Geometry: 1 - Boundary: 2 4 5 I tested several analytical functions and continuous, but I can not understand where is the error. I work with 4.0a. Regards Med.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 2, 2011, 9:36 a.m. EDT
Good evening
I think I managed to resolve the problem by the " piecewise ".
The syntax at the time of the call: " mod1.pw1 (t [ 1 / s ] ) " and it works.
At the time of the definition of the piecewise function ( PW1 ), I have directly affected the two concentration values ??reported as parameters with their units before and it is not the only way to do. It is absolutely smooth, I used as smoothing " Continuous first derivative ".

Regards Med.
Good evening I think I managed to resolve the problem by the " piecewise ". The syntax at the time of the call: " mod1.pw1 (t [ 1 / s ] ) " and it works. At the time of the definition of the piecewise function ( PW1 ), I have directly affected the two concentration values ??reported as parameters with their units before and it is not the only way to do. It is absolutely smooth, I used as smoothing " Continuous first derivative ". Regards Med.

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 2, 2011, 4:07 p.m. EDT
Hi

probably what you hit is that functions that are not continuous (or derivable at least once) do not give a easily defined Jacobian (the derivative materix) that is used for step and covergence by the solvers.

One rule in FEM:always adapt your functions so these are at least derivable at least once, even taking into account the "initial values" default "0" that often do not fit the driving functions, hence a large disastrous step at the first solver iteration, and before even the solver has managed to identify the "best" trend, to knowwhere to go for step #2

--
Good luck
Ivar
Hi probably what you hit is that functions that are not continuous (or derivable at least once) do not give a easily defined Jacobian (the derivative materix) that is used for step and covergence by the solvers. One rule in FEM:always adapt your functions so these are at least derivable at least once, even taking into account the "initial values" default "0" that often do not fit the driving functions, hence a large disastrous step at the first solver iteration, and before even the solver has managed to identify the "best" trend, to knowwhere to go for step #2 -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 2, 2011, 5:38 p.m. EDT
Hi Mr. Ivar

Exactly the problem was in the Jacobian matrix.
Now it's ok with the " piecewise " and thank you very much.

Regards Med.
Hi Mr. Ivar Exactly the problem was in the Jacobian matrix. Now it's ok with the " piecewise " and thank you very much. Regards Med.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago May 1, 2014, 11:16 p.m. EDT
Dear Ivar,

I tried to do the same. But a error message comes up saying" Invalid Lower Bound-empty expression". The same error comes when I tried the library model Second Harmonic Generation.
what should I do. I was trying with many rectangular, it was not working.

Thanks
Chandan
Dear Ivar, I tried to do the same. But a error message comes up saying" Invalid Lower Bound-empty expression". The same error comes when I tried the library model Second Harmonic Generation. what should I do. I was trying with many rectangular, it was not working. Thanks Chandan

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.