From 31e6249ac572428907f8d6698c86eb7e8c0689b1 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Thu, 24 Oct 2024 14:12:02 +0900 Subject: [PATCH 1/2] add a new parameter, kT_linspace_as_inverse_temperature for generating temperature points equally spaced in inverse temperature space --- abics/sampling/mc_mpi.py | 2 +- abics/sampling/pamc.py | 5 ++++- abics/sampling/rxmc.py | 5 ++++- abics/sampling/simple_parallel.py | 2 +- .../en/source/inputfiles/parameter_sampling.rst | 10 ++++++++++ .../ja/source/inputfiles/parameter_sampling.rst | 12 +++++++++++- 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/abics/sampling/mc_mpi.py b/abics/sampling/mc_mpi.py index e137f7b8..e8f53976 100644 --- a/abics/sampling/mc_mpi.py +++ b/abics/sampling/mc_mpi.py @@ -261,7 +261,7 @@ def __init__( self.write_node = write_node self.T2E = T2E self.E2T = 1.0 / T2E - self.kTs = [T2E * T for T in kTs] + self.kTs = np.array([T2E * T for T in kTs]) ## mycalc.kT and mycalc.config should be set later myconfig = configs[0] diff --git a/abics/sampling/pamc.py b/abics/sampling/pamc.py index 604f7f59..b7ed20fe 100644 --- a/abics/sampling/pamc.py +++ b/abics/sampling/pamc.py @@ -98,7 +98,10 @@ def from_dict(cls, d): kTstart = d["kTstart"] kTend = d["kTend"] kTnum = d["kTnum"] - params.kTs = np.linspace(kTstart, kTend, kTnum) + if d.get("kT_linspace_as_inverse_temperature", False): + params.kTs = 1.0 / np.linspace(1.0 / kTstart, 1.0 / kTend, kTnum) + else: + params.kTs = np.linspace(kTstart, kTend, kTnum) if "nsteps_between_anneal" in d: params.nsteps = d["nsteps_between_anneal"] * kTnum diff --git a/abics/sampling/rxmc.py b/abics/sampling/rxmc.py index 1fc1ecd8..7e7b0033 100644 --- a/abics/sampling/rxmc.py +++ b/abics/sampling/rxmc.py @@ -96,7 +96,10 @@ def from_dict(cls, d): else: kTstart = d["kTstart"] kTend = d["kTend"] - params.kTs = np.linspace(kTstart, kTend, params.nreplicas) + if d.get("kT_linspace_as_inverse_temperature", False): + params.kTs = 1.0 / np.linspace(1.0 / kTstart, 1.0 / kTend, params.nreplicas) + else: + params.kTs = np.linspace(kTstart, kTend, params.nreplicas) params.nsteps = d["nsteps"] params.RXtrial_frequency = d.get("RXtrial_frequency", 1) params.sample_frequency = d.get("sample_frequency", 1) diff --git a/abics/sampling/simple_parallel.py b/abics/sampling/simple_parallel.py index 34758ead..3a92c783 100644 --- a/abics/sampling/simple_parallel.py +++ b/abics/sampling/simple_parallel.py @@ -237,7 +237,7 @@ def __init__( kTs = [kTs] * self.procs self.T2E = T2E self.E2T = 1.0 / T2E - self.kTs = [T2E * T for T in kTs] + self.kTs = np.array([T2E * T for T in kTs]) self.model = model self.nreplicas = len(configs) self.write_node = write_node diff --git a/docs/sphinx/en/source/inputfiles/parameter_sampling.rst b/docs/sphinx/en/source/inputfiles/parameter_sampling.rst index 4133e750..d6241323 100644 --- a/docs/sphinx/en/source/inputfiles/parameter_sampling.rst +++ b/docs/sphinx/en/source/inputfiles/parameter_sampling.rst @@ -39,6 +39,7 @@ Keywords - Specify temperature points by using ``kTs`` or ``kTstart``, ``kTend``, and ``kTnum`` (lineary spaced). If ``kTs`` is specified, the others will be ignored. + - Temperatures should be given in the unit of Kelvin. - ``kTs`` @@ -70,6 +71,15 @@ Keywords The number of temperature points. When ``sampler = "RXMC"``, the number of temperature points will equal to ``nreplicas``. + - ``kT_linspace_as_inverse_temperature`` + + **Format :** true or false + + **Description :** + If true, temperature points are generated in the inverse temperature space with equal intervals. + If false, temperature points are generated in the temperature space with equal intervals. + Default value = false. + - About replica - ``nprocs_per_replica`` diff --git a/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst b/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst index 739c3749..55775557 100644 --- a/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst +++ b/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst @@ -40,6 +40,7 @@ - 温度点は ``kTs`` を用いて陽に指定するか、 ``kTstart`` と ``kTend`` とを用いて等間隔に自動生成するかのどちらかで指定します。 両方指定した場合、 ``kTs`` が優先されます. + - 温度はケルビンを単位とした絶対温度で指定します. - ``kTs`` @@ -70,7 +71,16 @@ **説明 :** 温度点の数. ``sampler = "PAMC"`` のときに使用. - ``sampler = "RXMC"`` のときは、 レプリカ数 ``nreplicas`` と同じ値になります. + ``sampler = "RXMC"`` のときは、 レプリカ数 ``nreplicas`` が温度点の数になります. + + - ``kT_linspace_as_inverse_temperature`` + + **形式 :** true or false + + **説明 :** + true の場合、温度点を生成する時に、逆温度空間で等間隔に生成します. + false の場合、温度空間で等間隔に生成します. + デフォルト値 = false. - レプリカに関する指定 From 7b58f3d52307ca9d2fd92080d689587fdb4371d6 Mon Sep 17 00:00:00 2001 From: Yuichi Motoyama Date: Thu, 24 Oct 2024 16:13:33 +0900 Subject: [PATCH 2/2] rename to `linspace_in_beta` --- abics/sampling/pamc.py | 2 +- abics/sampling/rxmc.py | 2 +- docs/sphinx/en/source/inputfiles/parameter_sampling.rst | 2 +- docs/sphinx/ja/source/inputfiles/parameter_sampling.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/abics/sampling/pamc.py b/abics/sampling/pamc.py index b7ed20fe..2c2f964c 100644 --- a/abics/sampling/pamc.py +++ b/abics/sampling/pamc.py @@ -98,7 +98,7 @@ def from_dict(cls, d): kTstart = d["kTstart"] kTend = d["kTend"] kTnum = d["kTnum"] - if d.get("kT_linspace_as_inverse_temperature", False): + if d.get("linspace_in_beta", False): params.kTs = 1.0 / np.linspace(1.0 / kTstart, 1.0 / kTend, kTnum) else: params.kTs = np.linspace(kTstart, kTend, kTnum) diff --git a/abics/sampling/rxmc.py b/abics/sampling/rxmc.py index 7e7b0033..602b102a 100644 --- a/abics/sampling/rxmc.py +++ b/abics/sampling/rxmc.py @@ -96,7 +96,7 @@ def from_dict(cls, d): else: kTstart = d["kTstart"] kTend = d["kTend"] - if d.get("kT_linspace_as_inverse_temperature", False): + if d.get("linspace_in_beta", False): params.kTs = 1.0 / np.linspace(1.0 / kTstart, 1.0 / kTend, params.nreplicas) else: params.kTs = np.linspace(kTstart, kTend, params.nreplicas) diff --git a/docs/sphinx/en/source/inputfiles/parameter_sampling.rst b/docs/sphinx/en/source/inputfiles/parameter_sampling.rst index d6241323..7d3817bc 100644 --- a/docs/sphinx/en/source/inputfiles/parameter_sampling.rst +++ b/docs/sphinx/en/source/inputfiles/parameter_sampling.rst @@ -71,7 +71,7 @@ Keywords The number of temperature points. When ``sampler = "RXMC"``, the number of temperature points will equal to ``nreplicas``. - - ``kT_linspace_as_inverse_temperature`` + - ``linspace_in_beta`` **Format :** true or false diff --git a/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst b/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst index 55775557..a8cd91a0 100644 --- a/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst +++ b/docs/sphinx/ja/source/inputfiles/parameter_sampling.rst @@ -73,7 +73,7 @@ ``sampler = "PAMC"`` のときに使用. ``sampler = "RXMC"`` のときは、 レプリカ数 ``nreplicas`` が温度点の数になります. - - ``kT_linspace_as_inverse_temperature`` + - ``linspace_in_beta`` **形式 :** true or false