parisolab / mathmod

Mathematical modelling software
https://www.facebook.com/parisolab/
Other
105 stars 19 forks source link

Thanks for your excellent work! #223

Open zhangfq-chemistry opened 1 year ago

parisolab commented 1 year ago

Thanks! 4D parametric surfaces is a quite complex topic but there are many useful videos on Youtube to start with ( example: https://www.youtube.com/watch?v=JmvHNatZgVI). There are five scripts for 4D parametric surfaces in MathMod and six controls for the 4D rotational plans to animate (rotate) them in the hyperspace (see attached picture)

parisolab commented 1 year ago

Screen Shot 2022-10-29 at 3 47 58 PM

zhangfq-chemistry commented 1 year ago

Would you like to add lambert-W and spherical-harmonics function to mathmod? Thanks!

parisolab commented 1 year ago

Would you like to add lambert-W and spherical-harmonics function to mathmod? Thanks!

Is there a general parametric description of these functions? (PS: Some [3D pictures of spherical harmonic functions can be found here]https://commons.wikimedia.org/wiki/File:Representative-spherical_harmonics.png (url) along with a MathLab script that can be easily translated to a MathMod script)

parisolab commented 1 year ago

Screen Shot 2022-11-03 at 10 23 18 PM

zhangfq-chemistry commented 1 year ago

Yes sir! I need Lambert-W function for display orbitals(dx.doi.org/10.1021/ed500470q, J. Chem. Educ. 2014, 91, 1739−1741)

//associated legendre double legendre_a (int n, int m, double x) { std::vector v(n+1, 0.0); if(m <= n ) { v[m] = 1.0;

    double fact = 1.0;
    for(int k = 0; k < m; k++) {
        v[m] *= -fact * std::sqrt(1.0 - x * x);
        fact += 2.0;
    }
}

if(m + 1 <= n ) {
    v[m+1] = x * ( double ) ( 2 * m + 1 ) * v[m];
}

for(int j = m + 2; j <= n; j++ ) {
    v[j] = ((double)(2 * j - 1 ) * x * v[(j-1)]
            + (double)(- j - m + 1 ) * v[(j-2)])
            / (double)(j - m);
}
return v[n];

}

//associated laguerre double laguerre_a(int n, int m, double x) { double v[n+1];

if (n < 0) {
    return -1;
}

v[0] = 1.0;
for (int i = 1; i <= n; i++) {
    v[i] = 0.0;
}

if (n == 0) {
    return v[0];
}

v[1] = (double)(m + 1) - x;

for (int i = 2; i <= n; i++) {
    v[i] = (((double)(m + 2 * i - 1) - x) * v[i-1]
           + ( double ) (-m - i + 1 ) * v[i-2])
           / ( double ) (i);
}
return v[n];

}