From b8ecc9f4b4316ebb1fcc79d520b69c44b0e50471 Mon Sep 17 00:00:00 2001 From: "T.Aoyama" Date: Fri, 19 Jul 2024 09:07:16 +0900 Subject: [PATCH] update samples --- extra/function/sample/booth/do.sh | 2 +- .../sample/himmelblau/plot_colormap_2d.py | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 extra/function/sample/himmelblau/plot_colormap_2d.py diff --git a/extra/function/sample/booth/do.sh b/extra/function/sample/booth/do.sh index cf17516f..a65cf432 100644 --- a/extra/function/sample/booth/do.sh +++ b/extra/function/sample/booth/do.sh @@ -1,3 +1,3 @@ #!/bin/sh -time mpiexec -np 4 python3 main.py +time python3 main.py diff --git a/extra/function/sample/himmelblau/plot_colormap_2d.py b/extra/function/sample/himmelblau/plot_colormap_2d.py new file mode 100644 index 00000000..e7cd25cc --- /dev/null +++ b/extra/function/sample/himmelblau/plot_colormap_2d.py @@ -0,0 +1,47 @@ +import numpy as np +import matplotlib.pyplot as plt + + +def himmel(x, y): + return (x ** 2 + y - 11) ** 2 + (x + y ** 2 - 7) ** 2 + + +npts = 201 +c_x, c_y = np.mgrid[-6 : 6 : npts * 1j, -6 : 6 : npts * 1j] +c_z = himmel(c_x, c_y) +levels = np.logspace(0.35, 3.2, 8) + +x = [] +y = [] +f = [] +file_input = open("output/ColorMap.txt", "r") +lines = file_input.readlines() +file_input.close() +for line in lines: + if line[0] != "/n": + data = line.split() + x.append(float(data[0])) + y.append(float(data[1])) + f.append(np.log10(float(data[2]))) + +vmin = np.amin(np.array(f)) +vmax = np.amax(np.array(f)) + +plt.contour(c_x, c_y, c_z, levels, colors="k", zorder=10.0, alpha=1.0, linewidths=0.5) +plt.scatter( + x, + y, + c=f, + s=50, + vmin=vmin, + vmax=vmax, + cmap="Blues_r", + linewidth=2, + alpha=1.0, + zorder=1.0, +) +plt.xlim(-6.0, 6.0) +plt.ylim(-6.0, 6.0) +plt.colorbar(label="log10(f)") +#plt.savefig("output/ColorMapFig.pdf") +plt.savefig("output/ColorMapFig.png")