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
All components in `ModelingToolkit` are created via a function that serves as the constructor and returns some form of system, in this case a`ODESystem`.
52
+
All components in `ModelingToolkit` are created via a function that serves as the constructor and returns some form of system, in this case, an`ODESystem`.
52
53
Since the non-linear resistor is essentially a standard electrical component with two ports, we can extend from the `OnePort` component of the library.
53
54
```julia
54
55
@named oneport =OnePort()
55
56
```
56
57
This creates a `OnePort` with the `name = :oneport`.
57
-
For easier notation we can unpack the states of the component
58
+
For easier notation, we can unpack the states of the component
58
59
```julia
59
60
@unpack v, i = oneport
60
61
```
61
62
It might be a good idea to create parameters for the constants of the `NonlinearResistor`.
62
63
```julia
63
64
pars =@parameters Ga=Ga Gb=Gb Ve=Ve
64
65
```
65
-
The syntax looks funny but it simply creates symbolic parameters with the name `Ga` where it's default value is set from the function's argument `Ga`.
66
-
While this is not strictly necessary it allows the user to `remake` the problem easily with different parameters or allow for auto-tuning or parameter optimization without having to do all costly steps that may be involved with building and simplifying a model.
66
+
The syntax looks funny but it simply creates symbolic parameters with the name `Ga` where its default value is set from the function's argument `Ga`.
67
+
While this is not strictly necessary it allows the user to `remake` the problem easily with different parameters or allow for auto-tuning or parameter optimization without having to do all the costly steps that may be involved with building and simplifying a model.
67
68
The non-linear (in this case piece-wise constant) equation for the current can be implemented using `IfElse.ifelse`.
68
69
Finally, the created `oneport` component is extended with the created equations and parameters.
69
-
In this case no extra state variables are added, hence an empty vector is supplied.
70
-
The independent variable `t` needs to be supplied as second argument.
70
+
In this case, no extra state variables are added, hence an empty vector is supplied.
71
+
The independent variable `t` needs to be supplied as the second argument.
0 commit comments