From a039ef077637669fc0874303a756c07485e5d94b Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Mon, 1 Aug 2022 15:09:09 +0100 Subject: [PATCH 1/5] Txt directly to mx3 --- mumax3c/scripts/driver.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mumax3c/scripts/driver.py b/mumax3c/scripts/driver.py index 35d7daf..6db6edc 100644 --- a/mumax3c/scripts/driver.py +++ b/mumax3c/scripts/driver.py @@ -5,7 +5,7 @@ import mumax3c as mc -def driver_script(driver, system, compute=None, ovf_format="bin4", **kwargs): +def driver_script(driver, system, compute=None, ovf_format="bin4", mx3_txt=None, **kwargs): mx3 = "tableadd(E_total)\n" mx3 += "tableadd(dt)\n" mx3 += "tableadd(maxtorque)\n" @@ -14,6 +14,10 @@ def driver_script(driver, system, compute=None, ovf_format="bin4", **kwargs): if attr != "evolver": mx3 += f"{attr} = {value}\n" + if mx3_txt is not None: + mx3 += "\n" + mx3 += mx3_txt + mx3 += "\n" mx3 += "minimize()\n\n" mx3 += "save(m_full)\n" mx3 += "tablesave()\n\n" @@ -28,6 +32,10 @@ def driver_script(driver, system, compute=None, ovf_format="bin4", **kwargs): if attr != "evolver": mx3 += f"{attr} = {value}\n" + if mx3_txt is not None: + mx3 += "\n" + mx3 += mx3_txt + mx3 += "\n" mx3 += "relax()\n\n" mx3 += "save(m_full)\n" mx3 += "tablesave()\n\n" @@ -77,6 +85,11 @@ def driver_script(driver, system, compute=None, ovf_format="bin4", **kwargs): mx3 += "setsolver(5)\n" mx3 += "fixDt = 0\n\n" + if mx3_txt is not None: + mx3 += "\n" + mx3 += mx3_txt + mx3 += "\n" + t, n = kwargs["t"], kwargs["n"] mx3 += f"for snap_counter:=0; snap_counter<{n}; snap_counter++{{\n" From 0e5683dc83668d07a6bb8fa558f02b7a708feff2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 14:10:27 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mumax3c/scripts/driver.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mumax3c/scripts/driver.py b/mumax3c/scripts/driver.py index 6db6edc..d2e80f8 100644 --- a/mumax3c/scripts/driver.py +++ b/mumax3c/scripts/driver.py @@ -5,7 +5,9 @@ import mumax3c as mc -def driver_script(driver, system, compute=None, ovf_format="bin4", mx3_txt=None, **kwargs): +def driver_script( + driver, system, compute=None, ovf_format="bin4", mx3_txt=None, **kwargs +): mx3 = "tableadd(E_total)\n" mx3 += "tableadd(dt)\n" mx3 += "tableadd(maxtorque)\n" From 67c73a81e8ac13f8ca4296944dc7a818a81b6c5f Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Mon, 1 Aug 2022 15:20:56 +0100 Subject: [PATCH 3/5] Update documentation --- mumax3c/drivers/driver.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mumax3c/drivers/driver.py b/mumax3c/drivers/driver.py index 710efb1..6a7ba89 100644 --- a/mumax3c/drivers/driver.py +++ b/mumax3c/drivers/driver.py @@ -39,7 +39,7 @@ def schedule_kwargs_setup(self, abspath=True, **kwargs): def _write_input_files(self, system, **kwargs): self.write_mx3(system, **kwargs) - def write_mx3(self, system, dirname=".", ovf_format="bin8", abspath=True, **kwargs): + def write_mx3(self, system, dirname=".", ovf_format="bin8", mx3_txt=None, abspath=True, **kwargs): """Write the mx3 file and related files. Takes ``micromagneticmodel.System`` and write the mx3 file (and related files) @@ -75,6 +75,12 @@ def write_mx3(self, system, dirname=".", ovf_format="bin8", abspath=True, **kwar single precision) or ``'txt'`` (text-based, double precision). Defaults to ``'bin8'``. + mx3_txt : str, optional + + Directly input string into mx3 file at a position immediately + before the type of driver explicity written. + + abspath : bool, optional If ``abspath=True`` absolute paths for additional input files (e.g. initial @@ -92,6 +98,7 @@ def write_mx3(self, system, dirname=".", ovf_format="bin8", abspath=True, **kwar system, compute=None, # TODO does mumax3 support compute? ovf_format=ovf_format, + mx3_txt=None, **kwargs, ) with open(self._mx3filename(system), "wt", encoding="utf-8") as mx3file: From 0a4797488860527ab58fe8965a3697f5bd941af2 Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Mon, 1 Aug 2022 16:21:11 +0100 Subject: [PATCH 4/5] Correct call --- mumax3c/drivers/driver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mumax3c/drivers/driver.py b/mumax3c/drivers/driver.py index 6a7ba89..d281a6a 100644 --- a/mumax3c/drivers/driver.py +++ b/mumax3c/drivers/driver.py @@ -98,7 +98,7 @@ def write_mx3(self, system, dirname=".", ovf_format="bin8", mx3_txt=None, abspat system, compute=None, # TODO does mumax3 support compute? ovf_format=ovf_format, - mx3_txt=None, + mx3_txt=mx3_txt, **kwargs, ) with open(self._mx3filename(system), "wt", encoding="utf-8") as mx3file: From 6c4164ed224b297d0c6153a2b14e1136d3805bac Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Aug 2022 15:21:30 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mumax3c/drivers/driver.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mumax3c/drivers/driver.py b/mumax3c/drivers/driver.py index d281a6a..666b37a 100644 --- a/mumax3c/drivers/driver.py +++ b/mumax3c/drivers/driver.py @@ -39,7 +39,15 @@ def schedule_kwargs_setup(self, abspath=True, **kwargs): def _write_input_files(self, system, **kwargs): self.write_mx3(system, **kwargs) - def write_mx3(self, system, dirname=".", ovf_format="bin8", mx3_txt=None, abspath=True, **kwargs): + def write_mx3( + self, + system, + dirname=".", + ovf_format="bin8", + mx3_txt=None, + abspath=True, + **kwargs, + ): """Write the mx3 file and related files. Takes ``micromagneticmodel.System`` and write the mx3 file (and related files)