---
url: /dyad/stable/stdlib/ElectricalComponents/components/Analog.Basic.Capacitor.md
description: Dyad Analog.Basic.Capacitor docs.  Ideal electrical capacitor.
---

# `Analog.Basic.Capacitor` {#Analog.Basic.Capacitor}

Ideal electrical capacitor.

This component models a linear capacitor, a fundamental passive two-terminal electrical component used to store energy electrostatically in an electric field. The relationship between the current `i` flowing through the capacitor and the voltage `v` across its terminals is defined by the equation:

$$C der(v) = i$$

where `C` is the capacitance value and `der(v)` is the time derivative of the voltage `v`.

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

## Usage {#Usage}

`ElectricalComponents.Analog.Basic.Capacitor(C)`

## Parameters: {#Parameters:}

| Name |                        Description | Units | Default value |
| ----:| ----------------------------------:| -----:| -------------:|
|  `C` | Capacitance of the ideal capacitor |     F |               |

## 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 \\
C ~ \frac{\mathrm{d}v\left( t \right)}{\mathrm{d}t} &= i\left( t \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Ideal electrical capacitor.

This component models a linear capacitor, a fundamental passive two-terminal electrical component
used to store energy electrostatically in an electric field. The relationship between the
current `i` flowing through the capacitor and the voltage `v` across its terminals is
defined by the equation:
```math
C der(v) = i
```
where `C` is the capacitance value and `der(v)` is the time derivative of the voltage `v`.
"""
component Capacitor
  extends ElectricalComponents.Analog.Interfaces.OnePort
  "Capacitance of the ideal capacitor"
  parameter C::Capacitance
relations
  C * der(v) = i
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 845, "rot": 0},
      {"label": "C=$(C)F", "x": 500, "y": 150, "rot": 0}
    ],
    "icons": {"default": "dyad://ElectricalComponents/Capacitor.svg"}
  }
}
end
````

````dyad
"""
Ideal electrical capacitor.

This component models a linear capacitor, a fundamental passive two-terminal electrical component
used to store energy electrostatically in an electric field. The relationship between the
current `i` flowing through the capacitor and the voltage `v` across its terminals is
defined by the equation:
```math
C der(v) = i
```
where `C` is the capacitance value and `der(v)` is the time derivative of the voltage `v`.
"""
component Capacitor
  "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
  "Capacitance of the ideal capacitor"
  parameter C::Capacitance
relations
  v = p.v - n.v
  i = p.i
  p.i + n.i = 0
  C * der(v) = i
metadata {
  "Dyad": {
    "labels": [
      {"label": "$(instance)", "x": 500, "y": 845, "rot": 0},
      {"label": "C=$(C)F", "x": 500, "y": 150, "rot": 0}
    ],
    "icons": {"default": "dyad://ElectricalComponents/Capacitor.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`DiodeBreakdown`](Analog.Basic.Capacitor.md)

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

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

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

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

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

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

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

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

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

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