Skip to content

Commit

Permalink
fix meshgrid
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Mar 13, 2024
1 parent d99a9b2 commit 4571a8e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
5 changes: 3 additions & 2 deletions doc/en/source/algorithm/mapper_mpi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ Mesh definition file
^^^^^^^^^^^^^^^^^^^^^^^^^^

Define the grid space to be explored in this file.
The first column is the index of the mesh, and the second and subsequent columns are the values of variables defined in ``string_list`` in the ``[solver.param]`` section.
1 + ``dimension`` columns are required.
The first column is the index of the mesh, and the second and subsequent columns are the values of parameter.

Below, a sample file is shown.
A sample file for two dimensions is shown below.

.. code-block::
Expand Down
7 changes: 4 additions & 3 deletions doc/ja/source/algorithm/mapper_mpi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ MPI 並列を行う場合は、 `mpi4py <https://mpi4py.readthedocs.io/en/stable
^^^^^^^^^^^^^^^^^^^^^^^^^^

本ファイルで探索するグリッド空間を定義します。
1 + ``dimension`` 列のテキストファイルで、
1列目にメッシュのインデックス、
2列目以降は ``[solver.param]`` セクションにある、
``string_list`` で定義された変数に入る値が入ります
2列目以降は探索パラメータ :math:`x` に対応する値を記載します。
また、 ``#`` から始まる行はコメントとして無視されます

以下、サンプルを記載します
以下、2次元パラメータ空間探索のサンプルを記載します

.. code-block::
Expand Down
6 changes: 6 additions & 0 deletions src/py2dmat/algorithm/_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ def _meshgrid(
data = np.loadtxt(
mesh_path, comments=comments, delimiter=delimiter, skiprows=skiprows,
)
if data.ndim == 1:
data = data.reshape(1, -1)
if data.shape[1] != self.dimension+1:
raise exception.InputError(
f"ERROR: data.shape[1] != dimension+1 ({data.shape[1]} != {self.dimension}+1)"
)
grid = data
else:
if "min_list" not in info_param:
Expand Down
33 changes: 18 additions & 15 deletions src/py2dmat/algorithm/mapper_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,25 @@ def _run(self) -> None:

print("mesh after:", mesh)

fx_order = np.argsort(fx_list)
minimum_point = []
print("mesh_list[fx_order[0]]:")
print(self.mesh_list[fx_order[0]])
for index in range(1, dimension + 1):
minimum_point.append(self.mesh_list[fx_order[0]][index])
if iterations > 0:
fx_order = np.argsort(fx_list)
minimum_point = []
print("mesh_list[fx_order[0]]:")
print(self.mesh_list[fx_order[0]])
for index in range(1, dimension + 1):
minimum_point.append(self.mesh_list[fx_order[0]][index])

time_sta = time.perf_counter()
file_CM.write("#Minimum point :")
for value in minimum_point:
file_CM.write(" {:8f}".format(value))
file_CM.write("\n")
file_CM.write("#R-factor : {:8f}\n".format(fx_list[fx_order[0]]))
file_CM.write("#see Log{}\n".format(round(self.mesh_list[fx_order[0]][0])))
time_end = time.perf_counter()
self.timer["run"]["file_CM"] += time_end - time_sta
time_sta = time.perf_counter()
file_CM.write("#Minimum point :")
for value in minimum_point:
file_CM.write(" {:8f}".format(value))
file_CM.write("\n")
file_CM.write("#R-factor : {:8f}\n".format(fx_list[fx_order[0]]))
file_CM.write("#see Log{}\n".format(round(self.mesh_list[fx_order[0]][0])))
time_end = time.perf_counter()
self.timer["run"]["file_CM"] += time_end - time_sta
else:
file_CM.write("# No mesh point\n")

print(
"complete main process : rank {:08d}/{:08d}".format(
Expand Down

0 comments on commit 4571a8e

Please sign in to comment.