---
url: /dyad/stable/stdlib/ElectricalComponents/components/Analog.Basic.Resistor.md
description: >-
  Dyad Analog.Basic.Resistor docs.  Linear electrical resistor following Ohm's
  Law.
---

# `Analog.Basic.Resistor` {#Analog.Basic.Resistor}

Linear electrical resistor following Ohm's Law.

This component represents an ideal linear resistor. The relationship between the voltage (`v`) across its terminals and the current (`i`) flowing through it is defined by Ohm's Law:

$$v = i \R$$

The resistance `R` is a configurable parameter. This component is intended to be used in electrical circuits where a constant resistance behavior is required.

This component extends from [`ElectricalComponents.Analog.Interfaces.OnePort`](../types/Analog.Interfaces.OnePort.md)

## Usage {#Usage}

`ElectricalComponents.Analog.Basic.Resistor(R)`

## Parameters: {#Parameters:}

| Name |                                       Description | Units | Default value |
| ----:| -------------------------------------------------:| -----:| -------------:|
|  `R` | The electrical resistance value of the component. |     Ω |               |

## Connectors {#Connectors}

* `p` - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. ([`Pin`](/stdlib/Dyad/connectors/Pin#Pin))

* `n` - This connector represents an electrical pin with voltage and current as the potential and flow variables, respectively. ([`Pin`](/stdlib/Dyad/connectors/Pin#Pin))

## Variables {#Variables}

| Name |                                                  Description | Units |
| ----:| ------------------------------------------------------------:| -----:|
|  `v` |      Voltage across the component (between pin p and pin n). |     V |
|  `i` | Current flowing through the component (from pin p to pin n). |     A |

## Behavior {#Behavior}

$$ \begin{align}
v\left( t \right) &=  - \mathtt{n.v}\left( t \right) + \mathtt{p.v}\left( t \right) \\
i\left( t \right) &= \mathtt{p.i}\left( t \right) \\
\mathtt{n.i}\left( t \right) + \mathtt{p.i}\left( t \right) &= 0 \\
v\left( t \right) &= R ~ i\left( t \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Linear electrical resistor following Ohm's Law.

This component represents an ideal linear resistor. The relationship between the
voltage (`v`) across its terminals and the current (`i`) flowing through it is
defined by Ohm's Law:
```math
v = i \R
```
The resistance `R` is a configurable parameter. This component is intended to be
used in electrical circuits where a constant resistance behavior is required.
"""
component Resistor
  extends ElectricalComponents.Analog.Interfaces.OnePort
  "The electrical resistance value of the component."
  parameter R::Resistance
relations
  "Ohm's Law"
  v = i * R
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 805, "rot": 0},
      {"label": "R=$(R)Ω", "x": 500, "y": 150, "rot": 0}
    ],
    "icons": {"default": "dyad://ElectricalComponents/Resistor.svg"}
  }
}
end
````

````dyad
"""
Linear electrical resistor following Ohm's Law.

This component represents an ideal linear resistor. The relationship between the
voltage (`v`) across its terminals and the current (`i`) flowing through it is
defined by Ohm's Law:
```math
v = i \R
```
The resistance `R` is a configurable parameter. This component is intended to be
used in electrical circuits where a constant resistance behavior is required.
"""
component Resistor
  "Positive electrical pin."
  p = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 450, "x2": 50, "y2": 550}}
    }
  }
  "Negative electrical pin."
  n = Pin() {
    "Dyad": {
      "placement": {"icon": {"iconName": "neg", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}}
    }
  }
  "Voltage across the component (between pin p and pin n)."
  variable v::Voltage
  "Current flowing through the component (from pin p to pin n)."
  variable i::Current
  "The electrical resistance value of the component."
  parameter R::Resistance
relations
  v = p.v - n.v
  i = p.i
  p.i + n.i = 0
  "Ohm's Law"
  v = i * R
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 805, "rot": 0},
      {"label": "R=$(R)Ω", "x": 500, "y": 150, "rot": 0}
    ],
    "icons": {"default": "dyad://ElectricalComponents/Resistor.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`AmplifierWithOpAmpDetailed`](Analog.Basic.Resistor.md)

  * [`CCC`](Analog.Basic.Resistor.md)

  * [`CCV`](Analog.Basic.Resistor.md)

  * [`DiodeBreakdown`](Analog.Basic.Resistor.md)

  * [`DiodeForward`](Analog.Basic.Resistor.md)

  * [`DiodeHeating`](Analog.Basic.Resistor.md)

  * [`DiodeTemperature`](Analog.Basic.Resistor.md)

  * [`DiodeTest`](Analog.Basic.Resistor.md)

  * [`MTransformer`](Analog.Basic.Resistor.md)

  * [`MultiSensor`](Analog.Basic.Resistor.md)

  * [`NMOSOperatingPoint`](Analog.Basic.Resistor.md)

  * [`NMOSTest`](Analog.Basic.Resistor.md)

  * [`NPNOperatingPoint`](Analog.Basic.Resistor.md)

  * [`NPNSwitching`](Analog.Basic.Resistor.md)

  * [`NPNTest`](Analog.Basic.Resistor.md)

  * [`PMOSOperatingPoint`](Analog.Basic.Resistor.md)

  * [`PMOSTest`](Analog.Basic.Resistor.md)

  * [`PNPOperatingPoint`](Analog.Basic.Resistor.md)

  * [`PNPTest`](Analog.Basic.Resistor.md)

  * [`Potentiometer`](Analog.Basic.Resistor.md)

  * [`Sensors`](Analog.Basic.Resistor.md)

  * [`VCC`](Analog.Basic.Resistor.md)

  * [`VCV`](Analog.Basic.Resistor.md)

  * [`VariableCapacitor`](Analog.Basic.Resistor.md)

  * [`VariableConductor`](Analog.Basic.Resistor.md)

  * [`VariableInductor`](Analog.Basic.Resistor.md)
