#import "../lib/unify.typ": qty, unit
#import "@preview/cetz:0.5.2"
#import "@preview/cetz-plot:0.1.4": plot

#figure(
  cetz.canvas({
    import cetz.draw: *

    plot.plot(
      size: (12, 6),
      x-mode: "log",
      x-label: [Frequency $f$ ($unit("Hz")$)],
      y-label: [$e_n(f)$ ($unit("nano volt per shertz")$)],
      x-min: 0.1,
      x-max: 100000,
      y-min: 0.5,
      y-max: 50,
      x-grid: "minor",
      y-grid: "minor",
      {
        // General purpose (TL072): e_white = 18 nV/sqrt(Hz), fc = 200 Hz
        plot.add(
          style: (stroke: (dash: "solid")),
          label: [TL07x],
          domain: (0.1, 100000),
          samples: 1000,
          f => 18 * calc.sqrt(1 + 200 / f),
        )
        // Low noise (OPA211): e_white = 1.1 nV/sqrt(Hz), fc = 10 Hz
        plot.add(
          style: (stroke: (dash: "dashed")),
          label: [OPA211],
          domain: (0.1, 100000),
          samples: 1000,
          f => 1.1 * calc.sqrt(1 + 10 / f),
        )
        //  Precision low noise (LT1028): e_white = 0.85 nV/sqrt(Hz), fc = 3.5 Hz
        plot.add(
          style: (stroke: (dash: "dotted")),
          label: [LT1028],
          domain: (0.1, 100000),
          samples: 1000,
          f => 0.85 * calc.sqrt(1 + 3.5 / f),
        )
        //  Chopper stabilized (LTC2057): e_white = 7 nV/sqrt(Hz), fc = 1 Hz
        plot.add(
          style: (stroke: (dash: "dash-dotted")),
          label: [LTC2057],
          domain: (0.1, 100000),
          samples: 1000,
          f => 7 * calc.sqrt(1 + 1 / f),
        )
      },
    )
  }),
  caption: [Comparison of operational amplifier voltage noise spectral density curves across frequency],
) <figure-opamp-voltage-noise-mathematical-model>
