Skip to content

Adds input/output meta data #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Blocks/utils.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@connector function RealInput(;name, nin=1, u_start=nin > 1 ? zeros(nin) : 0.0)
if nin == 1
@variables u(t) = u_start
@variables u(t) = u_start [input=true]
else
@variables u[1:nin](t) = u_start
@variables u[1:nin](t) = u_start [input=true]
u = collect(u)
end
ODESystem(Equation[], t, [u...], []; name=name)
Expand All @@ -22,9 +22,9 @@ Connector with one input signal of type Real.

@connector function RealOutput(;name, nout=1, u_start=nout > 1 ? zeros(nout) : 0.0)
if nout == 1
@variables u(t) = u_start
@variables u(t) = u_start [output=true]
else
@variables u[1:nout](t) = u_start
@variables u[1:nout](t) = u_start [output=true]
u = collect(u)
end
ODESystem(Equation[], t, [u...], []; name=name)
Expand Down Expand Up @@ -88,4 +88,4 @@ function MIMO(;name, nin=1, nout=1, u_start=zeros(nin), y_start=zeros(nout))
[y[i] ~ output.u[i] for i in 1:nout]...,
]
return ODESystem(eqs, t, vcat(u..., y...), []; name=name, systems=[input, output])
end
end
6 changes: 3 additions & 3 deletions src/Thermal/HeatTransfer/ideal_components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function HeatCapacitor(; name, C, T_start=273.15 + 20)
@parameters C=C
sts = @variables begin
T(t)=T_start
der_T(t)
der_T(t)=0.0
end

D = Differential(t)
Expand Down Expand Up @@ -81,7 +81,7 @@ function ConvectiveConductor(; name, G)
@named solid = HeatPort()
@named fluid = HeatPort()
@parameters G=G
sts = @variables Q_flow(t) dT(t)
sts = @variables Q_flow(t)=0.0 dT(t)=0.0
eqs = [
dT ~ solid.T - fluid.T
solid.Q_flow ~ Q_flow
Expand All @@ -107,7 +107,7 @@ function ConvectiveResistor(; name, R)
@named solidport = HeatPort()
@named fluidport = HeatPort()
@parameters R=R
sts = @variables Q_flow(t) dT(t)
sts = @variables Q_flow(t)=0.0 dT(t)=0.0
eqs = [
dT ~ solidport.T - fluidport.T
solidport.Q_flow ~ Q_flow
Expand Down
2 changes: 1 addition & 1 deletion test/Blocks/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ end

@testset "Math" begin
for (block, func) in [(Abs, abs), (Sign, sign), (Sin, sin), (Cos, cos), (Tan, tan), (Asin, asin), (Acos, acos), (Atan, atan), (Sinh, sinh), (Cosh, cosh), (Tanh, tanh), (Exp, exp)]
@named source = Sine(frequency=1)
@named source = Sine(frequency=1, amplitude=0.5)
@named b = block()
@named int = Integrator()
@named model = ODESystem([connect(source.output, b.input), connect(b.output, int.input)], t, systems=[int, b, source])
Expand Down