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
As can be seen, we get exactly the same result. The only difference here is that we are solving an extra equation, which allows us to plot the body position as well.
Copy file name to clipboardExpand all lines: docs/src/tutorials/custom_component.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,11 +109,11 @@ nothing # hide
109
109
110
110
## Simulating the Model
111
111
112
-
`@mtkbuild` builds a structurally simplified `ChaoticAttractor` model.
112
+
`@mtkcompile` builds a structurally simplified `ChaoticAttractor` model.
113
113
Since the initial voltage of the capacitors was already specified via `v` and the initial current of inductor via `i`, no initial condition is given and an empty pair is supplied.
@@ -134,7 +134,7 @@ function MassSpringDamper(; name)
134
134
D(x) ~ dx
135
135
D(dx) ~ ddx]
136
136
137
-
ODESystem(eqs, t, vars, pars; name, systems = [input])
137
+
System(eqs, t, vars, pars; name, systems = [input])
138
138
end
139
139
140
140
function MassSpringDamperSystem(data, time; name)
@@ -145,7 +145,7 @@ function MassSpringDamperSystem(data, time; name)
145
145
eqs = [connect(model.input, src.output)
146
146
connect(clk.output, src.input)]
147
147
148
-
ODESystem(eqs, t; name, systems = [src, clk, model])
148
+
System(eqs, t; name, systems = [src, clk, model])
149
149
end
150
150
151
151
function generate_data()
@@ -159,7 +159,7 @@ end
159
159
df = generate_data() # example data
160
160
161
161
@named system = MassSpringDamperSystem(df.data, df.time)
162
-
sys = structural_simplify(system)
162
+
sys = mtkcompile(system)
163
163
prob = ODEProblem(sys, [], (0, df.time[end]))
164
164
sol = solve(prob)
165
165
plot(sol)
@@ -213,11 +213,11 @@ function System(; name)
213
213
D(x) ~ dx
214
214
D(dx) ~ ddx]
215
215
216
-
ODESystem(eqs, t, vars, pars; name)
216
+
System(eqs, t, vars, pars; name)
217
217
end
218
218
219
219
@named system = System()
220
-
sys = structural_simplify(system)
220
+
sys = mtkcompile(system)
221
221
prob = ODEProblem(sys, [], (0, time[end]))
222
222
223
223
rdata[] = data1
@@ -240,7 +240,7 @@ Additional code could be added to resolve this issue, for example by using a `Re
240
240
241
241
## `SampledData` Component
242
242
243
-
To resolve the issues presented above, the `ModelingToolkitStandardLibrary.Blocks.SampledData` component can be used which allows for a resusable `ODESystem` and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to `solve()`.
243
+
To resolve the issues presented above, the `ModelingToolkitStandardLibrary.Blocks.SampledData` component can be used which allows for a resusable `System` and self contained data which ensures a solution which remains valid for it's lifetime. Now it's possible to also parallelize the call to `solve()`.
244
244
245
245
```julia
246
246
using ModelingToolkit
@@ -259,11 +259,11 @@ function System(; name)
259
259
D(x) ~ dx
260
260
D(dx) ~ ddx]
261
261
262
-
ODESystem(eqs, t, vars, pars; systems = [src], name)
0 commit comments