-
Notifications
You must be signed in to change notification settings - Fork 308
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
Sheath thickness functions #401
base: main
Are you sure you want to change the base?
Conversation
We sorta agreed a while ago to increase the line character limit for our code to 100. We should really make that more visible somehow. |
That's great! But are we going to refactor all current code for the new limit? |
Oh no, that would be a massive waste of time! I just mention that because the other changes you made to this module looked like you were shortening lines to fit 80, and I just wanted to keep you from wasting time on that :) |
I would kinda like to keep the current feature set before v0.1. Would you be fine with not merging this PR before that's done? |
Yes, seems like a good plan. |
02e758d
to
749a6bd
Compare
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.
Improve the tests a bit and then this should be good to merge.
plasmapy/physics/parameters.py
Outdated
|
||
lambda_D = Debye_length(T_e, n_s) | ||
|
||
s = (np.sqrt(2) / 3) * lambda_D * (2 * e * V_0 / T_e) ** 0.75 |
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.
Will the units here work out? Does astropy.units know that V/eV is unitless?
We might want to put these things in terms of kelvins or at least allow for interoperability (as per prior discussions).
|
||
V_0 = 80 * u.V | ||
|
||
assert matrix_sheath_thickness(V_0, n_e).unit.is_equivalent(u.m) |
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.
separate methods for each assert.
|
||
assert matrix_sheath_thickness(V_0, n_e).unit.is_equivalent(u.m) | ||
|
||
assert np.isclose(matrix_sheath_thickness(V_0, n_e).value, 1.329823977068723e-05) |
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.
error string message for when asserts fail.
# Conflicts: # plasmapy/physics/parameters.py
Hello @jasperbeckers! Thanks for updating your pull request.
Comment last updated on August 11, 2018 at 09:42 Hours UTC |
…asmaPy into langmuir-update
Sheath potential in units convertible to V. | ||
|
||
n_s : ~astropy.units.Quantity | ||
Sheath ion density in units convertible to m**-3. |
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.
Might be good to include some more description here of exactly which density is meant, since in the Child-law sheath the ion density is changing throughout the sheath. I'm 95% sure here you mean the density at the "sheath edge", or the point at which the ions have been accelerated to the Bohm speed through the presheath, and quasineutrality begins to break down. I think for a collisionless presheath this density is 1/sqrt(e) n_i ~= 0.606 n_i of the "bulk" plasma density n_i outside the presheath.
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.
Yes, and make sure to make this clear throughout the Langmuir probe code.
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.
I'm happy with merging this - just some minor suggested fixes.
@@ -273,7 +273,8 @@ def swept_probe_analysis(probe_characteristic, probe_area, gas, | |||
Estimate of the ion saturation current in units of Am^-2. | |||
|
|||
"hot_fraction" : float | |||
Estimate of the total hot (energetic) electron fraction. | |||
Estimate of the total hot (energetic) electron fraction. Only supplied | |||
if bimaxwellian is True. |
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.
This is minor, but I would call it a "bi-Maxwellian"
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.
re: @lemmatum: "bi-Maxwellian" is a better name, but it won't work as an argument.
@@ -974,7 +990,8 @@ def plasma_frequency(n, particle='e-', z_mean=None): | |||
# using user provided average ionization | |||
Z = z_mean | |||
Z = np.abs(Z) | |||
# TODO REPLACE WITH Z = np.abs(_grab_charge(particle, z_mean)), some bugs atm | |||
# TODO REPLACE WITH Z = np.abs(_grab_charge(particle, z_mean)), some |
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.
Are you going to do this? If not, raise it as a separate issue.
Sheath potential in units convertible to V. | ||
|
||
n_s : ~astropy.units.Quantity | ||
Sheath ion density in units convertible to m**-3. |
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.
Yes, and make sure to make this clear throughout the Langmuir probe code.
If one or more of the supplied parameters are not of the correct type. | ||
|
||
~astropy.units.UnitConversionError | ||
If one or more parameter cannot be succesfully converted to the |
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.
parameters, plural
respective unit. | ||
|
||
ValueError | ||
If one or more parameter does not have an appropriate value. |
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.
same as above - fix throughout
----- | ||
The Child law sheath model is self-consistent in terms of ion density | ||
throughout the sheath and assumes a large sheath potential compared to the | ||
electron temperature. The sheath thickness is given by |
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.
Out of curiosity, is there a good or commonly used criterion for this? For example, a potential 100x larger than electron temperature?
V_0 = 80 * u.V | ||
|
||
def test_correct_unit(self): | ||
assert matrix_sheath_thickness(self.V_0, n_e).unit.is_equivalent(u.m), \ |
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.
replace continuation slash
V_0 = 80 * u.V | ||
|
||
def test_correct_unit(self): | ||
assert Child_law_sheath_thickness(T_e, self.V_0, n_e).unit.is_equivalent(u.m), \ |
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.
replace continuation slash
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.
The code looks good, but I think there's a few doc fixes that would make this look much better!
@@ -273,7 +273,8 @@ def swept_probe_analysis(probe_characteristic, probe_area, gas, | |||
Estimate of the ion saturation current in units of Am^-2. | |||
|
|||
"hot_fraction" : float | |||
Estimate of the total hot (energetic) electron fraction. | |||
Estimate of the total hot (energetic) electron fraction. Only supplied | |||
if bimaxwellian is True. |
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.
re: @lemmatum: "bi-Maxwellian" is a better name, but it won't work as an argument.
'n_s': {'units': u.m ** -3, 'can_be_negative': False} | ||
}) | ||
def matrix_sheath_thickness(V_0, n_s): | ||
r"""Calculate the matrix sheath thickness for a high potential sheath. |
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.
I think this could potentially be more descriptive than repeating the function's name, but I don't really have any better suggestions!
>>> matrix_sheath_thickness(80 * u.V, 1e18 * u.m**-3) | ||
<Quantity 9.40327552e-05 m> | ||
|
||
""" |
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.
We could probably use a reference here.
>>> Child_law_sheath_thickness(1e6 * u.K, 80 * u.V, 1e18 * u.m**-3) | ||
<Quantity 5.17439662e-05 m> | ||
|
||
""" |
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.
Likewise, a reference would be nice to have here.
errStr = (f"The test result value of matrix_sheath_thickness is not correct " | ||
f"and returns {test_result} instead of {expected}.") | ||
|
||
assert test, errStr |
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.
I really think we need to start using http:https://docs.astropy.org/en/stable/api/astropy.tests.helper.assert_quantity_allclose.html?highlight=assert this function rather than run our custom checks! I'll just keep grumbling in reviews about it, I guess.
bump can we resolve conflicts, get those minor fixes done, and merge this? |
bump the 2nd |
This pull request will be closed in 14 days due to a year of inactivity unless the stale label or comment is removed. |
I will try to pick this up and finally get it merged! ... sometime for 0.7 :) |
Adds matrix and Child law sheath thickness functions to
parameters.py
. These are important in characterizing a plasma and defining criteria for the use of probes and other diagnostics (one of the items of #339).