Buckets:
| from fenics import * | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| def plot_sin(): | |
| x = np.linspace(0, 2 * np.pi, 100) | |
| y = np.sin(x) | |
| plt.plot(x, y) | |
| plt.title('Graphique de la fonction sin(x)') | |
| plt.xlabel('x') | |
| plt.ylabel('sin(x)') | |
| plt.grid(True) | |
| plt.show() | |
| # Appel de la fonction pour tracer le graphique | |
| plot_sin() | |
| # Paramètres de simulation | |
| L = 1.0 # Longueur de la barre | |
| T = 1.0 # Temps total | |
| num_steps = 10 # Nombre de pas de temps | |
| dt = T / num_steps # Taille des pas de temps | |
| E = 10.0 # Module d'élasticité | |
| A = 1.0 # Aire de la section transversale | |
| force = 1.0 # Force appliquée à l'extrémité de la barre | |
| # Création de la maille | |
| mesh = IntervalMesh(10, 0, L) | |
| V = FunctionSpace(mesh, 'P', 1) | |
| # Conditions aux limites | |
| u_D = Constant(0.0) # Déplacement à l'extrémité gauche | |
| bc = DirichletBC(V, u_D, "on_boundary") | |
| # Formulation du problème | |
| u = TrialFunction(V) | |
| v = TestFunction(V) | |
| a = E * A * inner(grad(u), grad(v)) * dx | |
| L = force * v * dx | |
| # Résoudre le problème | |
| u = Function(V) | |
| for n in range(num_steps): | |
| solve(a == L, u, bc) | |
| # Visualisation des résultats | |
| plot(u) | |
| plt.title('Déplacement de la barre') | |
| plt.xlabel('Position le long de la barre') | |
| plt.ylabel('Déplacement') | |
| plt.show() | |
| # ...existing code... | |
| def update_data(self): | |
| # Simulate changes (replace with your sensor data) | |
| self.distance_traveled += 0.01 # km | |
| self.energy_level -= 0.05 | |
| self.speed = 5 + (time.time() % 1) # Example Speed | |
| # Update labels with green background | |
| self.distance_label.config(text=f"Distance: {self.distance_traveled:.2f} km", bg="green") | |
| self.energy_label.config(text=f"Energy: {max(0, self.energy_level):.0f}%", bg="green") # Prevent energy going below 0 | |
| self.speed_label.config(text=f"Speed: {self.speed:.1f} km/h", bg="green") | |
| # Append to history | |
| self.history_text.insert(tk.END, f"Distance: {self.distance_traveled:.2f} km, Energy: {self.energy_level:.0f}%, Speed {self.speed:.1f} km/h\n") | |
| self.history_text.see(tk.END) # Scroll to bottom | |
| # Simulate movement on the map | |
| self.current_location = (self.current_location[0] + (0.00001 * (time.time() % 2)), | |
| self.current_location[1] + (0.00001 * (time.time() % 3))) | |
| self.update_marker() | |
| # Schedule the next update | |
| self.master.after(1000, self.update_data) # Update every second | |
| root = tk.Tk() | |
| app = GardenCartApp(root) | |
| root.mainloop() |
Xet Storage Details
- Size:
- 2.48 kB
- Xet hash:
- 13801efe53b94d5fb862ca63341547ddce169d11c75b7fb6dc9e230aed7aa139
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.