Skip to content

Commit 84e1c2c

Browse files
committed
add modulo block to math.jl
1 parent 7197b13 commit 84e1c2c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Blocks/math.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,28 @@ Output first input divided by second input.
208208
end
209209
end
210210

211+
"""
212+
Modulo(; name)
213+
214+
Output the remainder when the first input is divided by second input.
215+
216+
# Connectors:
217+
218+
- `input1`
219+
- `input2`
220+
- `output`
221+
"""
222+
@mtkmodel Modulo begin
223+
@components begin
224+
input1 = RealInput()
225+
input2 = RealInput(guess = 1.0) # denominator can not be zero
226+
output = RealOutput()
227+
end
228+
@equations begin
229+
output.u ~ input1.u % input2.u
230+
end
231+
end
232+
211233
"""
212234
StaticNonLinearity(func; name)
213235

0 commit comments

Comments
 (0)