Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem building/running Russell on macOS (Intel processor) #122

Closed
JEMH opened this issue Jul 17, 2024 · 12 comments
Closed

Problem building/running Russell on macOS (Intel processor) #122

JEMH opened this issue Jul 17, 2024 · 12 comments

Comments

@JEMH
Copy link

JEMH commented Jul 17, 2024

Hello,

I am trying to use the Russell Scientific Library on my MacBook Pro (with Intel processor) but am having problems.

I have done the following:

  • Installed lapack, openblas and suite-sparse using homebrew.
  • Created a new project 'expt-russell' using cargo.
  • Added the dependencies to the Cargo.toml file:
    [dependencies]
    russell_lab = ""
    russell_sparse = "

    russell_ode = "
    russell_stat = "

    russell_tensor = "*"
  • Copied the copied the contents of the example file arenstorf_dopri8.rs into main.rs (after removing the original "Hello World" content.
  • Performed „cargo run“ in the expt-russell directory .

Unfortunately the c libraries for umfpack were not found (see below).

I am new to Rust and so I could have missed something very elementary.

Do you have any suggestions as to how I should proceed?

I would be very grateful for any help.
Thanks in advance,
James Housden

expt_russell % cargo run
Updating crates.io index
Locking 49 packages to latest compatible versions
Adding ansi_term v0.12.1
Adding atty v0.2.14
Adding autocfg v1.3.0
Adding bitflags v1.3.2 (latest: v2.6.0)
Adding cc v1.1.5
Adding cfg-if v1.0.0
Adding clap v2.34.0 (latest: v4.5.9)
Adding getrandom v0.2.15
Adding heck v0.3.3 (latest: v0.5.0)
Adding hermit-abi v0.1.19 (latest: v0.4.0)
Adding itoa v1.0.11
Adding lazy_static v1.5.0
Adding libc v0.2.155
Adding libm v0.2.8
Adding num-complex v0.4.6
Adding num-traits v0.2.19
Adding ppv-lite86 v0.2.17
Adding proc-macro-error v1.0.4
Adding proc-macro-error-attr v1.0.4
Adding proc-macro2 v1.0.86
Adding quote v1.0.36
Adding rand v0.8.5
Adding rand_chacha v0.3.1
Adding rand_core v0.6.4
Adding rand_distr v0.4.3
Adding russell_lab v1.6.0
Adding russell_ode v1.6.0
Adding russell_sparse v1.6.0
Adding russell_stat v1.6.0
Adding russell_tensor v1.6.0
Adding ryu v1.0.18
Adding serde v1.0.204
Adding serde_derive v1.0.204
Adding serde_json v1.0.120
Adding strsim v0.8.0 (latest: v0.11.1)
Adding structopt v0.3.26
Adding structopt-derive v0.4.18
Adding syn v1.0.109 (latest: v2.0.71)
Adding syn v2.0.71
Adding textwrap v0.11.0 (latest: v0.16.1)
Adding unicode-ident v1.0.12
Adding unicode-segmentation v1.11.0
Adding unicode-width v0.1.13
Adding vec_map v0.8.2
Adding version_check v0.9.4
Adding wasi v0.11.0+wasi-snapshot-preview1 (latest: v0.13.1+wasi-0.2.0)
Adding winapi v0.3.9
Adding winapi-i686-pc-windows-gnu v0.4.0
Adding winapi-x86_64-pc-windows-gnu v0.4.0
Compiling proc-macro2 v1.0.86
Compiling unicode-ident v1.0.12
Compiling libc v0.2.155
Compiling version_check v0.9.4
Compiling autocfg v1.3.0
Compiling libm v0.2.8
Compiling cc v1.1.5
Compiling serde v1.0.204
Compiling syn v1.0.109
Compiling cfg-if v1.0.0
Compiling unicode-width v0.1.13
Compiling unicode-segmentation v1.11.0
Compiling strsim v0.8.0
Compiling textwrap v0.11.0
Compiling vec_map v0.8.2
Compiling serde_json v1.0.120
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling bitflags v1.3.2
Compiling num-traits v0.2.19
Compiling heck v0.3.3
Compiling ppv-lite86 v0.2.17
Compiling ansi_term v0.12.1
Compiling ryu v1.0.18
Compiling lazy_static v1.5.0
Compiling itoa v1.0.11
Compiling russell_lab v1.6.0
Compiling russell_sparse v1.6.0
Compiling quote v1.0.36
Compiling syn v2.0.71
Compiling getrandom v0.2.15
Compiling atty v0.2.14
Compiling clap v2.34.0
Compiling rand_core v0.6.4
Compiling rand_chacha v0.3.1
Compiling rand v0.8.5
Compiling serde_derive v1.0.204
Compiling rand_distr v0.4.3
Compiling structopt-derive v0.4.18
Compiling structopt v0.3.26
The following warnings were emitted during compilation:

warning: russell_sparse@1.6.0: c_code/interface_complex_umfpack.c:4:10: fatal error: 'umfpack.h' file not found
warning: russell_sparse@1.6.0: #include "umfpack.h"
warning: russell_sparse@1.6.0: ^~~~~~~~~~~
warning: russell_sparse@1.6.0: 1 error generated.

error: failed to run custom build command for russell_sparse v1.6.0

Caused by:
process didn't exit successfully: /Users/admin/RustroverProjects/expt_russell/target/debug/build/russell_sparse-beebd4751418e261/build-script-build (exit status: 1)
--- stdout
OUT_DIR = Some(/Users/admin/RustroverProjects/expt_russell/target/debug/build/russell_sparse-6ea65dc13eb23187/out)
TARGET = Some(x86_64-apple-darwin)
OPT_LEVEL = Some(0)
HOST = Some(x86_64-apple-darwin)
cargo:rerun-if-env-changed=CC_x86_64-apple-darwin
CC_x86_64-apple-darwin = None
cargo:rerun-if-env-changed=CC_x86_64_apple_darwin
CC_x86_64_apple_darwin = None
cargo:rerun-if-env-changed=HOST_CC
HOST_CC = None
cargo:rerun-if-env-changed=CC
CC = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
RUSTC_WRAPPER = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some(true)
cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET
MACOSX_DEPLOYMENT_TARGET = None
cargo:rerun-if-env-changed=CFLAGS_x86_64-apple-darwin
CFLAGS_x86_64-apple-darwin = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_apple_darwin
CFLAGS_x86_64_apple_darwin = None
cargo:rerun-if-env-changed=HOST_CFLAGS
HOST_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:warning=c_code/interface_complex_umfpack.c:4:10: fatal error: 'umfpack.h' file not found
cargo:warning=#include "umfpack.h"
cargo:warning= ^~~~~~~~~~~
cargo:warning=1 error generated.

--- stderr

error occurred: Command env -u IPHONEOS_DEPLOYMENT_TARGET "cc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "--target=x86_64-apple-darwin" "-mmacosx-version-min=14.5" "-I" "/usr/include/suitesparse" "-I" "/opt/homebrew/include/suitesparse" "-Wall" "-Wextra" "-o" "/Users/admin/RustroverProjects/expt_russell/target/debug/build/russell_sparse-6ea65dc13eb23187/out/be5a010cd526d178-interface_complex_umfpack.o" "-c" "c_code/interface_complex_umfpack.c" with args cc did not execute successfully (status code exit status: 1).

warning: build failed, waiting for other jobs to finish...

@cpmech
Copy link
Owner

cpmech commented Jul 22, 2024

Hi, can you search for "umfpack.h" in your system?

@JEMH
Copy link
Author

JEMH commented Jul 22, 2024 via email

@cpmech
Copy link
Owner

cpmech commented Jul 22, 2024

Can you please create the following link?

/opt/homebrew/include/suitesparse -> /usr/local/include/suitesparse

If it works, then I can publish another version with the fix.

@JEMH
Copy link
Author

JEMH commented Jul 22, 2024 via email

@cpmech
Copy link
Owner

cpmech commented Jul 22, 2024

Hi, can you search for:

  • libopenblas.*
  • liblapack.*

We need to crate a link for the libraries as well

@JEMH
Copy link
Author

JEMH commented Jul 23, 2024

Hi,
On my MacBook:

openblas include files at: /usr/local/opt/openblas/include
openblas libraries at: /usr/local/opt/openblas/lib

lapack include files at: /usr/local/opt/lapack/include
lapack libraries at: /usr/local/opt/lapack/lib

Regards,
James

@cpmech
Copy link
Owner

cpmech commented Jul 23, 2024

So, can you please create the following links:

/opt/homebrew/opt/openblas/lib -> /usr/local/opt/openblas/lib
/opt/homebrew/opt/lapack/lib -> /usr/local/opt/lapack/lib

(for some reason, Homebrew install those things in different places, depending on the version...)

@JEMH
Copy link
Author

JEMH commented Jul 23, 2024

Hi,
it' now looking a lot better.

I created the links as you suggested:
ln -s /usr/local/opt/openblas/lib /opt/homebrew/opt/openblas/lib
ln -s /usr/local/opt/lapack/lib /opt/homebrew/opt/lapack/lib.

I rebuilt Russell and ran the Arenstorf example as previously.
This ran to completion and generated the Arenstorf orbit plot which looks good.

Here is the console output:

Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.05s
 Running `/Users/admin/RustroverProjects/expt_russell/target/debug/expt_russell`

y_russell = [0.9943593998842639, 0.0007772233170978659, 0.11771274437464613, -1.937923583175161]
y_mathematica = [0.9939999999999928, 2.4228439406717e-14, 3.6631563591513e-12, -2.0015851063802006]
DoPri8: Dormand-Prince method (explicit, order 8(5,3), embedded)
Number of function evaluations = 825
Number of performed steps = 59
Number of accepted steps = 44
Number of rejected steps = 15
Last accepted/suggested stepsize = 0.005231119923792644
Max time spent on a step = 34.658µs
Total time = 4.756575ms

There are some differences between the y_russell and y_mathematica states but I guess that this is due to the tolerances used in the example.

What's the best way to set new absolute and relative tolerances when solving ODE's?

Thank you for taking the time to answer my questions.
Regards,
James

@cpmech
Copy link
Owner

cpmech commented Jul 23, 2024

Excellent! I'll publish another version later with the fix so that those symbolic links will no longer be necessary.

The difference between Russell and Mathematica happens because Russell is approximate and Mathematica is much more accurate.

As for the tolerances, this is the function to set them: https://docs.rs/russell_ode/latest/russell_ode/struct.Params.html#method.set_tolerances

And here is an example of how to use the function:

params.set_tolerances(1e-10, 1e-10, None)?;

Let's keep this issue open for now so I can remember to fix the links problem.

@JEMH
Copy link
Author

JEMH commented Jul 23, 2024

Thank you for the info.
By using stricter values for the relative and absolute tolerances, the differences between the Russel solution and the Mathematica solution all but disappear.

@cpmech
Copy link
Owner

cpmech commented Jul 23, 2024

Excellent!

I've published a new version that does not require those symbolic links in your system. You may delete the links.

The easiest way to use the updated code in your machine is to add the specific version such as

[dependencies]
russell_lab = "1.6.2"
russell_sparse = "1.6.2"
russell_ode = "1.6.2"
russell_stat = "1.6.2"
russell_tensor = "1.6.2"

Later, you may revert back to "*".

However, if you only need russell_ode, you just need a single line:

russell_ode = "*"

I appreciate if you could try the new version (after deleting the links I've suggested).

Thank you.

@JEMH
Copy link
Author

JEMH commented Jul 24, 2024 via email

@JEMH JEMH closed this as completed Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants