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.

Multiple concentration step function

Please login with a confirmed email address before reporting spam

Hi,

Have a great day.

I am a new user of comsol 3.5 version, currently, I am working with chronoamperometry and I am trying to simulate that one using comsol by multiple concentration step functions. My quit time is 5s, at this quit time, the c=1 and then, after 5s, it step to c=0 with pulse width of 10s and then back to c=1 which has a pulse width of 5s. Currently, I am trying to utilize Heaviside function (flchs(time, 0.00001)) however, it doesn't give me a multiple steps.
I wonder if there are people out there who had encountered or done things that is similar or related to this problem and who is willing to share an idea.

Thank you.


Erwin

19 Replies Last Post 11 avr. 2013, 01:26 UTC−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 2 avr. 2013, 14:59 UTC−4
Hi

you need to mix in a modulo function mod(,) to get repetition (in V4 it's far easier now). Define it in the function node so you canplot it to check the shapes (or use matlab)

--
Good luck
Ivar
Hi you need to mix in a modulo function mod(,) to get repetition (in V4 it's far easier now). Define it in the function node so you canplot it to check the shapes (or use matlab) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2 avr. 2013, 15:52 UTC−4
Hi Ivar:

Thank you for the response. As of now, I don't have the V4, so, is mixing with modulo function when using V3.5a is the only possible way of getting repetition?
Thank you



Erwin
Hi Ivar: Thank you for the response. As of now, I don't have the V4, so, is mixing with modulo function when using V3.5a is the only possible way of getting repetition? Thank you Erwin

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 2 avr. 2013, 17:10 UTC−4
Hi

At least its the first one I would try, I believe this has been discussed earlier too on the Forum

--
Good luck
Ivar
Hi At least its the first one I would try, I believe this has been discussed earlier too on the Forum -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2 avr. 2013, 17:33 UTC−4
Thank you Ivar.

I tried it already but, it doesn't work, it gives me a constant output current. Because the problem is all about stepping the concentration and the current is a function of concentration.
This is what I did,
heaviside: C1i+flc1hs(-5+t, 0.1)*(Ct-C1i), the 5 is the quit time where the conc=1=C1i and I want this function to drive it to zero conc, and back and forth width pulse width of 10s.

I am not sure with this modulo function because it is my first time to use this, C1i-flc1hs((-10+(mod(t,0.01))/time,0.1)*(Ct-C1i), the 10 here is the width of the pulse that is repeated. time=time normalizer

I used other equation that relate this to have the current as the output.
I am wondering if I am in the right track. Thank you for the comments and help.


Erwin
Thank you Ivar. I tried it already but, it doesn't work, it gives me a constant output current. Because the problem is all about stepping the concentration and the current is a function of concentration. This is what I did, heaviside: C1i+flc1hs(-5+t, 0.1)*(Ct-C1i), the 5 is the quit time where the conc=1=C1i and I want this function to drive it to zero conc, and back and forth width pulse width of 10s. I am not sure with this modulo function because it is my first time to use this, C1i-flc1hs((-10+(mod(t,0.01))/time,0.1)*(Ct-C1i), the 10 here is the width of the pulse that is repeated. time=time normalizer I used other equation that relate this to have the current as the output. I am wondering if I am in the right track. Thank you for the comments and help. Erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2 avr. 2013, 17:42 UTC−4
Dear Ivar;

PS: I am using 2D axial symmetry for my model.
I am wondering if this will matter.


Thank you and have a wonderful day.


Erwin
Dear Ivar; PS: I am using 2D axial symmetry for my model. I am wondering if this will matter. Thank you and have a wonderful day. Erwin

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 3 avr. 2013, 01:37 UTC−4
Hi

2D-axi is a good way (if you model AND all loads are 2D axisymmetric) as it uses far less RAM and solves quickly allowing you to change rapidly BC and adapt the model interactively, until you are happy, then run a model with a fine mesh for final results

I always start 2D or 2D axi when possible, then in last resort I make a 3D model

Note in 2D axi displacement are either radial or transverse along the axis Z (and radial means in a projection radial for any angular direction phi)

For the function, you really should write it out in the function tab and plot it, as it's easy to miss something

--
Good luck
Ivar
Hi 2D-axi is a good way (if you model AND all loads are 2D axisymmetric) as it uses far less RAM and solves quickly allowing you to change rapidly BC and adapt the model interactively, until you are happy, then run a model with a fine mesh for final results I always start 2D or 2D axi when possible, then in last resort I make a 3D model Note in 2D axi displacement are either radial or transverse along the axis Z (and radial means in a projection radial for any angular direction phi) For the function, you really should write it out in the function tab and plot it, as it's easy to miss something -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 3 avr. 2013, 08:53 UTC−4
If I understand you correctly you want to turn the concentration between C1 and C2 on and off every T s. The easiest way I find is to use the boolean

C1+(C2+C1)*(sin(pi*t/T)>=0)

which flicks between 1 and 0 depending on whether sin is +ve or -ve.

The main problem is you can't really smooth it which may lead to convergence problems.
If I understand you correctly you want to turn the concentration between C1 and C2 on and off every T s. The easiest way I find is to use the boolean C1+(C2+C1)*(sin(pi*t/T)>=0) which flicks between 1 and 0 depending on whether sin is +ve or -ve. The main problem is you can't really smooth it which may lead to convergence problems.

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 3 avr. 2013, 11:10 UTC−4
Hi

you could combine it with a smoothened step or rect operator in v4

--
Good luck
Ivar
Hi you could combine it with a smoothened step or rect operator in v4 -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 3 avr. 2013, 12:56 UTC−4
Thank you steve

I will try to use boolean.. Hope this will work..

have a great day

erwin
Thank you steve I will try to use boolean.. Hope this will work.. have a great day erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 3 avr. 2013, 12:59 UTC−4
Hi Ivar,

Thank you.

My problem is we don't have the v4 so I need to use mathematics to utilize v3.5a with this problem.. One thing that I need to consider is the relationship of the function that i am going to define using heaviside and modulo in relation to fick's second law of diffusion which is my basis of computing current.


Sincerely,

Erwin
Hi Ivar, Thank you. My problem is we don't have the v4 so I need to use mathematics to utilize v3.5a with this problem.. One thing that I need to consider is the relationship of the function that i am going to define using heaviside and modulo in relation to fick's second law of diffusion which is my basis of computing current. Sincerely, Erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 5 avr. 2013, 12:40 UTC−4
To All,

I tried to set up the heaviside mixed with modulo functions but it doesn't work. I am trying to use this for periodic concentration step from c=1 to c=0 back and forth for around 10 times. In every concentration, there is a 10 seconds before it steps down or up to the next concentration. Right now, I am using v3.5a.
My another problem with comsol is that t doesn't recognize the concentration units.
Is anyone there has an idea and encounter related problems with this? also, how to set up of heaviside mixed with modulo functions?
Hope to hear from anyone.

Thank you.

Erwin
To All, I tried to set up the heaviside mixed with modulo functions but it doesn't work. I am trying to use this for periodic concentration step from c=1 to c=0 back and forth for around 10 times. In every concentration, there is a 10 seconds before it steps down or up to the next concentration. Right now, I am using v3.5a. My another problem with comsol is that t doesn't recognize the concentration units. Is anyone there has an idea and encounter related problems with this? also, how to set up of heaviside mixed with modulo functions? Hope to hear from anyone. Thank you. Erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 5 avr. 2013, 13:49 UTC−4
Hi Ivar;


I tried to set up Heaviside mixed with modulo functions but it doesn't work. Do you have any idea on how to set up the mixed heaviside and modulo function?Thank you.



Erwin
Hi Ivar; I tried to set up Heaviside mixed with modulo functions but it doesn't work. Do you have any idea on how to set up the mixed heaviside and modulo function?Thank you. Erwin

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 5 avr. 2013, 15:21 UTC−4
Hi

well for the units, the functions require unitless arguments so you must "turn these off by [1/m] or [1/s] or whatever applies and then remultiply your function by 1[whatever units].

There shold be some old threads about 2-3 years ago now, that discussed this with examples (back in 3.5 and early 4. times ... modulo and Heavyside should realy work together I used to enter them into an analytical function to be able to plot them, I believe to remember thsi worked also so in v3.5 ;)

or debug the calls in Matlab, or Octave / Scilab or even Phyton, then prot them into COMSOl with a cut&paste (+ any naing correction)

--
Good luck
Ivar
Hi well for the units, the functions require unitless arguments so you must "turn these off by [1/m] or [1/s] or whatever applies and then remultiply your function by 1[whatever units]. There shold be some old threads about 2-3 years ago now, that discussed this with examples (back in 3.5 and early 4. times ... modulo and Heavyside should realy work together I used to enter them into an analytical function to be able to plot them, I believe to remember thsi worked also so in v3.5 ;) or debug the calls in Matlab, or Octave / Scilab or even Phyton, then prot them into COMSOl with a cut&paste (+ any naing correction) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 5 avr. 2013, 16:52 UTC−4
Hi Ivar:

Thank you for the prompt reply.

I have my heaviside mixed with modulo functions:

Cb-(flc1hs(10-mod(t, 0.1), 1)*(Cb+Ct)

Heaviside only:

Cb-flc1hs(10-t,0.1)*(Cb+Ct)

Cb-initial concentration which is 1
Ct-step concentration which I defined as:

Ct=Cb-sr*(t-10), where sr is the step rate=0.01

I just don't understand why I end up with sawtooth plot and the color of the concentration profile is blue which is instead to be red and only the boundary defined here is the one that is affected. Hope that you can give me your insights as to where on this functions I have mistaken that cause problems. My time for each pulse is 10 seconds.

Hope to hear from you.

Thank you Ivar.


Erwin
Hi Ivar: Thank you for the prompt reply. I have my heaviside mixed with modulo functions: Cb-(flc1hs(10-mod(t, 0.1), 1)*(Cb+Ct) Heaviside only: Cb-flc1hs(10-t,0.1)*(Cb+Ct) Cb-initial concentration which is 1 Ct-step concentration which I defined as: Ct=Cb-sr*(t-10), where sr is the step rate=0.01 I just don't understand why I end up with sawtooth plot and the color of the concentration profile is blue which is instead to be red and only the boundary defined here is the one that is affected. Hope that you can give me your insights as to where on this functions I have mistaken that cause problems. My time for each pulse is 10 seconds. Hope to hear from you. Thank you Ivar. Erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 7 avr. 2013, 22:17 UTC−4

If I understand you correctly you want to turn the concentration between C1 and C2 on and off every T s. The easiest way I find is to use the boolean

C1+(C2+C1)*(sin(pi*t/T)>=0)

which flicks between 1 and 0 depending on whether sin is +ve or -ve.

The main problem is you can't really smooth it which may lead to convergence problems.


Hi,
I am dealing with a similar issue. I have an "Inflow" BC where C= 0.001 mol/m^3 for t:[0,1] and C = 0 mol/m^3 for t: [1,2] and this repeats over the time interval. But I have never been able to go beyond the first pulse. I have used finer meshes, intermediate time stepping and tried out different heaviside functions, but no luck. Has anybody encountered similar issues ? Is pulsing BC too difficult to handle ?

Many thanks,
Sanket
[QUOTE] If I understand you correctly you want to turn the concentration between C1 and C2 on and off every T s. The easiest way I find is to use the boolean C1+(C2+C1)*(sin(pi*t/T)>=0) which flicks between 1 and 0 depending on whether sin is +ve or -ve. The main problem is you can't really smooth it which may lead to convergence problems. [/QUOTE] Hi, I am dealing with a similar issue. I have an "Inflow" BC where C= 0.001 mol/m^3 for t:[0,1] and C = 0 mol/m^3 for t: [1,2] and this repeats over the time interval. But I have never been able to go beyond the first pulse. I have used finer meshes, intermediate time stepping and tried out different heaviside functions, but no luck. Has anybody encountered similar issues ? Is pulsing BC too difficult to handle ? Many thanks, Sanket

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 7 avr. 2013, 22:33 UTC−4
Hi Erwin,
At the end of the first pulse I get the following error-"Reached error test failures-May have reached singularity". At this stage the concn is very very low like 10^-187 mol/m^3.
I think our problems maybe related. I ll post the solution if I manage to solve the problem.

PS: I am using a 2D axisymmetric model in COMSOL 4.3.

Best Luck,
Sanket
Hi Erwin, At the end of the first pulse I get the following error-"Reached error test failures-May have reached singularity". At this stage the concn is very very low like 10^-187 mol/m^3. I think our problems maybe related. I ll post the solution if I manage to solve the problem. PS: I am using a 2D axisymmetric model in COMSOL 4.3. Best Luck, Sanket

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 8 avr. 2013, 19:17 UTC−4
Hi Sanket:

Have a great day. Thank you so much in advance. I am working with it also as of now.. I hope I can have it.


Erwin
Hi Sanket: Have a great day. Thank you so much in advance. I am working with it also as of now.. I hope I can have it. Erwin

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 10 avr. 2013, 18:05 UTC−4
Hi Ivar;

I am going back to one of most basic things in the comsol, I am supposed to increase the mesh in exponential grid to generate 2-d dimensional grid. I am calculating current, but the result did not agree with the expected one which is based on the equation on the book. I check my model several times and there is no mistake on this matter. Do you have any idea on how to do this one in v3.5a?

Thank you.


Erwin
Hi Ivar; I am going back to one of most basic things in the comsol, I am supposed to increase the mesh in exponential grid to generate 2-d dimensional grid. I am calculating current, but the result did not agree with the expected one which is based on the equation on the book. I check my model several times and there is no mistake on this matter. Do you have any idea on how to do this one in v3.5a? Thank you. Erwin

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 11 avr. 2013, 01:26 UTC−4
Hi

3.5 is old for me, but I believe you had a possibility with the dimension tab to set an equation (select a boundary or edge and apply a structured mesh with a given distribution equation for the mesh nodes, then mesh the full surface

--
Good luck
Ivar
Hi 3.5 is old for me, but I believe you had a possibility with the dimension tab to set an equation (select a boundary or edge and apply a structured mesh with a given distribution equation for the mesh nodes, then mesh the full surface -- Good luck Ivar

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.