|
4 | 4 | [](http://mtkstdlib.sciml.ai/stable/)
|
5 | 5 | [](http://mtkstdlib.sciml.ai/dev/)
|
6 | 6 |
|
7 |
| -The ModelingToolkit Standard Library is standard library of components to model the world and beyond. |
| 7 | +The ModelingToolkit Standard Library is a standard library of components to model the world and beyond. |
8 | 8 |
|
9 | 9 | 
|
10 | 10 |
|
@@ -41,27 +41,30 @@ The following is the [RC Circuit Demonstration](http://mtkstdlib.sciml.ai/dev/tu
|
41 | 41 | ```julia
|
42 | 42 | using ModelingToolkit, OrdinaryDiffEq, Plots
|
43 | 43 | using ModelingToolkitStandardLibrary.Electrical
|
| 44 | +using ModelingToolkitStandardLibrary.Blocks: Constant |
44 | 45 |
|
45 | 46 | R = 1.0
|
46 | 47 | C = 1.0
|
47 | 48 | V = 1.0
|
48 | 49 | @variables t
|
49 | 50 | @named resistor = Resistor(R=R)
|
50 | 51 | @named capacitor = Capacitor(C=C)
|
51 |
| -@named source = ConstantVoltage(V=V) |
| 52 | +@named source = Voltage() |
| 53 | +@named constant = Constant(k=V) |
52 | 54 | @named ground = Ground()
|
53 | 55 |
|
54 | 56 | rc_eqs = [
|
| 57 | + connect(constant.output, source.V) |
55 | 58 | connect(source.p, resistor.p)
|
56 | 59 | connect(resistor.n, capacitor.p)
|
57 | 60 | connect(capacitor.n, source.n, ground.g)
|
58 | 61 | ]
|
59 | 62 |
|
60 |
| -@named rc_model = ODESystem(rc_eqs, t, systems=[resistor, capacitor, source, ground]) |
| 63 | +@named rc_model = ODESystem(rc_eqs, t, systems=[resistor, capacitor, constant, source, ground]) |
61 | 64 | sys = structural_simplify(rc_model)
|
62 | 65 | prob = ODAEProblem(sys, Pair[], (0, 10.0))
|
63 | 66 | sol = solve(prob, Tsit5())
|
64 |
| -plot(sol, vars = [capacitor.v,resistor.i], |
| 67 | +plot(sol, vars = [capacitor.v, resistor.i], |
65 | 68 | title = "RC Circuit Demonstration",
|
66 | 69 | labels = ["Capacitor Voltage" "Resistor Current"])
|
67 | 70 | savefig("plot.png")
|
|
0 commit comments