# Use a manufacturer's SPICE MOSFET or diode model in Voltecx

To use a manufacturer's SPICE model in Voltecx, list the models in the file with `spice.listModels`, place the one you want with `spice.placeModel`, and wire its pins. Voltecx reads the `.lib`, `.mod` or `.sub` file from your disk, builds the model as a subsystem in your circuit, and returns a warning for every parameter it does not model. Most vendor power-MOSFET models are `VDMOS` cards or `.subckt` macro-models, and both are supported; encrypted models are refused.

## What kinds of model files work?

| In the file | Placed as | Pins |
|---|---|---|
| `.subckt` (top level) | a subsystem with the subcircuit's elements | in the subcircuit's order |
| `.model … VDMOS` | an `nmos` or `pmos` at `level: vdmos`, with its capacitances and body diode | `d g s` |
| `.model … NMOS` / `PMOS` | level 1, or level 3 with `LEVEL=3`; other levels (BSIM among them) as level 1 with a warning | `d g s` |
| `.model … D` | the exponential diode when the card gives stored charge (`CJO` or `TT`), else a piecewise-linear diode | `a k` |
| `.model … NPN` / `PNP` | a bipolar transistor | `c b e` |

Inside a subcircuit, R, L, C, coupled inductors, independent sources, linear and common behavioural E/G sources, switches, B sources and nested subcircuits are read the way `file.import` reads a SPICE netlist. `.include` and `.lib` lines inside the model are followed relative to the file.

## Step by step

### 1. List the models in the file

```sh
powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \
  --cmd spice.listModels --params '{"path": "models/vendor.lib"}'
```

The reply lists every top-level `.subckt` and every placeable `.model` card, with its kind and pins.

### 2. See what the import keeps

```sh
powercraft-cli run --cmd spice.importReport --params '{"path": "models/vendor.lib", "name": "MYFET"}'
```

Before you place anything, the report lists each element and each `.model` parameter as mapped, approximated, dropped or unused (noise and information fields, which do nothing in SPICE either), with its line in the file and the reason. It ends with one line of fidelity, such as `MYFET: kept as written 5 of 6 elements and 30 of 34 model parameters; dropped: J1 TV.RTHJC`. In the app, the **Import vendor SPICE model** window (Library › Import Vendor SPICE Models) shows the same report under the model list, with the items that are not mapped as written; click another model's name to see its own.

### 3. Place the model

```sh
powercraft-cli run --cmd file.openExample --params '{"name": "buck"}' \
  --cmd spice.placeModel --params '{"path": "models/vendor.lib", "name": "MYFET", "instance": "Q2"}'
```

`name` is optional when the file has one model. The instance is placed with its pins unconnected and named as the model names them; wire them with `circuit.connect`. One undo removes the placement. From the AI assistant or the command line the same two commands run by id.

### 4. Read the warnings

Every element or parameter that is not mapped exactly is returned in `warnings`; nothing is dropped silently. Typical ones:

- **VDMOS**: quasi-saturation (`RQ`, `VQ`), the subthreshold shift `SUBSHIFT` and breakdown (`BV`, `IBV`, `NBV`) are modelled, and a part at another temperature than `TNOM` is moved there. The temperature coefficients `TEXP1` and `TKSUBTHRES1`/`2` and self-heating are not modelled.
- **Diodes**: breakdown, `IKF`, `ISR`/`NR`, temperature dependence and the area factor are not modelled.
- **Levels 2 and 3**: sheet resistance (`RSH`) and the body effect of a body off the source are not modelled. The instance's `AD`, `PD` and `AS` size the body junction from `CJ`, `CJSW` and `JS`, as in SPICE.

A model evaluated at `TNOM` (usually 27 °C) does not show the rise of $R_{DS(on)}$ with temperature. For loss and thermal work at a hot junction, scale the conduction loss by the data sheet's normalised $R_{DS(on)}$ curve at your junction temperature.

### 5. Check it against the data sheet

Before trusting a model in a design, run a double-pulse test at your voltage and current and compare the turn-on and turn-off waveforms, and the switching energies, with the data sheet's test conditions. Voltecx's own check of a VDMOS card against ngspice in a 400 V, 20 A double pulse is described in the manual.

## What does not work?

- **Encrypted models** (PSpice/Cadence encrypted blocks, LTspice-encrypted files) are refused with a message saying so: they cannot be read, so they cannot be simulated.
- **The vendor file is not shipped.** Voltecx keeps only the part it builds from the file, in your circuit file, and never copies or redistributes the vendor's file. Check the model's licence terms before sharing a circuit that contains it.

## When should I use a SPICE model instead of a library device?

- **Use the SPICE model** to study switching waveforms, ringing, dv/dt and gate behaviour with the capacitances the vendor fitted.
- **Use a data-sheet library device** for fast loss, efficiency and thermal estimates across many operating points; the library parts cite the data sheet each value comes from. See [models and parts](https://voltecx-web.nguyenvanqui291.workers.dev/features/models-and-parts).

[File compatibility](https://voltecx-web.nguyenvanqui291.workers.dev/features/file-compatibility) covers whole netlists and schematics from other tools, and the [design tools overview](https://voltecx-web.nguyenvanqui291.workers.dev/features/design-tools) shows where part choice sits in the flow.

## Frequently asked questions

### Can Voltecx read LTspice or PSpice MOSFET models?

It reads unencrypted SPICE `.model` and `.subckt` text in the common ngspice and LTspice syntax, including `VDMOS` cards and behavioural B sources. Encrypted models are refused.

### Why does my imported MOSFET model warn about temperature?

The model is evaluated at its nominal temperature (`TNOM`); temperature coefficients and self-heating are not modelled. Warnings name each parameter the card gives that is not applied.

### Does Voltecx ship vendor SPICE models?

No. You keep the vendor file; Voltecx stores only the part it built in your circuit file. The built-in library uses parts digitised from data sheets, each with its source.
