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

ODT files are not read correctly when using magnetoelasticity extension #14

Closed
stibus opened this issue Jun 22, 2021 · 1 comment · Fixed by #15
Closed

ODT files are not read correctly when using magnetoelasticity extension #14

stibus opened this issue Jun 22, 2021 · 1 comment · Fixed by #15

Comments

@stibus
Copy link
Contributor

stibus commented Jun 22, 2021

When adding the magnetoelastic term to my simulation, reading the generated ODT file would fail because the number of columns returned by ubermagtable.util.columns() would not match the number of columns in the data. Inspecting the code I figured that the YY_ prefix was not considered when splitting the column labels. This patch fixes the issue for me:

diff --git a/ubermagtable/table.py b/ubermagtable/table.py
index 8c4ffbc..6ab6113 100644
--- a/ubermagtable/table.py
+++ b/ubermagtable/table.py
@@ -272,11 +272,7 @@ class Table:
         >>> table = ut.Table.fromfile(odtfile, x='t')
 
         """
-        # MagnetoElastic OOMMF extension adds energy twice to data. The
-        # following lines are just a way to fix that in the data.
         cols = uu.columns(filename, rename=rename)
-        if 'MEL_E' in cols:
-            cols.insert(cols.index('E'), 'E')
 
         return cls(data=pd.DataFrame(uu.data(filename), columns=cols),
                    units=uu.units(filename, rename=rename), x=x)
diff --git a/ubermagtable/util/util.py b/ubermagtable/util/util.py
index f87ad86..b2765fb 100644
--- a/ubermagtable/util/util.py
+++ b/ubermagtable/util/util.py
@@ -43,8 +43,8 @@ oommf_dict = {'RungeKuttaEvolve:evolver:Total energy': 'E',
               'CGEvolve::Cycle count': 'cycle_count',
               'CGEvolve::Cycle sub count': 'cycle_sub_count',
               'CGEvolve::Energy calc count': 'energy_calc_count',
-              'CGEvolve:evolver:Energy calc count YY_FixedMEL::Energy':
-              'MEL_E',
+              'FixedMEL::Energy': 'MEL_E',
+              'FixedMEL:magnetoelastic:Energy': 'MEL_E',
               'SpinTEvolve:evolver:Total energy': 'E',
               'SpinTEvolve:evolver:Energy calc count': 'E_calc_count',
               'SpinTEvolve:evolver:Max dm/dt': 'max_dmdt',
@@ -183,7 +183,7 @@ def columns(filename, rename=True):
 
     if lines[0].startswith('# ODT'):  # OOMMF odt file
         cline = list(filter(lambda l: l.startswith('# Columns:'), lines))[0]
-        cline = re.split(r'Oxs_|Anv_|Southampton_|My_|UHH_', cline)[1:]
+        cline = re.split(r'Oxs_|Anv_|Southampton_|My_|YY_|UHH_', cline)[1:]
         cline = list(map(lambda col: re.sub(r'[{}]', '', col), cline))
         cols = list(map(lambda s: s.strip(), cline))
         cols_dict = oommf_dict
@marijanbeg
Copy link
Member

Hi @stibus, thank you very much for reporting this bug. Please feel free to contribute to the code by creating a pull request. We would love to acknowledge your contribution by adding you to the contributors' list.

Besides, if there are any extensions you want to have in any of the Ubermag packages, please feel free to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants