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.

How evaluate time when a variable assumes a given value

Please login with a confirmed email address before reporting spam

Hi,

It is known that the function "at" evaluates a function for a specific time value. Ex: at(1.5s, u). However, I'm looking for a way to get the instant of time (tx) when a variable (Var) (such as current density) takes an x value, during the simulation running.

I need to known this time "ti" to star another process during the simulation run.

More specifically, the problem is:
During the simulation, when J = const1 then time "ti" starts counting (from zero) for the expression rho = const2.* exp (ti / const3). Where Jc, const1 and const2 are constant. The simulation is NOT restarted. Only time variable (or watch) "ti" starts to be counted when the event J = const1 occurs.

Regards,

5 Replies Last Post May 10, 2016, 1:40 p.m. EDT
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 6, 2016, 8:43 a.m. EDT
Hello Gabriel,
The Event interface can be used for this purpose. See www.comsol.com/blogs/implementing-a-thermostat-with-the-events-interface/ for an introduction. You would use an Event to change from 0 to 1 the right hand side of the equation dti/dt=State .
I am sure there are other ways too, but the above should work for you.
Hope this helps,
Jeff
Hello Gabriel, The Event interface can be used for this purpose. See https://www.comsol.com/blogs/implementing-a-thermostat-with-the-events-interface/ for an introduction. You would use an Event to change from 0 to 1 the right hand side of the equation dti/dt=State . I am sure there are other ways too, but the above should work for you. Hope this helps, Jeff

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 10, 2016, 11:39 a.m. EDT
Thanks, Jeff.

Interesting solution, but i stil have a question.

If I understand well, you suggest create a variable "ti" that is initially constant (since it has dti / dt = 0) and after the event grows with a rate of 1 (due to dti / dt = 1).

I created the event just right, however, I do not know how or where to implement the expression dti / dt.

Can you help me ?

Regards,
Thanks, Jeff. Interesting solution, but i stil have a question. If I understand well, you suggest create a variable "ti" that is initially constant (since it has dti / dt = 0) and after the event grows with a rate of 1 (due to dti / dt = 1). I created the event just right, however, I do not know how or where to implement the expression dti / dt. Can you help me ? Regards,

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 10, 2016, 12:01 p.m. EDT
That is indeed what I suggest.

You can implement the equation for dti / dt by using a global ODE interface: in the Physics ribbon, click the "Add Physics" button and in the window that pops up choose Mathematics, ODE and DAE Interfaces, Global ODEs and DAEs.
If you've never used Global Equations before, you may want to read the section on them in the Reference Manual: it starts on page 827 of the Reference Manual for COMSOL Multiphysics, version 5.2.
Best,
Jeff
That is indeed what I suggest. You can implement the equation for dti / dt by using a global ODE interface: in the Physics ribbon, click the "Add Physics" button and in the window that pops up choose Mathematics, ODE and DAE Interfaces, Global ODEs and DAEs. If you've never used Global Equations before, you may want to read the section on them in the Reference Manual: it starts on page 827 of the Reference Manual for COMSOL Multiphysics, version 5.2. Best, Jeff

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 10, 2016, 1:11 p.m. EDT
Tranks, Jeff.

I implemented what you suggested, and it seems to work well. However, the time instants at which the variable "state" changes from 0 to 1, another variable of my simulation (current density) had spikes (impulses or Dirac), probably in instants that occurs change of dti/dt (= 0 to 1).

Is there any way to avoid these spikes?

Regards,
Tranks, Jeff. I implemented what you suggested, and it seems to work well. However, the time instants at which the variable "state" changes from 0 to 1, another variable of my simulation (current density) had spikes (impulses or Dirac), probably in instants that occurs change of dti/dt (= 0 to 1). Is there any way to avoid these spikes? Regards,

Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago May 10, 2016, 1:40 p.m. EDT
Hi Gabriel,
I am afraid I do not know your system sufficiently to tell whether such a spike is physical or not. If you require further help with this, please contact COMSOL's Support Team (support@comsol.com) and include a description of what you are trying to model and the .mph file (Clear the solution before sending, if the file is too large).
Best,
Jeff
Hi Gabriel, I am afraid I do not know your system sufficiently to tell whether such a spike is physical or not. If you require further help with this, please contact COMSOL's Support Team (support@comsol.com) and include a description of what you are trying to model and the .mph file (Clear the solution before sending, if the file is too large). Best, Jeff

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.