|
1 | 1 | # TODO: Sound speed
|
2 | 2 |
|
3 |
| -function Alfven_velocity(B::BField, ρ::Density) |
4 |
| - return B / sqrt(μ0 * ρ) |> upreferred |
| 3 | +const BFields = Union{BField,AbstractVector{<:BField}} |
| 4 | + |
| 5 | +""" |
| 6 | + Alfven_velocity(B::BFields, ρ::Density) |
| 7 | + Alfven_velocity(B::BFields, n::NumberDensity; mass_numb = 1, z = 1) |
| 8 | +
|
| 9 | +Calculate the Alfvén velocity (v_A = B/√(μ₀ρ)) in a magnetized plasma. |
| 10 | +
|
| 11 | +# Arguments |
| 12 | +- `B`: Magnetic field strength (scalar or vector) |
| 13 | +- `ρ`: Mass density |
| 14 | +- `n`: Number density |
| 15 | +- `mass_numb=1`: Mass number of the ion species |
| 16 | +- `z=1`: Ion charge number |
| 17 | +
|
| 18 | +# Examples |
| 19 | +```julia |
| 20 | +# Using mass density |
| 21 | +B = 1.0u"T" |
| 22 | +ρ = 1.0u"kg/m^3" |
| 23 | +va = Alfven_velocity(B, ρ) |
| 24 | +
|
| 25 | +# Using number density |
| 26 | +n = 1.0e19u"m^-3" |
| 27 | +va = Alfven_velocity(B, n, mass_numb=1, z=1) |
| 28 | +
|
| 29 | +# Vector input |
| 30 | +B = [1.0, 2.0, 3.0]u"T" |
| 31 | +va = Alfven_velocity(B, n) |
| 32 | +``` |
| 33 | +
|
| 34 | +See also: [`Alfven_speed`](@ref) |
| 35 | +""" |
| 36 | +function Alfven_velocity end |
| 37 | + |
| 38 | +@permutable_args function Alfven_velocity(B::BFields, ρ::Density) |
| 39 | + return B ./ sqrt(μ0 * ρ) .|> upreferred |
5 | 40 | end
|
6 | 41 |
|
7 |
| -function Alfven_velocity(B::BField, n::NumberDensity; mass_numb = 1, Z = 1) |
8 |
| - ρ = n * (mass_numb * mp + Z * me) |
| 42 | +@permutable_args function Alfven_velocity( |
| 43 | + B::BFields, |
| 44 | + n::NumberDensity; |
| 45 | + mass_numb = 1, |
| 46 | + z = 1, |
| 47 | +) |
| 48 | + ρ = n * (mass_numb * mp + z * me) |
9 | 49 | return Alfven_velocity(B, ρ)
|
10 | 50 | end
|
11 | 51 |
|
12 |
| -Alfven_velocity(B::AbstractVector, args...; kwargs...) = |
13 |
| - [Alfven_velocity(Bi, args...; kwargs...) for Bi in B] |
14 |
| - |
15 | 52 | """
|
16 |
| - Alfven_speed(args...; kwargs...) |
| 53 | + Alfven_speed(B::BField, ρ::Density) |
| 54 | + Alfven_speed(B::BField, n::NumberDensity; mass_numb = 1, z = 1) |
17 | 55 |
|
18 | 56 | The typical propagation speed of magnetic disturbances in a quasineutral plasma.
|
19 | 57 |
|
20 |
| -References: [PlasmaPy API Documentation](https://docs.plasmapy.org/en/stable/api/plasmapy.formulary.speeds.Alfven_speed.html) |
| 58 | +References: [Wikipedia](https://en.wikipedia.org/wiki/Alfven_wave), [PlasmaPy API](https://docs.plasmapy.org/en/latest/api/plasmapy.formulary.speeds.Alfven_speed.html) |
21 | 59 | """
|
22 |
| -Alfven_speed(args...; kwargs...) = norm(Alfven_velocity(args...; kwargs...)) |
| 60 | +function Alfven_speed end |
| 61 | + |
| 62 | +@permutable_args Alfven_speed(B::BFields, n::NumberDensity; mass_numb = 1, z = 1) = |
| 63 | + norm(Alfven_velocity(B, n; mass_numb, z)) |
| 64 | +@permutable_args Alfven_speed(B::BFields, ρ::Density) = norm(Alfven_velocity(B, ρ)) |
23 | 65 |
|
24 | 66 |
|
25 | 67 | function thermal_speed(
|
|
0 commit comments