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

Isotropic Exchange Interction #124

Draft
wants to merge 4 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
45 changes: 20 additions & 25 deletions oommfc/scripts/energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,31 @@ 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 += f" kernel 12ngbrmirror\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"
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"
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 += f" main main {term.A}\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
Expand Down Expand Up @@ -274,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"
Expand Down