Skip to content

Conversation

SebastianM-C
Copy link
Contributor

I added the solution key for problem 5. Let me know if the approach is ok.
I was wondering if I should have used ModeingTookit.jl for the system definition.

For the initial condition generation I used a simple rejection sampling like in @Datseris example here.

I also think there was a typo in the mathematical description of the the SecondOrderODEProblem.

Right now there is a problem with the initial conditions and with threading this crashes julia

signal (11): Segmentation fault
in expression starting at /home/sebastian/Documents/julia/DiffEqTutorials.jl/tutorials/exercises/02-workshop_solutions.jmd:263
┌ Warning: dt <= dtmin. Aborting. There is either an error in your model specification or the true solution is unstable.

Probably the numbers have to be tweaked a bit. I will investigate this further.

I was also thinking of doing the initial condition generation a bit more general (so that there is no need to hardcode arbitrary numbers) with IntervalConstraintProgramming.jl, but for a exercise marked for beginners, I think it's a bit too much.

@SebastianM-C
Copy link
Contributor Author

I rebased on master and fixed the problem in Part 3 and added Part 4.
@ChrisRackauckas I'm not sure what can I do about the plots. For this system the most used visualization is the Poincare map, but here I have full solutions.
Computing the Poincare section via a discrete callback is on my todo list, but I don't think it fits here.
Also one could do some kind of post solution interpolation, but again I'm not exactly sure if it would be something too complicated.

At Part 4 I get an error when trying to evaluate the solve statement

InvalidIRError: compiling gpu_kernel(Cassette.Context{nametype(Ctx),Nothing,Nothing,getfield(GPUifyLoops, Symbol("##PassType#363")),Nothing,Cassette.DisableHooks}, typeof(DiffEqGPU.gpu_kernel), ODEFunction{true,typeof(henon),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing}, CUDAnative.CuDeviceArray{Float64,2,CUDAnative.AS.Global}, CUDAnative.CuDeviceArray{Float64,2,CUDAnative.AS.Global}, CUDAnative.CuDeviceArray{Nothing,2,CUDAnative.AS.Global}, Float64) resulted in invalid LLVM IR
Reason: unsupported call to the Julia runtime (call to jl_f_tuple)
Stacktrace:
 [1] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:537
 [2] throw_boundserror at subarray.jl:43
 [3] checkbounds at abstractarray.jl:449
 [4] copyto! at multidimensional.jl:874
 [5] copyto! at broadcast.jl:838
 [6] copyto! at broadcast.jl:797
 [7] materialize! at broadcast.jl:756
 [8] henon at C:\Users\sebastian\Documents\julia\DiffEqTutorials.jl\tutorials\exercises\02-workshop_solutions.jmd:197
 [9] ODEFunction at /mnt/storage/.julia/packages/DiffEqBase/u5mMn/src/diffeqfunction.jl:193
 [10] gpu_kernel at /mnt/storage/.julia/packages/DiffEqGPU/QB1WC/src/DiffEqGPU.jl:6
 [11] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:0
Reason: unsupported call to the Julia runtime (call to jl_f_getfield)
Stacktrace:
 [1] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:537
 [2] throw_boundserror at subarray.jl:43
 [3] checkbounds at abstractarray.jl:449
 [4] copyto! at multidimensional.jl:874
 [5] copyto! at broadcast.jl:838
 [6] copyto! at broadcast.jl:797
 [7] materialize! at broadcast.jl:756
 [8] henon at C:\Users\sebastian\Documents\julia\DiffEqTutorials.jl\tutorials\exercises\02-workshop_solutions.jmd:197
 [9] ODEFunction at /mnt/storage/.julia/packages/DiffEqBase/u5mMn/src/diffeqfunction.jl:193
 [10] gpu_kernel at /mnt/storage/.julia/packages/DiffEqGPU/QB1WC/src/DiffEqGPU.jl:6
 [11] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:0
Reason: unsupported call to the Julia runtime (call to jl_f_tuple)
Stacktrace:
 [1] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:537
 [2] throw_boundserror at subarray.jl:43
 [3] checkbounds at abstractarray.jl:449
 [4] getindex at subarray.jl:260
 [5] henon at C:\Users\sebastian\Documents\julia\DiffEqTutorials.jl\tutorials\exercises\02-workshop_solutions.jmd:191
 [6] ODEFunction at /mnt/storage/.julia/packages/DiffEqBase/u5mMn/src/diffeqfunction.jl:193
 [7] gpu_kernel at /mnt/storage/.julia/packages/DiffEqGPU/QB1WC/src/DiffEqGPU.jl:6
 [8] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:0
Reason: unsupported call to the Julia runtime (call to jl_f_getfield)
Stacktrace:
 [1] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:537
 [2] throw_boundserror at subarray.jl:43
 [3] checkbounds at abstractarray.jl:449
 [4] getindex at subarray.jl:260
 [5] henon at C:\Users\sebastian\Documents\julia\DiffEqTutorials.jl\tutorials\exercises\02-workshop_solutions.jmd:191
 [6] ODEFunction at /mnt/storage/.julia/packages/DiffEqBase/u5mMn/src/diffeqfunction.jl:193
 [7] gpu_kernel at /mnt/storage/.julia/packages/DiffEqGPU/QB1WC/src/DiffEqGPU.jl:6
 [8] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:0
Reason: unsupported call through a literal pointer (call to jl_alloc_array_1d)
Stacktrace:
 [1] Type at boot.jl:402
 [2] Type at boot.jl:411
 [3] Type at boot.jl:419
 [4] similar at abstractarray.jl:618
 [5] similar at abstractarray.jl:617
 [6] vect at array.jl:130
 [7] henon at C:\Users\sebastian\Documents\julia\DiffEqTutorials.jl\tutorials\exercises\02-workshop_solutions.jmd:197
 [8] ODEFunction at /mnt/storage/.julia/packages/DiffEqBase/u5mMn/src/diffeqfunction.jl:193
 [9] gpu_kernel at /mnt/storage/.julia/packages/DiffEqGPU/QB1WC/src/DiffEqGPU.jl:6
 [10] overdub at /mnt/storage/.julia/packages/Cassette/IwsFs/src/overdub.jl:0
Reason: unsupported call through a literal pointer (call to jl_object_id)
Stacktrace:
....

@SebastianM-C
Copy link
Contributor Author

SebastianM-C commented Jul 16, 2019

I also tried the following for the GPU part

function henon_gpu(dz,z,p,t)
  @inbounds begin
    dz[1] = -z[3]*(1 + 2z[4])
    dz[2] = -z[4]-(z[3]^2 - z[4]^2)
    dz[3] = z[1]
    dz[4] = z[2]
  end
  return nothing
end

z0 = generate_ics(0.125, 5)
prob_gpu = ODEProblem(henon_gpu, u₀, (0., 10.))
ensprob = EnsembleProblem(prob_gpu, prob_func=prob_func)

but the error is still present.

@SebastianM-C
Copy link
Contributor Author

The problem was due to the input not being Float32, as mentioned by Chris on slack.
Everything should work now.

@SebastianM-C SebastianM-C marked this pull request as ready for review July 16, 2019 22:57
@ChrisRackauckas
Copy link
Member

Thanks!

@ChrisRackauckas ChrisRackauckas merged commit 417e202 into SciML:master Jul 16, 2019
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