You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/examples/automatic_differentiation.md
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,8 +108,8 @@ We start by defining a helper function `plot_optimized` that will evaluate the p
108
108
The constraint function `constraints` enforces the peak of the sensitivity function to be below `Msc`. Finally, we use [Optimization.jl](https://github.com/SciML/Optimization.jl) to optimize the cost function and tell it to use ForwardDiff.jl to compute the gradient of the cost function. The optimizer we use in this example is `Ipopt`.
109
109
110
110
```@example autodiff
111
-
using Optimization, Statistics, LinearAlgebra
112
-
using Ipopt, OptimizationMOI; MOI = OptimizationMOI.MOI
Here we demonstrate that we may use this simple framework to model also stateful nonlinearities, such as hysteresis. The `hysteresis` function internally creates a feedback interconnection between a fast first-order system and a `sign` or `tanh` nonlinearity to create a simple hysteresis loop. The width and amplitude of the loop can be adjusted through the parameters `width` and `amplitude`, respectively.
234
+
```@example HYSTERESIS
235
+
using ControlSystems, Plots
236
+
import ControlSystemsBase: hysteresis
237
+
238
+
amplitude = 0.7
239
+
width = 1.5
240
+
sys_hyst = hysteresis(; width, amplitude)
241
+
242
+
t = 0:0.01:20
243
+
ufun(y,x,t) = y .= 5.0 .* sin(t) ./ (1+t/5) # A sine wave that sweeps back and forth with decreasing amplitude
Create a hysteresis nonlinearity. The signal switches between `±amplitude` when the input crosses `±width`. `Tf` controls the time constant of the internal state that tracks the hysteresis, and `hardness` controls how sharp the transition is between the two states.
0 commit comments