---
url: /dyad/dev/stdlib/DiscreteComponents/components/Examples.Integrator.SimpleDiscreteIntegrator.md
description: >-
  Dyad Examples.Integrator.SimpleDiscreteIntegrator docs. 
  DiscreteComponents.Examples.Integrator.SimpleDiscreteIntegrator()
---

# `Examples.Integrator.SimpleDiscreteIntegrator` {#Examples.Integrator.SimpleDiscreteIntegrator}

## Usage {#Usage}

`DiscreteComponents.Examples.Integrator.SimpleDiscreteIntegrator()`

## Parameters: {#Parameters:}

| Name | Description | Units | Default value |
| ----:| -----------:| -----:| -------------:|
| `dt` |             |     – |           0.1 |

## Connectors {#Connectors}

* `u` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Variables {#Variables}

|          Name | Description | Units |
| -------------:| -----------:| -----:|
| `reset_value` |             |     – |

## Behavior {#Behavior}

$$ \begin{align}
\mathtt{reset_value}\left( t \right) &= NaN \\
0 &= \mathrm{connect}\left( y, unitdelay\_{+}u \right) \\
0 &= \mathrm{connect}\left( unitdelay\_{+}y, add\_{+}u1 \right) \\
0 &= \mathrm{connect}\left( add\_{+}y, y \right) \\
0 &= \mathrm{connect}\left( u, product\_{+}u1 \right) \\
0 &= \mathrm{connect}\left( sampletimeblock\_{+}y, product\_{+}u2 \right) \\
0 &= \mathrm{connect}\left( product\_{+}y, add\_{+}u2 \right) \\
\mathtt{unitdelay.y}\left( t \right) &= Shift(t, -1)\left( \mathtt{unitdelay.u}\left( t \right) \right) \\
\mathtt{add.y}\left( t \right) &= \mathtt{add.k1} ~ \mathtt{add.u1}\left( t \right) + \mathtt{add.k2} ~ \mathtt{add.u2}\left( t \right) \\
\mathtt{sampletimeblock.y}\left( t \right) &= SampleTime(ShiftIndex(InferredClock.Inferred(UUID("cdf2ee32-dfc3-4417-9291-6887a48a11b7")), 0), nothing) \\
\mathtt{product.y}\left( t \right) &= \mathtt{product.u1}\left( t \right) ~ \mathtt{product.u2}\left( t \right)
\end{align}
$$

## Source {#Source}

```dyad
component SimpleDiscreteIntegrator@[input clk]
  u = RealInput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 960, "y1": 450, "x2": 1060, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  unitdelay = DiscreteComponents.UnitDelay() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 290, "x2": 800, "y2": 390, "rot": 0}
      },
      "tags": []
    }
  }
  add = BlockComponents.Math.Add() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 790, "y1": 450, "x2": 890, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  sampletimeblock = DiscreteComponents.SampleTimeSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 430, "y1": 610, "x2": 530, "y2": 710, "rot": 0}
      },
      "tags": []
    }
  }
  product = BlockComponents.Math.Product() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 590, "y1": 490, "x2": 690, "y2": 590, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter dt::Real = 0.1
  variable reset_value::Real = NaN
relations
  """
    y@(clk) = ifelse(reset > 0.0, sample(reset_value, clk), y@(clk-1) + u(clk) * dt)
    reset_value@(clk) = ifelse(
      isnan_wrapper(sample(reset_value, clk)@(clk-1)),
      ic@(clk),
      reset_value@(clk-1)
    )
  """
  initial u@(clk-1) = 0.0
  initial reset_value@(clk-1) = 0.0
  initial y@(clk-1) = 0.0
  connect(unitdelay.u, y) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 1010, "y": 340}], "E": 2}]
    }
  }
  connect(unitdelay.y, add.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 640, "y": 340}, {"x": 640, "y": 470}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(add.y, y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(u, product.u1) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 0, "y": 510}], "E": 2}]
    }
  }
  connect(product.u2, sampletimeblock.y) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 558, "y": 570}, {"x": 558, "y": 660}], "E": 2}]
    }
  }
  connect(product.y, add.u2) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 740, "y": 540}, {"x": 740, "y": 530}], "E": 2}]
    }
  }
end
```

```dyad
component SimpleDiscreteIntegrator
  u = RealInput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  y = RealOutput@[clk]() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 960, "y1": 450, "x2": 1060, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  unitdelay = DiscreteComponents.UnitDelay() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 900, "y1": 290, "x2": 800, "y2": 390, "rot": 0}
      },
      "tags": []
    }
  }
  add = BlockComponents.Math.Add() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 790, "y1": 450, "x2": 890, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  sampletimeblock = DiscreteComponents.SampleTimeSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 430, "y1": 610, "x2": 530, "y2": 710, "rot": 0}
      },
      "tags": []
    }
  }
  product = BlockComponents.Math.Product() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 590, "y1": 490, "x2": 690, "y2": 590, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter dt::Real = 0.1
  variable reset_value::Real = NaN
relations
  """
    y@(clk) = ifelse(reset > 0.0, sample(reset_value, clk), y@(clk-1) + u(clk) * dt)
    reset_value@(clk) = ifelse(
      isnan_wrapper(sample(reset_value, clk)@(clk-1)),
      ic@(clk),
      reset_value@(clk-1)
    )
  """
  initial u@(clk-1) = 0.0
  initial reset_value@(clk-1) = 0.0
  initial y@(clk-1) = 0.0
  connect(unitdelay.u, y) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 1010, "y": 340}], "E": 2}]
    }
  }
  connect(unitdelay.y, add.u1) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 640, "y": 340}, {"x": 640, "y": 470}], "E": 2}],
      "renderStyle": "standard"
    }
  }
  connect(add.y, y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(u, product.u1) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 0, "y": 510}], "E": 2}]
    }
  }
  connect(product.u2, sampletimeblock.y) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 558, "y": 570}, {"x": 558, "y": 660}], "E": 2}]
    }
  }
  connect(product.y, add.u2) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 740, "y": 540}, {"x": 740, "y": 530}], "E": 2}]
    }
  }
metadata {}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`TestClockPropagator`](Examples.Integrator.SimpleDiscreteIntegrator.md)
