Hi,
I’m trying to solve some PDEs using a pseudo-spectral method with SplitODEProblem, which gives me a solution in the wavenumber domain. Is there a good way to take the inverse DCT of the solution, or am I going about this in completely the wrong way?
At the moment I am just taking the IDCT of solution.u which is fine but doesn’t work with code that needs continuous output.
It’s not a discrete cosine transform (DCT) if you want continuous output. What actual mathematical transformation do you need?
It’s a discrete transform in space, which leads to a system of ODEs with one equation with respect to time for each point in the wavenumber domain. After solving (with dense=true), the resulting ODESolution (with can then be called as solution(t) to give the value in the wavenumber domain at time t. What I would like to do is perform an inverse transform to get back to a solution in the spatial domain.
You can call solution(t)
, then call the IDCT on that, but this could be expensive if you want to do it at a large number of times t
.
In principle, internal to solution(t)
is probably a piecewise polynomial in time, and since polynomial evaluation is linear in the coefficients, you could call the IDCT on the coefficients to get a callable object spatialsolution(t)
that gives you the spatial solution at any desired t
(by evaluating the transformed coefficients). I’m not sure if DifferentialEquations.jl gives you enough access to the solution internals to do this, though?
sol.k[i] gives the coefficients of the ith polynomial. They are defined per method though so it can be a bit difficult to parse what that polynomial is if you need to find how exactly it is defined
I think that should work, thank you. The method doesn’t change so I should be able to write a dct method that operates on sol.k.