0 votes
asked by (180 points)

Dear ITensor Team,

I have a problem with the readFromFile(FileName, sites) function. I am using a custom SiteSet "OpenSystemSite", which is a mixture of bosonic and fermionic sites.
When compiling, the function throws an error

error: no matching function for call to ‘read(std::ifstream&, itensor::OpenSystemSite<itensor::BosonSiteOpen, itensor::ElectronSite>&)’

Reading in the MPS created on this SiteSet seems to work fine.
Is the build-in function readFromFile() just not compatible with a mixed SiteSet or do you have an idea how I could fix this?

Best wishes and thanks for the great work on Itensor!

Luisa

commented by (480 points)
From the documentation on readFromFile, it seems like you have to already have created the space for the MPS: http://itensor.org/docs.cgi?page=classes/readwrite&vers=cppv3

From that link:
//Initialize MPS with SiteSet "sites" before reading from file:
auto psi = readFromFile<MPS>("wavefunction_file",sites);

So, if you already have created the space that the MPS "lives in" in order to read in the MPS, why save the site space to file and read it?
commented by (70.1k points)
Hi Luisa,
Sorry for the very slow reply. Could you please provide a piece of the code or a minimal working example of code that causes this error to happen?

But I may also be able to guess what caused the erorr: did you define a .read(std::istream& s) class method on your OpenSystemSite class? If not, it will necessary to define this for your site set to be able to be read from disk. (Writing to disk is in many cases easier and ITensor can automatically figure the .write case out by default.)

See for example the provided template called MixedSiteSet which is in the file itensor/mps/siteset.h and which defines its .read method on line 545 of that file.
Here is a link to it:
https://github.com/ITensor/ITensor/blob/477aaed9e82ddc0d4685d943dcbb128919fefc84/itensor/mps/siteset.h#L545

Finally, it seems like MixedSiteSet already offers the features you may want, if you just plug your BosonSiteOpen and ElectronSite into it.

Here is a small code example page that talks about and shows the usage of the MixedSiteSet template class: http://itensor.org/docs.cgi?vers=cppv3&page=formulas/gs_holst_polaron

Best,
Miles

Please log in or register to answer this question.

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

...