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.

Stop condition function of solver configurations

Please login with a confirmed email address before reporting spam

Can anyone tell me what stop condition is (in Solver configurations> Solution 1> Time-Dependent solver 1> Stop condition)? and why it is not precise! I checked the Single Particle Model of a Lithium-Ion Battery from application gallery. There is a stop condition defined as: comp1.soc_neg-1e-3. So it is supposed to stop at state of charge (soc) equal to 1e-3, but it does not happen.


8 Replies Last Post 27.04.2015, 11:46 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 23.04.2015, 21:47 GMT-4
The stop condition is a check which if the value is negative stops the simulation immediately. It isn't an iterative solver which solves for the condition within an error tolerance of zero. For that it would need to step backward and forward in time to zero in on the target. That's different. This is more a case of "I don't care about the result any more so don't waste the effort".

Consider a circuit application where I want to simulate a transition until the output reached a critical threshold to constitute a change in logic state. Then I can run until the value crosses that threshold and then I interpolate the time it would equal the threshold. It would be nice if the code could directly determine that time, but in many cases interpolation, for example 2nd order, is virtually as good.
The stop condition is a check which if the value is negative stops the simulation immediately. It isn't an iterative solver which solves for the condition within an error tolerance of zero. For that it would need to step backward and forward in time to zero in on the target. That's different. This is more a case of "I don't care about the result any more so don't waste the effort". Consider a circuit application where I want to simulate a transition until the output reached a critical threshold to constitute a change in logic state. Then I can run until the value crosses that threshold and then I interpolate the time it would equal the threshold. It would be nice if the code could directly determine that time, but in many cases interpolation, for example 2nd order, is virtually as good.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 24.04.2015, 09:30 GMT-4
Thanks a lot Daniel,

I was wondering if there is a way to stop calculation immediately. For example consider a cyclic condition where the exact value of a parameter at the end of a cycle is critical for the next cycle. Do you have any suggestion to implement this situation?
Thanks a lot Daniel, I was wondering if there is a way to stop calculation immediately. For example consider a cyclic condition where the exact value of a parameter at the end of a cycle is critical for the next cycle. Do you have any suggestion to implement this situation?

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 24.04.2015, 10:13 GMT-4
BTW, I want to make clear I'm not a Comsol expert (I'm trying to learn). So don't view my comments as definitive.

I'm not certain this is what you're after, but there are methods to solve periodic nonlinear systems. A classic example is a CMOS ring oscillator: if the ring is long it will oscillate with a long-period square wave, not sinusoidally, due to the truncation imposed by the ground supply.

In real life you break the ring, excite the system with an input, then close the ring, and after a sufficiently large number of laps the signal will converge on a steady state. But to simulate this is impractical. So there's other techniques which are used. However, I don't think Comsol supports this sort of analysis, from what I've seen.

It's not enough, however, to wait for the output to return to the input because every degree of freedom in the model must be periodic, not just an output parameter.

If you're just looking for when the output hits a certain threshold I recommend interpolation, preferably 2nd order.
BTW, I want to make clear I'm not a Comsol expert (I'm trying to learn). So don't view my comments as definitive. I'm not certain this is what you're after, but there are methods to solve periodic nonlinear systems. A classic example is a CMOS ring oscillator: if the ring is long it will oscillate with a long-period square wave, not sinusoidally, due to the truncation imposed by the ground supply. In real life you break the ring, excite the system with an input, then close the ring, and after a sufficiently large number of laps the signal will converge on a steady state. But to simulate this is impractical. So there's other techniques which are used. However, I don't think Comsol supports this sort of analysis, from what I've seen. It's not enough, however, to wait for the output to return to the input because every degree of freedom in the model must be periodic, not just an output parameter. If you're just looking for when the output hits a certain threshold I recommend interpolation, preferably 2nd order.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 24.04.2015, 11:31 GMT-4
That was a good help, Thanks again Daniel.
That was a good help, Thanks again Daniel.

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27.04.2015, 05:11 GMT-4
Hi,

Stop conditions cannot be more accurate than the local time stepping. It stops at the first time when the condition becomes false . For a more accurate stop condition in time-dependent models, you can use events (in the Events interface). In the attached model (solved using COMSOL 5.1), I have added an Implicit Event for the stop condition comp1.soc_neg-1e-3<0 and used the Event tolerance setting (in the Time Stepping section in the Time-Dependent Solver node's Settings window) to provide an accurate stop. I have also added the solutions at the steps just before and after the event to the solution. I have attached a screenshot of the new settings for the stop condition.

Best regards,
Magnus Ringh, COMSOL

Hi, Stop conditions cannot be more accurate than the local time stepping. It stops at the first time when the condition becomes false . For a more accurate stop condition in time-dependent models, you can use events (in the Events interface). In the attached model (solved using COMSOL 5.1), I have added an Implicit Event for the stop condition comp1.soc_neg-1e-3


Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27.04.2015, 10:07 GMT-4
Thanks a lot Magnus!

That is right! Actually, I was thinking about using events instead of stop condition, however, I did not know how. Could you please tell me in adding solution what the steps before and after stop is for?

Regards,
Barzin
Thanks a lot Magnus! That is right! Actually, I was thinking about using events instead of stop condition, however, I did not know how. Could you please tell me in adding solution what the steps before and after stop is for? Regards, Barzin

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27.04.2015, 10:51 GMT-4
Hi Barzin,

Normally the solutions stored from the time-dependent solver are the solutions specified in the Times to store list for the time-dependent solver. The option to store the solutions before and after the stop condition has been fulfilled makes sure that the solutions available for postprocessing include the solutions for the times as close to the time when the stop condition is fulfilled as possible. You can then choose to store only some solutions and not all the solver steps up to, and after, this point in the time-stepping process.

Best regards,
Magnus Ringh, COMSOL


Hi Barzin, Normally the solutions stored from the time-dependent solver are the solutions specified in the Times to store list for the time-dependent solver. The option to store the solutions before and after the stop condition has been fulfilled makes sure that the solutions available for postprocessing include the solutions for the times as close to the time when the stop condition is fulfilled as possible. You can then choose to store only some solutions and not all the solver steps up to, and after, this point in the time-stepping process. Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 27.04.2015, 11:46 GMT-4
Hi Magnus,

Many thanks for the prompt reply! It was a good explanation.

Best regards,
Barzin
Hi Magnus, Many thanks for the prompt reply! It was a good explanation. Best regards, Barzin

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.