Exercise scripts#
Scripts for data generation and plotting for the exercises in assignment 2.
Exercise A#
Legendre Tau vs Collocation methods - convergence analysis.
Exercise B#
Fourier spectral methods.
Exercise C#
Boundary value problems and eigenvalue analysis.
KdV Eigenvalue Stability Analysis - Data Generation
Spatial and Temporal Convergence for Fourier KdV Solver
Exercise D#
Advanced eigenvalue problems.
Exercise E#
Time-dependent PDEs.
Exercise F#
KdV equation and invariants.
Space-Time Visualization for Two-Soliton Collision
Exercise G#
Nonlinear problems: profiling, scalability, and work-precision analysis for the KdV solver.
Available scripts
Profiling#
compute_profiling_functions.py– Function-level profiling using cProfile. Saves todata/A2/ex_g/cprofile_functions.parquet.compute_profiling_lines.py– Line-by-line profiling using line_profiler. Requires @profile decorators insrc/spectral/tdp.py.Usage:
uv run kernprof -l Exercises/exercise_g/compute_profiling_lines.pythenuv run python Exercises/exercise_g/compute_profiling_lines.py --parseplot_profiling_functions.py– Function-level profiling visualizations. Saves tofigures/A2/ex_g/function_profiling.pdf.plot_profiling_lines.py– Line-by-line profiling visualizations. Saves tofigures/A2/ex_g/line_profiling.pdf.
Performance Analysis#
compute_scalability.py– Measures strong/weak scaling behavior. Saves todata/A2/ex_g/scalability_timing.parquet.compute_work-precision.py– Sweeps stable time-step fractions for RK3/RK4 and records work vs accuracy metrics. Saves todata/A2/ex_g/work_precision.parquet.plot_scalability.py– Creates scalability analysis plots. Saves tofigures/A2/ex_g/scalability_analysis.pdf.plot_work-precision.py– Creates work-precision diagrams. Saves tofigures/A2/ex_g/work_precision.pdf.
Note: Run the corresponding compute_*.py or profile_*.py scripts before plotting.
Work-Precision Analysis: RK3 vs RK4 with Varying Grid Resolution
Exercise H#
Advanced applications.
Transport Equation Solution using Legendre Collocation