Code generation utilities

These are lower-level functions that ModelingToolkit leverages to generate code for building numerical problems.

Missing docstring.

Missing docstring for ModelingToolkit.generate_rhs. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_diffusion_function. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_jacobian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_tgrad. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_W. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_dae_jacobian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_history. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_boundary_conditions. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_cost. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_cost_gradient. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_cost_hessian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_cons. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_constraint_jacobian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_constraint_hessian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_control_jacobian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.build_explicit_observed_function. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_control_function. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_update_A. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.generate_update_b. Check Documenter's build log for details.

ModelingToolkit.generate_semiquadratic_functionsFunction
generate_semiquadratic_functions(
    sys::System,
    A,
    B,
    C;
    stiff_linear,
    stiff_quadratic,
    stiff_nonlinear,
    expression,
    wrap_gfw,
    eval_expression,
    eval_module,
    kwargs...
) -> Tuple{Tuple{Expr, Expr}, Tuple{Expr, Expr}}

Generate f1 and f2 for SemilinearODEFunction (internally represented as a SplitFunction). A, B, C are the matrices returned from calculate_semiquadratic_form. This expects that the system has the necessary extra parmameters added by add_semiquadratic_parameters.

Keyword Arguments

  • stiff_linear: Whether the linear part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no linear part.

  • stiff_quadratic: Whether the quadratic part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no quadratic part.

  • stiff_nonlinear: Whether the non-linear non-quadratic part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no such non-linear non-quadratic part.

  • expression: Val{true} if this should return an Expr (or tuple of Exprs) of the generated code. Val{false} otherwise.

  • wrap_gfw: Val{true} if the returned functions should be wrapped in a callable struct to make them callable using the expected syntax. The callable struct itself is internal API. If expression == Val{true}, the returned expression will construct the callable struct. If this function returns a tuple of functions/expressions, both will be identical if wrap_gfw == Val{true}.

  • eval_expression: Whether to compile any functions via eval or RuntimeGeneratedFunctions.

  • eval_module: If eval_expression == true, the module to eval into. Otherwise, the module in which to generate the RuntimeGeneratedFunction.

All other keyword arguments are forwarded to build_function_wrapper. Note that all three of stiff_linear, stiff_quadratic, stiff_nonlinear cannot be identical, and at least two of A, B, C returned from calculate_semiquadratic_form must be non-nothing. In other words, both of the functions in the split form must be non-empty.

Warn

This API is experimental and may change in a future non-breaking release.

source
ModelingToolkit.generate_semiquadratic_jacobianFunction
generate_semiquadratic_jacobian(
    sys::System,
    A,
    B,
    C,
    Cjac;
    sparse,
    stiff_linear,
    stiff_quadratic,
    stiff_nonlinear,
    expression,
    wrap_gfw,
    eval_expression,
    eval_module,
    kwargs...
) -> Tuple{Expr, Expr}

Generate the jacobian of f1 for SemilinearODEFunction (internally represented as a SplitFunction). A, B, C are the matrices returned from calculate_semiquadratic_form. Cjac is the jacobian of C with respect to the unknowns of the system, or nothing if C === nothing. This expects that the system has the necessary extra parmameters added by add_semiquadratic_parameters.

Keyword Arguments

  • stiff_linear: Whether the linear part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no linear part.

  • stiff_quadratic: Whether the quadratic part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no quadratic part.

  • stiff_nonlinear: Whether the non-linear non-quadratic part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no such non-linear non-quadratic part.

  • expression: Val{true} if this should return an Expr (or tuple of Exprs) of the generated code. Val{false} otherwise.

  • wrap_gfw: Val{true} if the returned functions should be wrapped in a callable struct to make them callable using the expected syntax. The callable struct itself is internal API. If expression == Val{true}, the returned expression will construct the callable struct. If this function returns a tuple of functions/expressions, both will be identical if wrap_gfw == Val{true}.

  • eval_expression: Whether to compile any functions via eval or RuntimeGeneratedFunctions.

  • eval_module: If eval_expression == true, the module to eval into. Otherwise, the module in which to generate the RuntimeGeneratedFunction.

All other keyword arguments are forwarded to build_function_wrapper. Note that all three of stiff_linear, stiff_quadratic, stiff_nonlinear cannot be identical, and at least two of A, B, C returned from calculate_semiquadratic_form must be non-nothing. In other words, both of the functions in the split form must be non-empty.

Warn

This API is experimental and may change in a future non-breaking release.

source
ModelingToolkit.get_semiquadratic_W_sparsityFunction
get_semiquadratic_W_sparsity(
    sys::System,
    A,
    B,
    C,
    Cjac;
    stiff_linear,
    stiff_quadratic,
    stiff_nonlinear,
    mm
) -> SparseArrays.SparseMatrixCSC{Bool, Int64}

Return the sparsity pattern of the jacobian of f1 for SemilinearODEFunction (internally represented as a SplitFunction). A, B, C are the matrices returned from calculate_semiquadratic_form. Cjac is the jacobian of C with respect to the unknowns of the system, or nothing if C === nothing. This expects that the system has the necessary extra parmameters added by add_semiquadratic_parameters.

Keyword Arguments

  • stiff_linear: Whether the linear part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no linear part.

  • stiff_quadratic: Whether the quadratic part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no quadratic part.

  • stiff_nonlinear: Whether the non-linear non-quadratic part of the equations should be part of the stiff function in the split form. Has no effect if the equations have no such non-linear non-quadratic part.

  • expression: Val{true} if this should return an Expr (or tuple of Exprs) of the generated code. Val{false} otherwise.

  • wrap_gfw: Val{true} if the returned functions should be wrapped in a callable struct to make them callable using the expected syntax. The callable struct itself is internal API. If expression == Val{true}, the returned expression will construct the callable struct. If this function returns a tuple of functions/expressions, both will be identical if wrap_gfw == Val{true}.

  • eval_expression: Whether to compile any functions via eval or RuntimeGeneratedFunctions.

  • eval_module: If eval_expression == true, the module to eval into. Otherwise, the module in which to generate the RuntimeGeneratedFunction.

  • mm: The mass matrix of sys.

Note that all three of stiff_linear, stiff_quadratic, stiff_nonlinear cannot be identical, and at least two of A, B, C returned from calculate_semiquadratic_form must be non-nothing. In other words, both of the functions in the split form must be non-empty.

Warn

This API is experimental and may change in a future non-breaking release.

source

For functions such as jacobian calculation which require symbolic computation, there are calculate_* equivalents to obtain the symbolic result without building a function.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_tgrad. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_jacobian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.jacobian_sparsity. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.jacobian_dae_sparsity. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_hessian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.hessian_sparsity. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_massmatrix. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.W_sparsity. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_W_prototype. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_cost_gradient. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_cost_hessian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.cost_hessian_sparsity. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_constraint_jacobian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_constraint_hessian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_control_jacobian. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ModelingToolkit.calculate_A_b. Check Documenter's build log for details.

All code generation eventually calls build_function_wrapper.

Missing docstring.

Missing docstring for ModelingToolkit.build_function_wrapper. Check Documenter's build log for details.