Skip to contents

homotopy(actual, simplified) declares that simplified is an easy to solve approximation of actual. Wherever the operator is evaluated numerically it is actual. A HomotopyProblem() built from a system that contains the operator replaces every node by the blend (1 - lambda) * simplified + lambda * actual and is solved by sweeping lambda from 0 to 1, which walks from the easy solution to the true one.

Usage

homotopy(actual, simplified)

HomotopyCtx

homotopy_enabled(sys)

strip_homotopy(sys)

Format

HomotopyCtx is the metadata key, a string.

Arguments

actual

The real expression.

simplified

An approximation whose solution is easy to reach.

sys

A System.

Value

A sym expression; a System for strip_homotopy(); a logical for homotopy_enabled().

Details

strip_homotopy(sys) replaces every node by its actual branch and records FALSE under the metadata key HomotopyCtx, which homotopy_enabled(sys) reads; in ModelingToolkit this is what mtkcompile(sys; homotopy = false) does.

Examples

y <- Variable("y")
sys <- complete(System(list(0 ~ homotopy(atan(y - 3), y)), name = "h"))
prob <- HomotopyProblem(sys, list(y ~ 12))
solve(prob)[y]
#> [1] 3
homotopy_enabled(sys)
#> [1] TRUE
equations(strip_homotopy(sys))
#> [[1]]
#> 0 ~ atan(y - 3) 
#>