-
Notifications
You must be signed in to change notification settings - Fork 339
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
Lite-Functions Ep. 1 | Jump to Hyperspace #1145
Changes from 1 commit
81404df
8fc110d
685273d
cac62a9
84d2f03
50b34f7
a29efc3
c0671a5
333601d
b6210b8
767881b
4a74376
26894e3
b3c3f3e
a1a6261
7f241f7
e4556ed
feec550
011684a
3b9a8b8
f041f4e
64690d2
18cb076
5e9e666
14f5dbd
8435067
a12bbdf
208e228
bda8d54
42a44d8
906e17d
ae3d7c0
dac26fb
ed02fda
b496f72
fd6d9cc
47902bd
15f12ae
e30a035
e6bf576
be2739a
92c2017
58683aa
2341c6f
cb3e074
eb54dd8
6e69676
7c45387
0a34a98
32c0c68
33d872f
69f40d9
c76cd3a
60969e0
54dfd9c
32ed7ed
523cd60
54c4b1a
0ccc0b3
5974b65
10341b2
bf444f8
38adced
1a2db15
6a2f132
1dd8f05
42db94a
606caf5
114d753
91a7ed5
5a11eaf
aab251b
c25d3e7
777936d
e6c4111
2b0e3d7
95f4984
fd86299
dbf78a1
78bf035
e1abbe9
5e60d07
8893cc4
19a7fe7
91e62d2
9e91a2e
2882998
a852895
c59122c
f88fa6d
6ca1451
0847791
4ce934c
936b098
e1e53dd
bd1e010
3912f21
d20088c
912e2c7
22f7db5
6efa364
d8fe850
c2e8f08
8d71e1b
535b01b
8257c43
d6473db
2a23c5f
49f1e81
76ab31f
52211f6
897e9d6
365f9ed
46eef57
da6bf9e
93f6c9a
d7b85a4
050577f
37c410d
35f6160
083f48e
d8f8326
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -623,11 +623,46 @@ def thermal_speed_coefficients(method: str, ndim: int) -> float: | |
|
||
@preserve_signature | ||
@njit | ||
def thermal_speed_lite(T, mass, coeff): | ||
""" | ||
A lite weight version of `~plasmapy.formulary.parameters.thermal_speed` | ||
intended for computational used and, thus, does not do any argument | ||
validation/conditioning. | ||
def thermal_speed_lite( | ||
T: numbers.Real, mass: numbers.Real, coeff: numbers.Real | ||
) -> numbers.Real: | ||
r""" | ||
The "Lite-Function" version of `~plasmapy.formulary.parameters.thermal_speed`. | ||
Performs the same thermal speed calculations as | ||
`~plasmapy.formulary.parameters.thermal_speed`, but is intended for | ||
computational use and, thus, has data conditioning safe-guards removed. | ||
rocco8773 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. math:: | ||
v_{th} = C_o \sqrt{\frac{k_B T}{m}} | ||
|
||
where :math:`T` is the temperature associated with the distribution, | ||
:math:`m` is the particle's mass, and :math:`C_o` is a constant of | ||
proportionality determined by the method in which :math:`v_{th}` is | ||
calculated and the dimensionality of the system (1D, 2D, 3D). For further | ||
details see the :ref:`Notes <thermal-speed-notes>` section in the | ||
`~plasmapy.formulary.parameters.thermal_speed` documentation. | ||
|
||
Parameters | ||
---------- | ||
T : `~numbers.Real` | ||
The temperature of the particle distribution, in units of kelvin. | ||
|
||
mass : `~numbers.Real` | ||
Mass of the particle in kg. | ||
Comment on lines
+651
to
+657
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm debating whether or not it would be worthwhile to change the parameter names to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get the point, but I'm more inclined to stick with our standard names and rely on all the disclaimers we've written in the documentation. I'm thinking the switch in naming could get annoying/frustrating for users. Additionally, I like collecting keywords in a dictionary and just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good points! And yeah...it's important to keep the signatures of the formulary functions identical to the lite functions to the extent that we can. The drawbacks to my suggestion outweigh the benefits, I think, so let's keep it as is. |
||
|
||
coeff : `~numbers.Real` | ||
The coefficient :math:`C_o` associated with the method used for | ||
calculating the thermal speed, see :ref:`Notes <thermal-speed-notes>` | ||
section in the `~plasmapy.formulary.parameters.thermal_speed` | ||
documentation. | ||
|
||
Examples | ||
-------- | ||
>>> from plasmapy.particles import Particle | ||
>>> mass = Particle("p").mass.value | ||
>>> coeff = thermal_speed_coefficients(method="most_probable", ndim=3) | ||
>>> thermal_speed_lite(T=1e6, mass=mass, coeff=coeff) | ||
128486... | ||
""" | ||
return coeff * np.sqrt(k_B_si_unitless * T / mass) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Since For now I'm updating the tests such that the following is essentially done... lite = thermal_speed_lite(**kwargs)
pylite = thermal_speed_lite.py_func(**kwargs)
assert lite == pylite The call to |
||
|
||
|
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.
Perhaps include a one-liner at the beginning of the docstring that parallels the docstring for
thermal_speed
? I was thinking it would show up better when you hover over it in an IDE, for example. One possibility would be this suggestion, though it'd be fine for it to be something different.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 did it this way for two reasons: (1) I'm trying to establish the terminology "lite-function" and what it means and (2) I want to push user to
thermal_speed
for the details. In the end I think this approach would be less maintenance for us.Maybe as a compromise I can add "lite-function" to the glossary and use that here.
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.
Sure! Good points. I do quite like the idea of adding "lite-function" to the glossary so we can link to it with the
:term:
role. In any case, I'm happy to go with whatever you decide on this.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.
lite-function is now added to the glossary. I also updated the description under the
automodapi
"Lite-Functions" section to point users to the lite-function glossary entry for details. Hopefully, this will minimize maintenance down the line if we modify the scope of lite-functions.