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

Comments and docstrings #20

Merged
merged 4 commits into from
Jan 3, 2018
Merged

Comments and docstrings #20

merged 4 commits into from
Jan 3, 2018

Conversation

ksunden
Copy link
Member

@ksunden ksunden commented Dec 31, 2017

Just some initial comments and docstrings and such, wanted someone else to read to ensure that I say what I mean to say, and that it makes sense.

Thanks

@ksunden
Copy link
Member Author

ksunden commented Dec 31, 2017

We may have some style inconsistencies, particularly in the C method description block comments.
I'm not worrying about that too much at this time, but it may be worth deciding on a styleguide to follow in the future.

Copy link
Member

@untzag untzag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate having an explicit marker for optional kwargs, consider (optional)

Shape T x N x N array with the full Hamiltonian at each time step.
N is the number of states in the Density vector.
"""
#TODO: Just put the body of this method in here, rather than calling _gen_matrix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to hold off for this PR, because I want this to be as much as possible limited to non-code, i.e. comments and docstrings. This is one of the first things to be done when I touch the code again though. This is issue #26.

except populations, which default to np.inf.
Default is 50. fs (scalar, then brodcast as above.
mu : 1-D array <Complex>
The magnetic suceptabilities used either in computing state densities or output intensities
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why you use the word "magnetic" (you go on to use it several times)

how about just "susceptibilities"? or "dipole moment"?

unless I'm mistaken (which I often am) these are not magnetic susceptabilities

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, my tired brain was mixing up susceptibilities and dipole moments, my mistake, thanks for catching it

The lifetime of the states in femptoseconds.
If tau is scalar, the same lifetime is used for all transitions,
except populations, which default to np.inf.
Default is 50. fs (scalar, then brodcast as above.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(scalar, then brodcast as above

don't know what this means? unintentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reading this again, and agree it's unclear, rather than try to explain what I meant here, I'm just going to have another go at writing it from scratch, hopefully that's clearer

mu : 1-D array <Complex>
The magnetic suceptabilities used either in computing state densities or output intensities
Array like structures are converted to the proper data type.
Order mattersd, and meaning is dependent on the individual Hamiltonian.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling of "matters"

The initial density vector, length defines N.
Default is 1. in the ground state (index 0), and 0. everywhere else.
tau : scalar or 1-D array
The lifetime of the states in femptoseconds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are many rates to consider, so I worry that users will be confused...

perhaps be explicit:
for coherences, tau is the pure dephasing time
for populations, tau is the population lifetime

I always get confused... are we sure tau is a time here? or is it actually a rate? just something to double check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tau is the time, the value that is used in computations is Gamma, which is computed to be 1/tau

@@ -95,7 +98,7 @@ def run(self, mp='cpu', chunk=False):
mp : {False, 'cpu', 'gpu'} (optional)
Select multiprocessing: False (or '' or None) means single-threaded.
'gpu' indicates to use the CUDA implementation
Any other value which evaluates to `True` indicates cpu multiprocessed.
Any other value which evaluates to ``True`` indicates cpu multiprocessed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is nice

with the code as it is now, I'm fairly sure that windows machines will require an if __name__ == '__main__' to prevent infinite spawning---we might want to mention this in the docstring

I think that the "if name" windows oddity can be fixed by using the new futures library, as opposed to multiprocessing, we should probably open an issue to figure that out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to refrain from tackling this particular issue for the moment. We have an ongoing discussion in #18 regarding this windows forkbomb.
I'd like to test it out and decide on the desired course of action prior to doing this particular bit of documentation.
I have not attempted running on Windows, and would like to see the problem first.

@ksunden
Copy link
Member Author

ksunden commented Jan 1, 2018

I have added the (optional) marker for now to the hamiltonian __init__. Admittedly, I didn't add it before partly because all of them are optional, partly because I think we may wish to do a bit better abstraction and have a base either without optional parameters, or at least some required fields. What makes it a little tricky is if we wish to change the ordering...

Having a base hamiltonian that is not any particular useful hamiltonian may be beneficial, simplifying some code, and allowing for easier reparameterization (e.g. w_central and coupling values, nonsensical for many potential hamiltonians, but useful for TRIVE). We then may wish to reorder the parameters from their current order. We may also wish to make some of the parameters not changeable via the init method, e.g. subclasses define the state labels, and do not necessarily expose those to the user in the init method.

What we have now is great, it works, but I think we may wish to have an abstracted version of this.
If done well, we may be able to have a single C struct for the CUDA implementation of all Hamiltonians (or at least most), reducing the need to program that and the transfer method for every hamiltonian.

@ksunden
Copy link
Member Author

ksunden commented Jan 3, 2018

ping @untzag

I plan on merging this tomorrow, however, if there are still comments, please let me know, I will address them as soon as I am able

@ksunden ksunden merged commit 392953b into master Jan 3, 2018
@ksunden ksunden deleted the comments branch January 3, 2018 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants