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.

Simple rectangular signal?

Please login with a confirmed email address before reporting spam

Hello,

I'm trying to put a rectangular signal as electric potential using time dependent, i.e. (-1)^(t+1), and set t=(0,1,3). However, the system gave me an error of:

Nonlinear solver did not converge.
Time : 0
Attempt to evaluate non-integral power of negative number.
Function: ^
Failed to evaluate variable.
Variable: mod1.es.V0, Defined as: ((-1)^(1+t))
Failed to evaluate expression.
Expression: mod1.es.V0-mod1.V2
Last time step is not converged.

Don't understand why (-1)^(0+1) is not calculated...

Thanks


8 Replies Last Post Jan 16, 2012, 9:54 a.m. EST
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 Jan 11, 2012, 12:45 p.m. EST
Hi

it could be that "t" is being adapted automatically, and I sometimes suspect that it can go negative, via a backtrack when trying to find a starting solution, all depends on your solver settings.

Anyhow, I would rather suggest that if you want a "square pulse train" use a "Definition Function Waveform Square", (0.5+wv1(t[1/s]) (with a freq 2*pi*Dt, an amplitude of 0.5 and possibly a dephasing) or combine a "rect1(t[1/s])*mod(t[1/s],Dt)" with a period "Dt".

There is anyhow an important rule to follow with PDE solving:
ALWAYS provide "smooth" (continuous derivable (isnt that a French word, not sure you say so in English?)) function, so that the solver can follow the gradient/slope for next throw estimations. The pulse, step and other functions proposed by COMSOL have a Heaviside type transition region that helps the solver.
And for periodic BC's do not forget to turn off the Free (automatic) time stepping and use "Intermediate" or "strict" and define a few time steps dutring the on/off transitions

--
Good luck
Ivar
Hi it could be that "t" is being adapted automatically, and I sometimes suspect that it can go negative, via a backtrack when trying to find a starting solution, all depends on your solver settings. Anyhow, I would rather suggest that if you want a "square pulse train" use a "Definition Function Waveform Square", (0.5+wv1(t[1/s]) (with a freq 2*pi*Dt, an amplitude of 0.5 and possibly a dephasing) or combine a "rect1(t[1/s])*mod(t[1/s],Dt)" with a period "Dt". There is anyhow an important rule to follow with PDE solving: ALWAYS provide "smooth" (continuous derivable (isnt that a French word, not sure you say so in English?)) function, so that the solver can follow the gradient/slope for next throw estimations. The pulse, step and other functions proposed by COMSOL have a Heaviside type transition region that helps the solver. And for periodic BC's do not forget to turn off the Free (automatic) time stepping and use "Intermediate" or "strict" and define a few time steps dutring the on/off transitions -- Good luck Ivar

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 11, 2012, 12:53 p.m. EST
French => English

derivable => differentiable
French => English derivable => differentiable

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 Jan 11, 2012, 3:15 p.m. EST
Thanks Jean-François

I end up mixing two many languages, but différentiable is also French, no ;)
Ah, ces faux amis ...

--
Good luck
Ivar
Thanks Jean-François I end up mixing two many languages, but différentiable is also French, no ;) Ah, ces faux amis ... -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 12, 2012, 3:42 p.m. EST
Thanks a lot Ivar! problem solved~
Thanks a lot Ivar! problem solved~

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 12, 2012, 4:37 p.m. EST
Hi Ivar,

Sorry another question comes up...

I defined a waveform function as you mentioned under definitions. However, is there any way I can apply it as a boundary condition? i.e. a electric potential under electrostatics? I tried to simply type 'wv' in but it is not recognized...

Thank you
Hi Ivar, Sorry another question comes up... I defined a waveform function as you mentioned under definitions. However, is there any way I can apply it as a boundary condition? i.e. a electric potential under electrostatics? I tried to simply type 'wv' in but it is not recognized... Thank you

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 Jan 13, 2012, 2:22 a.m. EST
Hi

I agree there a a few things I found also confusing, in the beginning, with COMSOL's math notations ;)

If you take V the scalar voltage you write V in all your equations, but in fact its a "field" and one should write it out , formally, as V(x,y,z,t) depending on the spatial and, if required, time variables. But COMSOL allows us to simplify the notation to only "V"

But this does not apply to other functions or operators (necesarily) sou if you define an analytical function vw1() you need to call it with the correct number of argument(s) (exception interpolation operators that you have defined with the option use spatial variables, that behave as the voltage "V" above.

You must then write wv1(t[1/s]). Then why the [1/s] it's because a function or operator expect (mostly as exception coming in the new definition in latest versions) unitless inputs and time "t" is defined by default in seconds. so writing t[1/s] gives a real number without units expressed in seconds. Just as t[1/h] gives a real number expressed in hours (or fraction thereof)

--
Good luck
Ivar
Hi I agree there a a few things I found also confusing, in the beginning, with COMSOL's math notations ;) If you take V the scalar voltage you write V in all your equations, but in fact its a "field" and one should write it out , formally, as V(x,y,z,t) depending on the spatial and, if required, time variables. But COMSOL allows us to simplify the notation to only "V" But this does not apply to other functions or operators (necesarily) sou if you define an analytical function vw1() you need to call it with the correct number of argument(s) (exception interpolation operators that you have defined with the option use spatial variables, that behave as the voltage "V" above. You must then write wv1(t[1/s]). Then why the [1/s] it's because a function or operator expect (mostly as exception coming in the new definition in latest versions) unitless inputs and time "t" is defined by default in seconds. so writing t[1/s] gives a real number without units expressed in seconds. Just as t[1/h] gives a real number expressed in hours (or fraction thereof) -- Good luck Ivar

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 Jan 13, 2012, 2:36 a.m. EST
Hi

try wv1(t[1/s]) with an argument made dimensionelss (see the other replies onthe other threads, try a search)

--
Good luck
Ivar
Hi try wv1(t[1/s]) with an argument made dimensionelss (see the other replies onthe other threads, try a search) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 16, 2012, 9:54 a.m. EST
Hi Ivar,

Thank you very much for your patient explanation. That makes a lot of sense and it is working now.

Really appreciate that!

Hi Ivar, Thank you very much for your patient explanation. That makes a lot of sense and it is working now. Really appreciate that!

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.