Skip to content

Set Seed for Random MPS #79

Answered by hczhai
jtcantin asked this question in Q&A
Discussion options

You must be logged in to vote

You can use driver.bw.b.Random.rand_seed to set a random seed before calling driver.get_random_mps. For example:

from pyblock2.driver.core import DMRGDriver, SymmetryTypes
from pyblock2.algebra.io import MPSTools

ncas, n_elec, spin = 10, 10, 0
driver = DMRGDriver(scratch="./tmp", symm_type=SymmetryTypes.SZ, n_threads=4)
driver.initialize_system(n_sites=ncas, n_elec=n_elec, spin=spin)

driver.bw.b.Random.rand_seed(1234)
ket = driver.get_random_mps(tag="GS", bond_dim=10, nroots=1, dot=1, occs=[0.5] * ncas)
pyket = MPSTools.from_block2(ket)
print('random block at site 1 =\n', pyket.tensors[1].blocks[0].reduced)

Note:

  1. driver.bw.b.Random.rand_seed(0) will generate different results every tim…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hczhai
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants