# 變壓器 (`transformer`)

> 匝數比為 n 的變壓器，可選擇加入磁化電感、漏感、繞組電阻、鐵損與飽和。

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

[元件參考](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/) · [English](https://voltecx-web.nguyenvanqui291.workers.dev/docs/reference/magnetics/transformer/)

**分類:** 磁性元件 · **種類:** `{"kind":"transformer"}`

## 何時使用

用於隔離與電壓轉換。選用參數都不設定時是理想元件；設定 llk1、rw1 等參數後，可以看到漏感造成的突波、銅損與磁化電流。

## 接腳

| 接腳 | 訊號域 | 意義 |
|---|---|---|
| `p1` | 電氣 | 一次側打點端；正電流由此流入 |
| `n1` | 電氣 | 一次側的另一端 |
| `p2` | 電氣 | 二次側打點端 |
| `n2` | 電氣 | 二次側的另一端 |

## 常用參數

- `n`: Turns ratio, first side to second side (預設值: 1)
- `lm`: Inductance that magnetizes the core (預設值: 選填（預設關閉）)

## 參數

| 鍵 | 單位 | 預設值 | 典型範圍 | 說明 |
|---|---|---|---|---|
| `n` | — | 1 |  | Turns ratio, first side to second side |
| `lm` | H | 選填（預設關閉） |  | Inductance that magnetizes the core |
| `im0` | A | 0 |  | Magnetizing current at the start, seen from the first side; needs lm or a core |
| `llk1` | H | 0 | 1n – 1m H | Leakage inductance in series with the first winding |
| `llk2` | H | 0 | 1n – 1m H | Leakage inductance in series with the second winding |
| `rw1` | Ω | 0 | 100u – 1 Ω | Wire resistance of the first winding |
| `rw2` | Ω | 0 | 100u – 1 Ω | Wire resistance of the second winding |
| `rcore` | Ω | 選填（預設關閉） | 100 – 10meg Ω | Resistance across the first winding that models core loss |
| `isat` | A | 選填（預設關閉） | 10m – 200 A | Magnetizing current where the core saturates; needs lm |
| `lmsat` | H | 選填（預設關閉） | 1n – 10 H | Magnetizing inductance once the core is saturated; a fifth of lm when unset |
| `core` | — | 選填（預設關閉） |  | Core from the catalogue; it sets the inductance curve and the core loss |
| `material` | — | 選填（預設關閉） |  | Core material; needed when core names a shape |
| `turns` | — | 選填（預設關閉） |  | Turns of the first winding |
| `gap` | m | 選填（預設關閉） |  | Air gap in the core; unset uses the catalogue core's gap |
| `fsw` | Hz | 選填（預設關閉） |  | Switching frequency; core and winding losses are worked out once per period |
| `coreTemp` | °C | 25 |  | Core and winding temperature |
| `coreAe` | m² | 選填（預設關閉） |  | Effective area of a core you describe yourself; use with coreLe instead of core |
| `coreLe` | m | 選填（預設關閉） |  | Magnetic path length of a core you describe yourself; use with coreAe |
| `coreVe` | m³ | 選填（預設關閉） |  | Volume of that core for its core loss; coreAe times coreLe when unset |
| `bhCurve` | — | 選填（預設關閉） |  | B-H curve of the core; pairs H:B in A/m and T, such as 0:0, 50:0.3, 200:0.45; replaces the material's curve |
| `psiCurve` | — | 選填（預設關閉） |  | Flux linkage of the winding against its current from a field solve; pairs i:λ in A and Wb, such as 0:0, 1:2e-3, 4:5e-3 (odd about zero current), or from a negative current through 0 for a magnet-biased winding, such as -4:-1e-3, 0:2e-3, 4:4e-3; replaces the core's curve |
| `steinmetzK` | W/m³ | 選填（預設關閉） |  | Steinmetz k of the core loss k·f^α·B^β, with f in Hz and B the peak flux density in T |
| `steinmetzAlpha` | — | 選填（預設關閉） |  | Steinmetz α, the frequency exponent of the core loss |
| `steinmetzBeta` | — | 選填（預設關閉） |  | Steinmetz β, the flux-density exponent of the core loss |
| `magneticsDesign` | — | 選填（預設關閉） |  | Saved design from magnetics.design; the separate core parameters win over it |
| `surface` | m² | 選填（預設關閉） |  | Outside surface of the wound part to the air; design.thermal gives its temperature rise from it and the loss |
| `coupledCurve` | — | 選填（預設關閉） |  | Incremental inductances of the two windings against the core's magnetizing current from a field solve; rows i:L11:M:L22 in A and H from 0 A, such as 0:1e-3:4.8e-4:2.5e-4, 0.4:2e-4:8e-5:5e-5; the whole magnetic model in place of n, lm and the core, with leakage, winding resistance and rcore still added |

_參數說明在兩種語言中都是英文。_

**適用於:** 隔離 · 隔離式 DC-DC 級 · 閘極驅動變壓器

**不適用於:** 三相變壓器 → [`transformer3`](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/magnetics/transformer3/) · 電流感測 → [`currentTransformer`](https://voltecx-web.nguyenvanqui291.workers.dev/zh/docs/reference/ic/currentTransformer/)

## 公式

| 公式 | 方程式 | 出處 |
|---|---|---|
| 二次側電壓 | v2 = v1 / n | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (the ideal transformer) |
| 反射到一次側的負載 | zin = n²·rl | Hayt, Kemmerly & Durbin, Engineering Circuit Analysis, 8th ed. (2012), ch. 13 (impedance matching) |
| 激磁電流漣波 | Δim = v1·ton / lm | Erickson & Maksimović, Fundamentals of Power Electronics, 3rd ed. (2020), §6.3 (transformer isolation, magnetizing inductance) |

## 快速驗算

輸入:

- `n`: 匝數比 N1/N2 = 4 —, `n`
- `v1`: 一次側電壓 = 48 V
- `rl`: 二次側負載 = 2 Ω
- `lm`: 激磁電感 = 500u H, `lm`
- `ton`: 施加電壓的時間 = 5u s

輸出:

- `v2`: 二次側電壓 = `v1/n` V
- `zin`: 反射負載 = `n^2*rl` Ω
- `dim`: 激磁電流漣波 = `v1*ton/lm` A

## 模型邏輯

- 理想繞組是一個額外的支路電流，強制 v1 = n·v2 與 i2 = −n·i1，因此單獨使用時它也能傳遞直流。
- rw1 與 llk1 串聯在一次側，rw2 與 llk2 串聯在二次側；為零時不加入，漏感初始電流為零。
- 設定 lm 時，跨在理想繞組 1 上的電感從 im0 開始，rcore 也跨在其上；未設定 lm 時完全沒有激磁電流。
- isat 讓 lm 依上一個接受步的電流成為兩段斜率轉折（超過時為 lmsat 或 0.2·lm）；型錄磁芯會以其曲線取代它。

## 模型

理想繞組遵循 v1 = n * v2，其中 n = N1 / N2；兩個電流都以流入打點端為正時，滿足 i2 = -n * i1。rw1 與 llk1 串聯在 p1 與理想繞組 1 之間，rw2 與 llk2 串聯在 p2 與理想繞組 2 之間，所以每一側的漏感與電阻都留在自己那一側。設定 lm 時，理想繞組 1 兩端會並聯該值的電感，承載磁化電流；rcore 也並聯在它兩端，用來表示鐵損。設定 isat 後，磁化電流大小低於 isat 時電感為 lm，超過後為 lmsat（lmsat 未設定時為 0.2 * lm），與電感元件相同的兩段式折點。所有選用參數都不設定時是理想元件，模擬結果與以前完全相同。

## 常見錯誤

- n 是 N1 / N2，所以 10 比 1 的降壓用 n = 10，填 0.1 則變成升壓。請對照額定的一次側與二次側電壓檢查比值。
- 二次側除非有東西接地，否則沒有參考點。一次側若有直流成分，lm 的電流會無限增加，除非設定 isat；即使設定了，lmsat 也只是讓它增加得慢一些。
- 每次一次側電流被切斷，漏感都會儲存大約 0.5 * llk1 * i^2 的能量。設定 llk1 卻沒有在開關兩端加箝位或緩衝電路的返馳式轉換器，會出現非常高的關斷突波。isat 需要 lm，因為它讓磁化電感飽和。

Problems 規則: `island.floating`, `param.out_of_range`

## 規格書與來源

n 取額定一次側電壓除以額定二次側電壓，或匝數比。lm 取二次側開路時，在一次側量到的電感。llk1 取二次側短路時在一次側量到的漏感；不清楚兩側如何分配時，全部放在一次側，llk2 設為零。rw1 與 rw2 取各繞組的直流電阻，isat 取電感下降到所列百分比時的磁化電流，rcore 是單一頻率的鐵損估計值。

## 範例

以指令 `file.openExample` 開啟範例，名稱為 `demo:transformer`.

---
由 `cargo xtask reference` 依使用說明文字與參數規格產生，請勿手動編輯。
