# Electric potential in Comsol

• Ma94
In summary, the user is seeking assistance in implementing a time-dependent potential for an electrode surface with two different potentials for two different time domains. The potential is described by a triangular function and the user is using a time-dependent study with the physics of transport of diluted species. The user is also asking for clarification on how to implement piecewise equations using boolean operators and the modulo operator for periodic functions.

#### Ma94

Can anyone know please know how can i impose the electrode surface potential to vary lineary and periodically with time as:
E(t)= phimin+v*t for 0<=t<t0
phimax-v*(t-t0) for t0<=t<2*t0
with t0=(phimax-phimin)/v
v=scan rate in V/s

What exactly do you have a problem with? Is it the fact that you have different potentials to impose for different time domains? Or do you have problems imposing even a simple time-dependent potential?

It would also help if you indicated what type of study you are doing (what physics and study type you have selected in COMSOL).

Thanks for your reply .As you said first i need to implant 2 différent potenials in the surface of an electrode for 2 different time domains .In fact the reference article that I'm using is a little bit difficult ,they said that the potential is a triangle time dependent so i will use time dependent study , for the physics i will use transport of diluted species and another one that i did'nt figure it out.

Ma94 said:
Thanks for your reply .As you said first i need to implant 2 différent potenials in the surface of an electrode for 2 different time domains .
Sorry, but this didn't answer my question. Would you know how to do it with only one time-dependent equation?

I am just trying to gauge the level of the difficulty. Otherwise, my answer might be rather unhelpful.

In any case, to implement piecewise equations, you need to use boolean operators. For instance, to implement
$$\left\{ \begin{array}{cl} 1 & x < 0 \\ x^2 + 1 & x \ge 0 \end{array} \right.$$
you would write
Code:
1 * (x < 0) + (x^2+1) * (x >= 0)
Doing it for periodic functions can be implement using the modulo operator in the boolean expression.