Methods

Index

Public

Missing docstring.

Missing docstring for length. Check Documenter's build log for details.

PhysicalParticles.split_dataFunction
split_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}:
 3
source
PhysicalParticles.extentFunction
extent(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)
source
Missing docstring.

Missing docstring for volume. Check Documenter's build log for details.

Missing docstring.

Missing docstring for area. Check Documenter's build log for details.

PhysicalParticles.distanceFunction
function distance(a::AbstractPoint, b::AbstractPoint)
distance(a::AbstractParticle, b::AbstractParticle)

Euclidean distance between two points or two particles.

source
PhysicalParticles.averageFunction
function 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)
source
PhysicalParticles.averagebymassFunction
function 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)
source
PhysicalParticles.pos_centerFunction
pos_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 particles
  • pos_center: average position of particles
  • mass_center: mass weighted average position of particles
  • median: middle value of positions of particles
source
PhysicalParticles.mass_centerFunction
mass_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 particles
  • pos_center: average position of particles
  • mass_center: mass weighted average position of particles
  • median: middle value of positions of particles
source
PhysicalParticles.pconvertFunction
pconvert(a::Abstractay{T,1}) where T<:Number

convert 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)
source
pconvert(a::Abstractay{T,2}) where T<:Number

convert 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)
source
PhysicalParticles.getuLengthFunction
function 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)
cm
source
PhysicalParticles.getuTimeFunction
function 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)
s
source
PhysicalParticles.getuCurrentFunction
function 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)
A
source
PhysicalParticles.getuTemperatureFunction
function 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)
K
source
PhysicalParticles.getuLuminosityFunction
function 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)
cd
source
PhysicalParticles.getuMassFunction
function 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)
g
source
PhysicalParticles.getuAmountFunction
function 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)
mol
source
PhysicalParticles.getuVelFunction
function 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^-1
source
PhysicalParticles.getuAccFunction
function 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^-2
source
PhysicalParticles.getuEnergyFunction
function 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^-2
source
PhysicalParticles.getuEntropyFunction
function 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^-2
source
PhysicalParticles.getuDensityFunction
function 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^-3
source
PhysicalParticles.getuDensity2DFunction
function 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^-2
source
PhysicalParticles.getuPressureFunction
function 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^-2
source
PhysicalParticles.axisunitFunction
axisunit(::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]"
source
PhysicalParticles.ZeroValueType
ZeroValue(::Type{T}, ::Nothing) where T<:Number
ZeroValue(::Type{T}, units::Vector{Unitful.FreeUnits{N, D, nothing} where D where N} = uAstro) where T<:Number

Construct 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)
source
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)
source
PhysicalParticles.randn_pvectorFunction
randn_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")
source
PhysicalParticles.randn_pvector2dFunction
randn_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")
source
PhysicalParticles.assign_particlesFunction
assign_particles(particles::Array{P,N} where P<:AbstractParticle, symbol::Symbol, data::Array) where N

Assign 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")
source
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")
source
PhysicalParticles.datadimensionFunction
function datadimension

Traits 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()
source
PhysicalParticles.centerFunction
center(
    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 particles
  • pos_center: average position of particles
  • mass_center: mass weighted average position of particles
  • median: middle value of positions of particles
source
PhysicalParticles.center_xFunction
center_x(
    a::Array{T<:Union{AbstractParticle, AbstractPoint}, N}
) -> Any

Compute box center of x direction of points or particles

source
PhysicalParticles.center_yFunction
center_y(
    a::Array{T<:Union{AbstractParticle, AbstractPoint}, N}
) -> Any

Compute box center of y direction of points or particles

source
PhysicalParticles.center_zFunction
center_z(
    a::Array{T<:Union{AbstractParticle3D, AbstractPoint3D}, N}
) -> Any

Compute box center of z direction of points or particles

source
PhysicalParticles.rotate_xFunction
rotate_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) |
source
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.
source
rotate_x(p::PVector, roll::Number, center::PVector)

Rotate p around the x-axis of center point by roll in radian angle.

source
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.
source
PhysicalParticles.rotate_yFunction
rotate_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) |
source
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.
source
rotate_y(p::PVector, pitch::Number, center::PVector)

Rotate p around the y-axis of center point by pitch in radian angle.

source
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.
source
PhysicalParticles.rotate_zFunction
rotate_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 |
source
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.
source
rotate_z(p::PVector, yaw::Number, center::PVector)

Rotate p around the z-axis of center point by yaw in radian angle.

source
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.
source
PhysicalParticles.rotateFunction
rotate(p::PVector, α::Number, β::Number, γ::Number)

Rotate p by radian Euler angles (α, β, γ) = (roll, pitch, yaw). Angles can have units, for example, u"°" (\degree).

source
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.
source
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).

source
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.
source

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  |
source
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.
source
rotate(p::PVector, vec::PVector, θ::Number, center::PVector)

Rotate p around direction vector vec at center point by angle θ.

source
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.
source
PhysicalParticles.cartesian2cylinderialFunction
cartesian2cylinderial(p::PVector2D) -> Tuple{Any, Any}

Convert PVector2D to Cylinderial Coordinates. Returns Tuple(r, θ)

source
cartesian2cylinderial(p::PVector) -> Tuple{Any, Any, Number}

Convert PVector to Spherical Coordinates. Returns Tuple(r, θ, z)

source
PhysicalParticles.cylinderial2cartesianFunction
cylinderial2cartesian(r::Number, θ::Number) -> PVector2D

Convert Cylinderial Coordinates to PVector2D

source
cylinderial2cartesian(
    r::Number,
    θ::Number,
    z::Number
) -> PVector

Convert Cylinderial Coordinates to PVector

source

Internal

PhysicalParticles.min_xFunction
min_x(a::AbstractPoint, b::AbstractPoint)
min_x(a::AbstractParticle, b::AbstractParticle)

Return the smaller :x field of a and b

source
PhysicalParticles.max_xFunction
max_x(a::AbstractPoint, b::AbstractPoint)
max_x(a::AbstractParticle, b::AbstractParticle)

Return the larger :x field of a and b

source
PhysicalParticles.min_yFunction
min_y(a::AbstractPoint, b::AbstractPoint)
min_y(a::AbstractParticle, b::AbstractParticle)

Return the smaller :y field of a and b

source
PhysicalParticles.max_yFunction
max_y(a::AbstractPoint, b::AbstractPoint)
max_y(a::AbstractParticle, b::AbstractParticle)

Return the larger :y field of a and b

source
PhysicalParticles.min_zFunction
min_z(a::AbstractPoint, b::AbstractPoint)
min_z(a::AbstractParticle, b::AbstractParticle)

Return the smaller :z field of a and b

source
PhysicalParticles.max_zFunction
max_z(a::AbstractPoint, b::AbstractPoint)
max_z(a::AbstractParticle, b::AbstractParticle)

Return the larger :z field of a and b

source
PhysicalParticles.minimum_xFunction
function 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

source
PhysicalParticles.maximum_xFunction
function 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

source
PhysicalParticles.minimum_yFunction
function 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

source
PhysicalParticles.maximum_yFunction
function 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

source
PhysicalParticles.minimum_zFunction
function 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

source
PhysicalParticles.maximum_zFunction
function 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

source