Skip to content

Commit

Permalink
resolved behaviour of shifted VelocityBoltzmann for 1D and >1D
Browse files Browse the repository at this point in the history
  • Loading branch information
reinimaurer1 committed Dec 16, 2023
1 parent dbeca25 commit 375e8a5
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/nuclear/boltzmann.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

"""
VelocityBoltzmann(temperature, masses::AbstractVector, dims::Dims{2}; centre = nothing)
VelocityBoltzmann(temperature, masses::AbstractVector, dims::Dims{2}; center::AbstractVector = zeros(dims))
Generate a Boltzmann distribution of velocities for each degree of freedom.
Expand All @@ -9,9 +9,16 @@ Generate a Boltzmann distribution of velocities for each degree of freedom.
* `temperature` - Atomic units or Unitful
* `masses` - Vector of masses for each atom
* `dims` - (ndofs, natoms). `natoms` must equal `length(masses)`
* `centre` - Vector of dimension ndofs that provides centre of mass velocity offset
* `center` - Vector of dimension ndofs that provides centre of mass velocity offset
"""
function VelocityBoltzmann(temperature, masses::AbstractVector, dims::Dims{2}; centre = zeros(dims))
return UnivariateArray([VelocityBoltzmann(temperature, masses[I[2]]; centre = centre[I]) for I in CartesianIndices(dims)])

function VelocityBoltzmann(temperature, masses::AbstractVector, dims::Dims{2}; center::Array{Float64} = zeros(dims))
return UnivariateArray([VelocityBoltzmann(temperature, masses[I[2]]; center = center[I]) for I in CartesianIndices(dims)])
end

"""
VelocityBoltzmann(temperature, mass; center = 0)
"""
function VelocityBoltzmann(temperature::Float64, mass::Float64; center::Float64 = 0)
return Normal(center, sqrt(austrip(temperature)/mass))
end
VelocityBoltzmann(temperature, mass; centre = 0) = Normal(centre, sqrt(austrip(temperature)/mass))

0 comments on commit 375e8a5

Please sign in to comment.