---
url: /dyad/dev/stdlib/BlockComponents/components/Sources.SineVariableFrequencyAndAmplitude.md
description: >-
  Dyad Sources.SineVariableFrequencyAndAmplitude docs.  Sine voltage source with
  adjustable frequency and amplitude through external signals.
---

# `Sources.SineVariableFrequencyAndAmplitude` {#Sources.SineVariableFrequencyAndAmplitude}

Sine voltage source with adjustable frequency and amplitude through external signals.

Generates a sine wave whose amplitude and frequency can be controlled dynamically through input connections. The component integrates the input frequency to compute the phase angle, then uses this phase to produce a sine wave output signal. The output formula is:

$$y = offset + amplitude\*sin(phi)$$

where phi evolves according to `der(phi) = 2*π*frequency`. This allows for creating time-varying oscillating signals with controllable parameters.

```
amplitude
↓
+-----+
frequency --→ |     | --→ y
+-----+
```

## Usage {#Usage}

`BlockComponents.Sources.SineVariableFrequencyAndAmplitude(phi0=0, offset=0)`

## Parameters: {#Parameters:}

|     Name |                    Description | Units | Default value |
| --------:| ------------------------------:| -----:| -------------:|
|   `phi0` | Initial phase of the sine wave |     – |             0 |
| `offset` |        Offset of the sine wave |     – |             0 |

## Connectors {#Connectors}

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

* `frequency` - 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 |
| -----:| ----------------------:| -----:|
| `phi` | Phase of the sine wave |   rad |

## Behavior {#Behavior}

$$ \begin{align}
\frac{\mathrm{d}\mathtt{phi}\left( t \right)}{\mathrm{d}t} &= 6.2832 ~ \mathtt{frequency}\left( t \right) \\
y\left( t \right) &= \mathtt{offset} + \mathtt{amplitude}\left( t \right) ~ \sin\left( \mathtt{phi}\left( t \right) \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Sine voltage source with adjustable frequency and amplitude through external signals.

Generates a sine wave whose amplitude and frequency can be controlled dynamically through
input connections. The component integrates the input frequency to compute the phase angle,
then uses this phase to produce a sine wave output signal. The output formula is:

```math
y = offset + amplitude*sin(phi)
```
where phi evolves according to `der(phi) = 2*π*frequency`. This allows for creating time-varying
oscillating signals with controllable parameters.

```
amplitude
↓
+-----+
frequency --→ |     | --→ y
+-----+
```
"""
component SineVariableFrequencyAndAmplitude
  "Input for controlling the amplitude of the sine wave"
  amplitude = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0}
      }
    }
  }
  "Input for controlling the frequency of the sine wave"
  frequency = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0}
      }
    }
  }
  "Output representing the resulting sine wave signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Initial phase of the sine wave"
  parameter phi0::Real = 0
  "Offset of the sine wave"
  parameter offset::Real = 0
  "Phase of the sine wave"
  variable phi::Angle
relations
  initial phi = phi0
  der(phi) = 2 * π * frequency
  y = offset + amplitude * sin(phi)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/SineVariableFrequencyAndAmplitude.svg"}
  }
}
end
````

````dyad
"""
Sine voltage source with adjustable frequency and amplitude through external signals.

Generates a sine wave whose amplitude and frequency can be controlled dynamically through
input connections. The component integrates the input frequency to compute the phase angle,
then uses this phase to produce a sine wave output signal. The output formula is:

```math
y = offset + amplitude*sin(phi)
```
where phi evolves according to `der(phi) = 2*π*frequency`. This allows for creating time-varying
oscillating signals with controllable parameters.

```
amplitude
↓
+-----+
frequency --→ |     | --→ y
+-----+
```
"""
component SineVariableFrequencyAndAmplitude
  "Input for controlling the amplitude of the sine wave"
  amplitude = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 170, "x2": 0, "y2": 270, "rot": 0}
      }
    }
  }
  "Input for controlling the frequency of the sine wave"
  frequency = RealInput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0},
        "diagram": {"iconName": "default", "x1": -100, "y1": 680, "x2": 0, "y2": 780, "rot": 0}
      }
    }
  }
  "Output representing the resulting sine wave signal"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Initial phase of the sine wave"
  parameter phi0::Real = 0
  "Offset of the sine wave"
  parameter offset::Real = 0
  "Phase of the sine wave"
  variable phi::Angle
relations
  initial phi = phi0
  der(phi) = 2 * π * frequency
  y = offset + amplitude * sin(phi)
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/SineVariableFrequencyAndAmplitude.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`VariableSinCos`](Sources.SineVariableFrequencyAndAmplitude.md)
