# Nonlinear Schrodinger equation/quantumoptics.jl

**URL:** <https://discourse.julialang.org/t/nonlinear-schrodinger-equation-quantumoptics-jl/57436>\
**Category:** Quantum\
**Tags:** quantum\
**Created:** [March 18, 2021, 4:27am UTC](https://discourse.julialang.org/t/nonlinear-schrodinger-equation-quantumoptics-jl/57436 "2021-03-18T04:27:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![narayan](https://avatars.discourse-cdn.com/v4/letter/n/22d042/32.png) [@narayan](https://discourse.julialang.org/u/narayan)\
**Post date:** [March 18, 2021, 4:27am UTC](https://discourse.julialang.org/t/nonlinear-schrodinger-equation-quantumoptics-jl/57436/1 "2021-03-18T04:27:49Z")

</div>

I saw in the documentation of quantumoptics.jl that it can simulate Spin F=1 spinor BEC which is basically three nonlinear coupled partial differential equations. I am wondering whether there is a way to solve GP equation(non-linear Schrodinger equation) for higher spins?

---

<div class="post-metadata">

**Author:** ![david-pl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/david-pl/32/6224_2.png) [@david-pl](https://discourse.julialang.org/u/david-pl)\
**Post date:** [March 30, 2021, 8:35am UTC](https://discourse.julialang.org/t/nonlinear-schrodinger-equation-quantumoptics-jl/57436/2 "2021-03-30T08:35:05Z")

</div>

@narayan Sure you can. You just need to add the necessary terms in the Hamiltonian using a `directsum`. Also, your components will be spin-N/2 rather than spin-1/2 as in the example, but you can just use `SpinBasis(N//2)` for that.

---

<div class="post-metadata">

**Author:** ![narayan](https://avatars.discourse-cdn.com/v4/letter/n/22d042/32.png) [@narayan](https://discourse.julialang.org/u/narayan)\
**Post date:** [March 30, 2021, 11:17am UTC](https://discourse.julialang.org/t/nonlinear-schrodinger-equation-quantumoptics-jl/57436/3 "2021-03-30T11:17:41Z")

</div>

And if I have integer spin, like F=2 or 3. Can I use imaginary time evolution in this kind of approach?

---

<div class="post-metadata">

**Author:** ![david-pl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/david-pl/32/6224_2.png) [@david-pl](https://discourse.julialang.org/u/david-pl)\
**Post date:** [March 30, 2021, 12:36pm UTC](https://discourse.julialang.org/t/nonlinear-schrodinger-equation-quantumoptics-jl/57436/4 "2021-03-30T12:36:15Z")

</div>

If I’m not mistaken imaginary time evolution should work regardless of the specific system you have. So yeah, you should just be able to adopt the example from the documentation to do what you need.

---

<div class="post-metadata">

**Author:** ![antoine-levitt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/antoine-levitt/32/4008_2.png) [@antoine-levitt](https://discourse.julialang.org/u/antoine-levitt)\
**Post date:** [March 30, 2021, 1:13pm UTC](https://discourse.julialang.org/t/nonlinear-schrodinger-equation-quantumoptics-jl/57436/5 "2021-03-30T13:13:10Z")

</div>

Imaginary time evolution is gradient descent, don’t do that. Instead, use a solver supporting manifold type constraints (Optim or Manopt) and a better algorithm, like CG or LBFGS.
