From 96bc3c262020479a2b06c5ec3b90b1f8e11c4e62 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Tue, 17 Feb 2026 00:29:29 +0100 Subject: [PATCH] better formalisation --- README.md | 2 ++ double_pendule.py | 6 ++---- double_pendule_a_ressort.py | 12 ++++-------- legrandchien.py | 7 ++++++- pendule_a_ressort.py | 6 ++---- pendule_simple.py | 3 +-- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7f1ad31..4af201d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # LeGrandChien - Système de Simulation Physique Symbolique +> **⚠️ Warning:** ne pas considérer ce projet sérieusement + ## Description **LeGrandChien** est une bibliothèque Python pour la simulation de systèmes physiques complexes utilisant le calcul symbolique et les équations de Lagrange. Elle permet de définir des systèmes mécaniques (pendules, ressorts, chutes libres) de manière intuitive et de les résoudre numériquement. diff --git a/double_pendule.py b/double_pendule.py index 743bdb7..9733d4e 100644 --- a/double_pendule.py +++ b/double_pendule.py @@ -29,10 +29,8 @@ V += m2 * g * x2 L = T - V init = { - "theta1" : -3 * np.pi/4, - "d_theta1" : 0, - "theta2" : -np.pi/2, - "d_theta2" : 0 + "theta1" : [-3 * np.pi/4, 0], # theta1, theta1.diff() + "theta2" : [-np.pi/2, 0], # theta2, theta2.diff() } dt = 0.01 diff --git a/double_pendule_a_ressort.py b/double_pendule_a_ressort.py index 474be5a..b9d4798 100644 --- a/double_pendule_a_ressort.py +++ b/double_pendule_a_ressort.py @@ -33,14 +33,10 @@ V += k2 * (r2 - r20) * (r2 - r20) L = T - V init = { - "theta1" : - np.pi/4, - "d_theta1" : 0, - "theta2" : - np.pi/4, - "d_theta2" : 0, - "r1" : 1, - "d_r1" : 0, - "r2" : 1, - "d_r2" : 0 + "theta1" : [- np.pi/4, 0], + "theta2" : [- np.pi/4, 0], + "r1" : [1, 0], + "r2" : [1, 0], } dt = 0.001 diff --git a/legrandchien.py b/legrandchien.py index 14236fb..22a839b 100644 --- a/legrandchien.py +++ b/legrandchien.py @@ -466,7 +466,12 @@ class Equation: self.compile() return self.compiled_function(dico) - def solve(self, dico, tmax=10, dt=0.01, progress_bar=True): + def solve(self, init, tmax=10, dt=0.01, progress_bar=True): + dico = {} + for v_name, v_init in init.items(): + for i in range(len(v_init)): + dico["d_"*i + v_name] = v_init[i] + self.simplify() variables = self.getAllVar() diff --git a/pendule_a_ressort.py b/pendule_a_ressort.py index fb39cc1..60414f4 100644 --- a/pendule_a_ressort.py +++ b/pendule_a_ressort.py @@ -20,10 +20,8 @@ V = m * g * r * lgc.cos(theta) + k * (r - r0) * (r - r0) L = T - V init = { - "theta" : -3.14/2, - "d_theta" : 0, - "r" : 1.2, - "d_r" : 0, + "theta" : [-3.14/2, 0], # theta, theta.diff() + "r" : [1.2, 0], # r, r.diff() } dt = 0.001 diff --git a/pendule_simple.py b/pendule_simple.py index 1d562a9..5854054 100644 --- a/pendule_simple.py +++ b/pendule_simple.py @@ -18,8 +18,7 @@ V = m * g * r * lgc.cos(theta) L = T - V init = { - "theta" : -3 * 3.14/4, - "d_theta" : 0, + "theta" : [-3 * 3.14/4, 0], # theta, theta.diff() } dt = 0.01