Code covered by the BSD License

# VINPFN

### Joel Clementson (view profile)

Transient simulations of Type A, B, and C PFNs connected to resistive or inductive loads.

pfnb(t, u, R_L, L_L, L, C, R, N, R_term, L_term)
```% pfnb.m - PFN B simulation
% J. Clementson 2013-04-16

function du = pfnb(t, u, R_L, L_L, L, C, R, N, R_term, L_term)

S = 0;
for k = 1: N
S = S + C(k)*u(2*k);
end

for i = 1: N
du(2*i-1) = u(2*i);
if i == 1 && N == 1
du(2) = - u(1)/(L(1)+L_term+L_L)/C(1) - (R(1)+R_term+R_L)/(L(1)+L_term+L_L)*u(2);
end
if i == 1 && N >= 2
du(2) = - u(1)/(L(1)+L_term+L_L)/C(1) - (u(1) - u(3))/L(2)/C(1) - (R(1)+R_term+R_L)/(L(1)+L_term+L_L)/C(1)*S ...
+ R(2)/L(2)/C(1)*(S-C(1)*u(2));
end
if i == N && N >= 2
du(2*i) = (u(2*i-3) - u(2*i-1))/L(i)/C(i) - R(i)/L(i)*u(2*i);
end
if i >= 2 && i <= N-1
Q = 0;
for k = i: N
Q = Q + C(k)*u(2*k);
end
du(2*i) = (u(2*i-3) - u(2*i-1))/L(i)/C(i) - (u(2*i-1) - u(2*i+1))/L(i+1)/C(i) ...
- R(i)/L(i)/C(i)*Q + R(i+1)/L(i+1)/C(i)*(Q-C(i)*u(2*i));
end
end

du = du';```