SciML / ODEInterfaceDiffEq.jl

Adds the common API onto ODEInterface classic Fortran methods for the SciML Scientific Machine Learning organization
Other
9 stars 17 forks source link

How to pass the options? #19

Closed JianghuiDu closed 5 years ago

JianghuiDu commented 5 years ago

I can't figure out how the solver specific options in ODEInterface are passed to solve. Can you give an example?

ChrisRackauckas commented 5 years ago

what options?

JianghuiDu commented 5 years ago
opt_radau=OptionsODE(
  OPT_RTOL             => rtol,
  OPT_ATOL             => atol,
  OPT_INITIALSS        => 1e-3,
  OPT_JACRECOMPFACTOR  => 0.1,
  OPT_FREEZESSLEFT     => 1.0,
  OPT_FREEZESSRIGHT    => 1.2,
  OPT_SSMINSEL         => 0.1,
  OPT_SSMAXSEL         => 10.0,
  OPT_JACOBIMATRIX     => reactran_steady_jac_int,
  OPT_JACOBIBANDSTRUCT => (bandwth,bandwth), 
  OPT_RHS_CALLMODE     => RHS_CALL_INSITU,
  OPT_LOGLEVEL         => LOG_NOTHING,
  OPT_OUTPUTMODE       => OUTPUTFCN_NEVER
  )

I see that options like RTOL and the output are inherited by solve, what about the other ones?

ChrisRackauckas commented 5 years ago

Most of it is handled automatically to match the common solve interface. Tolerances, inital step size, qmin/qmax, declaring Jacobians, log functions, call mode, and output mode are all handled. I guess we miss a few that can be added as solver specific.

JianghuiDu commented 5 years ago

Are the jacobian bandwidths inferred if specifying jac_prototype?

ChrisRackauckas commented 5 years ago

ahh, we missed banded Jacobians here. That would be worth adding for sure.

JianghuiDu commented 5 years ago

That would be great. I think ODEInterface has its own BandedMatrix type, not sure how it compares to BandedMatrices. I find out that ddebdf is a contender of CVODE_BDF. It's surprisingly fast. Also it is interesting that using the DifferentialEquations interface reduces allocations a lot when compared to the original ODEInterface interface.

ChrisRackauckas commented 5 years ago

Interesting. Can you share that problem where it's fast? All of the cases in DiffEqBenchmarks.jl shows it's slow, so I'm curious what properties of the ODE allowed it to work well.

JianghuiDu commented 5 years ago

One small glitch should be resolved quite easily. ODEInterface requires the rtol and atol be the same length. So I can't use a scalar for one and a vector for the other like I do in DifferentialEquations .

JianghuiDu commented 5 years ago

It's in my private repo and I've added you as collaborator. The relevant file is https://github.com/JianghuiDu/diagenetic-model/blob/master/testing.ode.jl. It's large system (3000) reaction transport model.

ChrisRackauckas commented 5 years ago

Try https://github.com/JuliaDiffEq/ODEInterfaceDiffEq.jl/pull/22 . dde_bdf(jac_lower=bandwidth,jac_upper=bandwidth). It's interesting that's doing well since every test that we have shows CVODE_BDF as faster than it, so by now I've almost given up on it.

That model looks pretty nice. Would you mind submitting it to DiffEqBenchmarks after it's done and published? It would be a good one to keep testing and improving against.

JianghuiDu commented 5 years ago

Yes. I'll submit it for benchmark after I'm done. It'd be good to have a large system among the examples.