How to generate a random MPS in tenpy

How do I use this algorithm? What does that parameter do?
Post Reply
QichengTang
Posts: 32
Joined: 08 Jan 2019, 03:03

How to generate a random MPS in tenpy

Post by QichengTang »

how to generate a random MPS? Is the function "npc.Array.from_func" helpful?
PS. I think it's worthy to add a function like "rand_mps".
bart
Posts: 26
Joined: 23 Jan 2019, 09:35

Re: How to generate a random MPS in tenpy

Post by bart »

I'm not sure exactly which type of random MPS you're looking for, however for a spin-1/2 example, I would do something like this to generate a random initial product state:

Code: Select all

product_state = []
for i in range(M.lat.N_sites):
    product_state.append(random.choice(["up", "down"]))
psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS)
This generates an initial MPS with a list of random up and down spins. Were you thinking of something like this?
QichengTang
Posts: 32
Joined: 08 Jan 2019, 03:03

Re: How to generate a random MPS in tenpy

Post by QichengTang »

Thanks for your reply. But what i'm looking for is not a random product state.
What I want is a general state not a product state.
I konw that there is a method to obtain a random state by a random unitary evolution process, but i'm asking a more simple way to get a random state, like by using some random function to get the matrices on each site.
Leon
Posts: 13
Joined: 23 Jul 2018, 09:08
Location: University of Kent

Re: How to generate a random MPS in tenpy

Post by Leon »

You could potentially use the classmethod from_full() in tenpy.networks.mps.py.

I am curious why you would need a fully random MPS. Does starting from a random product state with the mixer implemented not give your desired results?
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: How to generate a random MPS in tenpy

Post by Johannes »

Sorry for not coming back to this earlier.

The real question is: what do you mean with "random" when talking about an MPS?

When you draw a "random" state uniformly from the Hilbert space, it has a volume law entanglement; in fact it is almost maximally entangled!
Therefore, it won't work for large systems to draw a random vector uniformly from the Hilbertspace and convert it into an MPS.

You might want to a get an MPS with fixed (maximal) bond dimensions and "random" entries. But this is problematic as well:
A big point of TenPy is also to exploit symmetries, and these symmetries imply that certain entries of your tensors cannot be non-zero. To initialize an MPS compatible with the symmetries of your Hamiltonian, you need to specify the "LegCharge"s for these symmetries on the bonds of the MPS.
If you are willing to do that, you can use these LegCharges to initialize "B" matrices (using npc.Array.from_frunc, if you want to provide e.g. np.random.gaussian), and just initialize the MPS with them. However, specifying these charges is not really trivial...

I think the best way is with the RandomUnitaryEvolution you mentioned:
You can first initialize a product state, and then apply a few random two-site unitaries to it (which is a very well defined thing).
Be aware that this generates a state with only short-range entanglement (depending on how many steps you do with the random unitary evolution),
and that the bond dimension grows exponentially with the number of steps you do, so you might need to truncate strongly.
Since this is a simple TEBD-like scheme, the truncation will completely destroy the "canonical form", so you need to bring the state back into canonical form (assuming that you need that).

Here's an example code:

Code: Select all

# assuming that "M" is a model
# first initialize a product state
product_state = (["up", "down"] * (M.lat.N_sites))[:M.lat.N_sites]  # assuming you have spin sites
psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS)
TEBD_params = {'N_steps': 10, 'trunc_params':{'chi_max': 20}, 'verbose': 0}
eng = tebd.RandomUnitaryEvolution(psi, TEBD_params)
eng.run()
psi.canonical_form() # important if you truncate strongly during the random evolution!!!
# now psi has somewhat random entries
It's your responsibility to choose the initial state in a sensible way, e.g. if you have Sz conservation, choosing all up spins would be a bad idea...

Disclaimer: no guarantees whatsoever about the randomness / random properties of the generated state ;-)
QichengTang
Posts: 32
Joined: 08 Jan 2019, 03:03

Re: How to generate a random MPS in tenpy

Post by QichengTang »

Thanks for your reply!

In fact, I want to get some states with random entanglement entropy. I know the random unitary time evolution will be a good method.

I was thinking about that is there a method can directly obtain these states? The first coming problem is about the charge conserve as you said, and I do not know how to solve it.

As I understand, the random unitary time evolution is the most reliable and simple way to get these states. By adjust the time, it's possible to get states with random entanglement entropy including both strong entangled states and weak entangled \ disentangled states.
Post Reply