Skip to content

Connector name edits for Power and Modulo #359

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 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 12 additions & 14 deletions src/Blocks/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,18 @@ Output the exponential with base as the first input and exponent as second input

# Connectors:

- `input1`
- `input2`
- `base`
- `exponent`
- `output`
"""
@mtkmodel Power begin
@components begin
input1 = RealInput()
input2 = RealInput() # denominator can not be zero
base = RealInput()
exponent = RealInput()
output = RealOutput()
end
@equations begin
output.u ~ input1.u ^ input2.u
output.u ~ base.u ^ exponent.u
end
end

Expand All @@ -237,18 +237,18 @@ Output the remainder when the first input is divided by second input.

# Connectors:

- `input1`
- `input2`
- `output`
- `dividend`
- `divisor`
- `remainder`
"""
@mtkmodel Modulo begin
@components begin
input1 = RealInput()
input2 = RealInput(guess = 1.0) # denominator can not be zero
output = RealOutput()
dividend = RealInput()
divisor = RealInput(guess = 1.0) # denominator can not be zero
remainder = RealOutput()
end
@equations begin
output.u ~ mod(input1.u, input2.u)
remainder.u ~ mod(dividend.u, divisor.u)
end
end

Expand All @@ -272,7 +272,6 @@ Output the product of -1 and the input.
end
end

## Rounding functions add after the symbolic functions are registered
"""
Floor(; name)

Expand Down Expand Up @@ -313,7 +312,6 @@ Output the ceiling rounding of the input.
end
end


"""
StaticNonLinearity(func; name)

Expand Down
10 changes: 5 additions & 5 deletions test/Blocks/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ end
@named int = Integrator(; k = 1)
@named model = ODESystem(
[
connect(c1.output, pow.input1),
connect(c2.output, pow.input2),
connect(c1.output, pow.base),
connect(c2.output, pow.exponent),
connect(pow.output, int.input)
],
t,
Expand All @@ -184,8 +184,8 @@ end
@named modl = Modulo(;)
@named model = ODESystem(
[
connect(c1.output, modl.input1),
connect(c2.output, modl.input2)
connect(c1.output, modl.dividend),
connect(c2.output, modl.divisor)
],
t,
systems = [modl, c1, c2])
Expand All @@ -194,7 +194,7 @@ end
sol = solve(prob, Rodas4())
@test isequal(unbound_inputs(sys), [])
@test sol.retcode == Success
@test sol[modl.output.u] ≈ mod.(2 * sol.t,1)
@test sol[modl.remainder.u] ≈ mod.(2 * sol.t,1)
end

@testset "UnaryMinus" begin
Expand Down
Loading