Skip to content
DivisionTest.md

DivisionTest

Division operation that divides a first input by a second input.

Performs a simple division operation where the output y = u1/u2, dividing the first input (u1) by the second input (u2). This component requires that the second input (denominator) is non-zero to avoid division by zero errors.

Usage

BlockComponents.DivisionTest()

Behavior

[connect(c1+y(t),division+u1(t))connect(c2+y(t),division+u2(t))c1.y(t)=c1.kc2.y(t)=c2.kdivision.y(t)=division.u1(t)division.u2(t)]

Source

dyad
# Division operation that divides a first input by a second input.
#
# Performs a simple division operation where the output y = u1/u2, dividing the first input (`u1`)
# by the second input (`u2`). This component requires that the second input (denominator) is non-zero
# to avoid division by zero errors.
test component DivisionTest
  # Constant block that outputs the value 3 (numerator)
  c1 = Constant(k = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 30, "y1": 80, "x2": 130, "y2": 180, "rot": 0}
      }
    }
  }
  # Constant block that outputs the value 2 (denominator)
  c2 = Constant(k = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 30, "y1": 270, "x2": 130, "y2": 370, "rot": 0}
      }
    }
  }
  # Division block that divides the first input (u1) by the second input (u2)
  division = Division() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 330, "y1": 170, "x2": 430, "y2": 270, "rot": 0}
      }
    }
  }
relations
  # Connects the output of constant block c1 (3) to the numerator input of the division block
  connect(division.u1, c1.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 190, "y": 190}, {"x": 190, "y": 130}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  # Connects the output of constant block c2 (2) to the denominator input of the division block
  connect(division.u2, c2.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 190, "y": 250}, {"x": 190, "y": 320}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {"tests": {"case1": {"stop": 5, "expect": {"final": {"division.y": 1.5}}}}}
}
end
Flattened Source
dyad
# Division operation that divides a first input by a second input.
#
# Performs a simple division operation where the output y = u1/u2, dividing the first input (`u1`)
# by the second input (`u2`). This component requires that the second input (denominator) is non-zero
# to avoid division by zero errors.
test component DivisionTest
  # Constant block that outputs the value 3 (numerator)
  c1 = Constant(k = 3) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 30, "y1": 80, "x2": 130, "y2": 180, "rot": 0}
      }
    }
  }
  # Constant block that outputs the value 2 (denominator)
  c2 = Constant(k = 2) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 30, "y1": 270, "x2": 130, "y2": 370, "rot": 0}
      }
    }
  }
  # Division block that divides the first input (u1) by the second input (u2)
  division = Division() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 330, "y1": 170, "x2": 430, "y2": 270, "rot": 0}
      }
    }
  }
relations
  # Connects the output of constant block c1 (3) to the numerator input of the division block
  connect(division.u1, c1.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 190, "y": 190}, {"x": 190, "y": 130}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  # Connects the output of constant block c2 (2) to the denominator input of the division block
  connect(division.u2, c2.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 190, "y": 250}, {"x": 190, "y": 320}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {"tests": {"case1": {"stop": 5, "expect": {"final": {"division.y": 1.5}}}}}
}
end


Test Cases

Test Case case1