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

Ode check thread safety #86

Merged
merged 5 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
119 changes: 119 additions & 0 deletions russell_ode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ _This crate is part of [Russell - Rust Scientific Library](https://github.com/cp
* [Robertson's equation](#robertson)
* [Van der Pol's equation](#van-der-pol)
* [One-transistor amplifier](#amplifier1t)
* [PDE: discrete Laplacian (2D)](#laplacian)

## <a name="introduction"></a> Introduction

Expand Down Expand Up @@ -748,3 +749,121 @@ Total time = 97.951021ms
The results are plotted below:

![One-transistor Amplifier - Radau5](data/figures/amplifier1t_radau5.svg)

### <a name="laplacian"></a> PDE: discrete Laplacian operator in 2D

For convenience (e.g., in benchmarks), `russell_ode` implements a discrete Laplacian operator (2D) based on the Finite Differences Method.

This operator can be used to solve simple partial differential equation (PDE) problems.

#### Laplace equation

Approximate (with the Finite Differences Method, FDM) the solution of

```text
∂²ϕ ∂²ϕ
——— + ——— = 0
∂x² ∂y²
```

on a (1.0 × 1.0) rectangle with the following essential (Dirichlet) boundary conditions:

```text
left: ϕ(0.0, y) = 50.0
right: ϕ(1.0, y) = 0.0
bottom: ϕ(x, 0.0) = 0.0
top: ϕ(x, 1.0) = 50.0
```

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

The results are illustrated below:

![Laplace equation](data/figures/pde_laplace_equation.svg)

#### Poisson equation 1

Approximate (with the Finite Differences Method, FDM) the solution of

```text
∂²ϕ ∂²ϕ
——— + ——— = 2 x (y - 1) (y - 2 x + x y + 2) exp(x - y)
∂x² ∂y²
```

on a (1.0 × 1.0) square with the homogeneous boundary conditions.

The analytical solution is:

```text
ϕ(x, y) = x y (x - 1) (y - 1) exp(x - y)
```

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

The results are illustrated below:

![Poisson equation 1](data/figures/test_pde_poisson_1.svg)

#### Poisson equation 2

Approximate (with the Finite Differences Method, FDM) the solution of

```text
∂²ϕ ∂²ϕ
——— + ——— = - π² y sin(π x)
∂x² ∂y²
```

on a (1.0 × 1.0) square with the following essential boundary conditions:

```text
left: ϕ(0.0, y) = 0.0
right: ϕ(1.0, y) = 0.0
bottom: ϕ(x, 0.0) = 0.0
top: ϕ(x, 1.0) = sin(π x)
```

The analytical solution is:

```text
ϕ(x, y) = y sin(π x)
```

Reference: Olver PJ (2020) - page 210 - Introduction to Partial Differential Equations, Springer

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

The results are illustrated below:

![Poisson equation 2](data/figures/test_pde_poisson_2.svg)

#### Poisson equation 3

Approximate (with the Finite Differences Method, FDM) the solution of

```text
∂²ϕ ∂²ϕ
——— + ——— = source(x, y)
∂x² ∂y²
```

on a (1.0 × 1.0) square with homogeneous essential boundary conditions

The source term is given by (for a manufactured solution):

```text
source(x, y) = 14y³ - (16 - 12x) y² - (-42x² + 54x - 2) y + 4x³ - 16x² + 12x
```

The analytical solution is:

```text
ϕ(x, y) = x (1 - x) y (1 - y) (1 + 2x + 7y)
```

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

The results are illustrated below:

![Poisson equation 3](data/figures/test_pde_poisson_3.svg)
Loading