Table basics#

OOMMF saves the scalar data of micromagnetic simulations in .odt files, whereas mumax\(^{3}\) saves it in .txt files. ubermagtable is a convenience tool which provides functions for reading, manipulating, and visualising data from those files.

Reading data from OOMMF and mumax3 table files is done using ubermagtable.Table.fromfile class method. It takes filename as an input argument.

[1]:
import os

import ubermagtable as ut

# Sample OOMMF .odt file
dirname = os.path.join("..", "ubermagtable", "tests", "test_sample")
odtfile = os.path.join(dirname, "oommf-new-file2.odt")

table = ut.Table.fromfile(odtfile)

Table data is now loaded into pandas.DataFrame and it can be accessed via data attribute.

[2]:
table.data
[2]:
E E_calc_count max_dmdt dE/dt delta_E average_u E_exchange max_spin_ang_exchange stage_max_spin_ang_exchange run_max_spin_ang_exchange E_dmi E_uniaxialanisotropy iteration stage_iteration stage mx my mz last_time_step t
0 -3.138757e-19 61.0 5105.786662 1.131548e-09 1.234439e-22 400.0 7.819720e-19 24.981919 24.981919 24.981919 -1.791404e-18 6.955566e-19 8.0 8.0 0.0 -0.004356 0.001711 0.779309 1.146802e-13 1.000000e-12
1 -3.123365e-19 92.0 5393.820357 1.881778e-09 2.714936e-22 400.0 7.859070e-19 25.999114 25.999114 25.999114 -1.795166e-18 6.969222e-19 14.0 5.0 1.0 -0.007399 0.002527 0.779212 1.481817e-13 2.000000e-12
2 -3.101629e-19 129.0 5478.105937 2.410525e-09 1.525909e-22 400.0 7.908188e-19 26.839540 26.839540 26.839540 -1.800156e-18 6.991741e-19 21.0 6.0 2.0 -0.010058 0.002596 0.779103 6.371456e-14 3.000000e-12
3 -3.075651e-19 172.0 5775.596117 2.750961e-09 2.026333e-22 400.0 7.963184e-19 27.523018 27.523018 27.523018 -1.806035e-18 7.021517e-19 28.0 6.0 3.0 -0.012243 0.002078 0.779037 7.397143e-14 4.000000e-12
4 -3.046980e-19 209.0 6099.408455 2.938665e-09 1.417659e-22 400.0 8.020796e-19 27.968494 27.968494 27.968494 -1.812650e-18 7.058726e-19 35.0 6.0 4.0 -0.013915 0.001139 0.779058 4.838847e-14 5.000000e-12
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
195 -4.666219e-20 7786.0 6419.713717 2.798949e-10 1.373560e-23 400.0 1.222876e-18 29.279242 29.396487 33.740702 -1.937412e-18 6.678731e-19 1372.0 6.0 195.0 -0.007893 -0.008017 0.899229 5.094469e-14 1.960000e-10
196 -4.634379e-20 7829.0 6444.188876 2.763562e-10 1.564748e-23 400.0 1.222846e-18 29.358338 29.358338 33.740702 -1.936677e-18 6.674871e-19 1379.0 6.0 196.0 -0.007885 -0.008007 0.899298 6.044352e-14 1.970000e-10
197 -4.601751e-20 7866.0 6397.295744 2.905618e-10 1.926693e-23 400.0 1.222790e-18 29.418283 29.418283 33.740702 -1.935846e-18 6.670387e-19 1386.0 6.0 197.0 -0.007876 -0.007998 0.899383 7.101084e-14 1.980000e-10
198 -4.568193e-20 7909.0 6374.587944 3.124776e-10 1.795553e-23 400.0 1.222710e-18 29.397007 29.419861 33.740702 -1.934920e-18 6.665281e-19 1393.0 6.0 198.0 -0.007866 -0.007989 0.899482 5.961504e-14 1.990000e-10
199 -4.533615e-20 7946.0 6479.674566 3.377564e-10 2.490729e-23 400.0 1.222607e-18 29.301311 29.397007 33.740702 -1.933899e-18 6.659556e-19 1400.0 6.0 199.0 -0.007854 -0.007981 0.899595 7.547542e-14 2.000000e-10

200 rows × 20 columns

Apart from the data, units for individual columns are stored in units attribute.

[3]:
table.units
[3]:
{'E': 'J',
 'E_calc_count': '',
 'max_dmdt': 'deg/ns',
 'dE/dt': 'J/s',
 'delta_E': 'J',
 'average_u': 'm/s',
 'E_exchange': 'J',
 'max_spin_ang_exchange': 'deg',
 'stage_max_spin_ang_exchange': 'deg',
 'run_max_spin_ang_exchange': 'deg',
 'E_dmi': 'J',
 'E_uniaxialanisotropy': 'J',
 'iteration': '',
 'stage_iteration': '',
 'stage': '',
 'mx': '',
 'my': '',
 'mz': '',
 'last_time_step': 's',
 't': 's'}

This returns a dictionary, whose keys are column names and its values are the units.

By default, column names from OOMMF .odt and mumax3 .txt files are shortened. This can be changed by passing rename=False to the Table.fromfile class method:

[4]:
table_not_renamed = ut.Table.fromfile(odtfile, rename=False)

The column names are now:

[5]:
table_not_renamed.data
[5]:
SpinTEvolve:evolver:Total energy SpinTEvolve:evolver:Energy calc count SpinTEvolve:evolver:Max dm/dt SpinTEvolve:evolver:dE/dt SpinTEvolve:evolver:Delta E SpinTEvolve:evolver:average u UniformExchange:exchange:Energy UniformExchange:exchange:Max Spin Ang UniformExchange:exchange:Stage Max Spin Ang UniformExchange:exchange:Run Max Spin Ang DMI_Cnv:dmi:Energy UniaxialAnisotropy:uniaxialanisotropy:Energy TimeDriver::Iteration TimeDriver::Stage iteration TimeDriver::Stage TimeDriver::mx TimeDriver::my TimeDriver::mz TimeDriver::Last time step TimeDriver::Simulation time
0 -3.138757e-19 61.0 5105.786662 1.131548e-09 1.234439e-22 400.0 7.819720e-19 24.981919 24.981919 24.981919 -1.791404e-18 6.955566e-19 8.0 8.0 0.0 -0.004356 0.001711 0.779309 1.146802e-13 1.000000e-12
1 -3.123365e-19 92.0 5393.820357 1.881778e-09 2.714936e-22 400.0 7.859070e-19 25.999114 25.999114 25.999114 -1.795166e-18 6.969222e-19 14.0 5.0 1.0 -0.007399 0.002527 0.779212 1.481817e-13 2.000000e-12
2 -3.101629e-19 129.0 5478.105937 2.410525e-09 1.525909e-22 400.0 7.908188e-19 26.839540 26.839540 26.839540 -1.800156e-18 6.991741e-19 21.0 6.0 2.0 -0.010058 0.002596 0.779103 6.371456e-14 3.000000e-12
3 -3.075651e-19 172.0 5775.596117 2.750961e-09 2.026333e-22 400.0 7.963184e-19 27.523018 27.523018 27.523018 -1.806035e-18 7.021517e-19 28.0 6.0 3.0 -0.012243 0.002078 0.779037 7.397143e-14 4.000000e-12
4 -3.046980e-19 209.0 6099.408455 2.938665e-09 1.417659e-22 400.0 8.020796e-19 27.968494 27.968494 27.968494 -1.812650e-18 7.058726e-19 35.0 6.0 4.0 -0.013915 0.001139 0.779058 4.838847e-14 5.000000e-12
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
195 -4.666219e-20 7786.0 6419.713717 2.798949e-10 1.373560e-23 400.0 1.222876e-18 29.279242 29.396487 33.740702 -1.937412e-18 6.678731e-19 1372.0 6.0 195.0 -0.007893 -0.008017 0.899229 5.094469e-14 1.960000e-10
196 -4.634379e-20 7829.0 6444.188876 2.763562e-10 1.564748e-23 400.0 1.222846e-18 29.358338 29.358338 33.740702 -1.936677e-18 6.674871e-19 1379.0 6.0 196.0 -0.007885 -0.008007 0.899298 6.044352e-14 1.970000e-10
197 -4.601751e-20 7866.0 6397.295744 2.905618e-10 1.926693e-23 400.0 1.222790e-18 29.418283 29.418283 33.740702 -1.935846e-18 6.670387e-19 1386.0 6.0 197.0 -0.007876 -0.007998 0.899383 7.101084e-14 1.980000e-10
198 -4.568193e-20 7909.0 6374.587944 3.124776e-10 1.795553e-23 400.0 1.222710e-18 29.397007 29.419861 33.740702 -1.934920e-18 6.665281e-19 1393.0 6.0 198.0 -0.007866 -0.007989 0.899482 5.961504e-14 1.990000e-10
199 -4.533615e-20 7946.0 6479.674566 3.377564e-10 2.490729e-23 400.0 1.222607e-18 29.301311 29.397007 33.740702 -1.933899e-18 6.659556e-19 1400.0 6.0 199.0 -0.007854 -0.007981 0.899595 7.547542e-14 2.000000e-10

200 rows × 20 columns

We can specify the name of an independent variable in the table.

[6]:
table.x = "t"

If we already knew what the independent variable was going to be when we loaded the file, we could have passed it to fromfile method.

[7]:
table = ut.Table.fromfile(odtfile, x="t")

If table data was obtained by using time driver, table data store different values which are all a function of time. Column names of all time-dependent data can be obtained using y:

[8]:
table.y
[8]:
['E',
 'E_calc_count',
 'max_dmdt',
 'dE/dt',
 'delta_E',
 'average_u',
 'E_exchange',
 'max_spin_ang_exchange',
 'stage_max_spin_ang_exchange',
 'run_max_spin_ang_exchange',
 'E_dmi',
 'E_uniaxialanisotropy',
 'iteration',
 'stage_iteration',
 'stage',
 'mx',
 'my',
 'mz',
 'last_time_step']

Similarly, column name storing independent variable:

[9]:
table.x
[9]:
't'

The maximum value of x:

[10]:
table.xmax
[10]:
2e-10

Finally, the representation string of the table is:

[11]:
table
[11]:
                E  E_calc_count     max_dmdt         dE/dt       delta_E  \
0   -3.138757e-19          61.0  5105.786662  1.131548e-09  1.234439e-22
1   -3.123365e-19          92.0  5393.820357  1.881778e-09  2.714936e-22
2   -3.101629e-19         129.0  5478.105937  2.410525e-09  1.525909e-22
3   -3.075651e-19         172.0  5775.596117  2.750961e-09  2.026333e-22
4   -3.046980e-19         209.0  6099.408455  2.938665e-09  1.417659e-22
..            ...           ...          ...           ...           ...
195 -4.666219e-20        7786.0  6419.713717  2.798949e-10  1.373560e-23
196 -4.634379e-20        7829.0  6444.188876  2.763562e-10  1.564748e-23
197 -4.601751e-20        7866.0  6397.295744  2.905618e-10  1.926693e-23
198 -4.568193e-20        7909.0  6374.587944  3.124776e-10  1.795553e-23
199 -4.533615e-20        7946.0  6479.674566  3.377564e-10  2.490729e-23

     average_u    E_exchange  max_spin_ang_exchange  \
0        400.0  7.819720e-19              24.981919
1        400.0  7.859070e-19              25.999114
2        400.0  7.908188e-19              26.839540
3        400.0  7.963184e-19              27.523018
4        400.0  8.020796e-19              27.968494
..         ...           ...                    ...
195      400.0  1.222876e-18              29.279242
196      400.0  1.222846e-18              29.358338
197      400.0  1.222790e-18              29.418283
198      400.0  1.222710e-18              29.397007
199      400.0  1.222607e-18              29.301311

     stage_max_spin_ang_exchange  run_max_spin_ang_exchange         E_dmi  \
0                      24.981919                  24.981919 -1.791404e-18
1                      25.999114                  25.999114 -1.795166e-18
2                      26.839540                  26.839540 -1.800156e-18
3                      27.523018                  27.523018 -1.806035e-18
4                      27.968494                  27.968494 -1.812650e-18
..                           ...                        ...           ...
195                    29.396487                  33.740702 -1.937412e-18
196                    29.358338                  33.740702 -1.936677e-18
197                    29.418283                  33.740702 -1.935846e-18
198                    29.419861                  33.740702 -1.934920e-18
199                    29.397007                  33.740702 -1.933899e-18

     E_uniaxialanisotropy  iteration  stage_iteration  stage        mx  \
0            6.955566e-19        8.0              8.0    0.0 -0.004356
1            6.969222e-19       14.0              5.0    1.0 -0.007399
2            6.991741e-19       21.0              6.0    2.0 -0.010058
3            7.021517e-19       28.0              6.0    3.0 -0.012243
4            7.058726e-19       35.0              6.0    4.0 -0.013915
..                    ...        ...              ...    ...       ...
195          6.678731e-19     1372.0              6.0  195.0 -0.007893
196          6.674871e-19     1379.0              6.0  196.0 -0.007885
197          6.670387e-19     1386.0              6.0  197.0 -0.007876
198          6.665281e-19     1393.0              6.0  198.0 -0.007866
199          6.659556e-19     1400.0              6.0  199.0 -0.007854

           my        mz  last_time_step             t
0    0.001711  0.779309    1.146802e-13  1.000000e-12
1    0.002527  0.779212    1.481817e-13  2.000000e-12
2    0.002596  0.779103    6.371456e-14  3.000000e-12
3    0.002078  0.779037    7.397143e-14  4.000000e-12
4    0.001139  0.779058    4.838847e-14  5.000000e-12
..        ...       ...             ...           ...
195 -0.008017  0.899229    5.094469e-14  1.960000e-10
196 -0.008007  0.899298    6.044352e-14  1.970000e-10
197 -0.007998  0.899383    7.101084e-14  1.980000e-10
198 -0.007989  0.899482    5.961504e-14  1.990000e-10
199 -0.007981  0.899595    7.547542e-14  2.000000e-10

[200 rows x 20 columns]