Buckets:
| from fluidsim.solvers.ns2d.solver import Simul | |
| import numpy as np | |
| # Créer les paramètres avec sorties spatiales activées | |
| params = Simul.create_default_params() | |
| params.oper.type_fft = 'fft2d.with_pyfftw' | |
| params.oper.nx = params.oper.ny = 48 | |
| params.oper.Lx = params.oper.Ly = 8 | |
| params.time_stepping.t_end = 10 | |
| params.time_stepping.it_end = 10 | |
| # ACTIVER les sorties spatiales moyennes | |
| params.output.periods_save.spatial_means = 0.1 # Toutes les 0.1 unités de temps | |
| params.output.periods_save.phys_fields = 1.0 # Champs physiques toutes les 1.0 unités | |
| # Créer la simulation | |
| sim = Simul(params) | |
| # Initialisation CORRECTE des vortexes de Taylor-Green | |
| X, Y = sim.oper.X, sim.oper.Y | |
| ux = sim.state.get_var('ux') | |
| uy = sim.state.get_var('uy') | |
| rot = sim.state.get_var('rot') | |
| ux[:] = -np.cos(X) * np.sin(Y) | |
| uy[:] = np.sin(X) * np.cos(Y) | |
| rot[:] = 2 * np.cos(X) * np.cos(Y) | |
| print("=== INITIALISATION TAYLOR-GREEN AVEC SORTIES SPATIALES ===") | |
| print(".6f") | |
| energy_init = 0.5 * np.mean(ux**2 + uy**2) | |
| print(".6f") | |
| # Lancer la simulation | |
| sim.time_stepping.start() | |
| energy_final = 0.5 * np.mean(sim.state.get_var('ux')**2 + sim.state.get_var('uy')**2) | |
| print(".6f") | |
| print(f"\n=== SIMULATION TERMINÉE ===") | |
| print(f"Résultats: {sim.output.path_run}") | |
| print(f"Fichier spatial_means.txt: {sim.output.path_run}/spatial_means.txt") | |
| # Maintenant vous pouvez tracer | |
| print("\n=== TRACER LES MOYENNES SPATIALES ===") | |
| try: | |
| sim.output.spatial_means.plot() | |
| print("Graphique tracé avec succès") | |
| except Exception as e: | |
| print(f"Erreur lors du tracé: {e}") |
Xet Storage Details
- Size:
- 1.56 kB
- Xet hash:
- 4c014613b924561afec95fb8811fcec7e71dd97966638d72a1b1e58e39e6fa32
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.