# DC Voltage Source (`dcVoltageSource`)

> Holds a fixed voltage between its two terminals.

![dcVoltageSource](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/img/dcVoltageSource.svg)

[Component reference](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/) · [繁體中文](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/sources/dcVoltageSource/)

**Group:** Sources · **Kind:** `{"kind":"dcVoltageSource"}`

## When to use it

Use it for batteries, supply rails and DC buses. Use Sine Voltage Source for AC and Pulse Voltage Source for steps.

## Pins

| Pin | Domain | Meaning |
|---|---|---|
| `p` | electrical | Positive end |
| `n` | electrical | Negative end, the reference side |

## Common parameters

- `v`: Output voltage of the source (Default: required)
- `rs`: Resistance inside the source (Default: 0)

## Parameters

| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
| `v` | V | required |  | Output voltage of the source |
| `rs` | Ω | 0 | 1m – 10 Ω | Resistance inside the source |
| `pwl` | — | optional (off) |  | Time and value pairs joined by straight lines; replaces the fixed value |
| `repeat` | — | 0 |  | Set to 1 to repeat the pwl pattern over and over |

_Parameter descriptions are in English in both languages._

**Use for:** Supply rails · DC buses · Converter inputs

**Not for:** Batteries with state of charge → [`battery`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/battery/) · Supply steps and test pulses → [`pulseVoltageSource`](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/sources/pulseVoltageSource/)

## Formulas

| Formula | Equation | Source |
|---|---|---|
| Load current | I = v/(rs + rl) | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), §5.2 |
| Terminal voltage | Vt = v − I·rs | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), §5.2 |
| Load power | P = Vt·I | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), Ch. 2 |

## Quick check

Inputs:

- `v`: Source voltage = 12 V, `v`
- `rs`: Internal resistance = 0 Ω, `rs`
- `rl`: Load resistance = 6 Ω

Outputs:

- `current`: Load current = `v/(rs+rl)` A
- `vterm`: Terminal voltage = `v - current*rs` V
- `pload`: Load power = `vterm*current` W

## Model logic

- The part stamps an ideal voltage branch v(p) - v(n) = v whose current is a circuit unknown, so it sources or sinks any current with no limit.
- With rs above 0 a resistor rs is placed inside the part, in series on the n side; rs = 0, the default, leaves the source ideal.
- With pwl set the value follows straight lines between the points, holds the end values outside them, and repeats when repeat is 1.
- The step control lands on every pwl corner; a current limit, output capacitance, inductance and noise are not modelled.

## Model

The source forces v(p) - v(n) = v for any current, and the current through it is an unknown of the circuit. With rs set, a resistor rs sits in series inside the part, so the terminal voltage drops by rs times the load current. The part has no current limit. With pwl set to a list of times and values, the output follows straight lines between those points instead of holding v, stays at the last value after the last time, and starts over there when repeat is 1.

## Common mistakes

- Two ideal voltage sources in parallel, or in a loop with other ideal voltage sources and ammeters, leave the current undefined. Break the loop or give one source an rs.
- A circuit with no reference node has no defined voltages. Connect the negative end of the source to Ground.

Problems rules: `loop.voltage_sources`, `source.shorted`, `ground.missing`

## Datasheet and sources

v is the design voltage or the nominal battery or supply voltage. rs is the output resistance, which you can estimate as the voltage change divided by the load current change.

## Example

Open the example with the command `file.openExample` and the name `demo:dcVoltageSource`.

---
Generated by `cargo xtask reference` from the usage texts and parameter specs. Do not edit by hand.
