# Performing a Jordan Wigner transformation on fermionic MPS or MPO

**URL:** https://itensor.discourse.group/t/performing-a-jordan-wigner-transformation-on-fermionic-mps-or-mpo/556
**Category:** ITensor Julia Questions
**Tags:** mps, mpo, fermions, julia
**Created:** [December 9, 2022, 9:06pm UTC](https://itensor.discourse.group/t/performing-a-jordan-wigner-transformation-on-fermionic-mps-or-mpo/556 "2022-12-09T21:06:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aakhan3](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@aakhan3](https://itensor.discourse.group/u/aakhan3)
#### Post date: [December 9, 2022, 9:06pm UTC](https://itensor.discourse.group/t/performing-a-jordan-wigner-transformation-on-fermionic-mps-or-mpo/556/1 "2022-12-09T21:06:19Z")

</div>

Is there a straightforward method to convert an MPS or MPO with electronic site indices into an MPS or MPO with spin 1/2 indices via a Jordan Wigner transformation?

For example, suppose I have Fermi-Hubbard Hamiltonian:

```auto
sites = siteinds("Electron", Nx*Ny; conserve_nf = true, conserve_nfparity = true)

lattice = square_lattice(Nx, Ny; yperiodic=false, xperiodic=false)

ampo = OpSum()
for b in lattice
    ampo += t, "Cdagup", b.s1, "Cup", b.s2
    ampo += t, "Cdagup", b.s2, "Cup", b.s1
    ampo += t, "Cdagdn", b.s1, "Cdn", b.s2
    ampo += t, "Cdagdn", b.s2, "Cdn", b.s1
end
for i in 1:N
    ampo += u, "Nupdn", i
end
H = MPO(ampo, sites)

```

Does ITensors have any implementation like `jordan_wigner_transform(MPO::H)` that will result in an MPO with site indices having something like  
`(dim=2|id=825|"S=1/2,Site,n=1")`

---

<div class="post-metadata">

### Author: ![miles](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/miles/32/6_2.png) [@miles](https://itensor.discourse.group/u/miles)
#### Post date: [December 11, 2022, 8:42pm UTC](https://itensor.discourse.group/t/performing-a-jordan-wigner-transformation-on-fermionic-mps-or-mpo/556/2 "2022-12-11T20:42:39Z")

</div>

We don’t have a function that does that. In your case, I would suggest performing the Jordan-Wigner transformation analytically (detailed guide about the math here [http://itensor.org/docs.cgi?vers=cppv3&page=tutorials/fermions](http://itensor.org/docs.cgi?vers=cppv3&page=tutorials/fermions)) and then inputting the resulting spin Hamiltonian into OpSum to make the spin MPO.

---

<div class="post-metadata">

### Author: ![mtfishman](https://yyz2.discourse-cdn.com/free1/user_avatar/itensor.discourse.group/mtfishman/32/11_2.png) [@mtfishman](https://itensor.discourse.group/u/mtfishman)
#### Post date: [December 18, 2022, 5:41pm UTC](https://itensor.discourse.group/t/performing-a-jordan-wigner-transformation-on-fermionic-mps-or-mpo/556/3 "2022-12-18T17:41:52Z")

</div>

The MPO output by `MPO` already includes the Jordan-Wigner transformation. Are you specifically interested in having 2-dimension local Hilbert spaces instead of 4-dimensional local Hilbert spaces? If so you could use `"Fermion"` sites (which represent spinless fermions) and then write your `OpSum` in terms of spinless fermionic degrees of freedom.
