Git Product home page Git Product logo

Comments (16)

mikaem avatar mikaem commented on July 23, 2024

Hi Thilo,
Thanks for reporting this bug. I did some checking and found a rather deep error that had to do with the inhomogeneous boundary conditions and the non-standard domain sizes you are using. I will push a fix as soon as possible. If you're using the shenfun source code, then you can fix it by replacing this line with scb=sc.

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

I just realised that fixing the bug did not actually fix your code. It just fixed all other problems that used inhomogeneous boundary conditions and non-standard domain. Which may have been a recently introduced bug if you did managed to solve your problem for one of the cases above. I guess I will have to look some more.

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

I don't think your variational forms are identical, so I don't understand how you can expect both methods to work?

from shenfun.

thoeschler avatar thoeschler commented on July 23, 2024

For the pure Dirichlet problem both variational forms should be valid because in both cases the boundary integral vanishes as the test function vanishes on the entire boundary.

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

But I should be able to derive one from the other, and I can't.

from shenfun.

thoeschler avatar thoeschler commented on July 23, 2024

By use of the divergence theorem I was able to derive one form from the other.

from shenfun.

thoeschler avatar thoeschler commented on July 23, 2024

Hi Mikael,
in the following image I derived the equivalence of the two weak forms. Maybe you could take a look at it. The notation is a little different, I hope that is not a problem.
grafik

from shenfun.

thoeschler avatar thoeschler commented on July 23, 2024

Hi Mikael,
do you think that the two forms are equivalent? If you find some time to look into it, please let me know.

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

Hi Thilo,
Sorry, forgot about it. There are some issues with your note that I don't believe are correct and I don't really have time to look closely into it. Do you by any chance have a supervisor or someone to discuss these derivations with? For one, $\boldsymbol{u} \cdot \nabla$ is not the same as $\nabla \cdot \boldsymbol{u}$.

from shenfun.

thoeschler avatar thoeschler commented on July 23, 2024

Hi Mikael,
I discussed the equivalence of the two variational forms with my supervisor and we both agreed that the two forms seem to be equivalent. I have changed the derivation in my comment above to index notation so it is now a bit more readable. If you find some time, I would be grateful if you could take a look at it.

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

Hi Thilo,
I'm sorry for having been reluctant to look into this. It's very difficult and timeconsuming to find bugs when the reproducing code is 200 lines, and when it's not even obvious that it is a shenfun issue. However, I did have a look and quickly isolated the problem to the div div terms like inner(lambd*div(u), div(v)). There was an error in the precomputed matrices, and if you comment out line 1336

#((SD, 1), (SD, 0)): functools.partial(CSDSDmat, scale=-1.),

then it should work for the latest version of shenfun.
Actually, I realised this has deeper roots and will have to be fixed in inner. So great that you found and reported the error:-)

from shenfun.

thoeschler avatar thoeschler commented on July 23, 2024

Hi Mikael,

first of all thanks for taking the time to review this.

I tried commenting out the line

((SD, 1), (SD, 0)): functools.partial(CSDSDmat, scale=-1.),

that you were referring to. However, with the latest version of shenfun I wasn't able to run the test code from my initial comment at all. As far as I can tell the error that I get when running the test code has to do with the inhomogeneous boundary conditions that I am using:

 File "/home/student01/Dokumente/Projects/convergence_problem.py", line 61, in <module>
    vector_tensor_spaces.append(TensorProductSpace(comm, tuple(tensor_spaces)))

  File "/home/student01/Dokumente/Projects/shenfun/shenfun/tensorproductspace.py", line 322, in __init__
    base.bc.set_tensor_bcs(base, self)

  File "/home/student01/Dokumente/Projects/shenfun/shenfun/tensorproductspace.py", line 1602, in set_tensor_bcs
    b_hat = T.forward(b).copy()

  File "/home/student01/anaconda3/lib/python3.7/site-packages/mpi4py_fft/mpifft.py", line 73, in __call__
    self._xfftn[-1](**kw)

  File "/home/student01/Dokumente/Projects/shenfun/shenfun/spectralbase.py", line 1389, in __call__
    return self.func(input_array, output_array, **kw)

  File "/home/student01/Dokumente/Projects/shenfun/shenfun/spectralbase.py", line 1389, in __call__
    return self.func(input_array, output_array, **kw)

  File "/home/student01/Dokumente/Projects/shenfun/shenfun/spectralbase.py", line 262, in forward
    self.bc.add_mass_rhs(self.forward.output_array)

  File "/home/student01/Dokumente/Projects/shenfun/shenfun/tensorproductspace.py", line 1678, in add_mass_rhs
    self.set_boundary_dofs(u)

  File "/home/student01/Dokumente/Projects/shenfun/shenfun/tensorproductspace.py", line 1718, in set_boundary_dofs
    u[self.base.si[-(M)+i]] = self.bcs[i]

  File "/home/student01/anaconda3/lib/python3.7/site-packages/sympy/core/expr.py", line 358, in __float__
    raise TypeError("can't convert expression to float")

TypeError: can't convert expression to float

If you find some time, please let me know if you can successfully run the script with the latest version of shenfun.

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

Well, this looks more like a regular bug:-) I'll check it out.

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

With my version of shenfun it runs with:

error (analytical solution): 2.5716607593388476e-16

from shenfun.

mikaem avatar mikaem commented on July 23, 2024

Are you using the latest version of shenfun from github? I may have fixed the problem you see quite recently.

from shenfun.

thoeschler avatar thoeschler commented on July 23, 2024

I just cloned the latest version and now it works :) Thanks again!

from shenfun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.