|
1 | 1 | using ModelingToolkit, Test
|
2 | 2 | using ModelingToolkit: get_gui_metadata, VariableDescription, getdefault
|
3 | 3 | using URIs: URI
|
| 4 | +using Distributions |
| 5 | +using Unitful |
4 | 6 |
|
5 | 7 | ENV["MTK_ICONS_DIR"] = "$(@__DIR__)/icons"
|
6 | 8 |
|
7 | 9 | @connector RealInput begin
|
8 |
| - u(t), [input = true] |
| 10 | + u(t), [input = true, unit = u"V"] |
9 | 11 | end
|
10 | 12 | @connector RealOutput begin
|
11 |
| - u(t), [output = true] |
| 13 | + u(t), [output = true, unit = u"V"] |
12 | 14 | end
|
13 | 15 | @mtkmodel Constant begin
|
14 | 16 | @components begin
|
|
22 | 24 | end
|
23 | 25 | end
|
24 | 26 |
|
25 |
| -@variables t |
| 27 | +@variables t [unit = u"s"] |
26 | 28 | D = Differential(t)
|
27 | 29 |
|
28 | 30 | @connector Pin begin
|
29 |
| - v(t) # Potential at the pin [V] |
30 |
| - i(t), [connect = Flow] # Current flowing into the pin [A] |
| 31 | + v(t), [unit = u"V"] # Potential at the pin [V] |
| 32 | + i(t), [connect = Flow, unit = u"A"] # Current flowing into the pin [A] |
31 | 33 | @icon "pin.png"
|
32 | 34 | end
|
33 | 35 |
|
|
41 | 43 | n = Pin()
|
42 | 44 | end
|
43 | 45 | @variables begin
|
44 |
| - v(t) |
45 |
| - i(t) |
| 46 | + v(t), [unit = u"V"] |
| 47 | + i(t), [unit = u"A"] |
46 | 48 | end
|
47 | 49 | @icon "oneport.png"
|
48 | 50 | @equations begin
|
@@ -70,7 +72,7 @@ resistor_log = "$(@__DIR__)/logo/resistor.svg"
|
70 | 72 | @mtkmodel Resistor begin
|
71 | 73 | @extend v, i = oneport = OnePort()
|
72 | 74 | @parameters begin
|
73 |
| - R |
| 75 | + R, [unit = u"Ω"] |
74 | 76 | end
|
75 | 77 | @icon begin
|
76 | 78 | """<?xml version="1.0" encoding="UTF-8"?>
|
|
95 | 97 |
|
96 | 98 | @mtkmodel Capacitor begin
|
97 | 99 | @parameters begin
|
98 |
| - C |
| 100 | + C, [unit = u"F"] |
99 | 101 | end
|
100 | 102 | @extend v, i = oneport = OnePort(; v = 0.0)
|
101 | 103 | @icon "https://upload.wikimedia.org/wikipedia/commons/7/78/Capacitor_symbol.svg"
|
@@ -218,8 +220,8 @@ getdefault(a.b.j) == 30
|
218 | 220 | getdefault(a.b.k) == 40
|
219 | 221 |
|
220 | 222 | metadata = Dict(:description => "Variable to test metadata in the Model.structure",
|
221 |
| - :input => true, :bounds => :((-1, 1)), :connection_type => :Flow, :integer => true, |
222 |
| - :binary => false, :tunable => false, :disturbance => true, :dist => :(Normal(1, 1))) |
| 223 | + :input => true, :bounds => (-1, 1), :connection_type => :Flow, :integer => true, |
| 224 | + :binary => false, :tunable => false, :disturbance => true, :dist => Normal(1, 1)) |
223 | 225 |
|
224 | 226 | @connector MockMeta begin
|
225 | 227 | m(t),
|
|
0 commit comments