Skip to content
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

Added some comments and test example #326

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/DynamicsMethods/ClassicalMethods/diabatic_mdef.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ end
function DiabaticMDEF(masses::AbstractVector, DoFs::Integer, friction_method)
DiabaticMDEF(get_mass_scale_matrix(masses, DoFs), friction_method)
end
"""
当你在生成 simulation 时, method 选择了 DiabaticMDEF

电脑会选择跑下面这段代码

"""
function NQCDynamics.Simulation{DiabaticMDEF}(atoms::Atoms, model::Model;
friction_method, kwargs...
)
Expand Down Expand Up @@ -136,17 +141,38 @@ function (friction_method::DirectQuadrature)(∂Hᵢ, ∂Hⱼ, eigenvalues, μ,
return out
end

"""
WideBandExact is a method to evaulate friction that is exact for a wide band limit.

The function contains mainly three parts/steps:
1.struct type WideBandExact
2.compute the integral in the friction kernel
3.fill the friction tensor to evaluate_friction!

Usage: (potential, ∂potentialᵢ, ∂potentialⱼ) should be given


1.friction_method = WideBandExact(ρ, β)

2.integral = friction_method(potential, ∂potentialᵢ, ∂potentialⱼ, μ, β)

3.fill_friction_tensor!(Λ, friction_method::WideBandExact, potential, derivative, r, μ)

The friction integral details is given in https://doi.org/10.1063/5.0137137 (Eq.33-34)

"""
struct WideBandExact{T} <: FrictionEvaluationMethod
ρ::T
β::T
end
function (friction_method::WideBandExact)(potential, ∂potentialᵢ, ∂potentialⱼ, μ, β)
# Read reference paper from the details
h = potential[1,1]
∂hᵢ = ∂potentialᵢ[1,1]
∂hⱼ = ∂potentialⱼ[1,1]

ρ = friction_method.ρ
Γ = 2π * potential[2,1]^2 * ρ
Γ = 2π * potential[2,1]^2 * ρ # hybridization function Γ = 2π * |V|^2 * ρ
∂Γ∂potential = sqrt(8π * ρ * Γ)
∂Γᵢ = ∂Γ∂potential * ∂potentialᵢ[2,1]
∂Γⱼ = ∂Γ∂potential * ∂potentialⱼ[2,1]
Expand Down
2 changes: 2 additions & 0 deletions src/DynamicsMethods/DynamicsMethods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export run_trajectory
Each type of dynamics subtypes `Method` which is passed to
the `AbstractSimulation` as a parameter to determine the type of
dynamics desired.

julia> ttree(DynamicsMethods.Method)
"""
abstract type Method end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ struct VerletwithElectronics <: OrdinaryDiffEq.OrdinaryDiffEqAlgorithm end
struct MDEF_BAOAB <: StochasticDiffEq.StochasticDiffEqAlgorithm end
struct BCOCB <: StochasticDiffEq.StochasticDiffEqAlgorithm end


"""
This block of code below is to select the algorithm for each type of simulation.



"""

DynamicsMethods.select_algorithm(::RingPolymerSimulation{<:DynamicsMethods.SurfaceHoppingMethods.SurfaceHopping}) = BCBwithTsit5(OrdinaryDiffEq.Tsit5())
DynamicsMethods.select_algorithm(::RingPolymerSimulation{<:DynamicsMethods.EhrenfestMethods.AbstractEhrenfest}) = BCBwithTsit5(OrdinaryDiffEq.Tsit5())
DynamicsMethods.select_algorithm(::Simulation{<:DynamicsMethods.ClassicalMethods.AbstractMDEF}) = MDEF_BAOAB()
Expand Down
5 changes: 5 additions & 0 deletions src/Ensembles/selections.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

using NQCDistributions: DynamicalDistribution, ProductDistribution

"""
Check the tree structure of the type.
julia> ttree(Ensembles.AbstractSelection)
"""

abstract type AbstractSelection end

"""
Expand Down
31 changes: 31 additions & 0 deletions test/Hokseson_test/struct-function_same_name
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Define a simple type named Point
struct Point
x
y::Float64
end



# Constructor function for Point
# 由于我们设置多了一个变量 t, 所以我们在call Point的时候
# 多一个参数 t 就跑 function
# 总结!定义 同名 function 用来 丰富 struct的功能
function Point(x::Float64, y::Float64, t::Bool)
# This function is defined to convert x to Int64 if t is true otherwise leave it as Float64
if t == true
x = convert(Int64, x)
end

Point(x, y)
end

# Create an instance of Point using the constructor function
my_point = Point(3.0, 4.0, true)

# 直接跑 struct 创造 object
# my_point = Point(3.0, 4.0)

# Display the created instance
println("Point Instance:")
println("x: ", my_point.x)
println("y: ", my_point.y)
Loading