26 #include "runge_kutta.hpp"
31 int CASADI_INTEGRATOR_RK_EXPORT
36 plugin->version = CASADI_VERSION;
48 const std::vector<double>& tout)
60 casadi_assert(
nz_==0 &&
nrz_==0,
61 "Explicit Runge-Kutta integrators do not support algebraic variables");
76 MX h_half = h / 2, h_sixth = h / 6;
80 std::vector<MX> f_res;
92 f_arg[
DYN_T] = t0 + h_half;
93 f_arg[
DYN_X] = x0 + h_half * k1;
99 f_arg[
DYN_X] = x0 + h_half * k2;
105 f_arg[
DYN_T] = t0 + h;
106 f_arg[
DYN_X] = x0 + h * k3;
112 MX xf = x0 + h_sixth * (k1 + 2*k2 + 2*k3 + k4);
113 MX qf = h_sixth * (k1q + 2*k2q + 2*k3q + k4q);
128 {
"t",
"h",
"x0",
"v0",
"p",
"u"}, {
"xf",
"vf",
"qf"});
Helper class for Serialization.
void version(const std::string &name, int v)
static const Options options_
Options.
void init(const Dict &opts) override
Initialize stage.
void serialize_body(SerializingStream &s) const override
Serialize an object without type information.
const std::string & name() const
Name of the function.
Function reverse(casadi_int nadj) const
Get a function that calculates nadj adjoint derivatives.
const Sparsity & sparsity_in(casadi_int ind) const
Get sparsity of a given input.
static MX sym(const std::string &name, casadi_int nrow=1, casadi_int ncol=1)
Create an nrow-by-ncol symbolic primitive.
casadi_int nfwd_
Number of sensitivities.
void set_function(const Function &fcn, const std::string &fname, bool jit=false)
Function create_forward(const std::string &fname, casadi_int nfwd)
std::vector< std::string > get_function() const override
Get list of dependency functions.
static void registerPlugin(const Plugin &plugin, bool needs_lock=true)
Register an integrator in the factory.
static const std::string meta_doc
A documentation string.
void setup_step() override
Setup step functions.
RungeKutta(const std::string &name, const Function &dae, double t0, const std::vector< double > &tout)
Constructor.
void init(const Dict &opts) override
Initialize stage.
static ProtoFunction * deserialize(DeserializingStream &s)
Deserialize into MX.
static Integrator * creator(const std::string &name, const Function &dae, double t0, const std::vector< double > &tout)
Create a new integrator.
void serialize_body(SerializingStream &s) const override
Serialize an object without type information.
~RungeKutta() override
Destructor.
Helper class for Serialization.
void version(const std::string &name, int v)
@ STEP_NUM_IN
Number of arguments.
@ STEP_V0
Dependent variables.
@ STEP_XF
State vector at next time.
@ STEP_QF
Quadrature state contribution.
@ STEP_VF
Dependent variables at next time.
@ STEP_NUM_OUT
Number of arguments.
void CASADI_INTEGRATOR_RK_EXPORT casadi_load_integrator_rk()
int CASADI_INTEGRATOR_RK_EXPORT casadi_register_integrator_rk(Integrator::Plugin *plugin)
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.