## Square root in moving boundary

General discussions about how to formulate a script for FlexPDE.

### Square root in moving boundary

I am having a hard time setting up a problem with moving boundaries. I think the problem comes from the fact that the position of the moving boundary contains a square root.
So I modified the example file ‘1D_stretchx’ to demonstrate my issue.
The first file (1d_stretch_linear) shows the modified file where the position of the right boundary is expressed by lmove=L+alpha*t (L is the initial position of the boundary and alpha is a linear coefficient) which is a linear function. Everything runs very smoothly.
I then modified this file to get (1d_stretch_sqrt) where the position where the position of the right boundary is expressed by lmove=L+alpha*SQRT(t) which is not a linear function. I get a floating point error and I don’t get why.

I know there must be a pretty simple answer to my question but I have been looking around the forum and the help file over the past few days and I haven’t been able to fix my problem. So thanks in advance for your help.
Attachments
1d_stretch_sqrt.pde
1d_stretch_linear.pde
sidum_ulaval

Posts: 2
Joined: Tue Oct 21, 2014 11:20 am

### Re: Square root in moving boundary

OK, I have been working on my problem a bit more and the problem clearly lies on the squareroot.
Here are three versions of my complete problem of thaw consolidation.
The problem seems to be at the line where the position of the boundary is defined: lmove=L+alpha*t^0,5.
When the exponent is slightly below 0,5 (file:Thaw consolidation 0,49.pde) everything runs smoothly, same when the exponent is slightly above 0,5 (file:Thaw consolidation 0,51.pde). When it is exactly 0,5 it doesn't work (file:Thaw consolidation 0,5.pde).
I could set my exponent to a value like 0,5000000000000001 and it would work but there must be a more rigorous way to fix this.
Alright thank you in advance once again.
-Simon
Attachments
Thaw consolidation 0,51.pde
Thaw consolidation 0,50.pde
Thaw consolidation 0,49.pde
sidum_ulaval

Posts: 2
Joined: Tue Oct 21, 2014 11:20 am

### Re: Square root in moving boundary

I think the real source of the error is that you are taking a fractional power of 0 (at your start time). If you start your simulation time at 1e-10 instead of 0, you can use any fractional power and be safe. FlexPDE uses the C library implementation of power, which can get a range error when the base is 0. We will look into adding a diagnostic when this happens.
moderator

Posts: 862
Joined: Tue Jan 11, 2011 1:45 pm

### Re: Square root in moving boundary

Hello everybody!

I had the same problem in another script. The error is called "negative square root". Yes, it has something to do with the motion boundary. I use FlexPDE Pro v. 7.16. The movement of the sediment-liquid boundary is set as VELOCITY(h) = kd_ * Cp / cosphi, where kd_ is the deposition rate, Cp is the particle concentration, cosphi is the cos(the angle of the boundary h). In "Defenitions" section, there is "kd_ = 0.0002 * Temp^14". In other words, the deposition rate depends on the temperature in some way (particle adhesion to the heated surface). It should be noted that power function is also used here. In my opinion, this error occurs when the temperature is less than one, Temp < 1 (room temperature scaled value) or when its value is oscillated. I quickly solved this problem with using "kd_ = IF (Temp >= 1) THEN 0.0002 * Temp^14 ELSE 0". It is better to understand the reason of non-physical behavior of temperature, but this is already connected with another boundary condition and has no direct relation to the current issue. I think I'll do it soon.

It would be great if FlexPDE provides more details about this error to user in future, since it is not always possible to quickly detect it by yourself. I hope this example will be useful to some users if they get a similar error in another physical or mathematical problem.
Konstantin__Kolegov
ks87

Posts: 5
Joined: Sat Jul 14, 2018 7:51 pm

### Re: Square root in moving boundary

Can you send us an example script, so we can investigate it?
moderator

Posts: 862
Joined: Tue Jan 11, 2011 1:45 pm

### Re: Square root in moving boundary

The calculation lasts from several hours to several days. If you have time to investigate it, I will send the script to your email. I found a problem in setting the temperature boundary conditions. It remains to write down these conditions so that the program will perceive them properly. I need to take into account a variety of technical aspects, otherwise at first glance the correct conditions in the interpretation of the program will not be correct. For example, I have to remember that the direction of normal is to inside of area, and not in the direction of the axis, so I need to remember to change the sign, etc. The Linux (CentOS 7) version of FlexPDE 7.16 sometimes is closed suddenly during operation and I have to run the calculation again. I have noticed that it sometimes happens after pressing ctrl+F when I want to use the code text search.
Konstantin__Kolegov
ks87

Posts: 5
Joined: Sat Jul 14, 2018 7:51 pm

### Re: Square root in moving boundary

Send the script to support@pdesolutions.com.
We don't need to run it to completion to analyze what's happening.
moderator

Posts: 862
Joined: Tue Jan 11, 2011 1:45 pm