Git Product home page Git Product logo

Comments (5)

david-pl avatar david-pl commented on May 29, 2024

It's true, that there is no "native" support for more dimensions. However, this is simply because multiple dimensions are just a product space of one dimension such that they are still quite easy to implement.

When running your code, I get an AssertionError. This is caused by the last line H = LazySum(Hkinx, Hkiny). This is because you are taking the sum without building the product space first, i.e. you write H = Hkinx + Hkiny instead of H = Hkinx ⊗ one(b_positiony) + one(b_position) ⊗ Hkiny. The following lines of code give you what you are looking for in terms of lazy operations:

b_comp = b_position ⊗ b_positiony

Hkinx_comp = LazyTensor(b_comp, [1, 2], [Hkinx, one(b_positiony)])
Hkiny_comp = LazyTensor(b_comp, [1, 2], [one(b_position), Hkiny])

H = LazySum(Hkinx_comp, Hkiny_comp)

Using the composite space also answers your question about Gaussian states. A two-dimensional Gaussian state is just the tensor product of two one-dimensional states, e.g.:

ψx = gaussianstate(b_position, 0, 5, 2)
ψy = gaussianstate(b_positiony, 0, 5, 2)
ψ = ψx ⊗ ψy

Does this answer your question?

Addition Comments:

  • Be careful with your dimension parameter Npoints. Since the dimension are multiplied for a composite space it is quite easy to end up with a huge Hilbert space dimension.
  • If you want to calculate some dynamics, e.g. via a Schrödinger equation, note that there is, unfortunately, currently no implementation that works with a LazyTensor operator consisting of LazyProduct operators. So if this is what you are aiming for you can omit all lazy operations, or simply use sparse(full(H)) when calling the time evolution function.
  • I agree that there should be a different platform for questions, so I will look into gitter.

from quantumoptics.jl.

Datseris avatar Datseris commented on May 29, 2024

A very quick question: What is the latex completion entry for ⊗?
Also, does not have documentation strings, where can I look them up and learn more in the documentation?

Edit: LazyTensor does have a documentation string, it was a Juno display problem

Second edit: is equivalent with tensor, right?

from quantumoptics.jl.

Datseris avatar Datseris commented on May 29, 2024

Awesome, the tensor docstring also has the unicode symbol! I am sorry I am constantly asking stupid stuff, but I just started on the package so bear with me :P

from quantumoptics.jl.

Datseris avatar Datseris commented on May 29, 2024

@david-pl I am amazed!!!
Not only it worked perfectly, but I was also able to implement a one-dimensional potential barrier. I am extremely pleased with QuantumOptics.jl! In fact, I spent most of my time trying to animate the wavepacket motion; using QuantumOptics.jl was clearer and easier than using PyPlot.jl. (If you want a gif for the website let me know).

There is still one thing I could not conceptually understand. In the case of one-dimensional potential, I did the following:

function V_barrier(x)
    if x < -d/2 || x > d/2
        return 0.
    else
        return V0
    end
end
V = potentialoperator(b_position, V_barrier)
V_comp = LazyTensor(b_comp, [1, 2], [V, one(b_positiony)])
# Now you can do the sum
H = LazySum(Hkinx_comp, Hkiny_comp, V_comp)

And it worked fine. If I had a potential that was depended on both x and y but was separatable I could do the same V(x, y) = V1(x) + V2(y). What I am not sure about at the moment is how to add a potential that depends on both x and y at the same time without being separatable, e.g. V(x,y) = sin(x*y) for an extreme example.

V = potentialoperator(b_comp, V_f) does not work because potentialoperator doesn't know how to accept a composite basis.
Furthermore I don't see how to use V_comp = LazyTensor(b_comp, [1, 2], [V1, V2]) since I Cannot separate the potential to V1, V2.

from quantumoptics.jl.

david-pl avatar david-pl commented on May 29, 2024

I am glad you like our framework!

In order to create a potentialoperator in two dimensions that is dependent on both coordinates such as in your example sin(x*y) it is, unfortunately, not possible to use the implemented function potentialoperator. However, all this function does is to create a diagonaloperator. So, considering the fact that the operators x and y are diagonal in a position basis (and hence also their tensor product), applying a function to a tensor product x ⊗ y results in a diagonal operator where the function is applied to each element of a diagonal.

In terms of your example, this can be realized by

xspace = samplepoints(b_position)
yspace = samplepoints(b_positiony)

diag_comp = diagonaloperator(b_position, xspace) ⊗ diagonaloperator(b_positiony, yspace)
V_comp = V0*SparseOperator(b_comp, sin.(diag_comp.data))

You can check that this potential barrier has the correct form by plotting (using PyPlot)

barrier = reshape(diag(V_comp.data), (b_position.shape[1], b_positiony.shape[1]))
contourf(xspace, yspace, barrier)

I hope this resolves your problem! I had no time to check if this also results in the correct dynamics, though, so please make sure to double-check the code above.

In the meantime, I think this issue has gone far off-topic so I will close it. However, I created a Gitter room, so if you have further questions please ask them here. I will look into adding the badge to the GitHub page.

from quantumoptics.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.