{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 7: Magnetic Properties"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 1, Page number 7-22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "magnetic flux density is 0.628 wb/m**2\n",
      "magnetic moment is -2.0 A/m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "chi=-0.4*10**-5;       #magnetic susceptibility\n",
    "H=5*10**5;             #magnetic field intensity(amp/m)\n",
    "mew0=4*math.pi*10**-7;\n",
    "\n",
    "#Calculation\n",
    "B=mew0*H*(1+chi);       #magnetic flux density(wb/m**2)\n",
    "M=chi*H;                #magnetic moment(A/m)\n",
    "\n",
    "#Result\n",
    "print \"magnetic flux density is\",round(B,3),\"wb/m**2\"\n",
    "print \"magnetic moment is\",M,\"A/m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 2, Page number 7-22"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "magnetisation is -0.25 *10**-2 A/m\n",
      "magnetic flux density is 1.257 *10**-3 wb/m**2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "chi=-0.25*10**-5;       #magnetic susceptibility\n",
    "H=1000;             #magnetic field intensity(amp/m)\n",
    "mew0=4*math.pi*10**-7;\n",
    "\n",
    "#Calculation\n",
    "M=chi*H;                #magnetisation(A/m)\n",
    "B=mew0*(H+M);       #magnetic flux density(wb/m**2)\n",
    "\n",
    "#Result\n",
    "print \"magnetisation is\",M*10**2,\"*10**-2 A/m\"\n",
    "print \"magnetic flux density is\",round(B*10**3,3),\"*10**-3 wb/m**2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 3, Page number 7-23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "magnetisation is 3500 A/m\n",
      "magnetic flux density is 4.71 *10**-3 wb/m**2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "mewr=15;            #relative permeability\n",
    "H=250;              #magnetic field intensity(amp/m)\n",
    "mew0=4*math.pi*10**-7;\n",
    "\n",
    "#Calculation\n",
    "M=H*(mewr-1);       #magnetisation(A/m)\n",
    "B=mew0*(H+M);       #magnetic flux density(wb/m**2)\n",
    "\n",
    "#Result\n",
    "print \"magnetisation is\",M,\"A/m\"\n",
    "print \"magnetic flux density is\",round(B*10**3,2),\"*10**-3 wb/m**2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 4, Page number 7-23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "magnetisation is -0.42 A/m\n",
      "magnetic flux density is 1.2561 *10**-3 wb/m**2\n",
      "answer for flux density in the book varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "chi=-0.42*10**-3;       #magnetic susceptibility\n",
    "H=1000;             #magnetic field intensity(amp/m)\n",
    "mew0=4*math.pi*10**-7;\n",
    "\n",
    "#Calculation\n",
    "M=chi*H;                #magnetisation(A/m)\n",
    "B=mew0*(H+M);       #magnetic flux density(wb/m**2)\n",
    "\n",
    "#Result\n",
    "print \"magnetisation is\",M,\"A/m\"\n",
    "print \"magnetic flux density is\",round(B*10**3,4),\"*10**-3 wb/m**2\"\n",
    "print \"answer for flux density in the book varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 5, Page number 7-23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "magnetic moment is 3.93 *10**-3 A-m**2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "d=0.1;             #diameter(m)\n",
    "i=0.5;             #current(ampere)\n",
    "\n",
    "#Calculation\n",
    "r=d/2;            #radius of atom(m)\n",
    "mew=i*math.pi*r**2;     #magnetic moment(A-m**2)\n",
    "\n",
    "#Result\n",
    "print \"magnetic moment is\",round(mew*10**3,2),\"*10**-3 A-m**2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 6, Page number 7-23"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "magnetising force is 201.4 A/m\n",
      "relative permeability is 17.38\n",
      "answers given in the book are wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "mew0=4*math.pi*10**-7;\n",
    "B=0.0044;       #magnetic flux density(wb/m**2)\n",
    "M=3300;         #magnetisation(A/m)\n",
    "\n",
    "#Calculation\n",
    "H=(B/mew0)-M;   #magnetising force(amp/m)\n",
    "mewr=1+(M/H);   #relative permeability\n",
    "\n",
    "#Result\n",
    "print \"magnetising force is\",round(H,1),\"A/m\"\n",
    "print \"relative permeability is\",round(mewr,2)\n",
    "print \"answers given in the book are wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 7, Page number 7-24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change in magnetic moment is 5.705 *10**-29 A-m**2\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "r=0.52*10**-10;     #radius(m)\n",
    "B=3;     #magnetic induction(web/m**2)\n",
    "e=1.6*10**-19;      #charge(c)\n",
    "m=9.1*10**-31;      #mass(kg)\n",
    "\n",
    "#Calculation\n",
    "d_mew=e**2*r**2*B/(4*m);       #change in magnetic moment(Am**2)\n",
    "\n",
    "#Result\n",
    "print \"change in magnetic moment is\",round(d_mew*10**29,3),\"*10**-29 A-m**2\"\n",
    "print \"answer given in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 8, Page number 7-24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "change in magnetic moment is 3.936 *10**-29 A-m**2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "r=5.29*10**-11;     #radius(m)\n",
    "B=2;     #magnetic induction(web/m**2)\n",
    "e=1.6*10**-19;      #charge(c)\n",
    "m=9.1*10**-31;      #mass(kg)\n",
    "\n",
    "#Calculation\n",
    "d_mew=e**2*r**2*B/(4*m);       #change in magnetic moment(Am**2)\n",
    "\n",
    "#Result\n",
    "print \"change in magnetic moment is\",round(d_mew*10**29,3),\"*10**-29 A-m**2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 9, Page number 7-24"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ssusceptibility at 300K is 3.267 *10**-4\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "chi1=2.8*10**-4;       #susceptibility\n",
    "T1=350;                #temperature(K)\n",
    "T2=300;                #temperature(K)\n",
    "\n",
    "#Calculation\n",
    "chi2=(chi1*T1)/T2;     #susceptibility at 300K\n",
    "\n",
    "#Result\n",
    "print \"susceptibility at 300K is\",round(chi2*10**4,3),\"*10**-4\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 10, Page number 7-25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "relative permeability of iron is 2153.85\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "B0=6.5*10**-4;       #magnetic field(Tesla)\n",
    "B=1.4;               #magnetic field(Tesla)\n",
    "\n",
    "#Calculation\n",
    "mewr=B/B0;           #relative permeability of iron\n",
    "\n",
    "#Result\n",
    "print \"relative permeability of iron is\",round(mewr,2)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}