\section{Introduction}
Recently, superconducting hybrid systems have drawn attention due to their possible device applications as sensitive detectors\cite{hei,gua,pso}, low-temperature sensitive thermometers\cite{zgi,wang,luu}, heat valves\cite{yan,soth,dutta}, solid-state quantum machines\cite{mar,vis,kar}, solid-state micro-refrigerators\cite{mml,ngu,bos} and thermoelectric generators\cite{gma,huss,bra}.
Quantum thermodynamics implies the study of thermodynamic processes from the principle of quantum mechanics\cite{rko}, while refrigeration means transfer of heat from low to high temperature region\cite{kos} aided by work done on system. In this context  thermodynamic\cite{mjm,est,for,afo} properties of a Josephson Stirling engine have been discussed in Ref.~\onlinecite{bsc}, wherein a quantum spin Hall insulator based Josephson junction is shown to act as a quantum heat engine. Josephson Stirling engines aren't the only game in town, diffusive SNS junctions have been shown to operate as a Josephson-Otto or as Josephson-Stirling engines in Ref.~\onlinecite{carr}. 

In this paper, by doping a spin flipper in a 1D Josephson junction(JJ) loop which is in turn attached to two thermal reservoirs at in-equivalent temperatures via thermal valves, we show that this device can be employed both as a quantum heat engine as well as a refrigerator and can also work as a Joule pump or cold pump even.

The rest of the paper is arranged as follows. In section II the model is introduced via Hamiltonian, wave functions and boundary conditions so as to calculate different thermodynamic quantities. In section III the thermodynamic processes involved in the Josephson-Stirling cycle are discussed, then work done and heat exchanged during each of these processes is calculated. Next, in section IV the results are analyzed and different operating modes for Josephson-Stirling cycle are discussed. Our paper ends with an experimental realization of the proposed device and the take home messages are aggregated in section V.
\section{Theory}
The model device, depicted in Fig.~1, is formed from a 1D superconducting loop\cite{butt} interrupted by a spin flipper. An external magnetic flux $\Phi$ controls the superconducting phase difference across the spin-flipper. The JJ loop is attached, via two thermal valves $v_{L}$ and $v_{R}$, to reservoirs at either end which in turn are at temperatures $T_{L}$ and $T_{R}$. The two reservoirs can exchange heat $Q_{L}$ and $Q_{R}$ with the JJ loop. The scattering problem is solved using BTK approach\cite{BTK} for superconductor-spin flipper-superconductor junction as shown in dashed line box of Fig.~1. The two reservoirs control temperature of JJ loop via thermal valves $v_{L}$ and $v_{R}$. When valve $v_{R}$ is opened and $v_{L}$ is closed, JJ loop is in thermal contact with right reservoir at temperature $T_{R}$. Similarly, when valve $v_{L}$ is opened and $v_{R}$ is closed, JJ loop is in thermal contact with left reservoir at temperature $T_{L}$. On the other hand, phase difference across JJ loop is controlled via magnetic flux $\Phi$ enclosed by the loop. Thus, by controlling both temperature and phase difference, the JJ device can be driven from one state to another. We discuss this in more detail for a Stirling cycle in section III.
\begin{figure}[ht]
\centering{\includegraphics[width=0.5\textwidth]{spin-heat-engine.pdf}}
\caption{\small \sl 1D Josephson junction (JJ) loop (circumference $L_{S}$, in orange) doped with a spin flipper and attached to two thermal reservoirs at temperatures $T_{L}$ and $T_{R}$ via two thermal valves $v_{L}$ and $v_{R}$. A magnetic flux $\Phi$ controls phase difference $\varphi$ across spin flipper in JJ loop.}
\end{figure}
\subsection{Hamiltonian}
In our proposed set-up, a spin-flipper is embedded in the JJ loop of circumference $L_{S}$, see Fig.~1. We used BTK approach\cite{BTK} to solve the scattering problem. The spin-flipper is a point like magnetic impurity, see Ref.~\onlinecite{AJP}. Hamiltonian for spin-flipper, from Refs.~\onlinecite{AJP,Liu,Maru,FC,ysr} is,
\begin{equation}
H_{\mbox{spin-flipper}}=-J_{0}\vec{s}.\vec{S}.  
\label{spinflipper}
\end{equation}
Bogoliubov-de Gennes (BdG) Hamiltonian for the JJ loop is given as
\begin{equation}
H_{BdG}(x)=
\begin{pmatrix}
H\hat{I} & i\Delta(x) \hat{\sigma}_{y}  \\
-i\Delta^{*}(x) \hat{\sigma}_{y}   &  -H\hat{I}
\end{pmatrix},
\label{ham}
\end{equation}
where $H=p^2/2m^{\star}-J_{0}\delta(x)\vec s.\vec S-E_{F}$, with $p^2/2m^{\star}$ represents kinetic energy of electron-like or hole-like quasiparticle of mass $m^{\star}$, and $E_{F}$ is Fermi energy. Superconducting gap $\Delta(x)$ is of the form $\Delta(x)=\Delta[e^{i\varphi_{L}}\Theta(-x)+e^{i\varphi_{R}}\Theta(x)]$. For simplicity, we consider superconducting gap to be independent of temperature, i.e., $\Delta(T)\approx \Delta(T=0)$ with $\frac{\partial\Delta}{\partial T}\approx0$, which is valid if $T\ll T_{c}$, $T_{c}$ being superconducting critical temperature. $\varphi_{L}$ and $\varphi_{R}$ are superconducting phases for left and right superconductors respectively as shown in dashed line box of Fig.~1. In the manuscript, we use dimensionless parameter $J=\frac{m^{\star}J_{0}}{\hbar^2k_{F}}$ as a measure of strength of exchange interaction\cite{AJP} between quasi-particles and spin-flipper.
\subsection{Wavefunctions and boundary conditions}
Diagonalizing BdG Hamiltonian (Eq.~\eqref{ham}) one gets the wavefunctions in superconducting regions of our system for electron/hole like quasiparticle incidence.
For electronlike quasiparticle with spin up incident from left superconductor, wave function for left superconductor is\cite{LINDER}-
\begin{eqnarray}
\psi_{S_{L}}(x)=&&\begin{pmatrix}u\\
                              0\\
                              0\\ 
                              v
                              \end{pmatrix}e^{iq_{+}x}\phi_{m'}^{S}+r_{ee}^{\uparrow\uparrow}\begin{pmatrix}
                              u\\
                              0\\
                              0\\
                              v
                             \end{pmatrix}e^{-iq_{+}x}\phi_{m'}^{S}\nonumber\\&&+r_{ee}^{\uparrow\downarrow}\begin{pmatrix}
                             0\\
                             u\\
                            -v\\
                             0
                             \end{pmatrix}e^{-iq_{+}x}\phi_{m'+1}^{S}+r_{eh}^{\uparrow\uparrow}\begin{pmatrix}
                             0\\
                            -v\\
                             u\\
                             0
                             \end{pmatrix}e^{iq_{-}x}\phi_{m'+1}^{S}\nonumber\\&&+r_{eh}^{\uparrow\downarrow}\begin{pmatrix}
                             v\\
                             0\\
                             0\\
                             u
                             \end{pmatrix}e^{iq_{-}x}\phi_{m'}^{S}, \mbox{ for $x<0$ }.
                             \label{lsi}
                             \end{eqnarray}
$r_{ee}^{\uparrow\uparrow},r_{ee}^{\uparrow\downarrow},r_{eh}^{\uparrow\uparrow},r_{eh}^{\uparrow\downarrow}$ are normal reflection amplitude without any flip, normal reflection amplitude with flip, Andreev reflection amplitude with flip and Andreev reflection amplitude without any flip respectively.\\
The corresponding wave function in right superconductor,
\begin{eqnarray}
\psi_{S_{R}}(x)=&&t_{ee}^{\uparrow\uparrow}\begin{pmatrix}
                              ue^{i\varphi}\\
                              0\\
                              0\\
                              v
                             \end{pmatrix}e^{iq_{+}x}\phi_{m'}^{S}+t_{ee}^{\uparrow\downarrow}\begin{pmatrix}
                             0\\
                             ue^{i\varphi}\\
                             -v\\
                             0
                             \end{pmatrix}e^{iq_{+}x}\phi_{m'+1}^{S}\nonumber\\&&+t_{eh}^{\uparrow\uparrow}\begin{pmatrix}
                             0\\
                             -ve^{i\varphi}\\
                             u\\
                             0
                             \end{pmatrix}e^{-iq_{-}x}\phi_{m'+1}^{S}+t_{eh}^{\uparrow\downarrow}\begin{pmatrix}
                             ve^{i\varphi}\\
                             0\\
                             0\\
                             u
                             \end{pmatrix}e^{-iq_{-}x}\nonumber\\&&\phi_{m'}^{S},\mbox{ for $x>0$ },
                             \label{rsi}
                             \end{eqnarray}
$t_{ee}^{\uparrow\uparrow},t_{ee}^{\uparrow\downarrow},t_{eh}^{\uparrow\uparrow},t_{eh}^{\uparrow\downarrow}$ being transmission amplitudes, corresponding to reflection processes described above and $\varphi=\varphi_{R}-\varphi_{L}$ is phase difference between right and left superconductors. $\phi_{m'}^{S}$ represents eigenspinor of spin flipper, with the $S^{z}$ operator of spin-flipper acting as, $S^{z}\phi_{m'}^{S} = m'\phi_{m'}^{S}$, $m'$ being spin magnetic moment of spin-flipper. BCS coherence factors are $u=\sqrt{\frac{1}{2}\Bigg(1+\frac{\sqrt{E^2-\Delta^{2}}}{E}\Bigg)}$, $v=\sqrt{\frac{1}{2}\Bigg(1-\frac{\sqrt{E^2-\Delta^{2}}}{E}\Bigg)}$. Wavevectors for electron-like quasiparticles ($q_{+}$) and hole-like quasiparticles ($q_{-}$) are 
$q_{\pm}=\sqrt{\frac{2m^{\star}}{\hbar^2}(E_{F}\pm \sqrt{E^2-\Delta^2})}$. Andreev approximation\cite{Kri} gives $q_{+}=q_{-}=k_{F}$, with $k_{F}$ being Fermi wavevector, and $E_{F}>>\Delta$. Imposing boundary conditions on (\ref{lsi}, \ref{rsi}) at $x=0$, gives\\
\begin{equation}
\psi_{S_{L}}(x)=\psi_{S_{R}}(x),\,\, \frac{d\psi_{S_{R}}}{dx}-\frac{d\psi_{S_{L}}}{dx}=-\frac{2m^{\star}J_{0}\vec s.\vec S}{\hbar^2} \psi_{S_{L}},
\label{bc}
\end{equation}
where $\vec s.\vec S=s^{z}S^{z}+\frac{1}{2}(s^{-}S^{+}+s^{+}S^{-})$ represents exchange operator in Eq.~\eqref{spinflipper}, with
\begin{eqnarray}
&&\vec s.\vec S \psi_{S_{L}}(x=0)=\vec s.\vec S\begin{pmatrix}u\\
                              0\\
                              0\\ 
                              v
                              \end{pmatrix}\phi_{m'}^{S}+r_{ee}^{\uparrow\uparrow}\vec s.\vec S\begin{pmatrix}
                              u\\
                              0\\
                              0\\
                              v
                             \end{pmatrix}\phi_{m'}^{S}\nonumber\\&&+r_{ee}^{\uparrow\downarrow}\vec s.\vec S\begin{pmatrix}
                             0\\
                             u\\
                            -v\\
                             0
                             \end{pmatrix}\phi_{m'+1}^{S}+r_{eh}^{\uparrow\uparrow}\vec s.\vec S\begin{pmatrix}
                             0\\
                            -v\\
                             u\\
                             0
                             \end{pmatrix}\phi_{m'+1}^{S}+r_{eh}^{\uparrow\downarrow}\vec s.\vec S\begin{pmatrix}
                             v\\
                             0\\
                             0\\
                             u
                             \end{pmatrix}\phi_{m'}^{S}.\nonumber\\
\end{eqnarray}
$s^{\pm} = s_{x}\pm is_{y}$ and $S^{\pm} = S_{x}\pm iS_{y}$ are spin raising and spin lowering operators for electronlike quasiparticle/holelike quasiparticle and spin-flipper respectively. In Appendix A we give a detailed calculation as to how spin flipper interacts with electron-like and hole-like quasiparticles.
\subsection{Andreev bound states}
To calculate Andreev bound states (see Ref.~\cite{annu} for details of the method) we neglect contribution from incoming quasiparticle and insert wavefunctions (\ref{lsi}, \ref{rsi}) into boundary conditions (\ref{bc}). We get a homogeneous system of $8$ linear equations for the scattering amplitudes,
\begin{equation}
Py=0 
\end{equation}
where $y$ is a $8\times1$ column matrix and given as $y=[r_{ee}^{\uparrow\uparrow},r_{ee}^{\uparrow\downarrow},r_{eh}^{\uparrow\uparrow},r_{eh}^{\uparrow\downarrow},t_{ee}^{\uparrow\uparrow},t_{ee}^{\uparrow\downarrow},t_{eh}^{\uparrow\uparrow},t_{eh}^{\uparrow\downarrow}]$, $P$ being a $8\times8$ matrix. For nontrivial solution of this system, the determinant of $P=0$ and we get Andreev bound states as a function of phase difference $\varphi$ between two superconductors, i.e., Andreev bound state energy spectrum $E_{j}$, $j=\{1,...,4\}$\cite{Been}. We find that $E_{j}(\varphi)=E_{\sigma}^{\pm}(\varphi)=\pm E_{\sigma}(\varphi), (\sigma=\uparrow,\downarrow)$ and 
\begin{equation}
E_{\sigma}^{\pm}(\varphi)=\pm\Delta\sqrt{1+\frac{A(\varphi)}{C}+\rho_{\sigma}\frac{\sqrt{B(\varphi)}}{C}},\label{Eq:eb} 
\end{equation}
\begin{eqnarray}
\mbox{ where, } A(\varphi)=&&J^2(2+p^4J^2+2p^2(-2+J^2m'(1+m'))\nonumber\\
                           &&+m'(1+m')(4+J^2m'(1+m')))\nonumber\\
                           &&+2(8+J^2(1-2p^2+2m'(1+m')))\cos(\varphi),\nonumber
\end{eqnarray}
\begin{eqnarray}
B(\varphi)=&&2J^2(64p^4J^2+3(J+2Jm')^2+4p^2\nonumber\\
                           &&(16+J^2(5+4m'(1+m')))+4J^2(-4p^2+16p^4-\nonumber\\
                           &&(1+2m')^2)\cos(\varphi)+((J+2Jm')^2-4p^2(16+\nonumber\\
                           &&(J+2Jm')^2))\cos(2\varphi)),\nonumber\\
C=(1&&6+J^4(p^2+m'+m'^2)^2+J^2(4+8p^2+8m'(1+m'))),\nonumber
\end{eqnarray}
and $\rho_{\uparrow(\downarrow)}=+1(-1)$.\\ In absence of spin flip scattering ($p=0$), Eq.~\ref{Eq:eb} reduces to, 
\begin{equation}
E(\varphi)=\pm\Delta\sqrt{\frac{4\cos^2(\varphi/2)+J^2m'^2}{4+J^2m'^2}}. 
\end{equation}
\subsection{Superconductor-Spin flipper-Superconductor junction as a thermodynamic system}
Before analyzing the thermodynamic behavior of setup (Fig.~1), we introduce the different thermodynamic quantities. From Andreev bound state energies we can determine Free energy of JJ\cite{golu} (inset of Fig.~1) as
\begin{eqnarray}
F(\varphi,T)&&=-\frac{1}{\beta}\ln\Big[\prod_{i}(1+e^{-\frac{E_{j}(\varphi)}{k_{B}T}})\Big],\nonumber\\
            &&= -\frac{2}{\beta}\sum_{\sigma}\ln\Big[2\cosh\Big(\frac{E_{\sigma}(\varphi)}{2k_{B}T}\Big)\Big],
\label{ff}
\end{eqnarray}
where $k_{B}$ is Boltzmann constant. From Free energy we can calculate total Josephson current\cite{deG} as
\begin{equation}
I(\varphi,T)=\frac{2e}{\hbar}\frac{\partial F(\varphi,T)}{\partial \varphi},
\label{ff1}
\end{equation}
where $e$ is charge of electron. Entropy of our device can then be calculated from Free energy as
\begin{equation}
S(\varphi,T)=-\frac{\partial F(\varphi,T) }{\partial T}.
\end{equation}
From entropy $S$ one determines heat capacity of JJ as
\begin{equation}
C(\varphi,T)=T\frac{\partial S(\varphi,T)}{\partial T}. 
\end{equation}
\section{Josephson-Stirling Cycle}
Josephson-Stirling cycle\cite{carr,bsc} represented in Fig.~2, involves two isothermal and two isophasic processes. States $\textbf1$,$\textbf{2}$ involve right reservoir, while states $\textbf3$,$\textbf{4}$ involve left reservoir. Below we summarize these different processes-
\begin{itemize}
 \item \textbf{Isothermal process ($\textbf{1}\rightarrow\textbf{2}$)}: Thermal valve $v_{R}$ is open while $v_{L}$ is closed, thus system is in thermal contact with right reservoir at temperature $T_{R}$. The device or system  goes from state $\textbf{1}\equiv(\varphi=0,T_{R})$ to state $\textbf{2}\equiv(\varphi=\varphi_{f},T_{R})$.
 \item \textbf{Isophasic process ($\textbf{2}\rightarrow\textbf{3}$)}: Thermal valve $v_{L}$ is open while $v_{R}$ is closed and system is driven from state $\textbf{2}\equiv(\varphi=\varphi_{f},T_{R})$ to state $\textbf{3}\equiv(\varphi=\varphi_{f},T_{L})$.
 \item \textbf{Isothermal process ($\textbf{3}\rightarrow\textbf{4}$)}: In this stage valve $v_{R}$ is closed and $v_{L}$ is open. System is transferred from state $\textbf{3}\equiv(\varphi=\varphi_{f},T_{L})$ to state $\textbf{4}\equiv(\varphi=0,T_{L})$.
 \item \textbf{Isophasic process ($\textbf{4}\rightarrow\textbf{1}$)}: Final stage of cycle involves closing valve $v_{L}$ and opening valve $v_{R}$, with system being driven from state $\textbf{4}\equiv(\varphi=0,T_{L})$ to state $\textbf{1}\equiv(\varphi=0,T_{R})$.
\end{itemize}
\begin{figure}[ht]
\centering{\includegraphics[width=.99\linewidth]{Thermodynamic-cycle.pdf}}
\caption{\small \sl Josephson-Stirling cycle in TS (T is temperature and S is entropy) plane. Enclosed area in $T-S$ plane corresponds to  total heat exchanged $Q$, which is equal to total work done $W$ during the cycle.}
\end{figure}

When the device or system is driven from state $i$ to state $f$ ($i\rightarrow f$) during a quasi-static process, work done and heat released during the process are given as $W_{if}=-\frac{\hbar}{2e}\int_{\varphi_{i}}^{\varphi_{f}} I(\varphi,T)d\varphi$ and $Q_{if}=\int_{S(\varphi_{i},T)}^{S(\varphi_{f},T)} T dS$ respectively, where $I(\varphi,T)$ is Josephson current and $S$ is entropy of setup depicted in Fig.~1. In expressions for work done and heat released below, we have taken sign convention such that $W_{if}$ is positive when work is released to the universe while $Q_{if}$ is positive when heat is absorbed from the universe.
Work done and heat released for an isothermal process, where phase difference $\varphi$ changes from $\varphi_{i}\rightarrow\varphi_{f}$ at constant temperature $T$ is given as $W_{if}=-[F(\varphi_{f},T)-F(\varphi_{i},T)]$ and $Q_{if}=T[S(\varphi_{f},T)-S(\varphi_{i},T)]$ respectively. For an isophasic process, temperature changes from $T_{i}\rightarrow T_{f}$ at constant phase difference $\varphi$, $W_{if}=0$ and $Q_{if}=\int_{T_{i}}^{T_{f}}C(\varphi,T) dT$.
\subsection{Work done and heat exchanged in Josephson-Stirling Cycle}
We can now explicitly calculate total work done and heat exchanged during each stage of the Josephson-Stirling cycle, shown in Fig.~2. We also distinguish between four distinct modes of operation of the Josephson-Stirling cycle. In quantum heat engine mode: $W>0$ and $Q_{R}-Q_{L}>0$, in refrigerator mode: $W<0$ and $Q_{R}-Q_{L}>0$, while in Joule pump mode: $W<0$ and $Q_{R}+Q_{L}<0$, further in cold pump mode: $W<0$ and $Q_{R}-Q_{L}<0$. The total work done per cycle is $W=W_{12}+W_{34}$. Since $2\rightarrow3$ and $4\rightarrow1$ are isophasic processes, therefore $W_{23}=W_{41}=0$. Thus, work done $W$, can be calculated as,
\begin{widetext}
\footnotesize{
\begin{eqnarray}
W=&&\Delta\Bigg\{\Bigg(Y_{R}\ln\Bigg[4\cosh\Bigg(\frac{X_{R} E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]+Y_{R}\ln\Bigg[\cosh\Bigg(\frac{X_{R} E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]-Y_{L}\ln\Bigg[4\cosh\Bigg(\frac{X_{L} E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]-Y_{L}\ln\Bigg[\cosh\Bigg(\frac{X_{L} E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)\nonumber\\
&&-\Bigg(Y_{R}\ln\Big[\cosh\Big(X_{R}\Big)\Big]+Y_{R}\ln\Big[4\cosh\Big(X_{R} C^{\prime}\Big)\Big]-Y_{L}\ln\Big[\cosh\Big(X_{L}\Big)\Big]-Y_{L}\ln\Big[4\cosh\Big(X_{L}C^{\prime}\Big)\Big]\Bigg)\Bigg\},\label{work}\nonumber\\\\
\mbox{ where, }&&X_{L}=\frac{\Delta}{2k_{B}T_{L}},\,\, X_{R}=\frac{\Delta}{2k_{B}T_{R}},\,\, Y_{L}=\frac{1}{X_{L}},\,\, Y_{R}=\frac{1}{X_{R}},\,\, C_{1}=\sqrt{16+J^4 (p^2+m'+m'^2)^2+J^2 (4-8p^2+8m'(1+m'))},\nonumber\\
C_{2}=&&\sqrt{16+J^4(p^2+m'+m'^2)^2+J^2(4+8p^2+8m'(1+m'))},\, \mbox{ and } C^{\prime}=\frac{C_{1}}{C_{2}}.\nonumber 
\end{eqnarray}}
\normalsize
In absence of spin flip scattering ($p=0$), work done, \textquoteleft$W$\textquoteright{} in Eq.~\eqref{work}, simplifies to,
\begin{equation}
W=\Delta\Bigg\{\Bigg(Y_{L}\ln\Big[\cosh\Big(X_{L}\Big)\Big]-Y_{R}\ln\Big[\cosh\Big(X_{R}\Big)\Big]\Bigg)-\Bigg(Y_{L}\ln\Bigg[\cosh\Bigg(\frac{X_{L}E(\varphi_{f})}{\Delta}\Bigg)\Bigg]-Y_{R}\ln\Bigg[\cosh\Bigg(\frac{X_{R}E(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)\Bigg\},\label{worknoflip}
\end{equation}
where, $E(\varphi)=\Delta\sqrt{\frac{4\cos^2(\varphi/2)+J^2m'^2}{4+J^2m'^2}}$ is Andreev bound state energy for no flip case.

The heat exchanged with right reservoir at temperature $T_{R}$, $Q_{R}=Q_{12}+Q_{41}$ is
\small{
\begin{eqnarray}
Q_{R}=&&\Delta\Bigg(\ln\Bigg[\cosh\Bigg(\frac{X_{R} E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]+\ln\Bigg[4\cosh\Bigg(\frac{X_{R} E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)Y_{R}-E_{\uparrow}(\varphi_{f})\tanh\Bigg(\frac{X_{R}E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)-E_{\downarrow}(\varphi_{f})\tanh\Bigg(\frac{X_{R}E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\nonumber\\  
     &&-\Delta\Bigg(\ln\Big[\cosh\Big(X_{L} C^{\prime}\Big)\Big]+\ln\Big[4\cosh\Big(X_{L}\Big)\Big]\Bigg)Y_{L}
     +\Delta C^{\prime}\tanh\Big(X_{L} C^{\prime}\Big)+\Delta\tanh\Big(X_{L}\Big)\nonumber\\
     &&+\Delta\Bigg\{\Bigg(\ln\Big[\cosh\Big(X_{L}\Big)\Big]+\ln\Big[4\cosh\Big(X_{L}C^{\prime}\Big)\Big]\Bigg)Y_{L}-\Bigg(\ln\Big[\cosh\Big(X_{R}\Big)\Big]+\ln\Big[4\cosh\Big(X_{R} C^{\prime}\Big)\Big]\Bigg)Y_{R}\Bigg\},\nonumber\\
\label{hrr}
\end{eqnarray}}
\normalsize and for no flip process ($p=0$), Eq.~\eqref{hrr} reduces to,
\begin{equation}
Q_{R}=\Delta\Bigg(-\ln\Big[\cosh\Big(X_{R}\Big)\Big]+\ln\Bigg[\cosh\Bigg(\frac{X_{R}E(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)Y_{R}+\Delta\tanh\Big(X_{L}\Big)-E(\varphi)\tanh\Bigg(\frac{X_{R}E(\varphi_{f})}{\Delta}\Bigg).
\end{equation}
Finally, heat exchanged with left reservoir at temperature $T_{L}$, $Q_{L}=Q_{23}+Q_{34}$ is
\footnotesize{
\begin{eqnarray}
Q_{L}=&&-\Delta\Bigg(\ln\Bigg[\cosh\Bigg(\frac{X_{R} E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]+\ln\Bigg[4\cosh\Bigg(\frac{X_{R} E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)Y_{R}+E_{\uparrow}(\varphi_{f})\tanh\Bigg(\frac{X_{R}E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)+E_{\downarrow}(\varphi_{f})\tanh\Bigg(\frac{X_{R}E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\nonumber\\  
     &&+\Delta\Bigg(\ln\Big[\cosh\Big(X_{L} C^{\prime}\Big)\Big]+\ln\Big[4\cosh\Big(X_{L}\Big)\Big]\Bigg)Y_{L}-\Delta C^{\prime}\tanh\Big(X_{L} C^{\prime}\Big)-\Delta\tanh\Big(X_{L}\Big)\nonumber\\
     &&-\Delta\Bigg\{\Bigg(\ln\Bigg[4\cosh\Bigg(\frac{X_{L} E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]+\ln\Bigg[\cosh\Bigg(\frac{X_{L} E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)Y_{L}-\Bigg(\ln\Bigg[4\cosh\Bigg(\frac{X_{R} E_{\uparrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]+\ln\Bigg[\cosh\Bigg(\frac{X_{R} E_{\downarrow}(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)Y_{R}\Bigg\},\nonumber\\
\label{hlr}
\end{eqnarray}}
\normalsize and for no flip process ($p=0$), Eq.~\eqref{hlr}, reduces to,
\begin{equation}
Q_{L}=\Delta\Bigg(\ln\Big[\cosh\Big(X_{L}\Big)\Big]-\ln\Bigg[\cosh\Bigg(\frac{X_{L}E(\varphi_{f})}{\Delta}\Bigg)\Bigg]\Bigg)Y_{L}-\Delta\tanh\Big(X_{L}\Big)+E(\varphi)\tanh\Bigg(\frac{X_{R}E(\varphi_{f})}{\Delta}\Bigg). 
\end{equation}
\end{widetext}
Upper limit for $T_{L}$ and $T_{R}$ is constrained by superconducting transition temperature $T_{c}$. For \textquoteleft Pb\textquoteright{} superconductor, $T_{c}$ is $7$K, therefore upper limit for $T_{R}$ and $T_{L}$ is taken as $6.96$K ($<T_{c}$). In Figs.~3-8, we consider lead ($Pb$) superconductor, thus upper limit for $T_{R}$, $T_{L}$ is fixed at $6.96$K. From conservation of energy $W=Q$, with $Q=Q_{R}+Q_{L}$ being total heat exchanged during the cycle. When Josephson-Stirling cycle acts as a heat engine, work done $W$ and efficiency of cycle is $\eta=W/Q_{R}$. In refrigerator mode, the work done $W$ and coefficient of performance\cite{carr} of Josephson-Stirling cycle is given as $\mbox{COP}=Q_{R}/|W|$. Finally, in Joule pump mode the $COP$ is\cite{biz} $(|Q_{L}|+|Q_{R}|)/|W|$ with $Q_R$ being heat released to right reservoir and $Q_L$, being the heat released to left reservoir as Joule pump coverts the work to heat and transfers it to both reservoirs. A cold pump, on the other hand, has $COP=|Q_R|/|W|$\cite{biz}, as in cold pump $Q_R$ is negative implying heat energy is released to right reservoir which is cold reservoir because $T_L  > T_R$. A cold pump is used to heat the colder reservoir by transferring heat from hotter reservoir in turn cooling the hotter reservoir. Please also note that the expressions for COP in case of Joule pump  differs slightly from that in Ref.~\cite{biz} as we have taken the sign convention of heat flow or work done as in Ref.~\cite{bsc}.
\section{Results and Analysis}
\subsection{Josephson-Stirling cycle as quantum heat engine}
\begin{figure}[ht]
\centering{\includegraphics[width=.99\linewidth]{fig3-jos.pdf}}
\caption{\small \sl Total work done $W$ and efficiency $\eta$ of a Josephson-Stirling engine as a function of $\varphi_{f}$ (for (a,c)) and as a function of the right reservoir temperature $T_{R}$ (for (b,d)). Parameters are: Flip: $S=-m'=1/2$, $p=1$; No Flip: $S=m'=1/2$, $p=0$. Rest of parameters: $J=0.1$, $\varphi_{i}=0$, $\varphi_{f}=\pi$ (for (b,d)), $k_{B}T_{R}=0.6\Delta$ (for (a,c)), $k_{B} T_{L}=0.01\Delta$, $k_{B}T=0.1\Delta$. The black dotted line represents Carnot limit, $\eta_{C}=1-\frac{T_{L}}{T_{R}}$.}
\end{figure}
In Fig.~3 we plot work done $W$ (Eq.~\eqref{work}) and efficiency $\eta$ of Josephson quantum heat engine and compare no flip with spin flip processes. In Figs.~3(a) and 3(c), $W$ and $\eta$ are plotted as function of maximal phase change $\varphi_{f}$ during the cycle. The reason we plot work done, efficiency and COP as function of phase is because phase lends itself to external control via magnetic flux enclosed in Josephson junction loop, see Fig.~1. We consider here right reservoir to be hot and left reservoir to be cold, i.e., $T_{R}>T_{L}$. In the inset of Fig.~3(a), we show Free energy as function of $\varphi_{f}$. In Fig.~3(a) we see that $W$ is maximum at $\varphi_{f}=\pi$, irrespective of spin-flip scattering, however magnitude of $W_{max}$ for no flip process is much smaller than spin-flip process. In presence of spin-flip scattering magnitude of $W$ at $\varphi_{f}=\pi$, i.e., $W=1.15\Delta$ is maximum work done by our system. From inset of Fig.~3(a), we notice that Free energy is minimum at $\varphi_{f}=0$, i.e., when system shows $0$-junction behavior. From Fig.~3(c), we notice that at $\varphi_{f}=\pi$, efficiency $\eta$ for no flip case is a little bit larger than spin-flip case. Thus, spin flip process is better for work done, but no flip process is better for efficiency. In Figs.~3(b) and 3(d) we show dependence of work done and efficiency on $T_{R}$ for fixed $k_{B}T_{L}=0.01\Delta$ and compare the cycle's performance for no flip and spin flip scattering. In addition we plot Carnot efficiency in Fig.~3(d). Three important take home messages from Fig.~3 are (i) work done is maximum at $\varphi_{f}=\pi$ (see Fig.~3(a)), (ii) spin-flip scattering enhances work done (see Fig.~3(a)) and (iii) at $k_{B}T_{R}=0.6\Delta$, work done is maximum (see Fig.~3(b)). 

From Fig.~3(d), we notice that for small values of $T_{R}$, efficiency of a Josephson-Stirling engine is equal to Carnot efficiency $\eta_{C}$ regardless of spin-flip scattering, while at large values of $T_{R}$ in absence of spin-flip scattering, engine is more efficient and efficiency is close to Carnot limit. The reason we take low values of exchange coupling $J$ ($=0.1$) is because for these values of $J$ we get maximum work output \textquoteleft$W$\textquoteright{} and efficiency \textquoteleft$\eta$\textquoteright.
\begin{figure}[ht]
\centering{\includegraphics[width=.99\linewidth]{fig4-jos.pdf}}
\caption{\small \sl  Total work done $W$ and efficiency $\eta$ of a Josephson-Stirling engine as function of $\varphi_{f}$ (for (a,c)) and as function of $T_{R}$ (for (b,d)) in presence of spin-flip scattering. Other parameters are: $J=0.1$,  $\varphi_{i}=0$, $\varphi_{f}=\pi$ (for $p=1$), $\varphi_{f}=0.92\pi$ (for $p=3$), $\varphi_{f}=0.85\pi$ (for $p=5$), $k_{B}T_{L}=0.01\Delta$, $k_{B}T_{R}=0.6\Delta$ (for (a,c)), $k_{B}T=0.1\Delta$.}
\end{figure}
Next, in Fig.~4 we plot total work done $W$ and efficiency $\eta$ of a Josephson-Stirling engine for different levels of spin-flip scattering. In Figs.~4(a) and 4(c) we plot $W$ and $\eta$ as function of $\varphi_{f}$. We see that at $\varphi_{f}=\pi$ and for low values of spin-flip scattering, both work done and efficiency attain their maximum. In inset of Fig.~4(a), we notice that minimum of Free energy occurs at $\varphi_{f}=0$, i.e., system shows $0$-junction behavior when it operates as a Josephson quantum heat engine. In Figs.~4(b) and 4(d) we plot $W$ and $\eta$ as function of $T_{R}$ for different levels of spin flip scattering at fixed $k_{B}T_{L}=0.01\Delta$. We choose $\varphi_{f}$ in such a way that $W$ becomes maximum. We see that for low values of spin-flip scattering, both work done and efficiency are larger. 
\subsubsection{Condition for optimality}
Further we find in Fig.~4 that, at $k_{B}T_{R}=0.6\Delta$, both $W$ and $\eta$ are maximum. Thus, for spin-flip probability, $p=1$, $J=0.1$, $\varphi_{f}=\pi$, $k_{B}T_{L}=0.01\Delta$ and $k_{B}T_{R}=0.6\Delta$ both work done and efficiency of our Josephson quantum heat engine are larger and therefore this regime is an optimal operating range of our Josephson quantum heat engine. This condition of optimality for our case is contrasted with that in Ref.~\cite{bsc}. In Ref.~\cite{bsc}, parity-conserving heat engine operates in an optimal operating range at $\varphi_{f}=2\pi$, while non-parity-conserving heat engine works in an optimal operating range at $\varphi_{f}=\pi$.

\subsection{Josephson-Stirling cycle as quantum refrigerator}
Till now we have discussed work done and efficiency when Josephson-Stirling cycle acts as a quantum heat engine. In Fig.~5 we show action of Stirling cycle as a Josephson quantum refrigerator and calculate work done and coefficient of performance (COP). In Figs.~5(a) and 5(b), total work absorbed by refrigerator and COP are plotted as function of $\varphi_{f}$, for $T_{R}<T_{L}$ ($k_{B}T_{L}=0.4\Delta$ and $k_{B}T_{R}=0.39\Delta$). We see that for low values of spin flip scattering both $|W|$ and COP are larger and the product of COP and $|W|$ is maximum at $\varphi_{f}=\pi$. Thus,  Josephson quantum refrigerator works in an optimal operating range for parameters of Fig.~5. For optimal parameters, $|W|=0.017\Delta$ and $\mbox{COP}=38.48$. Although, our system exhibits maximum $|W|$ of $0.65\Delta$ at $k_{B}(T_{L}-T_{R})=0.3\Delta$ and a maximum COP of $58.27$ at $k_{B}(T_{L}-T_{R})=0.01\Delta$ as shown in Figs.~5(c) and 5(d) respectively.
\begin{figure}[ht]
\centering{\includegraphics[width=.99\linewidth]{fig5-jos.pdf}}
\caption{\small \sl (a,c) Total work $W$ absorbed, and (b,d) COP of quantum refrigerator as function of $\varphi_{f}$ in presence of spin-flip scattering. Other parameters are: $J=0.1$, $k_{B}T_{L}=0.4\Delta$ (for (a,b)), $k_{B}T_{R}=0.39\Delta$ (for (a,b)), $S=-m'=1/2$ (for (c,d)), $\varphi_{i}=0$.}
\end{figure}
\subsection{Phase diagram of Josephson-Stirling cycle}
In Figs.~3,4,5 we depict the performance of this device as a quantum heat engine or quantum refrigerator depending on relative temperatures of reservoirs. In this subsection we will discuss phase diagram of a Josephson-Stirling cycle as function of phase difference $\varphi_{f}$ during the cycle. In Fig.~6, we plot $W$, $Q_{R}$, $Q_{L}$, $\eta$ and COP as functions of $\varphi_{f}$ and $T_{R}$ for low values of spin flip scattering ($S=1/2$, $m'=-1/2$, $p=1$) and high values of exchange coupling ($J=2$) of spin flipper. We fix $k_{B}T_{L}=0.01\Delta$ and consider $T_{R}>T_{L}$. From Fig.~6(a) we notice that with change of  $\varphi_{f}$ there is a sign change in $W$. $W$ changes sign from $W>0$ to $W<0$ between $\varphi_{f}=0$ and $\varphi_{f}=\pi$ and again changes sign from $W<0$ to $W>0$ between $\varphi_{f}=\pi$ and $\varphi_{f}=2\pi$. The regime where $W$ is positive ($W>0$) in Fig.~6(a), $Q_{R}$ is positive (Fig.~6(b)) but $Q_{L}$ is negative (Fig.~6(c)), in these regimes Josephson-Stirling cycle acts as an engine. Similarly in regime, wherein both $W$ and $Q_{L}$ are negative, cycle acts as a refrigerator if $Q_{R}$ is positive while cycle acts as a Joule pump if $Q_{R}$ is negative. A Joule pump transforms work into heat released to the reservoirs. Thus, there is a transition from engine mode to refrigerator or Joule pump mode with change of $\varphi_{f}$. Since, $\varphi_{f}$ is controlled by magnetic flux $\Phi$, therefore by changing the enclosed flux $\Phi$ in the Josephson junction loop we can tune our system from engine mode to refrigerator/Joule pump mode which is an attractive feature of our device.
\begin{figure}[ht]
\centering{\includegraphics[width=.99\linewidth]{fig6-jos.pdf}}
\caption{\small \sl (a) Total work $W$ (b) $Q_{R}$ and (c) $Q_{L}$, (d) $\eta$ or COP as as function of $\varphi_{f}$ and $T_{R}$ in presence of spin flip scattering. Other parameters are: $S=1/2$, $m'=-1/2$, $J=2$, $k_{B}T_{L}=0.01\Delta$, $\varphi_{i}=0$.}
\end{figure}

\subsection{Why is spin-flip scattering necessary?}
In absence of spin-flip scattering ($p=0$), we find work done (see Eq.~\eqref{worknoflip}) $W>0$ since, 
\begin{eqnarray}
(Y_{L}\ln[\cosh(X_{L})]-Y_{R}\ln[\cosh(X_{R})]) &>& (Y_{L}\ln[\cosh(X_{L}E(\varphi_{f})/\Delta)]\nonumber\\
-Y_{R}\ln[\cosh(X_{R}E(\varphi_{f})/\Delta)]),
\end{eqnarray}
for $T_{R}>T_{L}$ and regardless of $\varphi_{f}$. Thus, $W$ is always positive ($W>0$) in absence of spin-flip scattering irrespective of $\varphi_{f}$ and the Josephson-Stirling cycle operates solely as a quantum heat engine. However, in presence of spin-flip scattering ($p\neq0$) and with $T_{R}>T_{L}$ , we find $W$ (see Eq.~\eqref{work}) is not always positive and depending on other parameter values, $W$ can be negative ($W<0$) in certain range of $\varphi_{f}$. In the parameter regime wherein $W$ is negative and $Q_{L}$ is negative with $Q_{R}$ being positive, the Josephson-Stirling cycle operates as a refrigerator. Similarly, in parameter regime wherein $W$, $Q_{R}$ and $Q_{L}$ are all negative, Josephson-Stirling cycle acts as a Joule pump. Thus, in presence of spin-flip scattering when $W$ is negative, the Josephson-Stirling cycle can act as a refrigerator or Joule pump even when $T_{R}>T_{L}$. This is unique to this proposal since in other proposals\cite{bsc,carr}, $W$ is always positive and Josephson-Stirling cycle only acts as a heat engine when $T_{R}>T_{L}$.
\begin{figure}[ht]
\centering{\includegraphics[width=.99\linewidth]{fig7-jos.pdf}}
\caption{\small \sl (a) Total work done $W$ (b) $Q_{R}$ and (c) $Q_{L}$  (d) efficiency $\eta$ as function of maximal phase change $\varphi_{f}$ during Stirling cycle and right reservoir temperature $T_{R}$ in absence of spin-flip scattering. Other parameters are: $S=m'=1/2$, $J=2$, $k_{B}T_{L}=0.01\Delta$, $\varphi_{i}=0$.}
\label{spinflip-fig}
\end{figure}
In Fig.~\ref{spinflip-fig}, $W$, $Q_{R}$, $Q_{L}$ and $\eta$ are plotted as function of $\varphi_{f}$ and $T_{R}$ in absence of spin-flip scattering ($S=m'=1/2$, $p=0$). We see that $W$ does not change sign with $\varphi_{f}$ and thus there is no transition from engine mode to refrigerator or Joule pump mode. Therefore, we can conclude that it is spin flip scattering, which is responsible for tuning our system from engine mode to refrigerator/Joule pump mode via magnetic flux $\Phi$.
\subsection{Josephson-Stirling cycle as Joule pump and cold pump}
Finally, our device doesn't only exhibit the engine, refrigerator and Joule pump phases, it also exhibits a cold pump phase again in presence of spin-flip scattering only. The thin sliver in Fig.~\ref{cold-pump}(a) at bottom right corner shows the cold pump phase. In Fig.~\ref{cold-pump}, we plot $W$, $Q_{R}$, $Q_{L}$, efficiency of  engine and COP of refrigerator as functions of $T_{R}$ and $T_{L}$ for low values of spin flip scattering ($S=1/2$, $m'=-1/2$, $p=1$) and low values of exchange coupling ($J=0.1$) of spin flipper. We choose $\varphi_{f}$ such that $|W|$ will be maximized. We see that for $T_{R}>T_{L}$, the Josephson-Stirling cycle acts as an engine. At $k_{B}T_{L}=0.01\Delta$ and $k_{B}T_{R}=0.6\Delta$, the work done and efficiency in the engine mode attain their maximum values which are $W_{max}=1.15\Delta$ and $\eta_{max}=0.923$. For $T_{R}<T_{L}$, we notice that the machine acts as a refrigerator or as Joule pump or cold pump depending on the relative values of $Q_{R}$ and $Q_{L}$. The work done in the refrigerator mode is maximum at $k_{B}T_{L}=0.44\Delta$ and $k_{B}T_{R}=0.14\Delta$ and the maximum value is $|W|_{max}=0.65\Delta$, while the COP of the refrigerator is maximum at $k_{B}T_{L}=0.6\Delta$ and $k_{B}T_{R}=0.59\Delta$ and the maximum value is $COP_{max}=58.27$. Further, in the Joule pump mode the work done is maximum at $k_{B}T_{L}=0.58\Delta$ and $k_{B}T_{R}=0.01\Delta$ and the maximum value is $|W|_{max}=1.13\Delta$, while the COP of the Joule pump is maximum at $k_{B}T_{L}=0.16\Delta$ and $k_{B}T_{R}=0.01\Delta$ and the maximum value is $COP_{max}=1.2$. If $Q_{R}<0$, $W<0$ and $Q_{L}>0$, the cycle acts as a cold pump which transfers heat from the hot reservoir to the cold reservoir. The work done in the cold pump mode is maximum at $k_{B}T_{L}=0.6\Delta$ and $k_{B}T_{R}=0.01\Delta$ and the maximum value is $|W|_{max}=1.15\Delta$, while the COP of the cold pump is maximum at $k_{B}T_{L}=0.6\Delta$ and $k_{B}T_{R}=0.01\Delta$ and the maximum value is $COP_{max}=0.55$. Thus, by tuning the temperature of the reservoirs our system can be tuned from engine mode to refrigerator or Joule pump or cold pump mode.
\begin{figure}[ht]
\centering{\includegraphics[width=.99\linewidth]{fig8-jos.pdf}}
\caption{\small \sl (a) Total work done $W$, (b) heat exchanged $Q_{R}$ and (c) $Q_{L}$ and  (d) efficiency $\eta$ or COP as function of temperatures $T_{R}$ and $T_{L}$ in presence of spin-flip scattering. Parameters are: $S=1/2$, $m'=-1/2$, $J=0.1$, $\varphi_{i}=0$, $\varphi_{f}=\pi$.}
\label{cold-pump}
\end{figure}
\section{Experimental realization and Conclusions}
Our proposed Josephson quantum spin thermodynamic device acts as a heat engine or refrigerator or Joule pump or as a cold pump via spin-flip scattering and is experimentally realizable. Doping a magnetic adatom or spin-flipper in an one dimensional superconducting loop shouldn't be difficult, especially with a $s$-wave superconductor like Lead or Aluminum it should be perfectly possible. Further, work done per cycle during each isothermal process can be experimentally determined via the current-phase relation. For a Josephson Stirling cycle work done during each isothermal process is given as $W_{if}=-\frac{\hbar}{2e}\int_{\varphi_{i}}^{\varphi_{f}}I(\varphi,T)d\varphi$, where $\varphi_{i}$ and $\varphi_{f}$ are the initial and final phases respectively. Thus, to measure the work done experimentally one needs to control phase difference $\varphi$ across the junction, regulated by flux $\Phi$, as well as to know about the Josephson current $I$ flowing through the loop. This can be done using a scanning superconducting quantum interference device (SQUID) microscope to perform the measurements of current-phase relation of the junction\cite{bsc,iso,sha}. By applying a current through the field coil of SQUID sensor, the magnetic flux through Josephson junction loop can be tuned. This magnetic flux, controls the phase difference across JJ and induces a supercurrent in Josephson junction loop. The supercurrent leads to a signal which is measured by pickup loop of SQUID sensor\cite{iso,iko}.

We have compared our proposal with other Josephson quantum heat engines and refrigerators in Table I. While, Refs.~\onlinecite{bsc}, \onlinecite{carr} are very important works which laid down the principle of Josephson quantum heat engine and refrigerator, efficiency and coefficient of performance (COP) of these can none-the-less be still enhanced, and the tunability of the device improved as we show in this work.   In both Refs.~\onlinecite{bsc} and \onlinecite{carr}, the Josephson quantum heat engine and refrigerator can be tuned from engine mode to refrigerator mode via changing the temperatures of left and right reservoirs only, while in this proposal it is seen that heat engine to refrigeration mode transition or for that matter to Joule or cold pump can be effected by either the magnetic flux enclosed or by tuning the temperature of reservoirs. This makes spin flipper doped Josephson junction loop much more versatile as regards possible applications. As a quantum heat engine, the proposed device is much more efficient than previously proposed Josephson quantum heat engines\cite{bsc,carr}. Further, when operating as a quantum refrigerator, COP of the proposed device is higher than that seen in Refs.~\cite{bsc,carr}. In Table I, we see that although work done by Josephson heat engine proposed in Ref.~\onlinecite{carr} is larger than ours, but efficiency of the Josephson quantum heat engine discussed in this work is much larger than those of Josephson heat engines of Refs.~\onlinecite{bsc,carr}. Further, as a Josephson quantum refrigerator, COP of the proposed device is huge compared to other Josephson quantum refrigerator proposals.
\begin{table}[ht]
\caption{Comparative analysis of Josephson junction based quantum heat engines and refrigerators} 
\begin{tabular}{|p{1.7cm}|p{1.7cm}|p{1.67cm}|p{1.38cm}|p{1.68cm}|}
\hline
& \multicolumn{2}{|c|}{Heat engine mode} & \multicolumn{2}{|c|}{Refrigerator mode} \\
\hline
& $W_{max}$ & $\eta_{max}$ & $|W_{max}|$ & $\mbox{COP}_{max}$ \\
\hline
The JJ device (Fig.~1) & $1.15\Delta$ ($\Delta=1meV$) (Fig.~3(a)) & $0.958$ (Fig.~3(c)) & $0.65\Delta$ (Fig.~5(c))  & $58.27$ (Fig.~5(d)) \\
\hline
Topological Josephson heat engine (Ref.~\onlinecite{bsc}) & $2\Delta$ ($\Delta=150\mu eV$) (Fig.~4(c) of Ref.~\onlinecite{bsc}) & $0.8$ (Figs.~4(b,d) of Ref.~\onlinecite{bsc}) & \hspace{0.5cm}$-$ & $20$  (Figs.~4(b,d) of Ref.~\onlinecite{bsc}) \\
\hline
Josephson heat engine (Ref.~\onlinecite{carr}) & $0.38\Delta$ ($\Delta=180eV$) (Fig.~14(a) of Ref.~\onlinecite{carr})  & $0.5$ (Fig.~15(a) of Ref.~\onlinecite{carr}) & \hspace{0.5cm}$-$ & $10$ (Fig.~15(a) of Ref.~\onlinecite{carr}) \\
\hline
\end{tabular}
\end{table}
To conclude, in this work we have shown that a 1D Josephson junction loop doped with a spin flipper, and attached to two thermal reservoirs at inequivalent temperatures via thermal valves can act as a Josephson quantum heat engine or  quantum refrigerator or as a Joule pump or even as a cold pump. The proposed device can be tuned from engine mode to other operating modes like refrigerator or Joule pump/Cold pump not only via changing the temperatures of the reservoirs, but also via the enclosed flux in Josephson junction loop which is the most lucrative aspect of work, since this fact alone implies a much greater possibility of our proposal being experimentally realized.
\acknowledgments
This work was supported by the grants: 1. Josephson junctions with strained Dirac materials and their application in quantum information processing, SERB Grant No. CRG/20l9/006258, and 2. Nash equilibrium versus Pareto optimality in N-Player games, SERB MATRICS Grant No. MTR/2018/000070.
