Skip to content

Commit

Permalink
add Jet
Browse files Browse the repository at this point in the history
remove Dates compat

interchange .. with interval in CTLibrary
  • Loading branch information
oameye committed Jul 23, 2024
1 parent 210fb78 commit 4b11884
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ repo = "https://github.com/juliadynamics/CriticalTransitions.jl.git"
version = "0.3.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
DiffEqNoiseProcess = "77a26b50-5914-5dd7-bc55-306e6241c503"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
2 changes: 1 addition & 1 deletion src/CoupledSDEs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function CoupledSDEs(
)
return CoupledSDEs(
dynamic_rule(ds),
prob.g,
g,
current_state(ds),
p,
noise_strength;
Expand Down
1 change: 1 addition & 0 deletions src/CriticalTransitions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using Symbolics: Symbolics

# io and documentation
using Format: Format
using Dates: Dates
using Printf: Printf
using Markdown: Markdown
using DocStringExtensions: TYPEDSIGNATURES
Expand Down
6 changes: 3 additions & 3 deletions src/largedeviations/action.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ Computes the action functional specified by `functional` for a given CoupledSDEs
* `functional = "FW"`: Returns the Freidlin-Wentzell action ([`fw_action`](@ref))
* `functional = "OM"`: Returns the Onsager-Machlup action ([`om_action`](@ref))
"""
function action(sys::CoupledSDEs, path::Matrix, time, functional; kwargs...)
function action(sys::CoupledSDEs, path::Matrix, time, functional)
if functional == "FW"
action = fw_action(sys, path, time; kwargs...)
action = fw_action(sys, path, time)
elseif functional == "OM"
action = om_action(sys, path, time; kwargs...)
action = om_action(sys, path, time)
end
return action
end;
Expand Down
2 changes: 2 additions & 0 deletions src/largedeviations/geometric_min_action_method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ function heymann_vandeneijnden_step(sys::CoupledSDEs, path, N, L; tau=0.1, diff_
lambdas, lambdas_prime = zeros(N), zeros(N)
x_prime = path_velocity(path, 0:dx:L; order=diff_order)

A = inv(covariance_matrix(sys))

for i in 2:(N - 1)
lambdas[i] = anorm(drift(sys, path[:, i]), A) / anorm(path[:, i], A)
end
Expand Down
4 changes: 3 additions & 1 deletion systems/CTLibrary.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module CTLibrary

using CriticalTransitions
using CriticalTransitions: CriticalTransitions, smoothabs
using IntervalArithmetic: interval
using StaticArrays: SA, SVector

include("fitzhughnagumo.jl")
include("truscottbrindley_mod.jl")
Expand Down
4 changes: 0 additions & 4 deletions systems/fitzhughnagumo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ function fitzhugh_nagumo(u, p, t)
return SA[dx, dy]
end

# For backwards compatibility
FitzHughNagumo(u, p, t) = fitzhugh_nagumo(u, p, t)
FitzHughNagumo!(u, p, t) = fitzhugh_nagumo!(u, p, t)

# """
# fhn_ϵσ(ϵ,σ)
# A shortcut command for returning a CoupledSDEs of the FitzHugh Nagumo system in a default setup with additive isotropic noise.
Expand Down
4 changes: 2 additions & 2 deletions systems/truscottbrindley_mod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function rampedmodifiedtruscottbrindley!(du, u, p, t)
P₁ *
* (P / P₁) * (1 - β * (P / P₁)) - γ * (Z / Z₁) * (P / P₁)^2 / (1 + (P / P₁)^2))
du[2] = ξ * Z₁ * ((Z / Z₁) * (P / P₁)^2 / (1 + (P / P₁)^2) - (Z / Z₁)^2)
return du[3] = t Ttrans .. (Ttrans + Tramp) ? v : 0
return du[3] = t interval(Ttrans, (Ttrans + Tramp)) ? v : 0
end

"""
Expand All @@ -99,7 +99,7 @@ function rampedmodifiedtruscottbrindley(u, p, t)
P₁ *
* (P / P₁) * (1 - β * (P / P₁)) - γ * (Z / Z₁) * (P / P₁)^2 / (1 + (P / P₁)^2))
dZ = ξ * Z₁ * ((Z / Z₁) * (P / P₁)^2 / (1 + (P / P₁)^2) - (Z / Z₁)^2)
= t Ttrans .. (Ttrans + Tramp) ? v : 0
= t interval(Ttrans, (Ttrans + Tramp)) ? v : 0

return SA[dP, dZ, dα]
end
Expand Down
4 changes: 2 additions & 2 deletions systems/truscottbrindley_orig.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function rampedoriginaltruscottbrindley!(du, u, p, t)

du[1] = r * P * (1 - P / K) - Rₘ * Z * P^2 /^2 + P^2)
du[2] = γ * Rₘ * Z * P^2 /^2 + P^2) - μ * Z
return du[3] = t Ttrans .. (Ttrans + Tramp) ? v : 0
return du[3] = t interval(Ttrans, (Ttrans + Tramp)) ? v : 0
end

"""
Expand All @@ -61,7 +61,7 @@ function rampedoriginaltruscottbrindley(u, p, t)

dP = r * P * (1 - P / K) - Rₘ * Z * P^2 /^2 + P^2)
dZ = γ * Rₘ * Z * P^2 /^2 + P^2) - μ * Z
dr = t Ttrans .. (Ttrans + Tramp) ? v : 0
dr = t interval(Ttrans, (Ttrans + Tramp)) ? v : 0

return SA[dP, dZ, dr]
end
Expand Down
4 changes: 2 additions & 2 deletions systems/truscottbrindley_orig1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function rampedoriginaltruscottbrindley1!(du, u, p, t)

du[1] = (1 / γ) * (r * P * (1 - P / K) - Rₘ * Z * P^2 /^2 + P^2))
du[2] = Rₘ * Z * P^2 /^2 + P^2) - μ * Z
return du[3] = t Ttrans .. (Ttrans + Tramp) ? v : 0
return du[3] = t interval(Ttrans, (Ttrans + Tramp)) ? v : 0
end

"""
Expand All @@ -61,7 +61,7 @@ function rampedoriginaltruscottbrindley1(u, p, t)

dP = (1 / γ) * (r * P * (1 - P / K) - Rₘ * Z * P^2 /^2 + P^2))
dZ = Rₘ * Z * P^2 /^2 + P^2) - μ * Z
dr = t Ttrans .. (Ttrans + Tramp) ? v : 0
dr = t interval(Ttrans, (Ttrans + Tramp)) ? v : 0

return SA[dP, dZ, dr]
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end

@testset "Code linting" begin
using JET
# JET.test_package(HarmonicBalance; target_defined_modules=true)
JET.test_package(CriticalTransitions; target_defined_modules=true)
end

@testset "CoupledSDEs" begin
Expand Down

0 comments on commit 4b11884

Please sign in to comment.