Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
runner = oc.oommf.get_oommf_runner()
runner.call(argstr=miffilename)
# Update system's m and datatable attributes if the derivation of
# E, Heff, or energy density was not asked.
if compute is None:
# Update system's magnetisation. An example .omf filename:
# test_sample-Oxs_TimeDriver-Magnetization-01-0000008.omf
omffiles = glob.iglob(f'{system.name}*.omf')
lastomffile = sorted(omffiles)[-1]
system.m.value = df.Field.fromfile(lastomffile)
# Update system's datatable.
system.table = ut.Table.fromfile(f'{system.name}.odt')
if compute is None:
system.drive_number += 1
else:
system.compute_number += 1
td.drive(system, t=1e-25, n=1, append=True,
compute=schedule_script(func, system))
if func.__name__ == 'energy':
extension = '*.odt'
elif func.__name__ == 'effective_field':
extension = '*.ohf'
elif func.__name__ == 'density':
extension = '*.oef'
dirname = os.path.join(system.name, f'compute-{system.compute_number-1}')
output_file = max(glob.iglob(os.path.join(dirname, extension)),
key=os.path.getctime)
if func.__name__ == 'energy':
table = ut.Table.fromfile(output_file, rename=False)
if isinstance(func.__self__, mm.Energy):
output = table.data['RungeKuttaEvolve:evolver:Total energy'][0]
else:
output = table.data[(f'{oxs_class(func.__self__, system)}:'
f'{func.__self__.name}:Energy')][0]
else:
output = df.Field.fromfile(output_file)
return output