I'm looking at the designs for a simple buck converter which has the P mosfet, inductor, capacitor and reverse based diode. Instead of PWM, I'm trying out to use an op-amp to switch the P mosfet but one thing that I notice is that if the load changes from low resistance to high resistance then the inductor spikes the voltage on the load to double what it is until it can re-stablise. (This is all in simulation)

Is this happening because I'm using the op-amp? How does using PWM affect the inductor in such a way that if the load would change from say 10 ohms to 100 ohms that the inductor won't spike the voltage? Perhaps PWM / fast switching keeps the inductor with such a low charge that when the load changes, the inductor doesn't have nearly enough voltage to do anything?

Cheers.


Question: Is there an "Appending \let"?
Answer: Without reinventing the wheel, we can use etoolbox:

\appto{\MySaved}{\textit{More text}}


with \gappto if the change should be global. If you want to add to \MySaved the (first level) expansion of \MyText, there's

\eappto{\MySaved}{\expandonce{\MyText}}


and \xappto will do the same globally. Let's see:

\documentclass{article}
\usepackage{etoolbox}
\def\MyText{\textbf{My Text}}
\let\MySaved\MyText
\def\MyText{\textit{More Text}}
\eappto\MySaved{\MyText}
\show\MySaved


The output on the terminal will be

&gt; \MySaved=macro:
-&gt;\textbf {My Text}\textit {More Text}.


To make the thing more symmetric, you can use

\eappto{\MySaved}{\expandonce{\MyText}}


also in place of \let, but this wouldn't reinitialize \MySaved.

If only Plain TeX is wanted, just copy the implementation:

\protected\def\appto#1#2{%
  \ifundef{#1}
    {\edef#1{\unexpanded{#2}}}
    {\edef#1{\expandonce#1\unexpanded{#2}}}}
\protected\def\eappto#1#2{%
  \ifundef{#1}
    {\edef#1{#2}}
    {\edef#1{\expandonce#1#2}}}
\protected\def\gappto#1#2{%
  \ifundef{#1}
    {\xdef#1{\unexpanded{#2}}}
    {\xdef#1{\expandonce#1\unexpanded{#2}}}}
\protected\def\xappto#1#2{%
  \ifundef{#1}
    {\xdef#1{#2}}
    {\xdef#1{\expandonce#1#2}}}
\def\ifundef#1{%
  \ifdefined#1%
    \ifx#1\relax
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \else
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \fi
  \else
    \expandafter\@firstoftwo
  \fi}
\long\def\@firstoftwo#1#2{#1}
\long\def\@secondoftwo#1#2{#2}
\def\expandonce#1{%
  \unexpanded\expandafter{#1}}