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

Improve documentation v2 #101

Merged
merged 54 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2f58e53
Remove unnecessary comment
cpmech Apr 20, 2024
7bca382
[russell_stat] Improve readme
cpmech Apr 20, 2024
5d84a4f
Improve lib.rs
cpmech Apr 20, 2024
739025c
Fix link in readme
cpmech Apr 20, 2024
adb062a
Add item to roadmap
cpmech Apr 20, 2024
25683aa
Add badges for documentation
cpmech Apr 20, 2024
0167ece
Add badges for documentation
cpmech Apr 20, 2024
e6655e7
Improve description of tensor lib
cpmech Apr 20, 2024
e7528e6
Improve description of sparse lib
cpmech Apr 20, 2024
6891eb2
Improve description of ode lib
cpmech Apr 20, 2024
504dd4f
Improve description of lab lib
cpmech Apr 20, 2024
24e591b
Improve description of lab lib
cpmech Apr 20, 2024
fe62dd0
Add example
cpmech Apr 20, 2024
c6f340a
Rename figure
cpmech Apr 20, 2024
d223b91
[lab] Improve readme
cpmech Apr 20, 2024
7334ed0
Add example to readme
cpmech Apr 20, 2024
787d6cf
Combine example: min solver and root solver
cpmech Apr 20, 2024
7836aa6
Add test for complete elliptic integral functions
cpmech Apr 20, 2024
e8ce392
Improve example
cpmech Apr 21, 2024
d914119
Improve error checking in elliptic integral functions
cpmech Apr 21, 2024
e94636a
Improve example
cpmech Apr 21, 2024
c5fb3ce
Improve reamde
cpmech Apr 21, 2024
c804e82
Add example
cpmech Apr 21, 2024
242bd12
[lab] Rename description of crate
cpmech Apr 21, 2024
eaf7c52
Improve readme (using VS Code Markdown All in One to generate TOC)
cpmech Apr 21, 2024
68083cb
Fix doc example
cpmech Apr 21, 2024
84290d4
Move linear_fitting to algo module
cpmech Apr 21, 2024
24caac7
Add example
cpmech Apr 21, 2024
5cbaa9b
Improve readme file
cpmech Apr 21, 2024
f86c555
Add example (sort)
cpmech Apr 21, 2024
850f7ce
Add example
cpmech Apr 21, 2024
808f184
Add example
cpmech Apr 21, 2024
f8c44d4
Add example
cpmech Apr 21, 2024
080104c
Improve readme
cpmech Apr 21, 2024
a9fbceb
Improve readme's TOC
cpmech Apr 21, 2024
0f851f2
Improve example output
cpmech Apr 21, 2024
5640b63
[wip] Impl deriv1_forward7
cpmech Apr 22, 2024
625d3bc
Rename files
cpmech Apr 22, 2024
0488b42
Rename deriv2_central9
cpmech Apr 22, 2024
49156ac
Fix constant name
cpmech Apr 23, 2024
ae9ae51
Impl deriv1_backward
cpmech Apr 23, 2024
66b35d9
Impl deriv1_approx_eq fw and bw
cpmech Apr 23, 2024
56b770a
Use one-sided numerical derivatives in test
cpmech Apr 23, 2024
c938d8f
Impl deriv2_forward7
cpmech Apr 23, 2024
dd8cb17
Impl deriv2_backward9
cpmech Apr 23, 2024
1d12fd4
Fix function names
cpmech Apr 23, 2024
7600455
Impl deriv2_approx_eq fw and bw
cpmech Apr 23, 2024
baa9eec
Improve headings in main readme file
cpmech Apr 23, 2024
b97b554
Add examples to main readme file
cpmech Apr 23, 2024
cb216ff
Improve import in example
cpmech Apr 23, 2024
2d29164
Improve ode readme file
cpmech Apr 23, 2024
cd7604a
Improve sparse readme file
cpmech Apr 23, 2024
d025405
Improve stat readme file
cpmech Apr 23, 2024
6b9bf9c
Improve tensor readme file
cpmech Apr 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 139 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
# Russell - Rust Scientific Library
# Russell - Rust Scientific Library <!-- omit from toc -->

[![codecov](https://codecov.io/gh/cpmech/russell/graph/badge.svg?token=PQWSKMZQXT)](https://codecov.io/gh/cpmech/russell)
[![Test & Coverage](https://github.com/cpmech/russell/actions/workflows/test_and_coverage.yml/badge.svg)](https://github.com/cpmech/russell/actions/workflows/test_and_coverage.yml)
[![Test with local libs](https://github.com/cpmech/russell/actions/workflows/test_with_local_libs.yml/badge.svg)](https://github.com/cpmech/russell/actions/workflows/test_with_local_libs.yml)
[![Test with Intel MKL](https://github.com/cpmech/russell/actions/workflows/test_with_intel_mkl.yml/badge.svg)](https://github.com/cpmech/russell/actions/workflows/test_with_intel_mkl.yml)

[![documentation: lab](https://img.shields.io/badge/russell_lab-documentation-blue)](https://docs.rs/russell_lab)
[![documentation: ode](https://img.shields.io/badge/russell_ode-documentation-blue)](https://docs.rs/russell_ode)
[![documentation: sparse](https://img.shields.io/badge/russell_sparse-documentation-blue)](https://docs.rs/russell_sparse)
[![documentation: stat](https://img.shields.io/badge/russell_stat-documentation-blue)](https://docs.rs/russell_stat)
[![documentation: tensor](https://img.shields.io/badge/russell_tensor-documentation-blue)](https://docs.rs/russell_tensor)

![Logo](logo.svg)

## Contents

* [Introduction](#introduction)
* [Crates](#crates)
* [Installation on Debian/Ubuntu/Linux](#installation)
* [Installation on macOS](#macos)
* [Number of threads](#threads)
* [Examples](#examples)
* [(lab) Singular value decomposition](#svd)
* [(lab) Cholesky factorization](#cholesky)
* [(lab) Solve a tiny (dense) linear system](#dense-lin-sys)
* [(sparse) Solve a small sparse linear system](#sparse-lin-sys)
* [(ode) Solve the brusselator ODE system](#brusselator)
* [(stat) Generate the Frechet distribution](#frechet)
* [(tensor) Allocate second-order tensors](#tensor)
* [Roadmap](#roadmap)

<a name="introduction"></a>
## Contents <!-- omit from toc -->

- [Introduction](#introduction)
- [Installation](#installation)
- [TL;DR (Debian/Ubuntu/Linux)](#tldr-debianubuntulinux)
- [Details](#details)
- [Case A: OpenBLAS](#case-a-openblas)
- [Default Debian packages](#default-debian-packages)
- [Locally compiled libraries](#locally-compiled-libraries)
- [Case B: Intel MKL](#case-b-intel-mkl)
- [Installation on macOS](#installation-on-macos)
- [Number of threads](#number-of-threads)
- [Examples](#examples)
- [(lab) Solution of a 1D PDE using spectral collocation](#lab-solution-of-a-1d-pde-using-spectral-collocation)
- [(lab) Matrix visualization](#lab-matrix-visualization)
- [(lab) Singular value decomposition](#lab-singular-value-decomposition)
- [(lab) Cholesky factorization](#lab-cholesky-factorization)
- [(lab) Solve a tiny (dense) linear system](#lab-solve-a-tiny-dense-linear-system)
- [(sparse) Solve a small sparse linear system using UMFPACK](#sparse-solve-a-small-sparse-linear-system-using-umfpack)
- [(ode) Brusselator ODE](#ode-brusselator-ode)
- [(ode) Brusselator PDE](#ode-brusselator-pde)
- [(stat) Generate the Frechet distribution](#stat-generate-the-frechet-distribution)
- [(tensor) Allocate second-order tensors](#tensor-allocate-second-order-tensors)
- [Roadmap](#roadmap)



## Introduction

**Russell** (Rust Scientific Library) assists in developing high-performance computations involving linear algebra, sparse linear systems, differential equations, statistics, and continuum mechanics using the Rust programming language. The applications built with Russell revolve around the computational mechanics discipline; however, since Russell deals with fundamental mathematics and numerics, it is also helpful for other disciplines.

<a name="crates"></a>

## Crates

Available crates:
Available libraries:

- [![Crates.io](https://img.shields.io/crates/v/russell_lab.svg)](https://crates.io/crates/russell_lab) [russell_lab](https://github.com/cpmech/russell/tree/main/russell_lab) Scientific laboratory with special math functions, linear algebra, interpolation, quadrature, numerical derivation, and more
- [![Crates.io](https://img.shields.io/crates/v/russell_ode.svg)](https://crates.io/crates/russell_ode) [russell_ode](https://github.com/cpmech/russell/tree/main/russell_ode) Solvers for ordinary differential equations (ODEs) and differential algebraic equations (DAEs)
Expand Down Expand Up @@ -70,13 +82,13 @@ External associated and recommended crates:
- [tritet](https://github.com/cpmech/tritet) Triangle and tetrahedron mesh generators (with Triangle and Tetgen)
- [gemlab](https://github.com/cpmech/gemlab) Geometry, meshes, and numerical integration for finite element analyses

<a name="installation"></a>


## Installation

At this moment, Russell works on **Linux** (Debian/Ubuntu; and maybe Arch). It has some limited functionality on macOS too. In the future, we plan to enable Russell on Windows; however, this will take time because some essential libraries are not easily available on Windows.

### TLDR (Debian/Ubuntu/Linux)
### TL;DR (Debian/Ubuntu/Linux)

First:

Expand Down Expand Up @@ -124,7 +136,7 @@ Run:
bash case-a-openblas-debian.bash
```

#### Locally compiled libraries (feature = local_libs)
#### Locally compiled libraries

Run:

Expand All @@ -134,7 +146,7 @@ bash case-a-openblas-local-libs.bash

Then, add `local_libs` to your Cargo.toml or use `cargo build --features local_libs`

### Case B: Intel MKL (feature = intel_mkl)
### Case B: Intel MKL

Run:

Expand All @@ -144,13 +156,11 @@ bash case-b-intel-mkl-local-libs.bash

Then, add `intel_mkl` to your Cargo.toml or use `cargo build --features intel_mkl` (note that the `local_libs` feature will be automatically enabled).

### Resulting files

If locally compiled, the above scripts will save the resulting files in `/usr/local/lib/{mumps,umfpack}` and `/usr/local/include/{mumps,umfpack}`.

<a name="macos"></a>

## Installation on macOS

### Installation on macOS

Currently, only OpenBLAS has been tested on macOS.

Expand All @@ -166,9 +176,9 @@ Next, we must set the `LIBRARY_PATH`:
export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix)/opt/lapack/lib:$(brew --prefix)/opt/openblas/lib
```

<a name="threads"></a>

## Number of threads

### Number of threads

By default, OpenBLAS will use all available threads, including Hyper-Threads that may worsen the performance. Thus, it is best to set the following environment variable:

Expand All @@ -184,7 +194,7 @@ Furthermore, if working on a multi-threaded application where the solver should
export OPENBLAS_NUM_THREADS=1
```

<a name="examples"></a>


## Examples

Expand All @@ -204,7 +214,65 @@ use num_complex::Complex64;

This line will bring `Complex64` to the scope. For convenience the (russell_lab) macro `cpx!` may be used to allocate complex numbers.

<a name="svd"></a>


### (lab) Solution of a 1D PDE using spectral collocation

This example illustrates the solution of a 1D PDE using the spectral collocation method. It employs the InterpLagrange struct.

```text
d²u du x
——— - 4 —— + 4 u = e + C
dx² dx

-4 e
C = ——————
1 + e²

x ∈ [-1, 1]
```

Boundary conditions:

```text
u(-1) = 0 and u(1) = 0
```

Reference solution:

```text
x sinh(1) 2x C
u(x) = e - ——————— e + —
sinh(2) 4
```

[See the code](https://github.com/cpmech/russell/tree/main/russell_lab/examples/algo_lorene_1d_pde_spectral_collocation.rs)

Results:

![algo_lorene_1d_pde_spectral_collocation](russell_lab/data/figures/algo_lorene_1d_pde_spectral_collocation.svg)



### (lab) Matrix visualization

We can use the fantastic tool named [vismatrix](https://github.com/cpmech/vismatrix/) to visualize the pattern of non-zero values of a matrix. With `vismatrix`, we can click on each circle and investigate the numeric values as well.

The function `mat_write_vismatrix` writes the input data file for `vismatrix`.

[See the code](https://github.com/cpmech/russell/tree/main/russell_lab/examples/matrix_visualization.rs)

After generating the "dot-smat" file, run the following command:

```bash
vismatrix /tmp/russell_lab/matrix_visualization.smat
```

Output:

![Matrix visualization](russell_lab/data/figures/matrix_vizualization.png)



### (lab) Singular value decomposition

Expand Down Expand Up @@ -257,7 +325,7 @@ fn main() -> Result<(), StrError> {
}
```

<a name="cholesky"></a>


### (lab) Cholesky factorization

Expand Down Expand Up @@ -326,7 +394,7 @@ fn main() -> Result<(), StrError> {
}
```

<a name="dense-lin-sys"></a>


### (lab) Solve a tiny (dense) linear system

Expand Down Expand Up @@ -356,7 +424,9 @@ fn main() -> Result<(), StrError> {
}
```

### <a name="sparse-lin-sys"></a> (sparse) Solve a small sparse linear system using UMFPACK


### (sparse) Solve a small sparse linear system using UMFPACK

```rust
use russell_lab::*;
Expand Down Expand Up @@ -422,9 +492,9 @@ fn main() -> Result<(), StrError> {
}
```

<a name="brusselator"></a>

### (ode) Solve the brusselator ODE system

### (ode) Brusselator ODE

The system is:

Expand Down Expand Up @@ -470,7 +540,33 @@ A plot of the (dense) solution is shown below:

![Brusselator results: DoPri8](russell_ode/data/figures/brusselator_dopri8.svg)

<a name="frechet"></a>


### (ode) Brusselator PDE

This example solves the Brusselator PDE described in (Hairer E, Wanner G (2002) Solving Ordinary Differential Equations II Stiff and Differential-Algebraic Problems. Second Revised Edition. Corrected 2nd printing 2002. Springer Series in Computational Mathematics, 614p).

See the code [brusselator_pde_radau5_2nd.rs](https://github.com/cpmech/russell/tree/main/russell_ode/examples/brusselator_pde_radau5_2nd.rs).

The results are shown below for the `U` field:

![brusselator_pde_radau5_2nd_u.jpg](russell_ode/data/figures/brusselator_pde_radau5_2nd_u.jpg)

And below for the `V` field:

![brusselator_pde_radau5_2nd_v.jpg](russell_ode/data/figures/brusselator_pde_radau5_2nd_v.jpg)

The code [brusselator_pde_2nd_comparison.rs](https://github.com/cpmech/russell/tree/main/russell_ode/examples/brusselator_pde_2nd_comparison.rs) compares `russell` results with Mathematica results.

The figure below shows the `russell` (black dashed lines) and Mathematica (red solid lines) results for the `U` field:

![comparison U](russell_ode/data/figures/brusselator_pde_2nd_comparison_t1_u.svg)

The figure below shows the `russell` (black dashed lines) and Mathematica (red solid lines) results for the `V` field:

![comparison V](russell_ode/data/figures/brusselator_pde_2nd_comparison_t1_v.svg)



### (stat) Generate the Frechet distribution

Expand Down Expand Up @@ -529,7 +625,7 @@ std_dev = 312.7131690782321
sum = 9008
```

<a name="tensor"></a>


### (tensor) Allocate second-order tensors

Expand Down Expand Up @@ -600,7 +696,7 @@ fn main() -> Result<(), StrError> {
}
```

<a name="todo"></a>


## Roadmap

Expand Down Expand Up @@ -651,6 +747,7 @@ fn main() -> Result<(), StrError> {
- [ ] Improve `russell_stat`
- [x] Add probability distribution functions
- [x] Implement drawing of ASCII histograms
- [ ] Implement FORM (first-order reliability method)
- [ ] Add more examples
- [ ] Improve `russell_tensor`
- [x] Implement functions to calculate invariants
Expand Down
2 changes: 1 addition & 1 deletion russell_lab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "russell_lab"
version = "1.1.1"
edition = "2021"
license = "MIT"
description = "Scientific lab with special math functions, linear algebra, interpolation, quadrature, num derivation"
description = "Scientific laboratory for linear algebra and numerical mathematics"
homepage = "https://github.com/cpmech/russell"
repository = "https://github.com/cpmech/russell"
documentation = "https://docs.rs/russell_lab"
Expand Down
Loading