spectralDNS / shenfun

High performance computational platform in Python for the spectral Galerkin method
http://shenfun.readthedocs.org
BSD 2-Clause "Simplified" License
198 stars 42 forks source link

1. Solver for multidimensional problem 2. Product with variable coefficients #93

Open ShengChenBNU opened 2 years ago

ShengChenBNU commented 2 years ago
  1. The one dimensional problem is easy to solve the matrix system Au=f by A.solve(f), however, the high dimensional problems quite different. Does it exist an easy method to solve the high dimensional problem? Do you have a tutorial?

  2. Do we have an operator to compute the inner product (cu,v) with variable coefficient c(x)?

mikaem commented 2 years ago
  1. The one dimensional problem is easy to solve the matrix system Au=f by A.solve(f), however, the high dimensional problems quite different. Does it exist an easy method to solve the high dimensional problem? Do you have a tutorial?

There are numerous demo programs for high-dimensional problems. Just survey the demo folder. If you mean problems with non-periodic boundary conditions in more than one direction, then look at poisson2ND.py.

  1. Do we have an operator to compute the inner product (cu,v) with variable coefficient c(x)?

Variable coefficients are straight-forward. See, for example, OrrSommerfeld_eigs.py.

ShengChenBNU commented 2 years ago

Great! I've successfully written the code for 2d Helmholtz equation -\Delta u + lam(x,y) u =f(x,y) by following your suggestions. Thanks a lot!
However, a new issue arises in numerical implementing when substituting the variable coefficient lam(x,y), e.g. lam(x,y)=sy.exp(x+y) in the equation. In my view, this problem may be caused by the inner product inner(v, lamu) due to Gaussian quadrature now is not accurate for vlam*u. Do you have any efficient technique to solve it? With my best regards!

mikaem commented 2 years ago

You can do the inner products with adaptive quadrature, or exact integration.

inner(v, lam*u, assemble='adaptive')
inner(v, lam*u, assemble='exact')

Exact may take too long time, depends on whether sympy can easily do the integration or not.

ShengChenBNU commented 2 years ago

Thank you so much. You're absolutely right! It takes too long time.

mzqr commented 1 month ago

For the second question, if it's not possible to find a symbolic variable to represent the coefficient, in other words, if c(x) can only be represented by some discrete points, is there still a solution

  1. Do we have an operator to compute the inner product (cu,v) with variable coefficient c(x)?