Boundary Value Problems (BVP)
This module provides numerical methods for solving boundary value problems in differential equations.
Matrix(h, n)
Constructs a tridiagonal matrix for the finite difference method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h
|
float
|
Step size. |
required |
n
|
int
|
Number of unknowns. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Tridiagonal matrix of size (n, n). |
Source code in openum/BVP.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
Matrix_method(x0, xn, n, y0, yn)
Solves a boundary value problem using the finite difference method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x0
|
float
|
Left boundary of the domain. |
required |
xn
|
float
|
Right boundary of the domain. |
required |
n
|
int
|
Number of interior grid points. |
required |
y0
|
float
|
Boundary condition at x0. |
required |
yn
|
float
|
Boundary condition at xn. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Solution values at the grid points. |
Source code in openum/BVP.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
Vector(n, y0, yn)
Constructs the right-hand side vector for the finite difference method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of unknowns. |
required |
y0
|
float
|
Boundary condition at x0. |
required |
yn
|
float
|
Boundary condition at xn. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Right-hand side vector. |
Source code in openum/BVP.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | |
solve_by_shooting(ode, x_1, x_2, n, v_0, u_1, u_2, max_iter)
Solves a boundary value problem using the shooting method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ode
|
callable
|
Function defining the ODE system. |
required |
x_1
|
float
|
Left boundary of the domain. |
required |
x_2
|
float
|
Right boundary of the domain. |
required |
n
|
int
|
Number of interior grid points. |
required |
v_0
|
list
|
Initial guesses for the derivative at x_1. |
required |
u_1
|
float
|
Boundary condition at x_1. |
required |
u_2
|
float
|
Boundary condition at x_2. |
required |
max_iter
|
int
|
Maximum number of iterations for root finding. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[float, ndarray, ndarray]
|
(Corrected initial derivative, solution grid points, solution values) |
Source code in openum/BVP.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |