From 88dea7eefb4783601bd71e5cc7bb7a96839c4125 Mon Sep 17 00:00:00 2001 From: 2211567 Date: Sat, 31 May 2025 13:59:22 +0200 Subject: [PATCH] made FHNParams constructor more readable --- src/constants.jl | 5 +++++ src/solver.jl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/constants.jl b/src/constants.jl index ff9eded..d1734e3 100644 --- a/src/constants.jl +++ b/src/constants.jl @@ -8,6 +8,11 @@ struct FHNParams ϵ::Float64 a::Float64 b::Float64 + + # Inner constructor that takes keyword arguments + # The semicolon ';' separates positional arguments from keyword arguments + FHNParams(; N::Int, dx::Float64, Du::Float64, Dv::Float64, ϵ::Float64, a::Float64, b::Float64) = + new(N, dx, Du, Dv, ϵ, a, b) end export FHNParams diff --git a/src/solver.jl b/src/solver.jl index e40ed47..8999319 100644 --- a/src/solver.jl +++ b/src/solver.jl @@ -44,7 +44,7 @@ end """ function run_simulation(tspan::Tuple{Float64,Float64}, N::Int) # Turing-spot parameters - p = FHNParams(N, 1.0, 1e-5, 1e-3, 0.01, 0.1, 0.5) + p = FHNParams(N = N, dx = 1.0, Du = 1e-5, Dv = 1e-3, ϵ = 0.01, a = 0.1, b = 0.5) # Initial conditions (random noise) Random.seed!(1234)