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

WIP: Helium approx. #374

Merged
merged 20 commits into from
Aug 19, 2015
Merged

WIP: Helium approx. #374

merged 20 commits into from
Aug 19, 2015

Conversation

aoifeboyle
Copy link
Contributor

Still working on this.

@aoifeboyle
Copy link
Contributor Author

@wkerzendorf Could you take a look at this and see if you're happy with how it's coded? I still have to add tests etc.

helium_population = deepcopy(level_boltzmann_factor.ix[2])
# He I excited states
he_one_population = level_boltzmann_factor.ix[2].ix[0] * \
Copy link
Member

Choose a reason for hiding this comment

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

this calculation is done somewhere else as well. Let's just make one function for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wkerzendorf So the He I level population calculation here is different to what the code normally uses because it's calculated from the GS of the He II ion rather than the He I ion. You're right with the He II and He III level populations though, but it's easier for me to keep all of these calculations in the same function so that I can normalise the populations easily using the number density. But I'm having a think now about ways to simplify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok so I was thinking that I could just use some kind of scaling method to change the He II and He III populations after the He II ground state population is set to 1.0, but that would require using the level_number_density property as an input property here, which would create a loop. I think this is the only way to do it simply.

Copy link
Member

Choose a reason for hiding this comment

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

@aoifeboyle What I meant was. Add functions (maybe static ones) to the other properties in the code that do similar calculations and then both properties use their functions. One such example is in level_populations in line 26 and 47. they both use the same calculation, but it is in the code twice. Use a static function there. We can skype on this if you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wkerzendorf Ok, so I can leave the HeliumNLTE property alone? I'll merge the two level_population properties into one now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wkerzendorf Let me know if you think what I have now for the level_populations is better. I had another look and all of the level population calculations in the HeliumNLTE property are different to the level population calculations in LevelNumberDensity because they are all calculated relative to ground state populations rather than using the ion populations. So being able to call the same calculations would not be helpful. Let me know if that makes sense to you. I think it's tidier now anyway.

@wkerzendorf
Copy link
Member

@aoifeboyle looks like a good first effort, but I feel that we should make sure that code is not repeated. Let me know if that explains it.

@aoifeboyle
Copy link
Contributor Author

@wkerzendorf Ok, I see what you mean. Leave it with me.

ionization_data, beta_rad, g, g_electron, w, t_rad, t_electrons,
delta, zeta_data, number_density):
helium_population = deepcopy(level_boltzmann_factor.ix[2])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to use deepcopy? It can be incredibly slow, could be a problem if this is called often.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orbitfold Not really! I just use it from habit. I didn't know it was slow. I'll replace it with copy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well you might need it depending on what you want to do. But if you can use copy do that.

@wkerzendorf
Copy link
Member

hi @aoifeboyle I can't see your comments for some reason on github (am getting emails about them). I can't look at it now in detail. But while we wait - have a look at line 26 and 47 in level_populations. you can make it one function callable from the other one (use static methods - let me know if that's unclear).

@aoifeboyle
Copy link
Contributor Author

@wkerzendorf So I've changed the Helium NLTE stuff so it makes use of the functions that already exist as static methods (the Phis, etc.), and I've removed repetition from other parts of the code too. Could you have a look through and tell me what you think when you have time?

phis = (1 / PhiSahaLTE.calculate(g_electron, beta_rad,
partition_function, ionization_data)) * electron_densities * \
(1.0/g.ix[2].ix[1].ix[0]) * (1/w) * (t_rad/t_electron)**(0.5)
Copy link
Member

Choose a reason for hiding this comment

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

you can do .ix[2, 1, 0]. Maybe try not to us ix but iloc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to .ix[2,1,0]. I used to use .iloc but it doesn't work with one of the Pandas versions on here so I always use .ix now.

@aoifeboyle
Copy link
Contributor Author

@wkerzendorf Can I merge this?

@aoifeboyle
Copy link
Contributor Author

@wkerzendorf Got the error 245 for one of the Travis checks here but nothing happens when I click the button to re-run it for some reason? It's definitely not the code because the previous commit worked fine and this one was just a small change to an .rst file.

@wkerzendorf
Copy link
Member

@aoifeboyle I think that looks very good. As I'm quite busy this week, I'll let @orbitfold have another look for any code style issues and then we can merge (do this at your own discretion).

@orbitfold
Copy link
Contributor

Well, one obvious thing is that there are no docstrings. And the chances of anyone adding them later if you don't now are slim :) And there should really be docstrings for each method explaining the arguments and what the method does and what it returns. I don't believe we are very consistent with our docstring conventions but any docstring is better than none. This is as good as anything for a style guide I guess:

http://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_google.html

Or look at our code that does contain them.

@wkerzendorf
Copy link
Member

We use numpydoc docstring format (if we do)
On Wed, Aug 19, 2015 at 14:15 Vytautas Jancauskas [email protected]
wrote:

Well, one obvious thing is that there are no docstrings. And the chances
of anyone adding them later if you don't now are slim :) And there should
really be docstrings for each method explaining the arguments and what the
method does and what it returns. I don't believe we are very consistent
with out docstring conventions but any docstring is better than none. This
is as good as anything for a style guide I guess:

http://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_google.html

Or look at our code that does contain them.


Reply to this email directly or view it on GitHub
#374 (comment).

@orbitfold
Copy link
Contributor

@aoifeboyle
Copy link
Contributor Author

Ok, I'll start on that now!

@aoifeboyle
Copy link
Contributor Author

@orbitfold Let me know if there are any other issues, because I might merge this and then create a new PR with docstrings for the whole plasma.

@orbitfold
Copy link
Contributor

I just looked through it and I can't think of anything nasty to say about it, I think it's fine. Why do you need a separate PR for docstrings though?

@aoifeboyle
Copy link
Contributor Author

I don't have to. It's just I haven't done proper docstrings for all the other plasma stuff I've added, so I'd like to do the whole lot at once.

@orbitfold
Copy link
Contributor

Either way is fine, just curious :)

aoifeboyle pushed a commit that referenced this pull request Aug 19, 2015
@aoifeboyle aoifeboyle merged commit 643a6b1 into tardis-sn:master Aug 19, 2015
@aoifeboyle aoifeboyle deleted the plasma/helium branch August 29, 2015 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants