Skip to content

Introduction ​

What is nP? ​

nP is a JavaScript library for constructing, analyzing, and visualizing RF and microwave circuits in the browser. Its central object is an n-port: a component or connected network represented by frequency-dependent S-parameters. The same n-port can be measured, connected to other n-ports, and used as a building block in a larger circuit.

What can you build? ​

You can combine resistors, capacitors, inductors, ideal connections, transmission lines, microstrip models, amplifiers, and other components. nP can report S-parameters, noise, and intermodulation results, and it can propagate digital or analog waveforms through a circuit. nP.schematic() draws the connected network; charts, tables, and Smith charts display its calculated results.

How nP works ​

The common RF analysis path is:

  1. Choose the analysis frequencies.
  2. Create n-port components.
  3. Connect them with nP.nodal() or nP.cascade().
  4. Select results with .out(...).
  5. Draw the network with nP.schematic(network).
  6. Display the output with a chart or table.

Components capture their frequency settings when they are created, so components in one network need matching frequency rows.

Two starting paths ​

For an RF frequency sweep, set nP.global.fList before creating components. Then connect the components and inspect results such as s11dB or s21dB.

For a sampled signal through a circuit, set nP.global.tList to one time per waveform sample, then create a transmitter with nP.mod(). It checks the time grid and establishes the signal's frequency grid. For a VNA frequency sweep, give nP.mod({mode: 'VNA-frequency', fList: frequencies}) the analysis frequencies; this mode needs no time grid. In either case, create the components afterward, attach the signal to the connected circuit, and read it with nP.demod(). nP.PN() can supply a clocked bit sequence, and nP.bitErrorRate() compares transmitted and recovered bits over repeated receptions.

A small example ​

This series resistor and inductor form a two-port circuit. Its output table has a frequency column followed by the selected S-parameters.

js
nP.global.fList = nP.global.fGen(0.1e9, 6e9, 101);

var r1 = nP.R(25);
var l1 = nP.L(2e-9);
var circuit = nP.nodal(
    [r1, 1, 2],
    [l1, 2, 3],
    ['out', 1, 3]
);

var response = circuit.out('s11dB', 's21dB');
nP.schematic(circuit);
nP.lineChart({inputTable: [response], title: 'Series R-L response'});

The schematic draws the resistor and inductor with the node numbers from nodal(). The chart shows their calculated response. Both displays come from the same circuit object. See Schematics for drawing controls and layout guidance for larger networks.

Where to go next ​