How to use the oommfc.oommf.oommf.OOMMFRunner function in oommfc

To help you get started, we’ve selected a few oommfc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ubermag / oommfc / oommfc / oommf / oommf.py View on Github external
return sp.run(cmd, stdout=stdout, stderr=stderr)

    def _kill(self, targets=['all']):
        sp.run(['tclsh', self.oommf_tcl, 'killoommf'] + targets)

    def errors(self):
        errors_file = os.path.join(os.path.dirname(self.oommf_tcl),
                                   'boxsi.errors')
        with open(errors_file, 'r') as f:
            errors = f.read()

        return errors


@uu.inherit_docs
class ExeOOMMFRunner(OOMMFRunner):
    """OOMMF runner using OOMMF executable, which can be found on $PATH.

    Parameters
    ----------
    oommf_exe: str

        Name of the OOMMF executable. Defaults to ``oommf``.

    """
    def __init__(self, oommf_exe='oommf'):
        self.oommf_exe = oommf_exe

    def _call(self, argstr, need_stderr=False):
        # Here we might need stderr = stdot = None like in
        # TclOOMMFRunner for Windows.  This is not clear because we
        # never use ExeOOMMFRunner on Windows.
github ubermag / oommfc / oommfc / oommf / oommf.py View on Github external
def errors(self):
        try:
            errors_file = os.path.join(
                os.path.dirname(shutil.which(self.oommf_exe)),
                '..', 'opt', 'oommf', 'boxsi.errors')
            with open(errors_file, 'r') as f:
                errors = f.read()
            return errors

        except FileNotFoundError:
            msg = 'boxsi.errors cannot be retrieved.'
            raise EnvironmentError(msg)


@uu.inherit_docs
class DockerOOMMFRunner(OOMMFRunner):
    """OOMMF runner using Docker.

    Parameters
    ----------
    docker_exe: str

        Docker executable. Defaults to ``docker``.

    image: str

        Docker image on DockerHub. Defaults to ``ubermag/oommf``.

    """
    def __init__(self, docker_exe='docker', image='ubermag/oommf'):
        self.docker_exe = docker_exe
        self.image = image
github ubermag / oommfc / oommfc / oommf / oommf.py View on Github external
1. Getting platform.

        >>> import oommfc as oc
        ...
        >>> runner = oc.oommf.get_oommf_runner()
        >>> runner.platform()
        Running OOMMF...
        '...'

        """
        res = self.call(argstr='+platform', need_stderr=True)
        return res.stderr.decode('utf-8')


@uu.inherit_docs
class TclOOMMFRunner(OOMMFRunner):
    """OOMMF runner using path to ``oommf.tcl``.

    Parameters
    ----------
    oommf_tcl: str

        Path to ``oommf.tcl``file.

    """
    def __init__(self, oommf_tcl):
        self.oommf_tcl = oommf_tcl  # a path to oommf.tcl

    def _call(self, argstr, need_stderr=False):
        cmd = ['tclsh', self.oommf_tcl, 'boxsi', '+fg',
               argstr, '-exitondone', '1']