Methods
Index
PhysicalParticles.ZeroValuePhysicalParticles.assign_particlesPhysicalParticles.astroPhysicalParticles.averagePhysicalParticles.averagebymassPhysicalParticles.axisunitPhysicalParticles.cartesian2cylinderialPhysicalParticles.cartesian2sphericalPhysicalParticles.centerPhysicalParticles.center_xPhysicalParticles.center_yPhysicalParticles.center_zPhysicalParticles.cgsPhysicalParticles.cylinderial2cartesianPhysicalParticles.datadimensionPhysicalParticles.distancePhysicalParticles.extentPhysicalParticles.getuAccPhysicalParticles.getuAmountPhysicalParticles.getuCurrentPhysicalParticles.getuDensityPhysicalParticles.getuDensity2DPhysicalParticles.getuEnergyPhysicalParticles.getuEntropyPhysicalParticles.getuLengthPhysicalParticles.getuLuminosityPhysicalParticles.getuMassPhysicalParticles.getuPressurePhysicalParticles.getuTemperaturePhysicalParticles.getuTimePhysicalParticles.getuVelPhysicalParticles.getunitsPhysicalParticles.mass_centerPhysicalParticles.max_xPhysicalParticles.max_yPhysicalParticles.max_zPhysicalParticles.maximum_xPhysicalParticles.maximum_yPhysicalParticles.maximum_zPhysicalParticles.min_xPhysicalParticles.min_yPhysicalParticles.min_zPhysicalParticles.minimum_xPhysicalParticles.minimum_yPhysicalParticles.minimum_zPhysicalParticles.pconvertPhysicalParticles.pos_centerPhysicalParticles.randn_pvectorPhysicalParticles.randn_pvector2dPhysicalParticles.rotatePhysicalParticles.rotate_xPhysicalParticles.rotate_yPhysicalParticles.rotate_zPhysicalParticles.siPhysicalParticles.spherical2cartesianPhysicalParticles.split_data
Public
Missing docstring for length. Check Documenter's build log for details.
PhysicalParticles.split_data — Functionsplit_data(data::AbstractArray, i::Int64, N::Int64)split data to N sections, return the ith section
Examples
julia> split_data([1,2,3], 1, 2)
2-element Vector{Int64}:
1
2
julia> split_data([1,2,3], 2, 2)
1-element Vector{Int64}:
3
julia> split_data([1,2,3], 3, 4)
1-element Vector{Int64}:
3PhysicalParticles.extent — Functionextent(a::Array{T, N})
extent(data::Dict)
extent(a::Extent2D, b::Extent2D)
extent(a::Extent, b::Extent)Get Extent of an array of mathical vectors or particles, or by comparing two Extents and even array of Extents
Examples
julia> extent([Ball(PVector(-1.0u"m", 1.0u"m", 1.0u"m"), PVector(u"m/s"), PVector(u"m/s^2"), 1.0u"kg", 1),
Ball(PVector(1.0u"m", -1.0u"m", -1.0u"m"), PVector(u"m/s"), PVector(u"m/s^2"), 1000.0u"g", 2)])
Extent: xMin = -1.0 m, xMax = 1.0 m, yMin = -1.0 m, yMax = 1.0 m, zMin = -1.0 m, zMax = 1.0 m, SideLength = 2.0 m, Center = PVector(0.0 m, 0.0 m, 0.0 m)Missing docstring for volume. Check Documenter's build log for details.
Missing docstring for area. Check Documenter's build log for details.
PhysicalParticles.distance — Functionfunction distance(a::AbstractPoint, b::AbstractPoint)
distance(a::AbstractParticle, b::AbstractParticle)Euclidean distance between two points or two particles.
PhysicalParticles.average — Functionfunction average(data, symbol::Symbol)Average on field symbol of elements in an array or dict of arrays
Examples
a = rand(PVector{Float64}, 5)
average(a, :x)PhysicalParticles.averagebymass — Functionfunction averagebymass(data, symbol::Symbol)
function averagebymass(data::StructArray, symbol::Symbol)Average on field symbol weighted by :Mass of elements in an array of dict of arrays
Examples
averagebymass(data, :Pos)PhysicalParticles.pos_center — Functionpos_center(a::Array{T}) where T <: AbstractParticle
pos_center(a::StructArray)Compute averaged position with equal weights. It is different from middle(a, :Pos) which computes the middle value of a symbol (useful to avoid influences from distant particles).
There are differences among center, pos_center, mass_center and median:
center: box center of particlespos_center: average position of particlesmass_center: mass weighted average position of particlesmedian: middle value of positions of particles
PhysicalParticles.mass_center — Functionmass_center(a::Array{T}) where T <: AbstractParticle
mass_center(a::StructArray)Compute mass center of particles, which is weighted by mass.
There are differences among center, pos_center, mass_center and median:
center: box center of particlespos_center: average position of particlesmass_center: mass weighted average position of particlesmedian: middle value of positions of particles
PhysicalParticles.pconvert — Functionpconvert(a::Abstractay{T,1}) where T<:Numberconvert two-element array to PVector2D, and three-element array to PVector
Examples
julia> pconvert([1.0, 2.0])
PVector2D{Float64}(1.0, 2.0)
julia> pconvert([1.0, 2.0, 3.0])
PVector{Float64}(1.0, 2.0, 3.0)pconvert(a::Abstractay{T,2}) where T<:Numberconvert 2xN Array to Array{PVector2D,1}, 3xN Array to Array{PVector,1}
Examples
julia> pconvert([1.0 3.0;
2.0 4.0])
2-element Vector{PVector2D}:
PVector2D{Float64}(1.0, 2.0)
PVector2D{Float64}(3.0, 4.0)
julia> pconvert([1.0 4.0;
2.0 5.0;
3.0 6.0])
2-element Vector{PVector}:
PVector{Float64}(1.0, 2.0, 3.0)
PVector{Float64}(4.0, 5.0, 6.0)PhysicalParticles.astro — FunctionSet default units to uAstro. See Unitful.preferunits for more info
PhysicalParticles.cgs — FunctionSet default units to uCGS. See Unitful.preferunits for more info
PhysicalParticles.si — FunctionSet default units to uSI. See Unitful.preferunits for more info
PhysicalParticles.getunits — Functiongetunits(units = uDefaults)Return Tuple of units from units
PhysicalParticles.getuLength — Functionfunction getuLength(::Nothing)
function getuLength(units)Extract length unit from units or nothing
Examples
julia> getuLength(nothing)
julia> getuLength(uAstro)
kpc
julia> getuLength(uSI)
m
julia> getuLength(uCGS)
cmPhysicalParticles.getuTime — Functionfunction getuTime(::Nothing)
function getuTime(units)Extract time unit from units or nothing
Examples
julia> getuTime(nothing)
julia> getuTime(uAstro)
Gyr
julia> getuTime(uSI)
s
julia> getuTime(uCGS)
sPhysicalParticles.getuCurrent — Functionfunction getuCurrent(::Nothing)
function getuCurrent(units)Extract electric current unit from units or nothing
Examples
julia> getuCurrent(nothing)
julia> getuCurrent(uAstro)
A
julia> getuCurrent(uSI)
A
julia> getuCurrent(uCGS)
APhysicalParticles.getuTemperature — Functionfunction getuTemperature(::Nothing)
function getuTemperature(units)Extract temperature unit from units or nothing
Examples
julia> getuTemperature(nothing)
julia> getuTemperature(uAstro)
K
julia> getuTemperature(uSI)
K
julia> getuTemperature(uCGS)
KPhysicalParticles.getuLuminosity — Functionfunction getuLuminosity(::Nothing)
function getuLuminosity(units)Extract luminosity unit from units or nothing
Examples
julia> getuLuminosity(nothing)
julia> getuLuminosity(uAstro)
cd
julia> getuLuminosity(uSI)
cd
julia> getuLuminosity(uCGS)
cdPhysicalParticles.getuMass — Functionfunction getuMass(::Nothing)
function getuMass(units)Extract mass unit from units or nothing
Examples
julia> getuMass(nothing)
julia> getuMass(uAstro)
M⊙
julia> getuMass(uSI)
kg
julia> getuMass(uCGS)
gPhysicalParticles.getuAmount — Functionfunction getuAmount(::Nothing)
function getuAmount(units)Extract amount unit from units or nothing
Examples
julia> getuAmount(nothing)
julia> getuAmount(uAstro)
mol
julia> getuAmount(uSI)
mol
julia> getuAmount(uCGS)
molPhysicalParticles.getuVel — Functionfunction getuVel(::Nothing)
function getuVel(units)Extract velocity unit from units or nothing
Examples
julia> getuVel(nothing)
julia> getuVel(uAstro)
kpc Gyr^-1
julia> getuVel(uSI)
m s^-1
julia> getuVel(uCGS)
cm s^-1PhysicalParticles.getuAcc — Functionfunction getuAcc(::Nothing)
function getuAcc(units)Extract acceleration unit from units or nothing
Examples
julia> getuAcc(nothing)
julia> getuAcc(uAstro)
kpc Gyr^-2
julia> getuAcc(uSI)
m s^-2
julia> getuAcc(uCGS)
cm s^-2PhysicalParticles.getuEnergy — Functionfunction getuEnergy(::Nothing)
function getuEnergy(units)Extract energy unit from units or nothing
Examples
julia> getuEnergy(nothing)
julia> getuEnergy(uAstro)
kpc^2 M⊙ Gyr^-2
julia> getuEnergy(uSI)
kg m^2 s^-2
julia> getuEnergy(uCGS)
g cm^2 s^-2PhysicalParticles.getuEntropy — Functionfunction getuEntropy(::Nothing)
function getuEntropy(units)Extract entropy unit from units or nothing
Examples
julia> getuEntropy(nothing)
julia> getuEntropy(uAstro)
kpc^2 M⊙ K^-1 Gyr^-2
julia> getuEntropy(uSI)
kg m^2 K^-1 s^-2
julia> getuEntropy(uCGS)
g cm^2 K^-1 s^-2PhysicalParticles.getuDensity — Functionfunction getuDensity(::Nothing)
function getuDensity(units)Extract 3D density unit from units or nothing
Examples
julia> getuDensity(nothing)
julia> getuDensity(uAstro)
M⊙ kpc^-3
julia> getuDensity(uSI)
kg m^-3
julia> getuDensity(uCGS)
g cm^-3PhysicalParticles.getuDensity2D — Functionfunction getuDensity2D(::Nothing)
function getuDensity2D(units)Extract 2D density unit from units or nothing
Examples
julia> getuDensity2D(nothing)
julia> getuDensity2D(uAstro)
M⊙ kpc^-2
julia> getuDensity2D(uSI)
kg m^-2
julia> getuDensity2D(uCGS)
g cm^-2PhysicalParticles.getuPressure — Functionfunction getuPressure(::Nothing)
function getuPressure(units)Extract 2D density unit from units or nothing
Examples
julia> getuPressure(nothing)
julia> getuPressure(uAstro)
M⊙ kpc^-1 Gyr^-2
julia> getuPressure(uSI)
kg m^-1 s^-2
julia> getuPressure(uCGS)
g cm^-1 s^-2PhysicalParticles.axisunit — Functionaxisunit(::Nothing)
axisunit(u::Units)
axisunit(s::AbstractString, u::Units)Return a String for pretty printing.
Examples
julia> axisunit(nothing)
""
julia> axisunit(u"m")
" [m]"
julia> axisunit("Time", u"Gyr")
"Time [Gyr]"PhysicalParticles.ZeroValue — TypeZeroValue(::Type{T}, ::Nothing) where T<:Number
ZeroValue(::Type{T}, units::Vector{Unitful.FreeUnits{N, D, nothing} where D where N} = uAstro) where T<:NumberConstruct an immutable struct providing zero values of type T in corresponding units (default is uAstro). Use nothing if unitless. Useful for accumulated summation, array initialization, etc.
Examples
ZeroValue(Float32, nothing)
ZeroValue(Int32)
ZeroValue(BigFloat, uSI)
ZeroValue(Measurement, uCGS)function ZeroValue(::Nothing)
function ZeroValue(units::Vector{Unitful.FreeUnits{N, D, nothing} where D where N} = uAstro)Construct an immutable struct providing zero Measurement values in corresponding units (default is uAstro). Use nothing if unitless. Useful for accumulated summation, array initialization, etc.
Examples
ZeroValue(nothing)
ZeroValue()
ZeroValue(uSI)
ZeroValue(uCGS)PhysicalParticles.randn_pvector — Functionrandn_pvector2d(n::Integer, T::DataType = Float64)
randn_pvector2d(n::Integer, u::Units, T::DataType = Float64)
randn_pvector(n::Integer, T::DataType = Float64)
randn_pvector(n::Integer, u::Units, T::DataType = Float64)Generate uniformly distributed PVectors
Examples
julia> p = randn_pvector(5)
julia> pu = randn_pvector2d(5, u"m")PhysicalParticles.randn_pvector2d — Functionrandn_pvector2d(n::Integer, T::DataType = Float64)
randn_pvector2d(n::Integer, u::Units, T::DataType = Float64)
randn_pvector(n::Integer, T::DataType = Float64)
randn_pvector(n::Integer, u::Units, T::DataType = Float64)Generate uniformly distributed PVectors
Examples
julia> p = randn_pvector(5)
julia> pu = randn_pvector2d(5, u"m")PhysicalParticles.assign_particles — Functionassign_particles(particles::Array{P,N} where P<:AbstractParticle, symbol::Symbol, data::Array) where NAssign the symbol of particles with elements in data one by one. particles and data must have equal length.
Examples
julia> assign_particles([Ball(uSI) for i=1:3], :Pos, rand(PVector{Float64}, 3) * u"m")assign_particles(particles::Array{P,N} where P<:AbstractParticle, symbol::Symbol, data) where N
assign_particles(particles::StructArray, symbol::Symbol, data)Assign the symbol of particles to data identically.
Examples
julia> assign_particles([Ball(uSI) for i=1:3], :Mass, 1.0u"kg")PhysicalParticles.datadimension — Functionfunction datadimensionTraits function to specify whether the data is unitful/unitless and 2D/3D.
Examples
julia> datadimension(PVector2D())
Unitless2D()
julia> datadimension(PVector())
Unitless3D()
julia> datadimension(Star2D(uAstro))
Physical2D()
julia> datadimension(Star(uAstro))
Physical3D()
julia> datadimension([PVector2D()])
Unitless2D()
julia> datadimension([PVector()])
Unitless3D()
julia> datadimension([Star2D(uAstro)])
Physical2D()
julia> datadimension([Star(uAstro)])
Physical3D()PhysicalParticles.center — Functioncenter(
a::Array{T<:Union{AbstractParticle2D, AbstractPoint2D}, N}
) -> Any
Compute box center of points or particles
There are differences among center, pos_center, mass_center and median:
center: box center of particlespos_center: average position of particlesmass_center: mass weighted average position of particlesmedian: middle value of positions of particles
PhysicalParticles.center_x — Functioncenter_x(
a::Array{T<:Union{AbstractParticle, AbstractPoint}, N}
) -> Any
Compute box center of x direction of points or particles
PhysicalParticles.center_y — Functioncenter_y(
a::Array{T<:Union{AbstractParticle, AbstractPoint}, N}
) -> Any
Compute box center of y direction of points or particles
PhysicalParticles.center_z — Functioncenter_z(
a::Array{T<:Union{AbstractParticle3D, AbstractPoint3D}, N}
) -> Any
Compute box center of z direction of points or particles
PhysicalParticles.rotate_x — Functionrotate_x(p::PVector, roll::Number)Rotate p around x-axis by roll in radian angle. The rotation direction is right-handed, which is counter-clockwise in y-z plane. Angles can have units, for example, u"°" (\degree).
The rotation matrix:
| 1 0 0 |
Rx(roll) = | 0 cos(roll) -sin(roll) |
| 0 sin(roll) cos(roll) |rotate_x(data, roll::Number; vel::Bool = true)Rotate all particles in data around x-axis by roll in radian angle.
vel::Bool = false: Rotate velocity around origin at the same time.
rotate_x(p::PVector, roll::Number, center::PVector)Rotate p around the x-axis of center point by roll in radian angle.
rotate_x(data, roll::Number, center::PVector; vel::Bool = true)Rotate all particles in data around the x-axis of center point by roll in radian angle.
vel::Bool = false: Rotate velocity around origin at the same time.
PhysicalParticles.rotate_y — Functionrotate_y(p::PVector, pitch::Number)Rotate p around y-axis by pitch in radian angle. The rotation direction is right-handed, which is counter-clockwise in y-z plane. Angles can have units, for example, u"°" (\degree).
The rotation matrix:
| cos(pitch) 0 sin(pitch) |
Ry(pitch) = | 0 1 0 |
| -sin(pitch) 0 cos(pitch) |rotate_y(data, pitch::Number; vel::Bool = true)Rotate all particles in data around y-axis by pitch in radian angle.
vel::Bool = false: Rotate velocity around origin at the same time.
rotate_y(p::PVector, pitch::Number, center::PVector)Rotate p around the y-axis of center point by pitch in radian angle.
rotate_y(data, pitch::Number, center::PVector; vel::Bool = true)Rotate all particles in data around the y-axis of center point by pitch in radian angle.
vel::Bool = false: Rotate velocity around origin at the same time.
PhysicalParticles.rotate_z — Functionrotate_z(p::PVector, yaw::Number)Rotate p around z-axis by yaw in radian angle. The rotation direction is right-handed, which is counter-clockwise in y-z plane. Angles can have units, for example, u"°" (\degree).
The rotation matrix:
| cos(yaw) -sin(yaw) 0 |
Rz(yaw) = | sin(yaw) cos(yaw) 0 |
| 0 0 1 |rotate_z(data, yaw::Number; vel::Bool = true)Rotate all particles in data around z-axis by yaw in radian angle.
vel::Bool = false: Rotate velocity around origin at the same time.
rotate_z(p::PVector, yaw::Number, center::PVector)Rotate p around the z-axis of center point by yaw in radian angle.
rotate_z(data, yaw::Number, center::PVector; vel::Bool = true)Rotate all particles in data around the z-axis of center point by yaw in radian angle.
vel::Bool = false: Rotate velocity around origin at the same time.
PhysicalParticles.rotate — Functionrotate(p::PVector, α::Number, β::Number, γ::Number)Rotate p by radian Euler angles (α, β, γ) = (roll, pitch, yaw). Angles can have units, for example, u"°" (\degree).
rotate(data, yaw::Number, center::PVector; vel::Bool = true)Rotate all particles in data by radian Euler angles (α, β, γ) = (roll, pitch, yaw).
vel::Bool = false: Rotate velocity around origin at the same time.
rotate(p::PVector, α::Number, β::Number, γ::Number, center::PVector)Rotate p by radian Euler angles (α, β, γ) = (roll, pitch, yaw) around center point. Angles can have units, for example, u"°" (\degree).
rotate(data, yaw::Number, center::PVector; vel::Bool = true)Rotate all particles in data by radian Euler angles (α, β, γ) = (roll, pitch, yaw) around center point.
vel::Bool = false: Rotate velocity around origin at the same time.
rotate(p::PVector, vec::PVector, θ::Number)
Rotate p around direction vector vec by angle θ.
For normalized vec = (x, y, z), the rotation matrix:
| cos(θ) + (1-cos(θ))*x^2 (1-cos(θ))*x*y - sin(θ)*z (1-cos(θ))*x*z + sin(θ)*y |
M(vec, θ) = | (1-cos(θ))*y*x + sin(θ)*z cos(θ) + (1-cos(θ))*y^2 (1-cos(θ))*y*z - sin(θ)*x |
| (1-cos(θ))*z*x - sin(θ)*y (1-cos(θ))*z*y + sin(θ)*x cos(θ) + (1-cos(θ))*z^2 |rotate(data::Array, vec::PVector, θ::Number; vel::Bool = true)Rotate all particles in data around direction vector vec by angle θ.
vel::Bool = false: Rotate velocity around origin at the same time.
rotate(p::PVector, vec::PVector, θ::Number, center::PVector)Rotate p around direction vector vec at center point by angle θ.
rotate(data, vec::PVector, θ::Number, center::PVector; vel::Bool = true)Rotate all particles in data around direction vector vec at center point by angle θ.
vel::Bool = false: Rotate velocity around origin at the same time.
PhysicalParticles.cartesian2cylinderial — Functioncartesian2cylinderial(p::PVector2D) -> Tuple{Any, Any}
Convert PVector2D to Cylinderial Coordinates. Returns Tuple(r, θ)
cartesian2cylinderial(p::PVector) -> Tuple{Any, Any, Number}
Convert PVector to Spherical Coordinates. Returns Tuple(r, θ, z)
PhysicalParticles.cartesian2spherical — Functioncartesian2spherical(p::PVector) -> Tuple{Any, Any, Any}
Convert PVector to Spherical Coordinates. Returns Tuple(r, θ, ϕ)
PhysicalParticles.cylinderial2cartesian — Functioncylinderial2cartesian(r::Number, θ::Number) -> PVector2D
Convert Cylinderial Coordinates to PVector2D
cylinderial2cartesian(
r::Number,
θ::Number,
z::Number
) -> PVector
Convert Cylinderial Coordinates to PVector
PhysicalParticles.spherical2cartesian — Functionspherical2cartesian(
r::Number,
θ::Number,
ϕ::Number
) -> Union{PVector, PVector2D}
Convert Spherical Coordinates to PVector
Internal
PhysicalParticles.min_x — Functionmin_x(a::AbstractPoint, b::AbstractPoint)
min_x(a::AbstractParticle, b::AbstractParticle)Return the smaller :x field of a and b
PhysicalParticles.max_x — Functionmax_x(a::AbstractPoint, b::AbstractPoint)
max_x(a::AbstractParticle, b::AbstractParticle)Return the larger :x field of a and b
PhysicalParticles.min_y — Functionmin_y(a::AbstractPoint, b::AbstractPoint)
min_y(a::AbstractParticle, b::AbstractParticle)Return the smaller :y field of a and b
PhysicalParticles.max_y — Functionmax_y(a::AbstractPoint, b::AbstractPoint)
max_y(a::AbstractParticle, b::AbstractParticle)Return the larger :y field of a and b
PhysicalParticles.min_z — Functionmin_z(a::AbstractPoint, b::AbstractPoint)
min_z(a::AbstractParticle, b::AbstractParticle)Return the smaller :z field of a and b
PhysicalParticles.max_z — Functionmax_z(a::AbstractPoint, b::AbstractPoint)
max_z(a::AbstractParticle, b::AbstractParticle)Return the larger :z field of a and b
PhysicalParticles.minimum_x — Functionfunction minimum_x(a::Array{T,N}) where T <: AbstractPoint where N
function minimum_x(a::Array{T,N}) where T <: AbstractParticle where N
function minimum_x(a::StructArray)Return the minimum :x field of points in array a Return the minimum Pos.x of particles in array a
PhysicalParticles.maximum_x — Functionfunction maximum_x(a::Array{T,N}) where T <: AbstractPoint where N
function maximum_x(a::Array{T,N}) where T <: AbstractParticle where N
function maximum_x(a::StructArray)Return the maximum :x field of points in array a Return the maximum Pos.x of particles in array a
PhysicalParticles.minimum_y — Functionfunction minimum_y(a::Array{T,N}) where T <: AbstractPoint where N
function minimum_y(a::Array{T,N}) where T <: AbstractParticle where N
function minimum_y(a::StructArray)Return the minimum :y field of points in array a Return the minimum Pos.y of particles in array a
PhysicalParticles.maximum_y — Functionfunction maximum_y(a::Array{T,N}) where T <: AbstractPoint where N
function maximum_y(a::Array{T,N}) where T <: AbstractParticle where N
function maximum_y(a::StructArray)Return the maximum :y field of points in array a Return the maximum Pos.y of particles in array a
PhysicalParticles.minimum_z — Functionfunction minimum_z(a::Array{T,N}) where T <: AbstractPoint where N
function minimum_z(a::Array{T,N}) where T <: AbstractParticle where N
function minimum_z(a::StructArray)Return the minimum :z field of points in array a Return the minimum Pos.z of particles in array a
PhysicalParticles.maximum_z — Functionfunction maximum_z(a::Array{T,N}) where T <: AbstractPoint where N
function maximum_z(a::Array{T,N}) where T <: AbstractParticle where N
function maximum_z(a::StructArray)Return the maximum :z field of points in array a Return the maximum Pos.z of particles in array a