ExternalDriver#
- class micromagneticmodel.ExternalDriver(**kwargs)#
Base class for existing external simulation packages (e.g. OOMMF, mumax3).
Methods
__dir__
Default dir() implementation.
__eq__
Return self==value.
__iter__
Iterator.
__repr__
Representation string.
Drives the system in phase space.
Abstract method to check and initialise kwargs for drive.
Schedule drive of the system in phase space.
Abstract method to check and initialise kwargs for schedule.
Properties
name
Name.
- drive(system, /, dirname='.', append=True, runner=None, ovf_format='bin8', verbose=1, **kwargs)#
Drives the system in phase space.
Takes
micromagneticmodel.System
and drives it in phase space. Ifappend=True
and the system director already exists, drive will be appended to that directory. Otherwise, an exception will be raised.This method accepts any other arguments that could be required by the specific driver. Refer to
drive_kwargs_setup
of the derived class for details.- Parameters:
system (micromagneticmodel.System) – System object to be driven.
dirname (str, optional) – Name of a base directory in which the simulation results are stored. Additional subdirectories based on the system name and the current drive number are created automatically (
dirname/<system-name>/drive-<number>
). If not specified the current workinng directory is used.append (bool, optional) – If
True
and the system directory already exists, drive or compute directories will be appended. Defaults toTrue
.runner (micromagneticmodel.ExternalRunner, optional) – External Runner which is going to be used for running the calculation. If
None
, a runner will be found automatically. Defaults toNone
.ovf_format (str) – Format of the magnetisation output files written by the external simulation tool. Can be one of
'bin8'
(binary, double precision),'bin4'
(binary, single precision) or'txt'
(text-based, double precision). Defaults to'bin8'
.verbose (int, optional) – If
verbose=0
, no output is printed. Forverbose=1
information about the runner and the runtime is printed to stdout. Forverbose=2
a progress bar is displayed for time drives. Note that this information only relies on the number of magnetisation snapshots already saved to disk and therefore only gives a rough indication of progress. Defaults to1
.kwargs – Additional calculator-specific keyword arguments can be passed. These are documented in
drive_kwargs_setup
of the individual calculators.
- Raises:
FileExistsError – If system directory already exists and append=False.
- abstract drive_kwargs_setup(drive_kwargs)#
Abstract method to check and initialise kwargs for drive.
- schedule(system, cmd, header, script_name='job.sh', dirname='.', append=True, runner=None, ovf_format='bin8', verbose=1, **kwargs)#
Schedule drive of the system in phase space.
Takes
micromagneticmodel.System
and drives it in phase space. This method writes the input files for the external package and then submits a job to the machine’s job scheduling system, e.g. Slurm. The command to schedule and the required resources in a format understood by the schedule command must be passed to the function.It is the user’s responsibility to ensure that the external package can be executed from the scheduled job.
If
append=True
and the system director already exists, drive will be appended to that directory. Otherwise, an exception will be raised.This method accepts any other arguments that could be required by the specific driver.
- Parameters:
system (micromagneticmodel.System) – System object to be driven.
cmd (str) – Name of the scheduling system’s submission program, e.g.
'sbatch'
for Slurm.header (str) – Filename of the submission header file or str with the data to specify system requirements such as number of CPUs and memory.
script_name (str, optional) – Name of the newly created OOMMF run script that is scheduled for execution.
dirname (str, optional) – Name of a base directory in which the simulation results are stored. Additional subdirectories based on the system name and the current drive number are created automatically. If not specified the current working directory is used.
append (bool, optional) – If
True
and the system directory already exists, drive or compute directories will be appended. Defaults toTrue
.runner (micromagneticmodel.ExternalRunner, optional) – External Runner which is going to be used for running the calculation. If
None
, a runner will be found automatically. Defaults toNone
.ovf_format (str) – Format of the magnetisation output files written by The external package. Can be one of
'bin8'
(binary, double precision),'bin4'
(binary, single precision) or'txt'
(text-based, double precision). Defaults to'bin8'
.verbose (int, optional) – If
verbose=0
, no output is printed. Forverbose=1
information about the submitted job is printed to stdout.kwargs – Additional calculator-specific keyword arguments can be passed. These are documented in
schedule_kwargs_setup
of the individual calculators.
- Raises:
FileExistsError – If system directory already exists and append=False.
- abstract schedule_kwargs_setup(schedule_kwargs)#
Abstract method to check and initialise kwargs for schedule.