Skip to content
LIBRARY
Math.Tests.Log10.md

Math.Tests.Log10

Computes the base-10 logarithm of constant and time-varying inputs.

Connects a constant source with value 100 to a Log10 block and verifies that log10(100) = 2. A second Log10 block is driven by a sine wave (offset 5.5, amplitude 4.5) that stays strictly positive (1..10) as required by the logarithm domain while varying over time.

Usage

BlockComponents.Math.Tests.Log10()

Behavior

Source

dyad
"""
Computes the base-10 logarithm of constant and time-varying inputs.

Connects a constant source with value 100 to a Log10 block and verifies that
log10(100) = 2. A second Log10 block is driven by a sine wave (offset 5.5,
amplitude 4.5) that stays strictly positive (1..10) as required by the
logarithm domain while varying over time.
"""
test component Log10
  "Constant source providing the input value"
  c1 = BlockComponents.Sources.Constant(k = 100) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Sine source kept strictly positive for the log domain"
  sine = BlockComponents.Sources.Sine(amplitude = 4.5, frequency = 1, offset = 5.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  "Log10 block under test"
  log10_block = BlockComponents.Math.Log10() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Second Log10 block driven by the sine source"
  log10_block_2 = BlockComponents.Math.Log10() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(c1.y, log10_block.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(sine.y, log10_block_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "expect": {"signals": ["log10_block.y", "log10_block_2.y", "sine.y"]}
      }
    }
  }
}
end
Flattened Source
dyad
"""
Computes the base-10 logarithm of constant and time-varying inputs.

Connects a constant source with value 100 to a Log10 block and verifies that
log10(100) = 2. A second Log10 block is driven by a sine wave (offset 5.5,
amplitude 4.5) that stays strictly positive (1..10) as required by the
logarithm domain while varying over time.
"""
test component Log10
  "Constant source providing the input value"
  c1 = BlockComponents.Sources.Constant(k = 100) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Sine source kept strictly positive for the log domain"
  sine = BlockComponents.Sources.Sine(amplitude = 4.5, frequency = 1, offset = 5.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  "Log10 block under test"
  log10_block = BlockComponents.Math.Log10() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 20, "x2": 260, "y2": 120, "rot": 0}
      },
      "tags": []
    }
  }
  "Second Log10 block driven by the sine source"
  log10_block_2 = BlockComponents.Math.Log10() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 140, "x2": 260, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(c1.y, log10_block.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(sine.y, log10_block_2.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 1,
        "expect": {"signals": ["log10_block.y", "log10_block_2.y", "sine.y"]}
      }
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt