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 potential

Please login with a confirmed email address before reporting spam

Hai, I am fairly new to COMSOL. I have been trying to add a time dependent potential to my model. That is, I need the potential to be, say, 10V from 0 second to 5 second and then become 20V from 5s to 10s. Then solve it in time dependent solver for the total time. How to add such a time dependent potential in COMSOL? Any help on this matter is appreciated, thanks.


10 Replies Last Post 06.07.2020, 12:10 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 03.07.2020, 05:54 GMT-4

Hi Harris,

I assume that by time-dependent potential you mean that you are applying a voltage as a boundary condition of your model, and that you have a working model to simulate the stationnary conditions.

In that case, in the field where you normally set the applied voltage, simply write whatever time-dependent expression, using the built-in variable t. This variable can only be accessed in time dependent studies.

You can also define a variable Va_t to write this expression, and type Va_t in the field for the applied voltage. Because the variable t is defined at the component level, you can not do this using global parameters, you must use component-level variables.

Hi Harris, I assume that by time-dependent potential you mean that you are applying a voltage as a boundary condition of your model, and that you have a working model to simulate the stationnary conditions. In that case, in the field where you normally set the applied voltage, simply write whatever time-dependent expression, using the built-in variable *t*. This variable can only be accessed in time dependent studies. You can also define a variable *Va_t* to write this expression, and type *Va_t* in the field for the applied voltage. Because the variable *t* is defined at the component level, you can not do this using global parameters, you must use component-level variables.

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 03.07.2020, 07:43 GMT-4

Hai Alexis,

What I need to do is that solve the model in time dependent solver for total of 10 seconds. Further, for the initial 10s I want my potential to be 10V and after 10s the potential should change to another constant value (0, 5, 20,..). I don't want potential to change continuously with time, I want to apply potential in some form similar to that of a square wave.

Hai Alexis, What I need to do is that solve the model in time dependent solver for total of 10 seconds. Further, for the initial 10s I want my potential to be 10V and after 10s the potential should change to another constant value (0, 5, 20,..). I don't want potential to change continuously with time, I want to apply potential in some form similar to that of a square wave.

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 03.07.2020, 08:06 GMT-4

This can be done using Global Definitions > Functions > Rectangle.

Alternatively, you can look-up "Events" in the user-guide. This is oftentimes better-suited for abrupt transitions like yours.

This can be done using `Global Definitions` > `Functions` > `Rectangle`. Alternatively, you can look-up "Events" in the user-guide. This is oftentimes better-suited for abrupt transitions like yours.

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 04.07.2020, 02:54 GMT-4

But how can I add this rectangle function as my potential in the electrostatic node?

But how can I add this rectangle function as my potential in the electrostatic node?

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 04.07.2020, 10:42 GMT-4
Updated: 4 years ago 04.07.2020, 10:42 GMT-4

When you define the function, you will give it a name. Simply use that name in the expression of the applied potential.

When you define the function, you will give it a name. Simply use that name in the expression of the applied potential.

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 05.07.2020, 09:09 GMT-4

Thank you for your patience Alexis, I am able to change material property in form of function, but in other physics nodes I can't change the variables into a function, it says unknown variable. Same when I try to add a varible as a function in global. I think I am making some simple mistake some where.

Thank you for your patience Alexis, I am able to change material property in form of function, but in other physics nodes I can't change the variables into a function, it says unknown variable. Same when I try to add a varible as a function in global. I think I am making some simple mistake some where.

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 05.07.2020, 17:19 GMT-4

Hi Harris,

I am unsure about how to help you. How are you setting the voltage at the moment? Perhaps consider providing screenshot(s) or attaching your model.

Hi Harris, I am unsure about how to help you. How are you setting the voltage at the moment? Perhaps consider providing screenshot(s) or attaching your model.

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 06.07.2020, 08:14 GMT-4

I was able to do this with analytic funtion, but finding difficult to doit with rectangle. By the way using events work like a charm. I am attaching the screencshot of using the rectangle function as potential, probable some error somewhere.

I was able to do this with analytic funtion, but finding difficult to doit with rectangle. By the way using events work like a charm. I am attaching the screencshot of using the rectangle function as potential, probable some error somewhere.


Please login with a confirmed email address before reporting spam

Posted: 4 years ago 06.07.2020, 09:39 GMT-4

rect1 is just the function name. You must call it with some argument.

For example use V0*rect1(sin(2*pi*f*t)) to obtain a periodic rectangular function with frequency f and magnitude V0. V0 and f can then be parameters that you define (in volts and Hz, respectively), whereas t is a built-in variable representing time.

But I think in your case, the function waveform is more appropriate, because you can directly select Type: Square and Angular frequency: f to get the same result.

Anyway, the point is that the function must be called func_name(argument) by something that is time dependent ;-)

`rect1` is just the function name. You must call it with some argument. For example use `V0*rect1(sin(2*pi*f*t))` to obtain a periodic rectangular function with frequency `f` and magnitude `V0`. `V0` and `f` can then be parameters that you define (in volts and Hz, respectively), whereas `t` is a built-in variable representing time. But I think in your case, the function `waveform` is more appropriate, because you can directly select `Type: Square` and `Angular frequency: f` to get the same result. Anyway, the point is that the function must be called `func_name(argument)` by something that is time dependent ;-)

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 06.07.2020, 12:10 GMT-4

Thanks Alexis, The problem is solved, I was only giving an argument as t, then my unit of potential won't be voltage. It was V*s, that were the problem. thank you very much for your help.

Thanks Alexis, The problem is solved, I was only giving an argument as t, then my unit of potential won't be voltage. It was V*s, that were the problem. thank you very much for your help.

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.