{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial 06: Driver base class\n", "\n", "> Interactive online tutorial:\n", "> [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ubermag/micromagneticmodel/master?filepath=docs%2Fipynb%2Findex.ipynb)\n", "\n", "In `micromagneticmodel` package, a base class `micromagneticmodel.Driver` is defined. Its purpose is to build individual drivers in a particular micromagnetic calculator. In this tutorial, we will demonstrate some of its basic properties." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import micromagneticmodel as mm\n", "\n", "driver = mm.Driver()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`Driver` class does not require any parameters to be passed at initialisation. However, any keyword argument can be passed." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "driver = mm.Driver(t=1e-9, n=30)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The attributes are" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1e-09" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "driver.t" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "30" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "driver.n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The main driver method which must be implemented by a derived class is `drive`." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Exception raised.\n" ] } ], "source": [ "try:\n", " driver.drive()\n", "except NotImplementedError:\n", " print('Exception raised.')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Other\n", "\n", "Full description of all existing descriptors can be found in the [API Reference](https://micromagneticmodel.readthedocs.io/en/latest/?badge=latest)." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }