Hi there, I’m trying to write a Bessel function in Grasshopper.
I already found this post, but unfortunately the link to the dll and this site are not available at the moment. Maybe somebody knows a way to do it?
moved to Grasshopper category
Same thing for me. Anyone who still has the VB script linked in the post above?
Hoping for you @laurent_delrieu
Thank you.
I’ve tried to find info on how to make mppath available to Grasshopper. How is it done?
I’ve downloaded the release from their website, but don’t know what to do with the files https://mpmath.org/
Much appreciate your assistance.
Download the library from this link
and extract to:
C:\Program Files\Rhino 7\Plug-ins\IronPython\Lib
Thanks a lot.
I suppose there is no way to make these sources available to grasshopper from a folder that isn’t within administrator rights? We’re a bigger office and I can’t just copy things to system folders sadly.
Check the first method to let Rhino use some Python27 modules, than you can install mpmath directly to Python27 and use it
So our system admin was kind enough to copy the mpmath
folder into C:\Program Files\Rhino 7\Plug-ins\IronPython\Lib
for me.
But after restarting Rhino and GH:
I worry Python itself must also be installed…? Python Releases for Windows | Python.org
I found solution how to install here
It works for me)
Check the folders in Python options
I’ve added that search path, thanks to the explanation posted by @alenustins.
It still won’t work
Grasshopper cannot find the module.
@alenustins is it mandatory that mppath
be saved under site-packages\
?
Hello
I don’t know your level in mathematics, but making an integral is not so difficult. It is 5 lines of code.
Here an approximation using Wikipedia equation and Euler integration
private void RunScript(double x, int n, ref object A)
{
//https://en.wikipedia.org/wiki/Bessel_function
//Laurent Delrieu
//14/07/2022
double j = 0;
double dteta = 0.001;
for (double teta = 0; teta <= Math.PI; teta += dteta)
{
j += Math.Cos(n * teta - x * Math.Sin(teta));
}
j = dteta * j / Math.PI;
A = j;
Component.Message = "Bessel Function";
}
Bessel Function LEGACY.gh (9.7 KB)
Error is 0.001 with dteta = 0.001
2 10e-6 with dteta = 0.0001 (n=0 and 2)
30 10e-6 with dteta = 0.0001 and n=1
Well my level of mathematics is certainly not yours
This is amazing, thank you !!
Note that it works only for integer and it is not optimized so it is far less fast that using a dedicated library.
Here the old library
Meta.Numerics.dll.zip (109.4 KB)