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

Cope with simplest delays #112

Merged
merged 16 commits into from
Nov 18, 2024
Merged

Cope with simplest delays #112

merged 16 commits into from
Nov 18, 2024

Conversation

richfitz
Copy link
Member

@richfitz richfitz commented Nov 13, 2024

No integration test yet but see it in action:

library(dust2)
gen <- odin({
  ylag <- delay(y, tau)
  initial(y) <- 0.5
  deriv(y) <- 0.2 * ylag * 1 / (1 + ylag^10) - 0.1 * y
  tau <- parameter(10, constant = TRUE)
})

t <- seq(0, 300, length.out = 301)

sys1 <- dust_system_create(gen)
dust_system_set_state_initial(sys1)
y1 <- dust_system_simulate(sys1, t)
plot(t, y1, ylab = "y", type = "l")

sys2 <- dust_system_create(gen, list(tau = 20))
dust_system_set_state_initial(sys2)
y2 <- dust_system_simulate(sys2, t)
plot(t, y2, ylab = "y", type = "l")

and compare with this example from the odin1 docs

@richfitz richfitz force-pushed the mrc-5997 branch 2 times, most recently from dfe0b91 to b95a5c4 Compare November 14, 2024 18:36
@richfitz richfitz marked this pull request as ready for review November 18, 2024 09:54
ylag <- delay(y, tau)
initial(y) <- 0.5
deriv(y) <- 0.2 * ylag * 1 / (1 + ylag^10) - 0.1 * y
tau <- parameter(10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameter(10, constant = TRUE) - works correctly!

@weshinsley weshinsley merged commit 45b95b6 into main Nov 18, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants