-
Notifications
You must be signed in to change notification settings - Fork 2
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
Stochsystem overhaul #76
Draft
oameye
wants to merge
28
commits into
main
Choose a base branch
from
stochsystem_overhaul
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
a4f339c
do not export dev functions
oameye 63ddb70
add ModelingToolkit SDE tests
oameye e5567fb
inspect integrator and parameter structure
oameye 5c98773
make CoupledSDE struct
oameye a901219
add option for Multiplicative noise a la StochasticDiffEq
oameye 36eac01
make CoupledSDEs a ContinuousTimeDynamicalSystem
oameye e5b9ba8
assume iterable object in predefined systems
oameye 79a8ea7
enable trajactory(::CoupledSDEs)
oameye e46779c
comment unneeded stuff
oameye 7c11459
rewrite stochprocess
oameye 2b33ba8
reorganise folders structure
oameye 1f6cc1c
update simulate and relax
oameye 91ff50b
update transition
oameye 84590b4
update transitions
oameye 60c8167
update action.jl
oameye b374ced
Merge branch 'main' into stochsystem_overhaul
oameye fecbfda
update min_action_method to work with CoupledSDEs
reykboerner 63f7cf9
adapted gMAM for CoupledSDEs and updated large deviations tests
reykboerner 18dc342
updated test of simulate and trajectory functions
reykboerner 649e893
streamline export
oameye 0a91810
do not require SVector
oameye 65e83a2
add skip kwargs to some tests
oameye 46b0dc9
add TYPEDSIGNATURES docstrings
oameye 7c91a83
delete auxilary action test file
oameye 4a3bee1
put basin code in extention
oameye 08b094c
exterminated Stochsystem in the docs
oameye bccbb18
fixed typo 'baisin' to 'basin'
reykboerner 74b8358
created StochSystem alias, re-added custom types
reykboerner File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
@testset "OuMAM" begin | ||
ou = StochSystem((u, p, t) -> -u, [], [1.0], 1.0) | ||
@testset "MAM FitzHugh-Nagumo" begin | ||
p = [0.1,3,1,1,1,0] | ||
fhn = CoupledSDEs(fitzhugh_nagumo, diag_noise_funtion(0.1), zeros(2), p) | ||
x_i = SA[sqrt(2/3), sqrt(2/27)] | ||
x_f = SA[0.001, 0.0] | ||
N, T = 200, 2.0 | ||
inst = min_action_method(fhn, x_i, x_f, N, T; maxiter=100, save_info=false) | ||
S = fw_action(fhn, inst, range(0., T, length=N)) | ||
@test isapprox(S, 0.18, atol=0.01) | ||
end | ||
|
||
@testset "MAM Ornstein-Uhlenbeck" begin | ||
ou = CoupledSDEs((u, p, t) -> -u, diag_noise_funtion(0.18), SA[1.0]) | ||
x0 = -1 | ||
xT = 2.0 | ||
T = 10.0 | ||
N = 51 | ||
t = range(0, T, N) | ||
inst_mam = min_action_method(ou, [x0], [xT], N, T, verbose = false, save_info = false) | ||
inst_mam = min_action_method(ou, SA[x0], SA[xT], N, T, verbose = false, save_info = false) | ||
inst_sol = ((xT - x0 * exp(-T)) * exp.(t) .+ (x0 * exp(T) - xT) * exp.(-t)) / | ||
(exp(T) - exp(-T)) | ||
@test maximum(abs.(inst_mam' .- inst_sol)) < 0.1 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Random | ||
Random.seed!(SEED) | ||
|
||
# System setup - FitzHugh-Nagumo model | ||
p = [1.0, 3.0, 1.0, 1.0, 1.0, 0.0] # Parameters (ϵ, β, α, γ, κ, I) | ||
σ = 0.215 # noise strength | ||
sys = CoupledSDEs(fitzhugh_nagumo, diag_noise_funtion(σ), zeros(2), p, seed = SEED) | ||
A = inv(CT.covariance_matrix(sys)) | ||
T, N = 2.0, 100 | ||
x_i = SA[sqrt(2/3), sqrt(2/27)] | ||
x_f = SA[0.0, 0.0] | ||
path = reduce(hcat, range(x_i, x_f, length=N)) | ||
time = range(0.0, T, length=N) | ||
|
||
@testset "fw_action" begin | ||
S = fw_action(sys, path, time) | ||
@test isapprox(S, 0.32, atol=0.01) | ||
end | ||
|
||
# Test om_action function | ||
@testset "om_action" begin | ||
sigma = 0.2 | ||
S = om_action(sys, path, time, sigma) | ||
@test isapprox(S, 0.26, atol=0.01) | ||
end | ||
|
||
# Test action function | ||
@testset "action" begin | ||
@test action(sys, path, time, "FW") == fw_action(sys, path, time) | ||
end | ||
|
||
# Test geometric_action function | ||
@testset "geometric_action" begin | ||
S = geometric_action(sys, path) | ||
@test isapprox(S, 0.23, atol=0.01) | ||
end | ||
|
||
# Test fw_integrand function | ||
@testset "fw_integrand" begin | ||
integrand = fw_integrand(sys, path, time, A) | ||
@test minimum(integrand) > 0.18 | ||
end | ||
|
||
# Test div_drift function | ||
@testset "div_drift" begin | ||
@test div_drift(sys, zeros(2)) == -2.0 | ||
@test div_drift(sys, x_i) == -4.0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the namespace minimal, we should limit the amount of functions we export. I don't think we need to export
div_drift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be convenient to export because it is quite central to the Onsager-Machlup action. Of course one can compute it pretty easily. We could also consider not exporting
fw_integrand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But a user would never call it in a usual workflow right? If they want to call they can just import the function in the namespace or calll it with Criticaltransition.div_drift