Skip to content

Commit

Permalink
Merge pull request #2200 from SciML/myb/renaming
Browse files Browse the repository at this point in the history
`@model` -> `@mtkmodel`
  • Loading branch information
YingboMa authored Jun 27, 2023
2 parents 67175ab + 786d42e commit 9869b2b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ModelingToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export JumpProblem, DiscreteProblem
export NonlinearSystem, OptimizationSystem, ConstraintsSystem
export alias_elimination, flatten
export connect, @connector, Connection, Flow, Stream, instream
export @component, @model
export @component, @mtkmodel
export isinput, isoutput, getbounds, hasbounds, isdisturbance, istunable, getdist, hasdist,
tunable_parameters, isirreducible, getdescription, hasdescription, isbinaryvar,
isintegervar
Expand Down
4 changes: 2 additions & 2 deletions src/systems/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ struct Model{F, S}
end
(m::Model)(args...; kw...) = m.f(args...; kw...)

for f in (:connector, :model)
for f in (:connector, :mtkmodel)
@eval begin
macro $f(name::Symbol, body)
esc($(Symbol(f, :_macro))(__module__, name, body))
Expand Down Expand Up @@ -173,7 +173,7 @@ function get_var(mod::Module, b)
b isa Symbol ? getproperty(mod, b) : b
end

function model_macro(mod, name, expr; arglist = Set([]), kwargs = Set([]))
function mtkmodel_macro(mod, name, expr; arglist = Set([]), kwargs = Set([]))
exprs = Expr(:block)
dict = Dict{Symbol, Any}()
dict[:kwargs] = Dict{Symbol, Any}()
Expand Down
16 changes: 8 additions & 8 deletions test/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end
@connector RealOutput begin
u(t), [output = true]
end
@model Constant begin
@mtkmodel Constant begin
@components begin
output = RealOutput()
end
Expand All @@ -34,7 +34,7 @@ end
@named p = Pin(; v = π)
@test getdefault(p.v) == π

@model OnePort begin
@mtkmodel OnePort begin
@components begin
p = Pin()
n = Pin()
Expand All @@ -51,7 +51,7 @@ end
end
end

@model Ground begin
@mtkmodel Ground begin
@components begin
g = Pin()
end
Expand All @@ -64,7 +64,7 @@ end
end

resistor_log = "$(@__DIR__)/logo/resistor.svg"
@model Resistor begin
@mtkmodel Resistor begin
@extend v, i = oneport = OnePort()
@parameters begin
R
Expand All @@ -90,7 +90,7 @@ l15 0" stroke="black" stroke-width="1" stroke-linejoin="bevel" fill="none"></pat
end
end

@model Capacitor begin
@mtkmodel Capacitor begin
@extend v, i = oneport = OnePort()
@parameters begin
C
Expand All @@ -101,7 +101,7 @@ end
end
end

@model Voltage begin
@mtkmodel Voltage begin
@extend v, i = oneport = OnePort()
@components begin
V = RealInput()
Expand All @@ -111,7 +111,7 @@ end
end
end

@model RC begin
@mtkmodel RC begin
@components begin
resistor = Resistor(; R)
capacitor = Capacitor(; C = 10)
Expand Down Expand Up @@ -145,7 +145,7 @@ end

@test length(equations(structural_simplify(rc))) == 1

@model MockModel begin
@mtkmodel MockModel begin
@parameters begin
a
b(t)
Expand Down

0 comments on commit 9869b2b

Please sign in to comment.