From 74681e8aa08a4b53b0040bc117580d622b25b33a Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Mon, 18 Jul 2022 14:27:09 +0100 Subject: [PATCH 1/6] aei script --- oommfc/scripts/energy.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/oommfc/scripts/energy.py b/oommfc/scripts/energy.py index d25ebd28..baceb41d 100644 --- a/oommfc/scripts/energy.py +++ b/oommfc/scripts/energy.py @@ -52,6 +52,42 @@ def exchange_script(term, system): return mif +def aei_script(term, system): + mif = f"# AEI\n" + mif += f"Specify Oxs_AEI:{term.Gamma} {{\n" + + if isinstance(term.Gamma, numbers.Real): + mif += f" default_Gamma {term.Gamma}\n" + mif += " atlas :main_atlas\n" + mif += " Gamma {\n" + if len(system.m.mesh.subregions) == 0: + mif += f" main main {term.Gamma}\n" + else: + mif += f" entire entire {term.Gamma}\n" + mif += " }\n" + mif += "}\n\n" + + elif isinstance(term.Gamma, dict): + if "default" in term.Gamma.keys(): + default_value = term.Gamma["default"] + else: + default_value = 0 + mif += f" default_Gamma {default_value}\n" + mif += " atlas :main_atlas\n" + mif += " Gamma {\n" + for key, value in term.Gamma.items(): + if key != "default": + if ":" in key: + region1, region2 = key.split(":") + else: + region1, region2 = key, key + mif += f" {region1} {region2} {value}\n" + mif += " }\n" + mif += "}\n\n" + + return mif + + def zeeman_script(term, system): Hmif, Hname = oc.scripts.setup_vector_parameter(term.H, f"{term.name}_H") From 731259e583fd6fcedcf6d8227c1d8020abe2b5d9 Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Fri, 29 Jul 2022 15:43:26 +0100 Subject: [PATCH 2/6] Correct name --- oommfc/scripts/energy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oommfc/scripts/energy.py b/oommfc/scripts/energy.py index baceb41d..3f69c051 100644 --- a/oommfc/scripts/energy.py +++ b/oommfc/scripts/energy.py @@ -54,7 +54,7 @@ def exchange_script(term, system): def aei_script(term, system): mif = f"# AEI\n" - mif += f"Specify Oxs_AEI:{term.Gamma} {{\n" + mif += f"Specify Oxs_AEI:{term.name} {{\n" if isinstance(term.Gamma, numbers.Real): mif += f" default_Gamma {term.Gamma}\n" From 36e4339d2002263b40396c63b36a53c30af9f618 Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Mon, 8 Aug 2022 10:41:27 +0100 Subject: [PATCH 3/6] Test new exchange --- oommfc/scripts/energy.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/oommfc/scripts/energy.py b/oommfc/scripts/energy.py index d25ebd28..63b241dd 100644 --- a/oommfc/scripts/energy.py +++ b/oommfc/scripts/energy.py @@ -15,10 +15,15 @@ def energy_script(system): def exchange_script(term, system): + if isinstance(term.A, numbers.Real): mif = "# UniformExchange\n" - mif += f"Specify Oxs_UniformExchange:{term.name} {{\n" - mif += f" A {term.A}\n" + mif += f"Specify Oxs_isoexch:{term.name} {{\n" + mif += f" default_A {term.A}\n" + mif += " atlas :main_atlas\n" + mif += " A {\n" + mif += f" main main {term.A}\n" + mif += " }\n" mif += "}\n\n" elif isinstance(term.A, dict): From 46032d5842a3758705393b3baa7a5042f1ebf8f4 Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Tue, 9 Aug 2022 18:26:56 +0100 Subject: [PATCH 4/6] add nn --- oommfc/scripts/energy.py | 46 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/oommfc/scripts/energy.py b/oommfc/scripts/energy.py index 63b241dd..402ba12d 100644 --- a/oommfc/scripts/energy.py +++ b/oommfc/scripts/energy.py @@ -15,9 +15,20 @@ def energy_script(system): def exchange_script(term, system): + if not isinstance(term.A, numbers.Real): + raise RuntimeError('Sam needs to actually sort this.') - if isinstance(term.A, numbers.Real): - mif = "# UniformExchange\n" + if not hasattr(term, 'nn'): + term.nn = None + + if term.nn == '12nn': + mif = "# UniformExchange 12nn\n" + mif += f"Specify Oxs_UniformExchange:{term.name} {{\n" + mif += f" A {term.A}\n" + mif += f" kernel 12ngbrmirror\n" + mif += "}\n\n" + elif term.nn == 'iso': + mif = "# UniformExchange iso\n" mif += f"Specify Oxs_isoexch:{term.name} {{\n" mif += f" default_A {term.A}\n" mif += " atlas :main_atlas\n" @@ -25,33 +36,10 @@ def exchange_script(term, system): mif += f" main main {term.A}\n" mif += " }\n" mif += "}\n\n" - - elif isinstance(term.A, dict): - if "default" in term.A.keys(): - default_value = term.A["default"] - else: - default_value = 0 - mif = "# Exchange6Ngbr\n" - mif += f"Specify Oxs_Exchange6Ngbr:{term.name} {{\n" - mif += f" default_A {default_value}\n" - mif += " atlas :main_atlas\n" - mif += " A {\n" - for key, value in term.A.items(): - if key != "default": - if ":" in key: - region1, region2 = key.split(":") - else: - region1, region2 = key, key - mif += f" {region1} {region2} {value}\n" - mif += " }\n" - mif += "}\n\n" - - elif isinstance(term.A, df.Field): - Amif, Aname = oc.scripts.setup_scalar_parameter(term.A, f"{term.name}_A") - mif = Amif - mif += "# ExchangePtwise\n" - mif += f"Specify Oxs_ExchangePtwise:{term.name} {{\n" - mif += f" A {Aname}\n" + else: + mif = "# UniformExchange 6nn\n" + mif += f"Specify Oxs_UniformExchange:{term.name} {{\n" + mif += f" A {term.A}\n" mif += "}\n\n" return mif From 9e2aa0e7f4b9c4db5aeeefee2c55ececbbeba03b Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Wed, 17 Aug 2022 16:22:46 +0100 Subject: [PATCH 5/6] 12nn DMI T --- oommfc/scripts/energy.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/oommfc/scripts/energy.py b/oommfc/scripts/energy.py index 402ba12d..58599d83 100644 --- a/oommfc/scripts/energy.py +++ b/oommfc/scripts/energy.py @@ -267,6 +267,8 @@ def dmi_script(term, system): warnings.warn(msg, FutureWarning) tcc = "Cnv_z" oxs = f"Oxs_DMI_{tcc}" + elif (tcc := term.crystalclass) in ["T_12"]: + oxs = "Oxs_DMI_T_12" mif = f"# DMI of crystallographic class {term.crystalclass}\n" mif += f"Specify {oxs}:{term.name} {{\n" From faab6548a43ad7a6cc2b507da0c197ee90ceb72c Mon Sep 17 00:00:00 2001 From: Sam Holt Date: Fri, 4 Nov 2022 13:57:15 +0000 Subject: [PATCH 6/6] AEI 12 nn --- oommfc/scripts/energy.py | 75 +++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/oommfc/scripts/energy.py b/oommfc/scripts/energy.py index a3bb0b0c..78e02ca8 100644 --- a/oommfc/scripts/energy.py +++ b/oommfc/scripts/energy.py @@ -16,18 +16,18 @@ def energy_script(system): def exchange_script(term, system): if not isinstance(term.A, numbers.Real): - raise RuntimeError('Sam needs to actually sort this.') + raise RuntimeError("Sam needs to actually sort this.") - if not hasattr(term, 'nn'): + if not hasattr(term, "nn"): term.nn = None - if term.nn == '12nn': + if term.nn == "12nn": mif = "# UniformExchange 12nn\n" mif += f"Specify Oxs_UniformExchange:{term.name} {{\n" mif += f" A {term.A}\n" - mif += f" kernel 12ngbrmirror\n" + mif += " kernel 12ngbrmirror\n" mif += "}\n\n" - elif term.nn == 'iso': + elif term.nn == "iso": mif = "# UniformExchange iso\n" mif += f"Specify Oxs_isoexch:{term.name} {{\n" mif += f" default_A {term.A}\n" @@ -46,36 +46,41 @@ def exchange_script(term, system): def aei_script(term, system): - mif = f"# AEI\n" - mif += f"Specify Oxs_AEI:{term.name} {{\n" - - if isinstance(term.Gamma, numbers.Real): - mif += f" default_Gamma {term.Gamma}\n" - mif += " atlas :main_atlas\n" - mif += " Gamma {\n" - if len(system.m.mesh.subregions) == 0: - mif += f" main main {term.Gamma}\n" - else: - mif += f" entire entire {term.Gamma}\n" - mif += " }\n" - mif += "}\n\n" - - elif isinstance(term.Gamma, dict): - if "default" in term.Gamma.keys(): - default_value = term.Gamma["default"] - else: - default_value = 0 - mif += f" default_Gamma {default_value}\n" - mif += " atlas :main_atlas\n" - mif += " Gamma {\n" - for key, value in term.Gamma.items(): - if key != "default": - if ":" in key: - region1, region2 = key.split(":") - else: - region1, region2 = key, key - mif += f" {region1} {region2} {value}\n" - mif += " }\n" + mif = "# AEI\n" + if term.nn == "12nn": + mif += f"Specify Oxs_AEI_12:{term.name} {{\n" + elif term.nn == "6nn": + mif += f"Specify Oxs_AEI:{term.name} {{\n" + else: + raise ValueError(f"{term.nn} not recognised") + + if isinstance(term.Gamma, numbers.Real): + mif += f" default_Gamma {term.Gamma}\n" + mif += " atlas :main_atlas\n" + mif += " Gamma {\n" + if len(system.m.mesh.subregions) == 0: + mif += f" main main {term.Gamma}\n" + else: + mif += f" entire entire {term.Gamma}\n" + mif += " }\n" + mif += "}\n\n" + + elif isinstance(term.Gamma, dict): + if "default" in term.Gamma.keys(): + default_value = term.Gamma["default"] + else: + default_value = 0 + mif += f" default_Gamma {default_value}\n" + mif += " atlas :main_atlas\n" + mif += " Gamma {\n" + for key, value in term.Gamma.items(): + if key != "default": + if ":" in key: + region1, region2 = key.split(":") + else: + region1, region2 = key, key + mif += f" {region1} {region2} {value}\n" + mif += " }\n" mif += "}\n\n" return mif