cpmech / russell

Rust Scientific Libary. ODE and DAE (Runge-Kutta) solvers. Special functions (Bessel, Elliptic, Beta, Gamma, Erf). Linear algebra. Sparse solvers (MUMPS, UMFPACK). Probability distributions. Tensor calculus.
MIT License
114 stars 8 forks source link

Van der Pol Radau5 example plotting fails #125

Closed JEMH closed 3 months ago

JEMH commented 3 months ago

When I tried to run the Van der Pol Radau5 example, the plot was not produced.

In the generated python script I see the line: plt.title(""" Van der Pol ($\varepsilon = 10^{-6}$) - Radau5 - Tol = 1e-4 """)

I changed this to: plt.title(""" Van der Pol ($\epsilon = 10^{-6}$) - Radau5 - Tol = 1e-4 """)

and ran the python script directly. This produced the desired graphic.

JEMH commented 3 months ago

I see that the problem lies in the file van_der_pol_radau5.rs. The line: plot.set_subplot(2, 1, 1) .set_title("Van der Pol ($\varepsilon = 10^{-6}$) - Radau5 - Tol = 1e-4")

should be replaced by:

plot.set_subplot(2, 1, 1)
    .set_title(r"Van der Pol ($\\epsilon = 10^{-6}$) - Radau5 - Tol = 1e-4")
cpmech commented 3 months ago

Hi,

Thank you for reporting this issue.

I suppose you've used the more recent Plotpy version (1.0.0) in the example. The version originally was 0.6.0.

The newer Plotpy version (1.0.0) has a different way of handling raw strings but did not handle well the case of \varepsilon from TeX (I like varepsilon instead of epsilon 😊). Python/Matplotlib has difficulty in handling \v.

Thus, to fix this problem once and for all, I've improved Plotpy (https://github.com/cpmech/plotpy/pull/48). Please use the Plotpy version "1.1.0" or newer in your examples.

Also, please note that this problem only arises with the optional plotting code used in the example.

Thanks again.

JEMH commented 3 months ago

Hello,

Using Plotpy 1.1.0 the example runs as desired. Thank you for the explanation.