+4 votes
asked by (230 points)

Hi, what is the best way to create a random initial product state of the form:

|psii> = cos(thi)|Up> + sin(th_i) |Dn>

|PSI> = |psi1> x ...x |psiN>

I tried something like this:

 auto psi = MPS(sites);
 for(int i=1; i<=Nspins; i++){
         double rndNum = (double) 2*M_PI*random()/RAND_MAX;
         auto si = sites(i);
         auto wf = ITensor(si);
         wf.set(si(1), cos(rndNum));
         wf.set(si(2), sin(rndNum));
         psi.setA(i,wf);
 }

But I feel like I need to account for the link indices some how? Am I doing this properly and/or is there a better way? Thanks.

1 Answer

+2 votes
answered by (14.1k points)

That looks like a fine way to do it. Note that you could also use an InitState and then apply a random on-site rotation, similar to the answer given here: http://www.itensor.org/support/1359/how-to-create-a-particular-initial-state-as-a-mps

You don't need to worry about the link indices, the MPS (sites) constructor makes a product state with only site indices. If you use your MPS in an algorithm that increases the bond dimension (such as 2-site DMRG or TEBD), the link indices will get "generated" by the SVD.

commented by (14.1k points)
My answer above was slightly wrong. The MPS(sites) constructor makes a product state that does have link indices (of dimension 1).

However, your approach above, which overwrites all of the MPS tensors with ITensors that only have site indices, is fine and will work with many ITensor functions (such as using it as a starting state in DMRG).

If you were to instead set the elements of the existing MPS tensors, instead of replacing them entirely, you would have to include the link indices of those tensors. For example, setting an element of the MPS tensor at site `i` might look like:

    auto i = 3;
    auto si = uniqueIndex(psi.A(i),psi.A(i-1),psi.A(i+1));
    auto li_1 = commonIndex(psi.A(i-1),psi.A(i));
    auto li = commonIndex(psi.A(i),psi.A(i+1));
    psi.Aref(i).set(si(1),li_1(1),li(1),cos(rndNum));

Potentially we could make this easier by allowing users to not include IndexVals for Indices with dimension 1, but that would require checks every time a value needs to be set so may not be a good idea.
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...