def METHOD_NAME( model, opts ):
    casadi_version = CasadiMeta.version()
    casadi_opts = dict(mex=False, casadi_int='int', casadi_real='double')
    if casadi_version not in (ALLOWED_CASADI_VERSIONS):
        casadi_version_warning(casadi_version)
    generate_hess = opts["generate_hess"]
    code_export_dir = opts["code_export_directory"]
    # load model
    x = model.x
    u = model.u
    p = model.p
    f_expl = model.f_expl_expr
    model_name = model.name
    ## get model dimensions
    nx = x.size()[0]
    nu = u.size()[0]
    if isinstance(f_expl, casadi.MX):
        symbol = MX.sym
    elif isinstance(f_expl, casadi.SX):
        symbol = SX.sym
    else:
        raise Exception("Invalid type for f_expl! Possible types are 'SX' and 'MX'. Exiting.")
    ## set up functions to be exported
    Sx = symbol('Sx', nx, nx)
    Sp = symbol('Sp', nx, nu)
    lambdaX = symbol('lambdaX', nx, 1)
    fun_name = model_name + '_expl_ode_fun'
    ## Set up functions
    expl_ode_fun = Function(fun_name, [x, u, p], [f_expl])
    vdeX = jtimes(f_expl,x,Sx)
    vdeP = jacobian(f_expl,u) + jtimes(f_expl,x,Sp)
    fun_name = model_name + '_expl_vde_forw'
    expl_vde_forw = Function(fun_name, [x, Sx, Sp, u, p], [f_expl, vdeX, vdeP])
    adj = jtimes(f_expl, vertcat(x, u), lambdaX, True)
    fun_name = model_name + '_expl_vde_adj'
    expl_vde_adj = Function(fun_name, [x, lambdaX, u, p], [adj])
    if generate_hess:
        S_forw = vertcat(horzcat(Sx, Sp), horzcat(DM.zeros(nu,nx), DM.eye(nu)))
        hess = mtimes(transpose(S_forw),jtimes(adj, vertcat(x,u), S_forw))
        hess2 = []
        for j in range(nx+nu):
            for i in range(j,nx+nu):
                hess2 = vertcat(hess2, hess[i,j])
        fun_name = model_name + '_expl_ode_hess'
        expl_ode_hess = Function(fun_name, [x, Sx, Sp, lambdaX, u, p], [adj, hess2])
    ## generate C code
    if not os.path.exists(code_export_dir):
        os.makedirs(code_export_dir)
    cwd = os.getcwd()
    os.chdir(code_export_dir)
    model_dir = model_name + '_model'
    if not os.path.exists(model_dir):
        os.mkdir(model_dir)
    model_dir_location = os.path.join('.', model_dir)
    os.chdir(model_dir_location)
    fun_name = model_name + '_expl_ode_fun'
    expl_ode_fun.generate(fun_name, casadi_opts)
    fun_name = model_name + '_expl_vde_forw'
    expl_vde_forw.generate(fun_name, casadi_opts)
    fun_name = model_name + '_expl_vde_adj'
    expl_vde_adj.generate(fun_name, casadi_opts)
    if generate_hess:
        fun_name = model_name + '_expl_ode_hess'
        expl_ode_hess.generate(fun_name, casadi_opts)
    os.chdir(cwd)
    return