# Finite element method, question about the solver

So I am working with COMSOL Multiphysics and I have a very complex simulation. I have a boundary condition that evaluates to 1 if the value of a variable is 20 and 0 otherwise. I could implement my code just fine in COMSOL. However, I am facing a problem (see a draft that I made below please). Basically, for the first iterations whenever the variable reaches 20 it turns the boundary condition to 0, but as I have more iterations the limit slightly increases (thus reaching values above 20). After some time the limit comes back to 20 and the same problem as before occurs again. Any thoughts? I have already tried to increase the solver tolerance but the some problem occurs Thanks in advance

• I can't see any draft Feb 11, 2020 at 17:04

In a nonlinear problem where you change some parameter, there is no guarantee that solutions for all values of the parameter will be stable. It is quite likely that for "small" values of the applied "load" (whatever that might be - not necessarily a physical force) there are stable solutions with your variable $$x < 20$$ and the boundary condition = 0, and for "large" loads there are stable solutions with $$x > 20$$ and the boundary condition = 1, but there is an intermediate range of loads with no stable solutions.

To figure out what is going on, I suggest you make three simulations with different conditions:

• fix the "0 or 1" boundary condition to 0 for all values of $$x$$.
• fix it to 1 for all values of $$x$$.
• Change the boundary conditions in the model so that you fix $$x = 20$$ and let the "0 or 1" quantity vary.

You will probably find there are some situations where there are stable solutions with $$x = 20$$ but your "0 or 1" variable has values between 0 and 1. Most likely, there are no stable solutions of your original model in that region. For example you may find there is a stable solution with $$x > 20$$ and the boundary value = 0, and another stable solution with $$x < 20$$ and the boundary value = 1.

Since we don't know anything about your model, it's impossible to say whether the fix is to change the model to get rid of the instabilities, or use a more sophisticated "path following" solution method (for example the Riks algorithm, or the "arc length" method - two names for pretty much the same thing) which can find the unstable solutions without failing numerically.

Instead of having a hard 0/1 binary boundary condition try having a smoth and continuous one, try using the tanh() function for instance