{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Carbon Chain (Part 2)\n",
"\n",
"This example demonstrates the calculations of charge current, spin torque, and interfacial spin current for a two-probe carbon chain. Unlike the first example, this device is subject to an electrical bias of 0.1 V.\n",
"\n",
"## Import Necessary Libraries"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import junpy as jp\n",
"from junpy.factory import nanodcal\n",
"from junpy.experiment.extend_center_2 import extend_center\n",
"%config InlineBackend.figure_formats = ['svg']\n",
"%config InlineBackend.rc = {'font.size': 12}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load Device\n",
"\n",
"In order to observe the variation of the spin torque and interfacial spin current beyond the central region, we can include the electrode atoms into the central region using the `extend_center` function. `repeatL` and `repeatR` specify the repetition multiples of the left and right electrodes, respectively."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"filename = (\n",
" 'jpdataset/nanodcal/twoprobe_carbon_chain/'\n",
" 'LDA_NC_dC-3.0-ang/sys_6C-vac5ang-6C_zx0-zx90/v0.10/NanodcalStructObject.mat')\n",
"device = nanodcal.load_nanodcal_device(filename)\n",
"device_ext = extend_center(device, repeatL=3, repeatR=3)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Calculate Charge Current\n",
"\n",
"We first calculate the charge current using the Landau's formula. `jp.BiasWindow(interval=0.005)` specifies that the energy integral is in the bias window and the interval is `0.005`."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"tags": [
"hide-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"JunPy version---------------------------: 0.15.0.post29+ga5b3260\n",
"Parallelization information\n",
" BLAS Vendor-----------------------------: MKL\n",
" Total number of MPI processes-----------: 1\n",
" OMP_NUM_THREADS-------------------------: 1\n",
" MKL_NUM_THREADS-------------------------: unset\n",
" OPENBLAS_NUM_THREADS--------------------: unset\n",
"Calculating current... (2024-08-15 20:30:08)\n",
" Device information\n",
" bias (mu2-mu1)--------------------------: 0.10000001031619467\n",
" central.numberOfSites-------------------: 12\n",
" central.spinType------------------------: SpinType.GeneralSpin\n",
" lead1.numberOfSites---------------------: 3\n",
" lead1.spinType--------------------------: SpinType.GeneralSpin\n",
" lead1.direction-------------------------: -3\n",
" lead1.temperature-----------------------: 0.0\n",
" lead1.chemicalPotential-----------------: -0.0\n",
" lead2.numberOfSites---------------------: 3\n",
" lead2.spinType--------------------------: SpinType.GeneralSpin\n",
" lead2.direction-------------------------: -3\n",
" lead2.temperature-----------------------: 0.0\n",
" lead2.chemicalPotential-----------------: 0.10000001031619467\n",
" Energy sampling\n",
" samplingName----------------------------: CustomSampling\n",
" range-----------------------------------: [0.0000e+00, 1.0000e-01]\n",
" number----------------------------------: 21\n",
" K-space sampling\n",
" samplingName----------------------------: GammaKspaceSampling\n",
" numReducedKpoints-----------------------: 1\n",
" Runtime message\n",
" Integrate over energy and k-space...\n",
" Start MPI execution...\n",
" --> 9.5% finished (Elapsed time: 0:00:00.228234)\n",
" --> 14.3% finished (Elapsed time: 0:00:00.109371)\n",
" --> 19.0% finished (Elapsed time: 0:00:00.106565)\n",
" --> 23.8% finished (Elapsed time: 0:00:00.109306)\n",
" --> 28.6% finished (Elapsed time: 0:00:00.106735)\n",
" --> 33.3% finished (Elapsed time: 0:00:00.109937)\n",
" --> 38.1% finished (Elapsed time: 0:00:00.111408)\n",
" --> 42.9% finished (Elapsed time: 0:00:00.114061)\n",
" --> 47.6% finished (Elapsed time: 0:00:00.137588)\n",
" --> 52.4% finished (Elapsed time: 0:00:00.116131)\n",
" --> 57.1% finished (Elapsed time: 0:00:00.120204)\n",
" --> 61.9% finished (Elapsed time: 0:00:00.121313)\n",
" --> 66.7% finished (Elapsed time: 0:00:00.116271)\n",
" --> 71.4% finished (Elapsed time: 0:00:00.117937)\n",
" --> 76.2% finished (Elapsed time: 0:00:00.126648)\n",
" --> 81.0% finished (Elapsed time: 0:00:00.111192)\n",
" --> 85.7% finished (Elapsed time: 0:00:00.111798)\n",
" --> 90.5% finished (Elapsed time: 0:00:00.119536)\n",
" --> 95.2% finished (Elapsed time: 0:00:00.117534)\n",
" --> 100.0% finished (Elapsed time: 0:00:00.114353)\n",
" Wait for other processes...\n",
" --> finished (Elapsed time: 0:00:00.000057)\n",
" Gather results from other processes...\n",
" --> finished (Elapsed time: 0:00:00.000071)\n",
" Transmission report\n",
" Energy_eV T_up-up T_dn-dn T_Re-up-dn T_Im-up-dn\n",
" 0.000000e+00 5.125604e-03 5.155845e-03 5.125587e-03 5.870280e-07\n",
" 5.000000e-03 5.168260e-03 5.199103e-03 5.168243e-03 2.792357e-07\n",
" 1.000000e-02 5.177481e-03 5.208924e-03 5.177463e-03 -4.197218e-08\n",
" 1.500000e-02 5.153973e-03 5.186013e-03 5.153955e-03 -3.766792e-07\n",
" 2.000000e-02 5.103020e-03 5.135655e-03 5.103002e-03 -7.248664e-07\n",
" 2.500000e-02 5.033139e-03 5.066364e-03 5.033122e-03 -1.086472e-06\n",
" 3.000000e-02 4.953992e-03 4.987802e-03 4.953974e-03 -1.461457e-06\n",
" 3.500000e-02 4.874493e-03 4.908883e-03 4.874476e-03 -1.849847e-06\n",
" 4.000000e-02 4.801748e-03 4.836712e-03 4.801731e-03 -2.251742e-06\n",
" 4.500000e-02 4.740657e-03 4.776187e-03 4.740640e-03 -2.667317e-06\n",
" 5.000000e-02 4.694354e-03 4.730444e-03 4.694337e-03 -3.096793e-06\n",
" 5.500000e-02 4.664560e-03 4.701202e-03 4.664543e-03 -3.540424e-06\n",
" 6.000000e-02 4.652075e-03 4.689260e-03 4.652058e-03 -3.998476e-06\n",
" 6.500000e-02 4.657063e-03 4.694781e-03 4.657046e-03 -4.471221e-06\n",
" 7.000000e-02 4.679121e-03 4.717362e-03 4.679104e-03 -4.958921e-06\n",
" 7.500000e-02 4.717060e-03 4.755813e-03 4.717043e-03 -5.461822e-06\n",
" 8.000000e-02 4.768320e-03 4.807572e-03 4.768303e-03 -5.980142e-06\n",
" 8.500000e-02 4.827857e-03 4.867596e-03 4.827840e-03 -6.514042e-06\n",
" 9.000000e-02 4.886376e-03 4.926586e-03 4.886358e-03 -7.063593e-06\n",
" 9.500000e-02 4.927877e-03 4.968544e-03 4.927859e-03 -7.628725e-06\n",
" 1.000000e-01 4.927375e-03 4.968483e-03 4.927357e-03 -8.209163e-06\n",
" Current report\n",
" Bias[V] I_tot[A] I_up[A] I_dn[A] I_s[A] I_sp[%]\n",
" 1.000000e-01 3.791430e-08 1.888751e-08 1.902679e-08 -1.392818e-10 -3.673596e-01\n",
"Calculation of current finished (2024-08-15 20:30:11)\n",
"Elapsed time----------------------------: 0:00:02.463467\n"
]
}
],
"source": [
"calcr = jp.Current(\n",
" device=device,\n",
" energies=jp.BiasWindow(interval=0.005),\n",
" etaSigma=1e-6,\n",
" etaGF=0)\n",
"jp.run(calcr, savefile=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `[calcr].current` function returns the calculated value."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The charge current is [3.79142962e-08] ampere.\n"
]
}
],
"source": [
"current = calcr.current(spin=\"sum\")\n",
"print(f'The charge current is {current} ampere.')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Calculate Spin Torque\n",
"\n",
"We use the `jp.SpinTorque` class to build a calculation for spin torque. `nonequilibriumEnergies` specifies the energy sampling for integrating the real-axis energy for the Green's function. `equilibriumEnergies` specifies the energy sampling for integrating the complex contour energy for the Green's function. `circlePoints` is the number of points, and `lowestEnergy` is the starting point for the lowest energy. `spinAccumulationDetail` specifies whether to compute the spin accumulation or not."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"tags": [
"hide-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"JunPy version---------------------------: 0.15.0.post29+ga5b3260\n",
"Parallelization information\n",
" BLAS Vendor-----------------------------: MKL\n",
" Total number of MPI processes-----------: 1\n",
" OMP_NUM_THREADS-------------------------: 1\n",
" MKL_NUM_THREADS-------------------------: unset\n",
" OPENBLAS_NUM_THREADS--------------------: unset\n",
"Calculating spin torque... (2024-08-15 20:30:17)\n",
" Device information\n",
" bias (mu2-mu1)--------------------------: 0.10000001031619467\n",
" central.numberOfSites-------------------: 30\n",
" central.spinType------------------------: SpinType.GeneralSpin\n",
" lead1.numberOfSites---------------------: 3\n",
" lead1.spinType--------------------------: SpinType.GeneralSpin\n",
" lead1.direction-------------------------: -3\n",
" lead1.temperature-----------------------: 0.0\n",
" lead1.chemicalPotential-----------------: -0.0\n",
" lead2.numberOfSites---------------------: 3\n",
" lead2.spinType--------------------------: SpinType.GeneralSpin\n",
" lead2.direction-------------------------: 3\n",
" lead2.temperature-----------------------: 0.0\n",
" lead2.chemicalPotential-----------------: 0.10000001031619467\n",
" Energy sampling (equilibrium)\n",
" samplingName----------------------------: SemiCircleContourEnergySampling\n",
" range-----------------------------------: [-3.0000e+01+7.3317e-02j, 4.9821e-02+7.3317e-02j]\n",
" number----------------------------------: 30\n",
" temperature-----------------------------: 0.0\n",
" chemicalPotential-----------------------: 0.050000005158097334\n",
" circlePoints----------------------------: 30\n",
" lowestEnergy----------------------------: -30\n",
" Energy sampling (non-equilibrium)\n",
" samplingName----------------------------: CustomSampling\n",
" range-----------------------------------: [0.0000e+00, 1.0000e-01]\n",
" number----------------------------------: 21\n",
" K-space sampling\n",
" samplingName----------------------------: GammaKspaceSampling\n",
" numReducedKpoints-----------------------: 1\n",
" Runtime message\n",
" Integrate over energy and k-space...\n",
" Start MPI execution...\n",
" --> 6.7% finished (Elapsed time: 0:00:03.509986)\n",
" --> 13.3% finished (Elapsed time: 0:00:03.485396)\n",
" --> 20.0% finished (Elapsed time: 0:00:03.381314)\n",
" --> 26.7% finished (Elapsed time: 0:00:03.340263)\n",
" --> 33.3% finished (Elapsed time: 0:00:03.272934)\n",
" --> 40.0% finished (Elapsed time: 0:00:03.311562)\n",
" --> 46.7% finished (Elapsed time: 0:00:03.324781)\n",
" --> 53.3% finished (Elapsed time: 0:00:03.312329)\n",
" --> 60.0% finished (Elapsed time: 0:00:03.297522)\n",
" --> 66.7% finished (Elapsed time: 0:00:03.231385)\n",
" --> 70.0% finished (Elapsed time: 0:00:01.634883)\n",
" --> 73.3% finished (Elapsed time: 0:00:01.609632)\n",
" --> 76.7% finished (Elapsed time: 0:00:01.619557)\n",
" --> 80.0% finished (Elapsed time: 0:00:01.621894)\n",
" --> 83.3% finished (Elapsed time: 0:00:01.684925)\n",
" --> 86.7% finished (Elapsed time: 0:00:01.621701)\n",
" --> 90.0% finished (Elapsed time: 0:00:01.623025)\n",
" --> 93.3% finished (Elapsed time: 0:00:01.670311)\n",
" --> 96.7% finished (Elapsed time: 0:00:01.610550)\n",
" --> 100.0% finished (Elapsed time: 0:00:01.606518)\n",
" Wait for other processes...\n",
" --> finished (Elapsed time: 0:00:00.000006)\n",
" Gather results from other processes...\n",
" --> finished (Elapsed time: 0:00:00.000104)\n",
" Integrate over energy and k-space...\n",
" Start MPI execution...\n",
" --> 9.5% finished (Elapsed time: 0:00:03.526256)\n",
" --> 14.3% finished (Elapsed time: 0:00:01.806523)\n",
" --> 19.0% finished (Elapsed time: 0:00:01.749344)\n",
" --> 23.8% finished (Elapsed time: 0:00:01.746309)\n",
" --> 28.6% finished (Elapsed time: 0:00:01.757293)\n",
" --> 33.3% finished (Elapsed time: 0:00:01.760958)\n",
" --> 38.1% finished (Elapsed time: 0:00:01.754006)\n",
" --> 42.9% finished (Elapsed time: 0:00:01.828860)\n",
" --> 47.6% finished (Elapsed time: 0:00:01.799265)\n",
" --> 52.4% finished (Elapsed time: 0:00:01.826866)\n",
" --> 57.1% finished (Elapsed time: 0:00:01.796251)\n",
" --> 61.9% finished (Elapsed time: 0:00:01.931762)\n",
" --> 66.7% finished (Elapsed time: 0:00:01.980609)\n",
" --> 71.4% finished (Elapsed time: 0:00:01.833493)\n",
" --> 76.2% finished (Elapsed time: 0:00:02.077866)\n",
" --> 81.0% finished (Elapsed time: 0:00:01.868748)\n",
" --> 85.7% finished (Elapsed time: 0:00:01.795185)\n",
" --> 90.5% finished (Elapsed time: 0:00:01.882095)\n",
" --> 95.2% finished (Elapsed time: 0:00:01.828351)\n",
" --> 100.0% finished (Elapsed time: 0:00:01.782389)\n",
" Wait for other processes...\n",
" --> finished (Elapsed time: 0:00:00.000021)\n",
" Gather results from other processes...\n",
" --> finished (Elapsed time: 0:00:00.000098)\n",
" Report of the spin accumulation (Hamiltonian = H)\n",
" Site Ax_eV Ay_eV Az_eV\n",
" 0.000000e+00 2.391885e-10 -7.026460e-10 1.629750e-02\n",
" 1.000000e+00 -2.836272e-09 -2.179475e-09 -1.671807e-02\n",
" 2.000000e+00 4.118441e-09 9.829391e-09 4.697895e-04\n",
" 3.000000e+00 1.159065e-08 6.948219e-09 2.901698e-05\n",
" 4.000000e+00 -3.516658e-08 -7.322370e-08 -1.246392e-06\n",
" 5.000000e+00 -3.264152e-08 1.540051e-08 -1.772569e-07\n",
" 6.000000e+00 2.525382e-07 5.097357e-07 4.042458e-08\n",
" 7.000000e+00 -9.355308e-08 -6.991133e-07 1.133889e-09\n",
" 8.000000e+00 -1.694422e-06 -3.231379e-06 -1.555806e-09\n",
" 9.000000e+00 2.215984e-06 6.009934e-06 3.682049e-10\n",
" 1.000000e+01 5.445955e-06 1.254568e-05 -9.172095e-11\n",
" 1.100000e+01 -8.368109e-06 -2.281097e-05 -2.218483e-10\n",
" 1.200000e+01 -2.192596e-05 -5.769606e-05 -1.193909e-09\n",
" 1.300000e+01 3.141844e-05 7.138241e-05 -4.728251e-09\n",
" 1.400000e+01 6.940915e-05 1.611806e-04 -2.494360e-07\n",
" 1.500000e+01 2.445917e-07 -1.560270e-04 -6.818500e-05\n",
" 1.600000e+01 6.256708e-09 -7.588276e-05 -3.145995e-05\n",
" 1.700000e+01 1.165871e-09 5.219711e-05 1.951402e-05\n",
" 1.800000e+01 3.661119e-10 2.726874e-05 9.048806e-06\n",
" 1.900000e+01 1.037239e-10 -1.131641e-05 -4.704706e-06\n",
" 2.000000e+01 -7.983134e-10 -6.642211e-06 -2.171086e-06\n",
" 2.100000e+01 2.470659e-09 2.656863e-06 1.306189e-06\n",
" 2.200000e+01 3.708007e-09 1.125140e-06 2.496813e-07\n",
" 2.300000e+01 -3.855253e-08 -5.336990e-07 -2.256748e-07\n",
" 2.400000e+01 1.020493e-07 -6.952084e-08 -2.963345e-09\n",
" 2.500000e+01 -1.795353e-06 8.784957e-08 3.642886e-08\n",
" 2.600000e+01 3.277303e-05 -1.797359e-10 -3.976666e-09\n",
" 2.700000e+01 4.139673e-04 -1.383013e-08 -5.682770e-09\n",
" 2.800000e+01 -1.800594e-02 1.570455e-09 1.319261e-09\n",
" 2.900000e+01 1.748407e-02 1.468057e-09 4.787378e-10\n",
" Report of the spin torque (Hamiltonian = Hxc)\n",
" Site Tx_eV Ty_eV Tz_eV\n",
" 0.000000e+00 3.269584e-10 1.223634e-09 -1.324897e-55\n",
" 1.000000e+00 2.785171e-09 2.166280e-09 -1.257245e-56\n",
" 2.000000e+00 -4.123942e-09 -9.813811e-09 5.993176e-55\n",
" 3.000000e+00 -1.159091e-08 -6.942518e-09 -7.645471e-56\n",
" 4.000000e+00 3.516636e-08 7.322534e-08 -4.216161e-54\n",
" 5.000000e+00 3.264148e-08 -1.539991e-08 3.151663e-54\n",
" 6.000000e+00 -2.525382e-07 -5.097355e-07 3.949711e-53\n",
" 7.000000e+00 9.355309e-08 6.991135e-07 -6.324194e-52\n",
" 8.000000e+00 1.694423e-06 3.231379e-06 -9.014559e-13\n",
" 9.000000e+00 -2.215984e-06 -6.009935e-06 1.441766e-11\n",
" 1.000000e+01 -5.445954e-06 -1.254568e-05 2.673385e-11\n",
" 1.100000e+01 8.368109e-06 2.281097e-05 2.245092e-10\n",
" 1.200000e+01 2.192596e-05 5.769606e-05 1.195948e-09\n",
" 1.300000e+01 -3.141844e-05 -7.138241e-05 4.727459e-09\n",
" 1.400000e+01 -6.940915e-05 -1.611806e-04 2.494362e-07\n",
" 1.500000e+01 -2.445916e-07 1.560270e-04 6.818500e-05\n",
" 1.600000e+01 -6.255845e-09 7.588276e-05 3.145995e-05\n",
" 1.700000e+01 -1.175754e-09 -5.219711e-05 -1.951402e-05\n",
" 1.800000e+01 -3.346235e-10 -2.726874e-05 -9.048806e-06\n",
" 1.900000e+01 -3.892913e-11 1.131641e-05 4.704706e-06\n",
" 2.000000e+01 -1.767191e-11 6.642212e-06 2.171086e-06\n",
" 2.100000e+01 9.832168e-13 -2.656864e-06 -1.306189e-06\n",
" 2.200000e+01 -1.226281e-19 -1.125140e-06 -2.496813e-07\n",
" 2.300000e+01 1.219638e-19 5.336987e-07 2.256747e-07\n",
" 2.400000e+01 1.818635e-21 6.952008e-08 2.963127e-09\n",
" 2.500000e+01 -1.892528e-20 -8.785165e-08 -3.642946e-08\n",
" 2.600000e+01 2.226064e-21 1.724682e-10 3.974142e-09\n",
" 2.700000e+01 2.499830e-21 1.380589e-08 5.675230e-09\n",
" 2.800000e+01 -7.099308e-22 -1.569675e-09 -1.304434e-09\n",
" 2.900000e+01 -4.567913e-22 -2.116465e-09 -8.689176e-10\n",
" Report of the spin torque (Hamiltonian = Hso)\n",
" Site Tx_eV Ty_eV Tz_eV\n",
" 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 3.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 4.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 5.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 6.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 7.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 8.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 9.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.000000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.100000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.200000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.300000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.400000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.500000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.600000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.700000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.800000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 1.900000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.000000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.100000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.200000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.300000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.400000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.500000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.600000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.700000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.800000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
" 2.900000e+01 0.000000e+00 0.000000e+00 0.000000e+00\n",
"Calculation of spin torque finished (2024-08-15 20:31:46)\n",
"Elapsed time----------------------------: 0:01:28.597522\n"
]
}
],
"source": [
"calcr_st = jp.SpinTorque(\n",
" device=device_ext,\n",
" nonequilibriumEnergies=jp.BiasWindow(interval=0.005),\n",
" equilibriumEnergies=dict(\n",
" circlePoints=30,\n",
" lowestEnergy=-30),\n",
" spinAccumulationDetail=True)\n",
"jp.run(calcr_st, savefile=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this example, we have 30 atoms in the extended central region. We create an array `sites` to label them:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"sites = np.arange(0, 30)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `[calcr].spin_torque` function returns the computed spin torque values. The `hamiltonian` parameter specifies the Hamiltonian used for computing the spin torque. Possible values are `'full'` (default), `'H0'`, `'Hxc'`, and `'Hso'`. Note that `'Hxc'` and `'Hso'` correspond to the exchange spin torque ($T^\\mathrm{XC}$) and spin-orbit torque ($T^\\mathrm{SO}$), respectively."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# shape: (#kpoints, #energies, #sites, #spin)\n",
"st = calcr_st.spin_torque(hamiltonian='Hxc')\n",
"# shape: (#sites, #spin)\n",
"st = st[0,0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We exclude the boundary atoms using `[3:-3]` to remove the uncalculated boundary results:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(sites[3:-3], st[3:-3,0]*1e3, '.-', label='Txc_x')\n",
"plt.plot(sites[3:-3], st[3:-3,1]*1e3, '.-', label='Txc_y')\n",
"plt.plot(sites[3:-3], st[3:-3,2]*1e3, '.-', label='Txc_z')\n",
"plt.xlabel('Site (#)')\n",
"plt.ylabel('Spin torque (meV)')\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `[calcr].spin_accumulation` function is used to retrieve the computed spin accumulation values ($\\Phi$)."
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# shape: (#kpoints, #energies, #sites, #spin)\n",
"sa = calcr_st.spin_accumulation()\n",
"# shape: (#sites, #spin)\n",
"sa = sa[0,0]\n",
"\n",
"plt.plot(sites[3:-3], sa[3:-3,0]*1e3, '.-', label='$\\Phi$x')\n",
"plt.plot(sites[3:-3], sa[3:-3,1]*1e3, '.-', label='$\\Phi$y')\n",
"plt.plot(sites[3:-3], sa[3:-3,2]*1e3, '.-', label='$\\Phi$z')\n",
"plt.xlabel('Site (#)')\n",
"plt.ylabel('Spin accumulation (meV)')\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Calculate Interfacial Spin Current\n",
"\n",
"For comparison, we also compute the interfacial spin current using the `jp.SpinCurrent` class."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"tags": [
"hide-output"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"JunPy version---------------------------: 0.15.0.post29+ga5b3260\n",
"Parallelization information\n",
" BLAS Vendor-----------------------------: MKL\n",
" Total number of MPI processes-----------: 1\n",
" OMP_NUM_THREADS-------------------------: 1\n",
" MKL_NUM_THREADS-------------------------: unset\n",
" OPENBLAS_NUM_THREADS--------------------: unset\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Calculating spin current... (2024-08-15 20:38:09)\n",
" Device information\n",
" bias (mu2-mu1)--------------------------: 0.10000001031619467\n",
" central.numberOfSites-------------------: 30\n",
" central.spinType------------------------: SpinType.GeneralSpin\n",
" lead1.numberOfSites---------------------: 3\n",
" lead1.spinType--------------------------: SpinType.GeneralSpin\n",
" lead1.direction-------------------------: -3\n",
" lead1.temperature-----------------------: 0.0\n",
" lead1.chemicalPotential-----------------: -0.0\n",
" lead2.numberOfSites---------------------: 3\n",
" lead2.spinType--------------------------: SpinType.GeneralSpin\n",
" lead2.direction-------------------------: 3\n",
" lead2.temperature-----------------------: 0.0\n",
" lead2.chemicalPotential-----------------: 0.10000001031619467\n",
" Energy sampling (equilibrium)\n",
" samplingName----------------------------: SemiCircleContourEnergySampling\n",
" range-----------------------------------: [-3.0000e+01+7.3317e-02j, 4.9821e-02+7.3317e-02j]\n",
" number----------------------------------: 30\n",
" temperature-----------------------------: 0.0\n",
" chemicalPotential-----------------------: 0.050000005158097334\n",
" circlePoints----------------------------: 30\n",
" lowestEnergy----------------------------: -30\n",
" Energy sampling (non-equilibrium)\n",
" samplingName----------------------------: CustomSampling\n",
" range-----------------------------------: [0.0000e+00, 1.0000e-01]\n",
" number----------------------------------: 21\n",
" K-space sampling\n",
" samplingName----------------------------: GammaKspaceSampling\n",
" numReducedKpoints-----------------------: 1\n",
" Runtime message\n",
" Integrate over energy and k-space...\n",
" Start MPI execution...\n",
" --> 6.7% finished (Elapsed time: 0:00:01.713761)\n",
" --> 13.3% finished (Elapsed time: 0:00:01.681413)\n",
" --> 20.0% finished (Elapsed time: 0:00:01.666176)\n",
" --> 26.7% finished (Elapsed time: 0:00:01.703826)\n",
" --> 33.3% finished (Elapsed time: 0:00:01.640098)\n",
" --> 40.0% finished (Elapsed time: 0:00:01.701506)\n",
" --> 46.7% finished (Elapsed time: 0:00:01.668116)\n",
" --> 53.3% finished (Elapsed time: 0:00:01.661861)\n",
" --> 60.0% finished (Elapsed time: 0:00:01.669353)\n",
" --> 66.7% finished (Elapsed time: 0:00:01.700550)\n",
" --> 70.0% finished (Elapsed time: 0:00:00.787154)\n",
" --> 73.3% finished (Elapsed time: 0:00:00.786871)\n",
" --> 76.7% finished (Elapsed time: 0:00:00.775879)\n",
" --> 80.0% finished (Elapsed time: 0:00:00.811188)\n",
" --> 83.3% finished (Elapsed time: 0:00:00.822507)\n",
" --> 86.7% finished (Elapsed time: 0:00:00.823056)\n",
" --> 90.0% finished (Elapsed time: 0:00:00.829303)\n",
" --> 93.3% finished (Elapsed time: 0:00:00.829970)\n",
" --> 96.7% finished (Elapsed time: 0:00:00.836421)\n",
" --> 100.0% finished (Elapsed time: 0:00:00.872034)\n",
" Wait for other processes...\n",
" --> finished (Elapsed time: 0:00:00.000024)\n",
" Gather results from other processes...\n",
" --> finished (Elapsed time: 0:00:00.007837)\n",
" Integrate over energy and k-space...\n",
" Start MPI execution...\n",
" --> 9.5% finished (Elapsed time: 0:00:01.974358)\n",
" --> 14.3% finished (Elapsed time: 0:00:00.994233)\n",
" --> 19.0% finished (Elapsed time: 0:00:00.979632)\n",
" --> 23.8% finished (Elapsed time: 0:00:00.976806)\n",
" --> 28.6% finished (Elapsed time: 0:00:00.980045)\n",
" --> 33.3% finished (Elapsed time: 0:00:00.990213)\n",
" --> 38.1% finished (Elapsed time: 0:00:00.980436)\n",
" --> 42.9% finished (Elapsed time: 0:00:00.976911)\n",
" --> 47.6% finished (Elapsed time: 0:00:00.979780)\n",
" --> 52.4% finished (Elapsed time: 0:00:00.979087)\n",
" --> 57.1% finished (Elapsed time: 0:00:00.976780)\n",
" --> 61.9% finished (Elapsed time: 0:00:01.039201)\n",
" --> 66.7% finished (Elapsed time: 0:00:00.977404)\n",
" --> 71.4% finished (Elapsed time: 0:00:00.977939)\n",
" --> 76.2% finished (Elapsed time: 0:00:00.978536)\n",
" --> 81.0% finished (Elapsed time: 0:00:00.986795)\n",
" --> 85.7% finished (Elapsed time: 0:00:00.974766)\n",
" --> 90.5% finished (Elapsed time: 0:00:00.987233)\n",
" --> 95.2% finished (Elapsed time: 0:00:00.979331)\n",
" --> 100.0% finished (Elapsed time: 0:00:00.979152)\n",
" Wait for other processes...\n",
" --> finished (Elapsed time: 0:00:00.000012)\n",
" Gather results from other processes...\n",
" --> finished (Elapsed time: 0:00:00.009382)\n",
" Report of the intra-atomic spin current accumulation\n",
" Site A0_intra_eV Ax_intra_eV Ay_intra_eV Az_intra_eV\n",
" 0.000000e+00 9.497611e-17 -1.439967e-27 -4.761170e-26 1.517883e-17\n",
" 1.000000e+00 -1.439532e-18 6.602011e-26 6.019083e-26 7.951522e-20\n",
" 2.000000e+00 -1.047351e-19 -9.094378e-26 -9.527625e-26 -1.004776e-20\n",
" 3.000000e+00 1.001354e-21 4.256611e-26 1.862764e-26 1.414944e-21\n",
" 4.000000e+00 -6.349936e-22 7.181482e-25 -6.966878e-25 7.961581e-22\n",
" 5.000000e+00 8.885729e-26 1.253659e-25 4.422670e-25 -2.430610e-23\n",
" 6.000000e+00 2.895082e-24 -2.007251e-24 7.347041e-24 2.056567e-24\n",
" 7.000000e+00 1.428565e-24 1.306155e-24 -1.526988e-24 -2.773661e-24\n",
" 8.000000e+00 -1.690550e-23 3.034477e-23 5.394769e-23 5.557620e-24\n",
" 9.000000e+00 1.137373e-24 8.575940e-24 7.837859e-23 -8.065011e-24\n",
" 1.000000e+01 2.773640e-23 1.062410e-22 -1.556909e-22 4.213451e-24\n",
" 1.100000e+01 -2.982051e-23 -8.116710e-24 -2.998530e-24 -3.317124e-23\n",
" 1.200000e+01 -1.257315e-22 -4.113156e-22 1.100977e-21 1.406207e-22\n",
" 1.300000e+01 -1.819797e-21 -5.012715e-22 7.385069e-21 -1.058791e-22\n",
" 1.400000e+01 3.388132e-21 -4.870439e-21 2.541099e-21 -3.811648e-21\n",
" 1.500000e+01 -3.176374e-21 -3.176374e-21 2.541109e-21 5.717472e-21\n",
" 1.600000e+01 -8.007108e-22 9.264423e-23 6.220462e-22 -1.968690e-22\n",
" 1.700000e+01 -1.159707e-21 1.579915e-22 1.049696e-21 9.802090e-22\n",
" 1.800000e+01 -2.305766e-23 2.838263e-23 3.207374e-22 1.000372e-23\n",
" 1.900000e+01 -5.893662e-24 5.014782e-24 1.912843e-22 -1.487633e-23\n",
" 2.000000e+01 -8.375204e-24 9.822770e-24 2.613797e-23 -2.985605e-23\n",
" 2.100000e+01 2.347125e-23 1.386820e-23 -2.245020e-23 -1.368725e-23\n",
" 2.200000e+01 -3.709250e-25 -8.239982e-25 5.641294e-25 -1.129269e-23\n",
" 2.300000e+01 -2.448624e-25 1.672612e-24 -4.979871e-24 -2.134205e-24\n",
" 2.400000e+01 8.229801e-24 8.211222e-25 2.421712e-24 -5.315009e-26\n",
" 2.500000e+01 2.583001e-23 3.915149e-22 1.730736e-24 7.056834e-25\n",
" 2.600000e+01 2.568913e-21 8.360211e-22 1.327838e-26 -2.261822e-26\n",
" 2.700000e+01 1.766072e-20 -1.159577e-19 -1.714033e-25 1.033319e-33\n",
" 2.800000e+01 -1.074885e-18 5.283368e-20 4.623434e-26 -9.309110e-34\n",
" 2.900000e+01 -8.326673e-17 -2.818926e-18 -1.234095e-26 -5.617810e-33\n",
" Report of the inter-atomic spin current accumulation\n",
" Site A0_inter_eV Ax_inter_eV Ay_inter_eV Az_inter_eV\n",
" 0.000000e+00 3.309805e-02 2.391885e-10 -7.026460e-10 1.629750e-02\n",
" 1.000000e+00 -3.299830e-02 -2.836272e-09 -2.179475e-09 -1.671807e-02\n",
" 2.000000e+00 -3.247305e-05 4.118441e-09 9.829391e-09 4.697895e-04\n",
" 3.000000e+00 1.166710e-05 1.159065e-08 6.948219e-09 2.901698e-05\n",
" 4.000000e+00 -1.915138e-06 -3.516658e-08 -7.322370e-08 -1.246392e-06\n",
" 5.000000e+00 -2.031594e-07 -3.264152e-08 1.540051e-08 -1.772569e-07\n",
" 6.000000e+00 3.946354e-08 2.525382e-07 5.097357e-07 4.042459e-08\n",
" 7.000000e+00 1.102399e-09 -9.355308e-08 -6.991133e-07 1.133891e-09\n",
" 8.000000e+00 -1.557392e-09 -1.694422e-06 -3.231379e-06 -1.555806e-09\n",
" 9.000000e+00 3.826318e-10 2.215984e-06 6.009934e-06 3.682017e-10\n",
" 1.000000e+01 -6.498934e-11 5.445955e-06 1.254568e-05 -9.172633e-11\n",
" 1.100000e+01 2.660680e-12 -8.368109e-06 -2.281097e-05 -2.218487e-10\n",
" 1.200000e+01 2.040275e-12 -2.192596e-05 -5.769606e-05 -1.193908e-09\n",
" 1.300000e+01 -7.924081e-13 3.141844e-05 7.138241e-05 -4.728251e-09\n",
" 1.400000e+01 1.665564e-13 6.940915e-05 1.611806e-04 -2.494360e-07\n",
" 1.500000e+01 2.178072e-14 2.445917e-07 -1.560270e-04 -6.818500e-05\n",
" 1.600000e+01 8.634398e-13 6.256708e-09 -7.588276e-05 -3.145995e-05\n",
" 1.700000e+01 -9.883084e-12 1.165871e-09 5.219711e-05 1.951402e-05\n",
" 1.800000e+01 3.148942e-11 3.661123e-10 2.726874e-05 9.048806e-06\n",
" 1.900000e+01 6.480213e-11 1.037237e-10 -1.131641e-05 -4.704706e-06\n",
" 2.000000e+01 -8.159100e-10 -7.983134e-10 -6.642211e-06 -2.171086e-06\n",
" 2.100000e+01 2.471897e-09 2.470660e-09 2.656863e-06 1.306189e-06\n",
" 2.200000e+01 3.692503e-09 3.708007e-09 1.125140e-06 2.496813e-07\n",
" 2.300000e+01 -3.921867e-08 -3.855253e-08 -5.336990e-07 -2.256748e-07\n",
" 2.400000e+01 8.183146e-08 1.020493e-07 -6.952084e-08 -2.963342e-09\n",
" 2.500000e+01 -2.351105e-06 -1.795353e-06 8.784957e-08 3.642885e-08\n",
" 2.600000e+01 1.777699e-05 3.277303e-05 -1.797358e-10 -3.976661e-09\n",
" 2.700000e+01 -3.198684e-05 4.139673e-04 -1.383013e-08 -5.682770e-09\n",
" 2.800000e+01 -3.261158e-02 -1.800594e-02 1.570455e-09 1.319258e-09\n",
" 2.900000e+01 3.255123e-02 1.748407e-02 1.468057e-09 4.787358e-10\n",
"Calculation of spin current finished (2024-08-15 20:38:55)\n",
"Elapsed time----------------------------: 0:00:45.843087\n"
]
}
],
"source": [
"calcr_sc = jp.SpinCurrent(\n",
" device=device_ext,\n",
" nonequilibriumEnergies=jp.BiasWindow(interval=0.005),\n",
" equilibriumEnergies=dict(\n",
" circlePoints=30,\n",
" lowestEnergy=-30))\n",
"jp.run(calcr_sc, savefile=False)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Given that the central region consists of 30 atoms aligned along the $z$ axis, there are 29 interfaces. The `[calcr].interfacial_spin_current` function returns the electron current in units of eV. The spin currents, `Qx`, `Qy`, and `Qz`, correspond to the projections onto the Pauli matrices $\\sigma_x$, $\\sigma_y$, and $\\sigma_z$, respectively. `Q0` represents the total current, obtained by summing the spin-up and spin-down components, which is equivalent to projecting onto $\\sigma_0$."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# #interfaces = #sites - 1\n",
"interfaces = np.arange(0, 29)\n",
"# shape: (#interfaces, #spin)\n",
"isc = calcr_sc.interfacial_spin_current()\n",
"\n",
"plt.plot(interfaces[3:-3], isc[3:-3,1]*1e3, '.-', label='Qx')\n",
"plt.plot(interfaces[3:-3], isc[3:-3,2]*1e3, '.-', label='Qy')\n",
"plt.plot(interfaces[3:-3], isc[3:-3,3]*1e3, '.-', label='Qz')\n",
"plt.plot(interfaces[3:-3], isc[3:-3,0]*1e3, '.-', label='Q0')\n",
"plt.xlabel('Interface (#)')\n",
"plt.ylabel('Interfacial spin current (meV)')\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We also convert the electron current to the charge current in units of amperes by multiplying by $-2e/\\hbar$. Note that the almost constant value of charge (`I0=3.74e-8`) is close to the value calculated by `jp.Current`."
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"isc2 = isc*(-1*jp.util.E2OVERHBAR)\n",
"plt.plot(interfaces[3:-3], isc2[3:-3,1], '.-', label='Ix')\n",
"plt.plot(interfaces[3:-3], isc2[3:-3,2], '.-', label='Iy')\n",
"plt.plot(interfaces[3:-3], isc2[3:-3,3], '.-', label='Iz')\n",
"plt.plot(interfaces[3:-3], isc2[3:-3,0], '.-', label='I0')\n",
"plt.xlabel('Interface (#)')\n",
"plt.ylabel('Interfacial spin current (A)')\n",
"plt.legend()\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The gradient of the interfacial spin current should yield the results of spin accumulation. One can compare with the results from the `[calcr].spin_accumulation` calculation above."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# shape: (#sites-2, #spin)\n",
"isca = -np.diff(isc, axis=0)\n",
"\n",
"plt.plot(sites[3:-3], isca[2:-2, 1]*1e3, '.-', label=r'-$\\nabla$Qx')\n",
"plt.plot(sites[3:-3], isca[2:-2, 2]*1e3, '.-', label=r'-$\\nabla$Qy')\n",
"plt.plot(sites[3:-3], isca[2:-2, 3]*1e3, '.-', label=r'-$\\nabla$Qz')\n",
"plt.plot(sites[3:-3], isca[2:-2, 0]*1e3, '.-', label=r'-$\\nabla$Q0')\n",
"plt.xlabel('Site (#)')\n",
"plt.ylabel('Spin current accumulation (meV)')\n",
"plt.legend()\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "junpy",
"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.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}