JuliaDynamics/DynamicalSystems.jl

Support for Complex number equations?

Open

#181 aberto em 21 de abr. de 2022

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)Julia (102 forks)batch import
documentationgood first issue

Métricas do repositório

Stars
 (928 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

The example is simple:

using DynamicalSystems

function route(dx, x, p, t)
    dx[1] =  1im * ( p[1] * x[1] - 2 * real(x[2]) * x[1] - 0.5) - 0.05 * x[1]
    dx[2] = -1im * (0.75 * abs(x[1])^2 + x[2]) - 0.0005* x[2]
end

ds = DiscreteDynamicalSystem(route, ComplexF64[0, 0], [1])

Was trying to define a Dynamical system. And:

ArgumentError: Cannot create a dual over scalar type ComplexF64. If the type behaves as a scalar, define ForwardDiff.can_dual(::Type{ComplexF64}) = true.

So I manually set

ForwardDiff.can_dual(::Type{ComplexF64}) = true

And run it again:

MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{DynamicalSystemsBase.var"#5#11"{typeof(route), Vector{Int64}, Int64}, ComplexF64}, ComplexF64, 2})
Closest candidates are:
  (::Type{T})(::Real, ::RoundingMode) where T<:AbstractFloat at C:\Softwares\Julia\share\julia\base\rounding.jl:200
  (::Type{T})(::T) where T<:Number at C:\Softwares\Julia\share\julia\base\boot.jl:770 
  (::Type{T})(::VectorizationBase.Double{T}) where T<:Union{Float16, Float32, Float64, VectorizationBase.Vec{<:Any, <:Union{Float16, Float32, Float64}}, VectorizationBase.VecUnroll{var"#s35", var"#s34", var"#s33", V} where {var"#s35", var"#s34", var"#s33"<:Union{Float16, Float32, Float64}, V<:Union{Bool, Float16, Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8, SIMDTypes.Bit, VectorizationBase.AbstractSIMD{var"#s34", var"#s33"}}}} at 

If I remove the im in the equation and change ComplexF64 to Float64 then it works fine. So does this mean DynamicalSystem.jl doesn't support complex numbers?

Package versions

versions:

  [608a59af] ChaosTools v2.8.1
  [5732040d] DelayEmbeddings v2.1.0
  [61744808] DynamicalSystems v2.3.0
  [6e36e845] DynamicalSystemsBase v2.7.0
  [ed8fcbec] Entropies v1.1.2
  [639c3291] RecurrenceAnalysis v1.8.0

Guia do colaborador