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

Create function for simulating whole trajectories #15

Closed
smith-garrett opened this issue Jan 4, 2023 · 2 comments
Closed

Create function for simulating whole trajectories #15

smith-garrett opened this issue Jan 4, 2023 · 2 comments

Comments

@smith-garrett
Copy link
Owner

Simulate solution of master equation by applying uniformization incrementally, e.g., starting at time point 0 w/ initial conditions, solve for t=0.01. That solution is now the initial state for getting the solution at t=0.02, e.g. This avoids problems related to stiffness: When the (time * uniformization rate) gets large, uniformization becomes inefficient due to the many matrix multiplications that have to be performed.

It would be interesting to consider adaptive time stepping or adaptation of the uniformization rate, but that might be too much initially.

@smith-garrett
Copy link
Owner Author

Should take advantage of the fact that p(t + dt) = exp((t + dt) * Q) p(t)

@smith-garrett
Copy link
Owner Author

Sketch:

function solve(Q, p0, tspan, dt, params)
soln = zeros(maximum(tspan) / dt + 1, size(Q, 1))

if minimum(tspan) != 0
soln[1,:] = uniformize(Q, p0, params.k, minimum(tspan))
else
soln[1,:] = p0
end

for i in 2:size(soln, 1)
soln[i, :] = uniformize(Q, soln[i-1,:], params.k, dt)
end
soln
end

Will probably need to redo interface of uniformization() to take a params NamedTuple (#14) first to make passing parameters smoother.

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

No branches or pull requests

1 participant