Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anisotropic exchange interaction #123

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 54 additions & 18 deletions oommfc/scripts/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,65 @@ def energy_script(system):


def exchange_script(term, system):
if isinstance(term.A, numbers.Real):
mif = "# UniformExchange\n"
if not isinstance(term.A, numbers.Real):
raise RuntimeError("Sam needs to actually sort this.")

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 += " 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"
mif += " A {\n"
mif += f" main main {term.A}\n"
mif += " }\n"
mif += "}\n\n"
else:
mif = "# UniformExchange 6nn\n"
mif += f"Specify Oxs_UniformExchange:{term.name} {{\n"
mif += f" A {term.A}\n"
mif += "}\n\n"

elif isinstance(term.A, dict):
if "default" in term.A.keys():
default_value = term.A["default"]
return mif


def aei_script(term, system):
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 = "# Exchange6Ngbr\n"
mif += f"Specify Oxs_Exchange6Ngbr:{term.name} {{\n"
mif += f" default_A {default_value}\n"
mif += f" default_Gamma {default_value}\n"
mif += " atlas :main_atlas\n"
mif += " A {\n"
for key, value in term.A.items():
mif += " Gamma {\n"
for key, value in term.Gamma.items():
if key != "default":
if ":" in key:
region1, region2 = key.split(":")
Expand All @@ -41,14 +83,6 @@ def exchange_script(term, system):
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"
mif += "}\n\n"

return mif


Expand Down Expand Up @@ -274,6 +308,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"
Expand Down