-
Notifications
You must be signed in to change notification settings - Fork 64
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
Methods for calculating expectation values from a list of observables, sampling from final state. #61
Conversation
`run()` method now only creates self.output with the state evolution and there's a new method `expect()` that takes a list of observables (Qobjs or ndarrays).
If the user wants the Qobjs, she can access them from `Simulation.output`.
Comments/Reviews are very welcome, @HGSilveri , @LucasGitQ @cdalyac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some remarks and potential improvements.
I still think these methods would fit better in a dedicated SimulationResults
class, which would be the output of Simulation.run()
.
Ah I remark that one of my comments on N was also pointed out by Henrique. The fix still does not address the 2-level nature of the measurement vs the (occasional) 3-level nature of the system. |
You're right, I forgot about this. It also reminds me that we choose the measurement basis in |
I will open a new issue for this three-state measurement. For the moment, the sampling method will only work for two-state measurement. |
A minor edit that you can maybe put in this pull request. Now that we have the interaction_coeff and rydberg_blockade_radius in device, I think we can safely suppress self._U. What do you think ? |
Yes, I forgot about that, thank you. |
It will now be a `SimulationResults` instance.
…nto simul_samples
Thanks, this is looking pretty good. One question: normally one would declare a measurement basis in the sequence (by adding a |
I thought about this. The downsides are that it requires making and simulating a new sequence to change the measurement basis and that it might be confusing when you're not sampling, as having a measurement at the end of a Sequence can be equated to a projection of the state vector. When you're interested in the full state vector, I would lean towards a sequence without a measurement. That being said, perhaps we can make |
I think this is a good solution, |
Also typo in ValueError in `simresults`
So how is this looking now? Can we merge so that the notebooks in ( |
I'll do another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good overall. After you address these remarks, it should be okay to merge on my end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me.
The `expect()` method now accepts `numpy.ndarray` for listing operators.
pulser/simresults.py
Outdated
|
||
Keyword Args: | ||
meas_basis (None or str): The basis in which a sampling measurement | ||
is desired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: needs a tab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that nit, it looks good to me!
…nto simul_samples
…nto simul_samples
Changes:
Simulation.run()
only evaluates the states at each timeSimulation.run()
outputs a list ofnumpy.ndarray
vectors instead ofqutip.Qobj
Simulation.expect()
allows for a list of observables to be provided, then uses the states at each time step to show the evolution of the observables.Simulation.sample_final_state()
returns acollections.Count
dictionary with a chosen number of samples from the final state of evolution.The notebooks have been adapted to reflect these proposed changes.
This also in reference to #55 and #56