From c16a7d248a3f21d4bd1fa30ec1478298d4be481a Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Tue, 10 Feb 2026 11:25:14 -0700 Subject: [PATCH 1/4] Remove mpl_ascii dependency --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 50243e2..6bba871 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,6 @@ name = "diffusion-model" version = "0.6" dependencies = [ "matplotlib", - "mpl_ascii", "numpy", ] From 871bdc8329ee0b94fc1b1631fc960136498e2c63 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Tue, 10 Feb 2026 11:31:12 -0700 Subject: [PATCH 2/4] Save profile plots to image files --- diffusion_model.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/diffusion_model.py b/diffusion_model.py index f23e9ad..d71fb0d 100644 --- a/diffusion_model.py +++ b/diffusion_model.py @@ -46,6 +46,7 @@ def plot_profile(x, concentration, color="r"): plt.xlabel("x") plt.ylabel("C") plt.title("Concentration profile") + return plt def calculate_second_derivative(y, dx=1.0): @@ -84,9 +85,10 @@ def run_diffusion_model( initial_concentration, stop_time, dx=dx, diffusivity=diffusivity ) - plot_profile(x, initial_concentration, "g") - plot_profile(x, concentration, "r") - plt.show() + initial_plot = plot_profile(x, initial_concentration, "g") + initial_plot.savefig("initial_profile.png") + final_plot = plot_profile(x, concentration, "r") + final_plot.savefig("final_profile.png") return concentration @@ -98,13 +100,6 @@ def load_params_from_path(filepath): if __name__ == "__main__": - import matplotlib as mpl - import mpl_ascii - - mpl_ascii.AXES_WIDTH = 70 - mpl_ascii.AXES_HEIGHT = 15 - - mpl.use("module://mpl_ascii") filepath = "diffusion.toml" From 5ad9eb918e9a72bd1437a6d05c23e1567c66eb31 Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Tue, 10 Feb 2026 11:51:46 -0700 Subject: [PATCH 3/4] Dump final profile to a text file --- diffusion_model.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/diffusion_model.py b/diffusion_model.py index d71fb0d..0ea7fb4 100644 --- a/diffusion_model.py +++ b/diffusion_model.py @@ -102,11 +102,10 @@ def load_params_from_path(filepath): if __name__ == "__main__": filepath = "diffusion.toml" - if os.path.isfile(filepath): params = load_params_from_path(filepath) else: params = {} - concentration = run_diffusion_model(**params) - np.savetxt(sys.stdout, concentration, fmt="%.6f") + concentration = run_diffusion_model(**params) + np.savetxt("diffusion_model.out", concentration, fmt="%.6f") From 343f7658041a56c55adf2506b83d5e0d37e6030c Mon Sep 17 00:00:00 2001 From: Mark Piper Date: Tue, 10 Feb 2026 15:09:52 -0700 Subject: [PATCH 4/4] Revert "Dump final profile to a text file" This reverts commit 5ad9eb918e9a72bd1437a6d05c23e1567c66eb31. Redirect from stdout, if desired. --- diffusion_model.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/diffusion_model.py b/diffusion_model.py index 0ea7fb4..d71fb0d 100644 --- a/diffusion_model.py +++ b/diffusion_model.py @@ -102,10 +102,11 @@ def load_params_from_path(filepath): if __name__ == "__main__": filepath = "diffusion.toml" + if os.path.isfile(filepath): params = load_params_from_path(filepath) else: params = {} - concentration = run_diffusion_model(**params) - np.savetxt("diffusion_model.out", concentration, fmt="%.6f") + + np.savetxt(sys.stdout, concentration, fmt="%.6f")