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.

potential step experiment using Heaviside functions

Please login with a confirmed email address before reporting spam

I am using 2D axial mode in Comsol 3.5a with Chemical Engineering Module- Diffusion. I want to do a potential step with time. Right now i am using Heaviside function flc1hs(x,scale). This gives out come of 0 when X>scale and 1 when x<scale but when x=0 this gives 0.5 as the out come. I need a function like If x>=scale, E=1 if not E=0. But i couldn't use if fuction comsol. If anyone have Suggestion that would be great.

Thanks
Chandima

7 Replies Last Post 20.05.2015, 08:15 GMT-4
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 02.08.2010, 15:44 GMT-4
Hi

the heaviside functions are symmetric, so you need to add (or substract) an offset corresponding to the rise time to start at "0". Use the plotting capability to check your functions

--
Good luck
Ivar
Hi the heaviside functions are symmetric, so you need to add (or substract) an offset corresponding to the rise time to start at "0". Use the plotting capability to check your functions -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 02.08.2010, 15:58 GMT-4
Hi Ivar
Thank you very much for your comment. I have 5 stepping times. When i use Heaviside fuctions for each of these stepping times. This is how i am writing the formula. E1-flc1hs((t-St)/time,0.0001)*(E1-E2) here E1 and E2 are potentialsand t is time St is stepping time. time is to normalized the left side. When i plot the fuction there is a value of 0.5(E1+E2) when the (t-St) =0. I need to get over this value. all the other time it is either E1 or E2.

Thank you

Chandima
Hi Ivar Thank you very much for your comment. I have 5 stepping times. When i use Heaviside fuctions for each of these stepping times. This is how i am writing the formula. E1-flc1hs((t-St)/time,0.0001)*(E1-E2) here E1 and E2 are potentialsand t is time St is stepping time. time is to normalized the left side. When i plot the fuction there is a value of 0.5(E1+E2) when the (t-St) =0. I need to get over this value. all the other time it is either E1 or E2. Thank you Chandima

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 03.08.2010, 03:30 GMT-4
Hi

I do not really catch your question, as for me that is very normal flc1hs(x,step) is a smooth transition of width 2*step stating at x=-step and ending at x=+step with a transition of 0 to 1.

so clearly while your value is E1 up to your (t-St)/time <= -0.0001 and is equal to E1-(E1-E2)=E2 while (t-St/time >=+0.0001, and is equal to the mean E1-(E1-E2)/2=(E1+E2)/2 for (t-St)/time=0 the mid point

You might be using a very short transition 0.0001 compared to your solver steps. If you leave COMSOL solving, it will adapt and most probably calculate a few points during this transition, but then would not save them if you have not selected to save intermediate step values

--
Good luck
Ivar
Hi I do not really catch your question, as for me that is very normal flc1hs(x,step) is a smooth transition of width 2*step stating at x=-step and ending at x=+step with a transition of 0 to 1. so clearly while your value is E1 up to your (t-St)/time =+0.0001, and is equal to the mean E1-(E1-E2)/2=(E1+E2)/2 for (t-St)/time=0 the mid point You might be using a very short transition 0.0001 compared to your solver steps. If you leave COMSOL solving, it will adapt and most probably calculate a few points during this transition, but then would not save them if you have not selected to save intermediate step values -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 03.08.2010, 18:20 GMT-4
Hi Ivar,

Thank you very much for your comment. Once i used realy small number for the Heaviside fuction (step) only few points are there. But i try to use operator if(t>1,expr1,expr2) (t is time) it didnt work. Thank you very much

Chandima
Hi Ivar, Thank you very much for your comment. Once i used realy small number for the Heaviside fuction (step) only few points are there. But i try to use operator if(t>1,expr1,expr2) (t is time) it didnt work. Thank you very much Chandima

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 04.08.2010, 01:46 GMT-4
Hi

Do not mix, the heaviside function is defined "independently" of the points of the solver. What often happens is that the solver has problems to "see" the short step functions, then you must help it on its way, by defining manual time steps that are "thight" around the transitions,
I mostly use the solver in automatic mode, and just define some 5-10 points on all my transitions, and few in-between

--
Good luck
Ivar
Hi Do not mix, the heaviside function is defined "independently" of the points of the solver. What often happens is that the solver has problems to "see" the short step functions, then you must help it on its way, by defining manual time steps that are "thight" around the transitions, I mostly use the solver in automatic mode, and just define some 5-10 points on all my transitions, and few in-between -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 04.08.2010, 09:49 GMT-4
Hi Ivar,
I am using Time dependent solver with time range(0,0.01,6) and make relative tolerance 0.001 and absolute tolerance 0.00010 with linear system solver Direact(UMFPACK). This one take more than hours to solve the problem even though degrees of freedom 379122. Need to think about faster way to solve the problem. Thank you

Chandima
Hi Ivar, I am using Time dependent solver with time range(0,0.01,6) and make relative tolerance 0.001 and absolute tolerance 0.00010 with linear system solver Direact(UMFPACK). This one take more than hours to solve the problem even though degrees of freedom 379122. Need to think about faster way to solve the problem. Thank you Chandima

Please login with a confirmed email address before reporting spam

Posted: 10 years ago 20.05.2015, 08:15 GMT-4
sir i am working on comsol 4.4 . i want to set up pressure as a heaviside function of time. how to set up heaviside function in comsol.
sir i am working on comsol 4.4 . i want to set up pressure as a heaviside function of time. how to set up heaviside function in comsol.

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.