Bessel functions as CoefficientFunctions

Hi,

I want to use the bessel function from a python library (for example scipy.special) as a CoefficientFunctions.

my code:
from ngsolve import *
from scipy.special import jn #import bessel J function
uexact = jn(1,x)

I get the following error:
uexact = jn(1,x)
TypeError: ufunc ‘jv’ not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ‘‘safe’’

Is there a way to use these functions from a python library as CoefficentFunction?

Thank you,

Renzo

Hi, no you cannot use scipy functions as coefficients, but we have the ngs-special-functions addon that provides these functions:

Best
Christopher

Hi Christopher,
Thank you for your answer!
I followed the instruction to install the package on Linux and I tried to run the demo bessel.py but I get an import error:

ImportError: /home/c/rzanol/.local/lib/python3.8/site-packages/ngsolve/special_functions.so: undefined symbol: _ZNK5ngfem19CoefficientFunction14GetDescriptionB5cxx11Ev

Do you have any idea what could be the problem?

Hi, i tried to install ngs-special-functions as decribed on GitHub repository.
However i do not have “make” command, probably due to missing VC toolchain on my Win11 pc.
What toolchain would you recomend installing for best compatibility on Win11?
Sorry for the beginner question.

follow the build/install instruction from

could you run cmake ?

Thank you for Your quick replay joachim.

  • I followed the GitHub instruction.
  • the cmake … worked wihout error message
  • it created some *.vcxproj, *.filters and ngsolve_special_functions.sln
  • but on my system i do not have make

i think i have to do some compatible tool chain instalation.
i have

  • win11
  • conda
  • installed ngsolve via: pip install --pre --upgrade ngsolve
  • where cl returns: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\Hostx64\x64\cl.