Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measurement function fixes #182

Merged
merged 12 commits into from Nov 4, 2022
Merged

Measurement function fixes #182

merged 12 commits into from Nov 4, 2022

Conversation

jhauschild
Copy link
Member

Again, this change is backwards incompatible, so I'm creating a pull request to make the change more visible and track it better.

The relevant incompatibility is in f580506 (cherry-picked from 2a5052a), namely that measurement functions need to accept models as additional arguments. This is necessary to ensure compatiblity of the psi to be measured with the model, e.g. when grouping sites.

While you're changing those measurement functions, you might also want to follow the new TeNPy convention that they start with an m_, e.g. we renamed tenpy.simulations.measurement.bond_dimension to tenpy.simulations.measurement.m_bond_dimension. For now, the old names still work in the config/yaml files, but they give a FutureWarning.
You should update the config yaml files in projects where you want to update to a new TeNPy version:

  • update the connect_measurements simulation parameter: all direct measurement functions (taking results, psi, model, simulation as arguments and saving to results) defined in TeNPy have been renamed to start with m_.
    At this point, all those functions are defined in tenpy.simulations.measurement.py.
  • If you're using psi_method to measure e.g. correlation functions, you need to update the entry as follows:
    An old python entry for connect_measurements
{...,
 'connect_measurements': [['tenpy.simulations.measurement',
                           'psi_method',
                           'correlation_function',
                           {'key': '<Sp_i Sm_j>', 'ops1': 'Sp', 'ops2': 'Sm'},
                          ],
                          ...
                          ]

can get replaced with new entry:

{...,
 'connect_measurements': [['psi_method',
                           'wrap correlation_function',
                           {'key': '<Sp_i Sm_j>', 'ops1': 'Sp', 'ops2': 'Sm'},
                          ],
                          ...
                          ]

Similarly, an old yaml entry for connect_measurements

connect_measurements:
    - - tenpy.simulations.measurement
      - psi_method
      - method: correlation_function
        key: '<Sp_i Sm_j>'
        ops1: Sp
        ops2: Sm
    - ...

can get replaced with new yaml:

connect_measurements:
    - - psi_method
      - wrap correlation_function
      - results_key: '<Sp_i Sm_j>'
        ops1: Sp
        ops2: Sm
    - ...

The wrappers provide a simple way to measure not only global functions
but also methods of psi and the simulation class.

Here, the fix of 2a5052a
is not yet included, so the next commit is a cherry-pick merging only that.
…rameter

This is necessary to avoid special-cases inside measurment functions for
grouped sites, orthogonalExcitations and others. The model is guaranteed
to be compatible with the state.

This is a cherry-pick of a previous commit 2a5052a
not yet merged in the main branch, but already existing other branches, in particular excitations_science and vumps.
E.g. tenpy.simulations.measurement.bond_dimension(...) is now tenpy.simulations.measurement.m_bond_dimension(...)
@jhauschild jhauschild added the incompatible breaks backward compatibility label Oct 17, 2022
@jhauschild jhauschild added this to the Release 0.10 milestone Nov 4, 2022
@jhauschild jhauschild merged commit c2f26f3 into main Nov 4, 2022
@jhauschild jhauschild deleted the measurement_function_fixes branch November 4, 2022 13:16
@jhauschild
Copy link
Member Author

Further information can also be found in the new measurement user guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible breaks backward compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant