analysenum.py

Created by mael-bergerac

Created on May 27, 2025

3.04 KB

rien


# Méthodes numériques pour EDO & EDP : Résumé détaillé et formules clés
"""
CHAPITRE 4 – Méthodes numériques pour EDO
-----------------------------------------
1. Définitions
   - EDO d'ordre n : y^(n) = f(t, y, y', ...)
   - Système d'ordre 1 via variables d'état.

2. Méthodes à un pas
   - **Euler explicite** (ordre 1) :
       y^{n+1} = y^n + h · f(t_n, y^n)
   - **α = 1/2 : méthode de Heun** :
       y^{n+1} = y^n 
                  + (h/2) · f(t_n, y^n)
                  + (h/2) · f(t_{n+1}, y^n + h·f(t_n, y^n))
   - **α = 1 : point milieu / Euler modifiée** :
       y^{n+1} = y^n 
                  + h · f(t_n + h/2, y^n + (h/2)·f(t_n, y^n))
   - **Runge–Kutta d’ordre 2, 3, 4** selon tableaux de Butcher.

3. Méthodes multi‐pas
   - **Adams–Bashforth 2** (explicite) :
       y^{n+1} = y^n + (h/2)·(3·f_n − f_{n−1})
   - **Adams–Moulton 2** (implicite) :
       y^{n+1} = y^n + (h/2)·(f_{n+1} + f_n)

4. Propriétés
   - Ordre, consistance, stabilité, convergence (Lax–Richtmyer).

CHAPITRE 5 – Méthodes numériques pour EDP
------------------------------------------
**Principales équations :**
1. **Chaleur 1D (parabolique)**  
   ∂θ/∂t = K · ∂2θ/∂x2  
   – Conditions aux limites Dirichlet, Neumann, Robin.

2. **Poisson / Laplace (elliptique)**  
   ∂2φ/∂x2 + ∂2φ/∂y2 = f(x,y)   (Poisson)  
   ∂2φ/∂x2 + ∂2φ/∂y2 = 0       (Laplace)

3. **Onde 1D (hyperbolique)**  
   ∂2u/∂t2 = c2 · ∂2u/∂x2

4. **Advection (transport)**  
   ∂u/∂t + v · ∂u/∂x = 0

**Discrétisations spatiales (différences finies) :**
- Dérivée première centrée : (u_{i+1} − u_{i−1})/(2Δx)
- Dérivée seconde centrée : (u_{i+1} − 2u_i + u_{i−1})/Δx2

**Schémas temps‐espace :**

1. **Chaleur FTCS (explicite)**  
   u_i^{n+1} = u_i^n + λ·(u_{i+1}^n − 2u_i^n + u_{i−1}^n),  
   λ = K·Δt/Δx2, condition CFL: λ ≤ 1⁄2.

2. **Chaleur BTCS (implicite)**  
   u_i^{n+1} = u_i^n + λ·(u_{i+1}^{n+1} − 2u_i^{n+1} + u_{i−1}^{n+1}),  
   inconditionnellement stable → tridiagonal à résoudre.

3. **Crank–Nicolson (semi‐implicite)**  
   u_i^{n+1} = u_i^n 
       + (λ/2)[(u_{i+1}^n − 2u_i^n + u_{i−1}^n)
              + (u_{i+1}^{n+1} − 2u_i^{n+1} + u_{i−1}^{n+1})]

4. **Onde (schéma Leap‐Frog)**  
   u_i^{n+1} = 2u_i^n − u_i^{n−1} + (cΔt/Δx)2·(u_{i+1}^n − 2u_i^n + u_{i−1}^n)

5. **Advection (upwind explicite)**  
   u_i^{n+1} = u_i^n − (vΔt/Δx)·(u_i^n − u_{i−1}^n),  CFL: |vΔt/Δx| ≤ 1

**Matrice 2D elliptique** : système creux tridiagonal par lignes.

"""

# (Le code d'implémentation EDP serait similaire aux fonctions FTCS, BTCS, etc., vues plus haut.)

def euler_explicit(f, t_n, y_n, h):
    return y_n + h * f(t_n, y_n)

def heun(f, t_n, y_n, h):
    k1 = f(t_n, y_n)
    y_euler = y_n + h * k1
    k2 = f(t_n + h, y_euler)
    return y_n + 0.5*h*(k1 + k2)

def midpoint(f, t_n, y_n, h):
    k1 = f(t_n, y_n)
    k2 = f(t_n + 0.5*h, y_n + 0.5*h*k1)
    return y_n + h * k2

# ... (reste des fonctions EDO)

if __name__ == "__main__":
    # Exemple rapide pour EDO
    import math
    def f_ex(t, y): return -y
    y, t, h = 1.0, 0.0, 0.1
    print("Heun:", heun(f_ex, t, y, h))

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.